/trunk/kernel/arch/sparc64/src/asm.S |
---|
106,3 → 106,40 |
memsetb: |
b _memsetb |
nop |
.macro WRITE_ALTERNATE_REGISTER reg, bit |
save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp |
rdpr %pstate, %l0 |
wrpr %l0, \bit, %pstate |
mov %i0, \reg |
wrpr %l0, 0, %pstate |
ret |
restore |
.endm |
.macro READ_ALTERNATE_REGISTER reg, bit |
save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp |
rdpr %pstate, %l0 |
wrpr %l0, \bit, %pstate |
mov \reg, %i0 |
wrpr %l0, 0, %pstate |
ret |
restore |
.endm |
.global write_to_ag_g6 |
write_to_ag_g6: |
WRITE_ALTERNATE_REGISTER %g6, PSTATE_AG_BIT |
.global write_to_ag_g7 |
write_to_ag_g7: |
WRITE_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT |
.global write_to_ig_g6 |
write_to_ig_g6: |
WRITE_ALTERNATE_REGISTER %g6, PSTATE_IG_BIT |
.global read_from_ag_g7 |
read_from_ag_g7: |
READ_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT |
/trunk/kernel/arch/sparc64/src/proc/scheduler.c |
---|
36,6 → 36,8 |
#include <proc/thread.h> |
#include <arch.h> |
#include <arch/asm.h> |
#include <arch/regdef.h> |
#include <arch/stack.h> |
#include <arch/mm/tlb.h> |
#include <arch/mm/page.h> |
#include <config.h> |
51,6 → 53,8 |
* |
* Ensure that thread's kernel stack, as well as userspace window |
* buffer for userspace threads, are locked in DTLB. |
* For userspace threads, initialize reserved global registers |
* in the alternate and interrupt sets. |
*/ |
void before_thread_runs_arch(void) |
{ |
82,6 → 86,14 |
dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) uw_buf); |
dtlb_insert_mapping(uw_buf, KA2PA(uw_buf), PAGESIZE_8K, true, true); |
} |
/* |
* Write kernel stack address to %g6 and a pointer to the last item |
* in the userspace window buffer to %g7 in the alternate and interrupt sets. |
*/ |
write_to_ig_g6((uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS); |
write_to_ag_g6((uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS); |
write_to_ag_g7((uintptr_t) THREAD->arch.uspace_window_buffer); |
} |
} |
123,6 → 135,9 |
*/ |
dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) uw_buf); |
} |
/* sample the state of the userspace window buffer */ |
THREAD->arch.uspace_window_buffer = (uint8_t *) read_from_ag_g7(); |
} |
} |
/trunk/kernel/arch/sparc64/src/trap/trap_table.S |
---|
203,6 → 203,18 |
spill_0_normal: |
SPILL_NORMAL_HANDLER_KERNEL |
/* TT = 0x84, TL = 0, spill_1_normal handler */ |
.org trap_table + TT_SPILL_1_NORMAL*ENTRY_SIZE |
.global spill_1_normal |
spill_1_normal: |
SPILL_NORMAL_HANDLER_USERSPACE |
/* TT = 0x88, TL = 0, spill_2_normal handler */ |
.org trap_table + TT_SPILL_2_NORMAL*ENTRY_SIZE |
.global spill_2_normal |
spill_2_normal: |
SPILL_TO_USPACE_WINDOW_BUFFER |
/* TT = 0xc0, TL = 0, fill_0_normal handler */ |
.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE |
.global fill_0_normal |
209,6 → 221,12 |
fill_0_normal: |
FILL_NORMAL_HANDLER_KERNEL |
/* TT = 0xc4, TL = 0, fill_1_normal handler */ |
.org trap_table + TT_FILL_1_NORMAL*ENTRY_SIZE |
.global fill_1_normal |
fill_1_normal: |
FILL_NORMAL_HANDLER_USERSPACE |
/* |
* Handlers for TL>0. |
*/ |
267,6 → 285,18 |
spill_0_normal_high: |
SPILL_NORMAL_HANDLER_KERNEL |
/* TT = 0x88, TL > 0, spill_2_normal handler */ |
.org trap_table + (TT_SPILL_2_NORMAL+512)*ENTRY_SIZE |
.global spill_2_normal_high |
spill_2_normal_high: |
SPILL_TO_USPACE_WINDOW_BUFFER |
/* TT = 0xa0, TL > 0, spill_0_other handler */ |
.org trap_table + (TT_SPILL_0_OTHER+512)*ENTRY_SIZE |
.global spill_0_other_high |
spill_0_other_high: |
SPILL_TO_USPACE_WINDOW_BUFFER |
/* TT = 0xc0, TL > 0, fill_0_normal handler */ |
.org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE |
.global fill_0_normal_high |
289,7 → 319,7 |
* %g1 Address of function to call. |
* %g2 Argument for the function. |
* %g6 Pre-set as kernel stack base if trap from userspace. |
* %g7 Reserved. |
* %g7 Pre-set as address of the userspace window buffer. |
*/ |
.global preemptible_handler |
preemptible_handler: |