trampin -> uservec
trampout -> userret
This commit is contained in:
parent
4e62de64cd
commit
ea95a6654c
6 changed files with 18 additions and 17 deletions
|
@ -12,7 +12,7 @@ SECTIONS
|
||||||
{
|
{
|
||||||
*(.text)
|
*(.text)
|
||||||
. = ALIGN(0x1000);
|
. = ALIGN(0x1000);
|
||||||
*(trampoline)
|
*(trampsec)
|
||||||
}
|
}
|
||||||
|
|
||||||
. = ALIGN(0x1000);
|
. = ALIGN(0x1000);
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct spinlock pid_lock;
|
||||||
extern void forkret(void);
|
extern void forkret(void);
|
||||||
static void wakeup1(struct proc *chan);
|
static void wakeup1(struct proc *chan);
|
||||||
|
|
||||||
extern char trampout[]; // trampoline.S
|
extern char trampoline[]; // trampoline.S
|
||||||
|
|
||||||
void
|
void
|
||||||
procinit(void)
|
procinit(void)
|
||||||
|
@ -159,7 +159,7 @@ proc_pagetable(struct proc *p)
|
||||||
// only the supervisor uses it, on the way
|
// only the supervisor uses it, on the way
|
||||||
// to/from user space, so not PTE_U.
|
// to/from user space, so not PTE_U.
|
||||||
mappages(pagetable, TRAMPOLINE, PGSIZE,
|
mappages(pagetable, TRAMPOLINE, PGSIZE,
|
||||||
(uint64)trampout, PTE_R | PTE_X);
|
(uint64)trampoline, PTE_R | PTE_X);
|
||||||
|
|
||||||
// map the trapframe just below TRAMPOLINE, for trampoline.S.
|
// map the trapframe just below TRAMPOLINE, for trampoline.S.
|
||||||
mappages(pagetable, TRAPFRAME, PGSIZE,
|
mappages(pagetable, TRAPFRAME, PGSIZE,
|
||||||
|
|
|
@ -32,10 +32,10 @@ extern struct cpu cpus[NCPU];
|
||||||
// sits in a page by itself just under the trampoline page in the
|
// sits in a page by itself just under the trampoline page in the
|
||||||
// user page table. not specially mapped in the kernel page table.
|
// user page table. not specially mapped in the kernel page table.
|
||||||
// the sscratch register points here.
|
// the sscratch register points here.
|
||||||
// trampin in trampoline.S saves user registers in the trapframe,
|
// uservec in trampoline.S saves user registers in the trapframe,
|
||||||
// then initializes registers from the trapframe's
|
// then initializes registers from the trapframe's
|
||||||
// kernel_sp, kernel_hartid, kernel_satp, and jumps to kernel_trap.
|
// kernel_sp, kernel_hartid, kernel_satp, and jumps to kernel_trap.
|
||||||
// usertrapret() and trampout in trampoline.S set up
|
// usertrapret() and userret in trampoline.S set up
|
||||||
// the trapframe's kernel_*, restore user registers from the
|
// the trapframe's kernel_*, restore user registers from the
|
||||||
// trapframe, switch to the user page table, and enter user space.
|
// trapframe, switch to the user page table, and enter user space.
|
||||||
// the trapframe includes callee-saved user registers like s0-s11 because the
|
// the trapframe includes callee-saved user registers like s0-s11 because the
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
# in user and kernel space so that it continues
|
# in user and kernel space so that it continues
|
||||||
# to work when it switches page tables.
|
# to work when it switches page tables.
|
||||||
#
|
#
|
||||||
# kernel.ld causes trampout to be aligned
|
# kernel.ld causes userret to be aligned
|
||||||
# to a page boundary.
|
# to a page boundary.
|
||||||
#
|
#
|
||||||
.globl usertrap
|
.section trampsec
|
||||||
.section trampoline
|
.globl trampoline
|
||||||
.globl trampout
|
trampoline:
|
||||||
trampout:
|
.globl userret
|
||||||
# trampout(trapframe, pagetable)
|
userret:
|
||||||
|
# userret(trapframe, pagetable)
|
||||||
# switch from kernel to user.
|
# switch from kernel to user.
|
||||||
# usertrapret() calls here.
|
# usertrapret() calls here.
|
||||||
# a0: p->tf in user page table
|
# a0: p->tf in user page table
|
||||||
|
@ -67,8 +68,8 @@ trampout:
|
||||||
sret
|
sret
|
||||||
|
|
||||||
.align 4
|
.align 4
|
||||||
.globl trampin
|
.globl uservec
|
||||||
trampin:
|
uservec:
|
||||||
#
|
#
|
||||||
# trap.c set stvec to point here, so
|
# trap.c set stvec to point here, so
|
||||||
# user interrupts and exceptions start here,
|
# user interrupts and exceptions start here,
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
struct spinlock tickslock;
|
struct spinlock tickslock;
|
||||||
uint ticks;
|
uint ticks;
|
||||||
|
|
||||||
extern char trampout[], trampin[];
|
extern char trampoline[], uservec[];
|
||||||
|
|
||||||
// in kernelvec.S, calls kerneltrap().
|
// in kernelvec.S, calls kerneltrap().
|
||||||
void kernelvec();
|
void kernelvec();
|
||||||
|
@ -96,7 +96,7 @@ usertrapret(void)
|
||||||
intr_off();
|
intr_off();
|
||||||
|
|
||||||
// send interrupts and exceptions to trampoline.S
|
// send interrupts and exceptions to trampoline.S
|
||||||
w_stvec(TRAMPOLINE + (trampin - trampout));
|
w_stvec(TRAMPOLINE + (uservec - trampoline));
|
||||||
|
|
||||||
// set up values that trampoline.S will need when
|
// set up values that trampoline.S will need when
|
||||||
// the process next re-enters the kernel.
|
// the process next re-enters the kernel.
|
||||||
|
|
|
@ -13,7 +13,7 @@ pagetable_t kernel_pagetable;
|
||||||
|
|
||||||
extern char etext[]; // kernel.ld sets this to end of kernel code.
|
extern char etext[]; // kernel.ld sets this to end of kernel code.
|
||||||
|
|
||||||
extern char trampout[]; // trampoline.S
|
extern char trampoline[]; // trampoline.S
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create a direct-map page table for the kernel and
|
* create a direct-map page table for the kernel and
|
||||||
|
@ -46,7 +46,7 @@ kvminit()
|
||||||
|
|
||||||
// map the trampoline for trap entry/exit to
|
// map the trampoline for trap entry/exit to
|
||||||
// the highest virtual address in the kernel.
|
// the highest virtual address in the kernel.
|
||||||
kvmmap(TRAMPOLINE, (uint64)trampout, PGSIZE, PTE_R | PTE_X);
|
kvmmap(TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch h/w page table register to the kernel's page table,
|
// Switch h/w page table register to the kernel's page table,
|
||||||
|
|
Loading…
Reference in a new issue