nothing much

This commit is contained in:
Robert Morris 2022-08-09 15:11:25 -04:00 committed by Frans Kaashoek
parent 62d8da06cd
commit 535f1797f0
5 changed files with 21 additions and 15 deletions

View file

@ -159,7 +159,7 @@ void kvminithart(void);
void kvmmap(pagetable_t, uint64, uint64, uint64, int); void kvmmap(pagetable_t, uint64, uint64, uint64, int);
int mappages(pagetable_t, uint64, uint64, uint64, int); int mappages(pagetable_t, uint64, uint64, uint64, int);
pagetable_t uvmcreate(void); pagetable_t uvmcreate(void);
void uvminit(pagetable_t, uchar *, uint); void uvmfirst(pagetable_t, uchar *, uint);
uint64 uvmalloc(pagetable_t, uint64, uint64); uint64 uvmalloc(pagetable_t, uint64, uint64);
uint64 uvmdealloc(pagetable_t, uint64, uint64); uint64 uvmdealloc(pagetable_t, uint64, uint64);
int uvmcopy(pagetable_t, pagetable_t, uint64); int uvmcopy(pagetable_t, pagetable_t, uint64);

View file

@ -109,8 +109,8 @@ bfree(int dev, uint b)
// its size, the number of links referring to it, and the // its size, the number of links referring to it, and the
// list of blocks holding the file's content. // list of blocks holding the file's content.
// //
// The inodes are laid out sequentially on disk at // The inodes are laid out sequentially on disk at block
// sb.startinode. Each inode has a number, indicating its // sb.inodestart. Each inode has a number, indicating its
// position on the disk. // position on the disk.
// //
// The kernel keeps a table of in-use inodes in memory // The kernel keeps a table of in-use inodes in memory

View file

@ -21,7 +21,8 @@ plicinithart(void)
{ {
int hart = cpuid(); int hart = cpuid();
// set uart's enable bit for this hart's S-mode. // set enable bits for this hart's S-mode
// for the uart and virtio disk.
*(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ); *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ);
// set this hart's S-mode priority threshold to 0. // set this hart's S-mode priority threshold to 0.

View file

@ -30,7 +30,8 @@ struct spinlock wait_lock;
// Map it high in memory, followed by an invalid // Map it high in memory, followed by an invalid
// guard page. // guard page.
void void
proc_mapstacks(pagetable_t kpgtbl) { proc_mapstacks(pagetable_t kpgtbl)
{
struct proc *p; struct proc *p;
for(p = proc; p < &proc[NPROC]; p++) { for(p = proc; p < &proc[NPROC]; p++) {
@ -42,7 +43,7 @@ proc_mapstacks(pagetable_t kpgtbl) {
} }
} }
// initialize the proc table at boot time. // initialize the proc table.
void void
procinit(void) procinit(void)
{ {
@ -69,7 +70,8 @@ cpuid()
// Return this CPU's cpu struct. // Return this CPU's cpu struct.
// Interrupts must be disabled. // Interrupts must be disabled.
struct cpu* struct cpu*
mycpu(void) { mycpu(void)
{
int id = cpuid(); int id = cpuid();
struct cpu *c = &cpus[id]; struct cpu *c = &cpus[id];
return c; return c;
@ -77,7 +79,8 @@ mycpu(void) {
// Return the current struct proc *, or zero if none. // Return the current struct proc *, or zero if none.
struct proc* struct proc*
myproc(void) { myproc(void)
{
push_off(); push_off();
struct cpu *c = mycpu(); struct cpu *c = mycpu();
struct proc *p = c->proc; struct proc *p = c->proc;
@ -86,7 +89,8 @@ myproc(void) {
} }
int int
allocpid() { allocpid()
{
int pid; int pid;
acquire(&pid_lock); acquire(&pid_lock);
@ -210,7 +214,8 @@ proc_freepagetable(pagetable_t pagetable, uint64 sz)
} }
// a user program that calls exec("/init") // a user program that calls exec("/init")
// od -t xC initcode // assembled from ../user/initcode.S
// od -t xC ../user/initcode
uchar initcode[] = { uchar initcode[] = {
0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x45, 0x02, 0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x45, 0x02,
0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x35, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x35, 0x02,
@ -230,9 +235,9 @@ userinit(void)
p = allocproc(); p = allocproc();
initproc = p; initproc = p;
// allocate one user page and copy init's instructions // allocate one user page and copy initcode's instructions
// and data into it. // and data into it.
uvminit(p->pagetable, initcode, sizeof(initcode)); uvmfirst(p->pagetable, initcode, sizeof(initcode));
p->sz = PGSIZE; p->sz = PGSIZE;
// prepare for the very first "return" from kernel to user. // prepare for the very first "return" from kernel to user.

View file

@ -43,7 +43,7 @@ kvmmake(void)
// the highest virtual address in the kernel. // the highest virtual address in the kernel.
kvmmap(kpgtbl, TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X); kvmmap(kpgtbl, TRAMPOLINE, (uint64)trampoline, PGSIZE, PTE_R | PTE_X);
// map kernel stacks // allocate and map a kernel stack for each process.
proc_mapstacks(kpgtbl); proc_mapstacks(kpgtbl);
return kpgtbl; return kpgtbl;
@ -203,12 +203,12 @@ uvmcreate()
// for the very first process. // for the very first process.
// sz must be less than a page. // sz must be less than a page.
void void
uvminit(pagetable_t pagetable, uchar *src, uint sz) uvmfirst(pagetable_t pagetable, uchar *src, uint sz)
{ {
char *mem; char *mem;
if(sz >= PGSIZE) if(sz >= PGSIZE)
panic("inituvm: more than a page"); panic("uvmfirst: more than a page");
mem = kalloc(); mem = kalloc();
memset(mem, 0, PGSIZE); memset(mem, 0, PGSIZE);
mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U); mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);