rename p->tf to p->trapframe, for consistency with p->context
This commit is contained in:
parent
7a7cd1adef
commit
d6dad42aaf
|
@ -97,7 +97,7 @@ exec(char *path, char **argv)
|
|||
// arguments to user main(argc, argv)
|
||||
// argc is returned via the system call return
|
||||
// value, which goes in a0.
|
||||
p->tf->a1 = sp;
|
||||
p->trapframe->a1 = sp;
|
||||
|
||||
// Save program name for debugging.
|
||||
for(last=s=path; *s; s++)
|
||||
|
@ -109,8 +109,8 @@ exec(char *path, char **argv)
|
|||
oldpagetable = p->pagetable;
|
||||
p->pagetable = pagetable;
|
||||
p->sz = sz;
|
||||
p->tf->epc = elf.entry; // initial program counter = main
|
||||
p->tf->sp = sp; // initial stack pointer
|
||||
p->trapframe->epc = elf.entry; // initial program counter = main
|
||||
p->trapframe->sp = sp; // initial stack pointer
|
||||
proc_freepagetable(oldpagetable, oldsz);
|
||||
|
||||
return argc; // this ends up in a0, the first argument to main(argc, argv)
|
||||
|
|
|
@ -62,6 +62,6 @@
|
|||
// fixed-size stack
|
||||
// expandable heap
|
||||
// ...
|
||||
// TRAPFRAME (p->tf, used by the trampoline)
|
||||
// TRAPFRAME (p->trapframe, used by the trampoline)
|
||||
// TRAMPOLINE (the same page as in the kernel)
|
||||
#define TRAPFRAME (TRAMPOLINE - PGSIZE)
|
||||
|
|
|
@ -106,7 +106,7 @@ found:
|
|||
p->pid = allocpid();
|
||||
|
||||
// Allocate a trapframe page.
|
||||
if((p->tf = (struct trapframe *)kalloc()) == 0){
|
||||
if((p->trapframe = (struct trapframe *)kalloc()) == 0){
|
||||
release(&p->lock);
|
||||
return 0;
|
||||
}
|
||||
|
@ -129,9 +129,9 @@ found:
|
|||
static void
|
||||
freeproc(struct proc *p)
|
||||
{
|
||||
if(p->tf)
|
||||
kfree((void*)p->tf);
|
||||
p->tf = 0;
|
||||
if(p->trapframe)
|
||||
kfree((void*)p->trapframe);
|
||||
p->trapframe = 0;
|
||||
if(p->pagetable)
|
||||
proc_freepagetable(p->pagetable, p->sz);
|
||||
p->pagetable = 0;
|
||||
|
@ -164,7 +164,7 @@ proc_pagetable(struct proc *p)
|
|||
|
||||
// map the trapframe just below TRAMPOLINE, for trampoline.S.
|
||||
mappages(pagetable, TRAPFRAME, PGSIZE,
|
||||
(uint64)(p->tf), PTE_R | PTE_W);
|
||||
(uint64)(p->trapframe), PTE_R | PTE_W);
|
||||
|
||||
return pagetable;
|
||||
}
|
||||
|
@ -206,8 +206,8 @@ userinit(void)
|
|||
p->sz = PGSIZE;
|
||||
|
||||
// prepare for the very first "return" from kernel to user.
|
||||
p->tf->epc = 0; // user program counter
|
||||
p->tf->sp = PGSIZE; // user stack pointer
|
||||
p->trapframe->epc = 0; // user program counter
|
||||
p->trapframe->sp = PGSIZE; // user stack pointer
|
||||
|
||||
safestrcpy(p->name, "initcode", sizeof(p->name));
|
||||
p->cwd = namei("/");
|
||||
|
@ -262,10 +262,10 @@ fork(void)
|
|||
np->parent = p;
|
||||
|
||||
// copy saved user registers.
|
||||
*(np->tf) = *(p->tf);
|
||||
*(np->trapframe) = *(p->trapframe);
|
||||
|
||||
// Cause fork to return 0 in the child.
|
||||
np->tf->a0 = 0;
|
||||
np->trapframe->a0 = 0;
|
||||
|
||||
// increment reference counts on open file descriptors.
|
||||
for(i = 0; i < NOFILE; i++)
|
||||
|
|
|
@ -98,7 +98,7 @@ struct proc {
|
|||
uint64 kstack; // Virtual address of kernel stack
|
||||
uint64 sz; // Size of process memory (bytes)
|
||||
pagetable_t pagetable; // Page table
|
||||
struct trapframe *tf; // data page for trampoline.S
|
||||
struct trapframe *trapframe; // data page for trampoline.S
|
||||
struct context context; // swtch() here to run process
|
||||
struct file *ofile[NOFILE]; // Open files
|
||||
struct inode *cwd; // Current directory
|
||||
|
|
|
@ -37,17 +37,17 @@ argraw(int n)
|
|||
struct proc *p = myproc();
|
||||
switch (n) {
|
||||
case 0:
|
||||
return p->tf->a0;
|
||||
return p->trapframe->a0;
|
||||
case 1:
|
||||
return p->tf->a1;
|
||||
return p->trapframe->a1;
|
||||
case 2:
|
||||
return p->tf->a2;
|
||||
return p->trapframe->a2;
|
||||
case 3:
|
||||
return p->tf->a3;
|
||||
return p->trapframe->a3;
|
||||
case 4:
|
||||
return p->tf->a4;
|
||||
return p->trapframe->a4;
|
||||
case 5:
|
||||
return p->tf->a5;
|
||||
return p->trapframe->a5;
|
||||
}
|
||||
panic("argraw");
|
||||
return -1;
|
||||
|
@ -135,12 +135,12 @@ syscall(void)
|
|||
int num;
|
||||
struct proc *p = myproc();
|
||||
|
||||
num = p->tf->a7;
|
||||
num = p->trapframe->a7;
|
||||
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
|
||||
p->tf->a0 = syscalls[num]();
|
||||
p->trapframe->a0 = syscalls[num]();
|
||||
} else {
|
||||
printf("%d %s: unknown sys call %d\n",
|
||||
p->pid, p->name, num);
|
||||
p->tf->a0 = -1;
|
||||
p->trapframe->a0 = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ usertrap(void)
|
|||
struct proc *p = myproc();
|
||||
|
||||
// save user program counter.
|
||||
p->tf->epc = r_sepc();
|
||||
p->trapframe->epc = r_sepc();
|
||||
|
||||
if(r_scause() == 8){
|
||||
// system call
|
||||
|
@ -58,7 +58,7 @@ usertrap(void)
|
|||
|
||||
// sepc points to the ecall instruction,
|
||||
// but we want to return to the next instruction.
|
||||
p->tf->epc += 4;
|
||||
p->trapframe->epc += 4;
|
||||
|
||||
// an interrupt will change sstatus &c registers,
|
||||
// so don't enable until done with those registers.
|
||||
|
@ -100,10 +100,10 @@ usertrapret(void)
|
|||
|
||||
// set up trapframe values that uservec will need when
|
||||
// the process next re-enters the kernel.
|
||||
p->tf->kernel_satp = r_satp(); // kernel page table
|
||||
p->tf->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
|
||||
p->tf->kernel_trap = (uint64)usertrap;
|
||||
p->tf->kernel_hartid = r_tp(); // hartid for cpuid()
|
||||
p->trapframe->kernel_satp = r_satp(); // kernel page table
|
||||
p->trapframe->kernel_sp = p->kstack + PGSIZE; // process's kernel stack
|
||||
p->trapframe->kernel_trap = (uint64)usertrap;
|
||||
p->trapframe->kernel_hartid = r_tp(); // hartid for cpuid()
|
||||
|
||||
// set up the registers that trampoline.S's sret will use
|
||||
// to get to user space.
|
||||
|
@ -115,7 +115,7 @@ usertrapret(void)
|
|||
w_sstatus(x);
|
||||
|
||||
// set S Exception Program Counter to the saved user pc.
|
||||
w_sepc(p->tf->epc);
|
||||
w_sepc(p->trapframe->epc);
|
||||
|
||||
// tell trampoline.S the user page table to switch to.
|
||||
uint64 satp = MAKE_SATP(p->pagetable);
|
||||
|
|
Loading…
Reference in a new issue