summaryrefslogtreecommitdiff
path: root/kernel/proc.h
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-07-10 08:57:51 -0400
committerRobert Morris <[email protected]>2019-07-10 08:57:51 -0400
commit9981bb227093373649acd019d378dfccb54189c8 (patch)
treee59d819bf17d5acea8a6f86811fd2ca6640e3733 /kernel/proc.h
parent2f22a3ed6a8dbdd4dcfb2c0a43dc854a36a59cfc (diff)
downloadxv6-labs-9981bb227093373649acd019d378dfccb54189c8.tar.gz
xv6-labs-9981bb227093373649acd019d378dfccb54189c8.tar.bz2
xv6-labs-9981bb227093373649acd019d378dfccb54189c8.zip
tweak some comments.
Diffstat (limited to 'kernel/proc.h')
-rw-r--r--kernel/proc.h32
1 files changed, 18 insertions, 14 deletions
diff --git a/kernel/proc.h b/kernel/proc.h
index 687fdd1..373b605 100644
--- a/kernel/proc.h
+++ b/kernel/proc.h
@@ -18,33 +18,37 @@ struct context {
uint64 s11;
};
-// Per-CPU state
+// Per-CPU state.
struct cpu {
- struct proc *proc; // The process running on this cpu or null
- struct context scheduler; // swtch() here to enter scheduler
- int noff; // Depth of push_off() nesting.
- int intena; // Were interrupts enabled before push_off()?
+ struct proc *proc; // The process running on this cpu, or null.
+ struct context scheduler; // swtch() here to enter scheduler().
+ int noff; // Depth of push_off() nesting.
+ int intena; // Were interrupts enabled before push_off()?
};
extern struct cpu cpus[NCPU];
//PAGEBREAK: 17
-// per-process data for the early trap handling code in trampoline.S.
+// per-process data for the trap handling code in trampoline.S.
// sits in a page by itself just under the trampoline page in the
// user page table. not specially mapped in the kernel page table.
// the sscratch register points here.
-// trampoline.S saves user registers, then restores kernel_sp and
-// kernel_satp.
-// includes callee-saved registers like s0-s11 because the
+// trampin in trampoline.S saves user registers in the trapframe,
+// then initializes registers from the trapframe's
+// kernel_sp, kernel_hartid, kernel_satp, and jumps to kernel_trap.
+// usertrapret() and trampout in trampoline.S set up
+// the trapframe's kernel_*, restore user registers from the
+// trapframe, switch to the user page table, and enter user space.
+// the trapframe includes callee-saved user registers like s0-s11 because the
// return-to-user path via usertrapret() doesn't return through
// the entire kernel call stack.
struct trapframe {
- /* 0 */ uint64 kernel_satp;
- /* 8 */ uint64 kernel_sp;
- /* 16 */ uint64 kernel_trap; // usertrap()
- /* 24 */ uint64 epc; // saved user program counter
- /* 32 */ uint64 hartid;
+ /* 0 */ uint64 kernel_satp; // kernel page table
+ /* 8 */ uint64 kernel_sp; // top of process's kernel stack
+ /* 16 */ uint64 kernel_trap; // usertrap()
+ /* 24 */ uint64 epc; // saved user program counter
+ /* 32 */ uint64 kernel_hartid; // saved kernel tp
/* 40 */ uint64 ra;
/* 48 */ uint64 sp;
/* 56 */ uint64 gp;