/branches/sparc/kernel/arch/sparc64/include/sun4v/arch.h |
---|
51,6 → 51,12 |
/* register where the CPUID will be stored */ |
#define SCRATCHPAD_CPUID 0x08 |
/* register where the kernel stack address will be stored */ |
#define SCRATCHPAD_KSTACK 0x10 |
/* register where the userspace window buffer address will be stored */ |
#define SCRATCHPAD_WBUF 0x18 |
#endif |
/** @} |
/branches/sparc/kernel/arch/sparc64/include/sun4v/cpu.h |
---|
70,28 → 70,6 |
#ifdef __ASM__ |
/* |
* Computes the pointer to the kstack_wbuf_ptr structure of the current CPU. |
* |
* Parameters: |
* tmpreg1 global register to be used for scratching purposes |
* result register where the resulting pointer will be saved |
*/ |
.macro get_kstack_wbuf_ptr tmpreg1, result |
! load CPUID to tmpreg1 |
or %g0, SCRATCHPAD_CPUID, \tmpreg1 |
ldxa [\tmpreg1] ASI_SCRATCHPAD, \tmpreg1 |
! compute offset within the array of kstack_wbuf_ptr structures (each |
! such structure is 16 bytes long) |
mulx \tmpreg1, KSTACK_WBUF_PTR_SIZE, \tmpreg1 |
! compute the pointer to the structure for the current CPU |
sethi %hi(kstack_wbuf_ptrs), \result |
or \result, %lo(kstack_wbuf_ptrs), \result |
add \result, \tmpreg1, \result |
.endm |
#endif |
#endif |
/branches/sparc/kernel/arch/sparc64/include/trap/sun4v/regwin.h |
---|
45,8 → 45,8 |
* \tmpreg2 global register to be used for scratching purposes |
*/ |
.macro SAVE_TO_USPACE_WBUF tmpreg1, tmpreg2 |
get_kstack_wbuf_ptr \tmpreg1, \tmpreg2 |
ldx [\tmpreg2 + 8], \tmpreg1 |
set SCRATCHPAD_WBUF, \tmpreg2 |
ldxa [\tmpreg2] ASI_SCRATCHPAD, \tmpreg1 |
stx %l0, [\tmpreg1 + L0_OFFSET] |
stx %l1, [\tmpreg1 + L1_OFFSET] |
stx %l2, [\tmpreg1 + L2_OFFSET] |
64,7 → 64,7 |
stx %i6, [\tmpreg1 + I6_OFFSET] |
stx %i7, [\tmpreg1 + I7_OFFSET] |
add \tmpreg1, STACK_WINDOW_SAVE_AREA_SIZE, \tmpreg1 |
stx \tmpreg1, [\tmpreg2 + 8] |
stxa \tmpreg1, [\tmpreg2] ASI_SCRATCHPAD |
.endm |
/* |
/branches/sparc/kernel/arch/sparc64/src/sun4v/start.S |
---|
273,9 → 273,3 |
.global mmu_fsas |
mmu_fsas: |
.space (MMU_FSA_SIZE * MAX_NUM_STRANDS) |
/* area containing kernel stack and uspace window buffer pointers of all CPUs */ |
.align KSTACK_WBUF_PTR_SIZE |
.global kstack_wbuf_ptrs |
kstack_wbuf_ptrs: |
.space (KSTACK_WBUF_PTR_SIZE * MAX_NUM_STRANDS) |
/branches/sparc/kernel/arch/sparc64/src/proc/sun4v/scheduler.c |
---|
58,10 → 58,9 |
if ((THREAD->flags & THREAD_FLAG_USPACE)) { |
uint64_t sp = (uintptr_t) THREAD->kstack + STACK_SIZE - |
(STACK_BIAS + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT)); |
int cpuid = asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_CPUID); |
kstack_wbuf_ptrs[cpuid].kstack = sp; |
kstack_wbuf_ptrs[cpuid].wbuf = |
(uintptr_t) THREAD->arch.uspace_window_buffer; |
asi_u64_write(ASI_SCRATCHPAD, SCRATCHPAD_KSTACK, sp); |
asi_u64_write(ASI_SCRATCHPAD, SCRATCHPAD_WBUF, |
(uintptr_t) THREAD->arch.uspace_window_buffer); |
} |
} |
70,9 → 69,9 |
{ |
if ((THREAD->flags & THREAD_FLAG_USPACE)) { |
/* sample the state of the userspace window buffer */ |
int cpuid = asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_CPUID); |
THREAD->arch.uspace_window_buffer = |
(uint8_t *) kstack_wbuf_ptrs[cpuid].wbuf; |
(uint8_t *) asi_u64_read(ASI_SCRATCHPAD, SCRATCHPAD_WBUF); |
} |
} |
/branches/sparc/kernel/arch/sparc64/src/trap/sun4v/trap_table.S |
---|
771,8 → 771,8 |
INLINE_SPILL_TO_WBUF %g3, %g4, %g7 |
2: |
get_kstack_wbuf_ptr %g3, %g4 |
ldx [%g4], %g6 |
set SCRATCHPAD_KSTACK, %g4 |
ldxa [%g4] ASI_SCRATCHPAD, %g6 |
save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp |
.if \is_syscall |
823,8 → 823,8 |
/* Restoring userspace windows: */ |
/* Save address of the userspace window buffer to the %g7 register. */ |
get_kstack_wbuf_ptr %g1, %g5 |
ldx [%g5 + 8], %g7 |
set SCRATCHPAD_WBUF, %g5 |
ldxa [%g5] ASI_SCRATCHPAD, %g7 |
rdpr %cwp, %g1 |
rdpr %otherwin, %g2 |
874,7 → 874,7 |
6: |
/* Save changes of the address of the userspace window buffer. */ |
stx %g7, [%g5 + 8] |
stxa %g7, [%g5] ASI_SCRATCHPAD |
/* |
* Switch back to the proper current window and adjust |