From 431e21f7d49a53c853876cc9b74f356c3f4927b9 Mon Sep 17 00:00:00 2001 From: Ravjot Singh Samra Date: Tue, 28 Dec 2021 13:53:42 +1300 Subject: [PATCH 1/5] Added missing va_end(). --- kernel/printf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/printf.c b/kernel/printf.c index e1347de..1a50203 100644 --- a/kernel/printf.c +++ b/kernel/printf.c @@ -109,6 +109,7 @@ printf(char *fmt, ...) break; } } + va_end(ap); if(locking) release(&pr.lock); From f33f0d8622ab13fc6f4571bf10bfab54dd81b040 Mon Sep 17 00:00:00 2001 From: mrm Date: Tue, 28 Dec 2021 07:06:14 +0900 Subject: [PATCH 2/5] fix comment in mkfs.c --- mkfs/mkfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index 9ad4abb..1ec326b 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -42,7 +42,7 @@ uint ialloc(ushort type); void iappend(uint inum, void *p, int n); void die(const char *); -// convert to intel byte order +// convert to riscv byte order ushort xshort(ushort x) { From 96da76a728d5737e05f1ef19c87ec6eb740f2e8c Mon Sep 17 00:00:00 2001 From: WaheedHafez Date: Fri, 19 Nov 2021 18:45:49 +0200 Subject: [PATCH 3/5] fix 'kfree' comment in kalloc.c 'kfree' has a parameter named 'pa' but referenced in the comment as 'v'. --- kernel/kalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kalloc.c b/kernel/kalloc.c index fa6a0ac..0699e7e 100644 --- a/kernel/kalloc.c +++ b/kernel/kalloc.c @@ -39,7 +39,7 @@ freerange(void *pa_start, void *pa_end) kfree(p); } -// Free the page of physical memory pointed at by v, +// Free the page of physical memory pointed at by pa, // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) From 62d8da06cd11f88163acd51fe2a27b0b005ef47f Mon Sep 17 00:00:00 2001 From: John Jolly Date: Sat, 6 Nov 2021 04:47:37 +0000 Subject: [PATCH 4/5] [user/ls]: List specific device file When using the ls userspace program to list a specific device file, nothing would be displayed. This was because ls only tests for T_FILE and T_DIR. T_DEVICE files would fall through the case block. Adding T_DEVICE to the T_FILE case allows a device file to be listed. $ ls console console 3 19 0 --- user/ls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/user/ls.c b/user/ls.c index b54d951..c67b84b 100644 --- a/user/ls.c +++ b/user/ls.c @@ -42,6 +42,7 @@ ls(char *path) } switch(st.type){ + case T_DEVICE: case T_FILE: printf("%s %d %d %l\n", fmtname(path), st.type, st.ino, st.size); break; From 535f1797f0d849e77b49bebec0b45077fc5fde9a Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Tue, 9 Aug 2022 15:11:25 -0400 Subject: [PATCH 5/5] nothing much --- kernel/defs.h | 2 +- kernel/fs.c | 4 ++-- kernel/plic.c | 3 ++- kernel/proc.c | 21 +++++++++++++-------- kernel/vm.c | 6 +++--- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/kernel/defs.h b/kernel/defs.h index 3564db4..049569e 100644 --- a/kernel/defs.h +++ b/kernel/defs.h @@ -159,7 +159,7 @@ void kvminithart(void); void kvmmap(pagetable_t, uint64, uint64, uint64, int); int mappages(pagetable_t, uint64, uint64, uint64, int); pagetable_t uvmcreate(void); -void uvminit(pagetable_t, uchar *, uint); +void uvmfirst(pagetable_t, uchar *, uint); uint64 uvmalloc(pagetable_t, uint64, uint64); uint64 uvmdealloc(pagetable_t, uint64, uint64); int uvmcopy(pagetable_t, pagetable_t, uint64); diff --git a/kernel/fs.c b/kernel/fs.c index 40c9bd4..53a3a0f 100644 --- a/kernel/fs.c +++ b/kernel/fs.c @@ -109,8 +109,8 @@ bfree(int dev, uint b) // its size, the number of links referring to it, and the // list of blocks holding the file's content. // -// The inodes are laid out sequentially on disk at -// sb.startinode. Each inode has a number, indicating its +// The inodes are laid out sequentially on disk at block +// sb.inodestart. Each inode has a number, indicating its // position on the disk. // // The kernel keeps a table of in-use inodes in memory diff --git a/kernel/plic.c b/kernel/plic.c index 5acba39..d4fd122 100644 --- a/kernel/plic.c +++ b/kernel/plic.c @@ -21,7 +21,8 @@ plicinithart(void) { 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); // set this hart's S-mode priority threshold to 0. diff --git a/kernel/proc.c b/kernel/proc.c index 22e7ce4..2d0ffa1 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -30,7 +30,8 @@ struct spinlock wait_lock; // Map it high in memory, followed by an invalid // guard page. void -proc_mapstacks(pagetable_t kpgtbl) { +proc_mapstacks(pagetable_t kpgtbl) +{ struct proc *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 procinit(void) { @@ -69,7 +70,8 @@ cpuid() // Return this CPU's cpu struct. // Interrupts must be disabled. struct cpu* -mycpu(void) { +mycpu(void) +{ int id = cpuid(); struct cpu *c = &cpus[id]; return c; @@ -77,7 +79,8 @@ mycpu(void) { // Return the current struct proc *, or zero if none. struct proc* -myproc(void) { +myproc(void) +{ push_off(); struct cpu *c = mycpu(); struct proc *p = c->proc; @@ -86,7 +89,8 @@ myproc(void) { } int -allocpid() { +allocpid() +{ int pid; acquire(&pid_lock); @@ -210,7 +214,8 @@ proc_freepagetable(pagetable_t pagetable, uint64 sz) } // a user program that calls exec("/init") -// od -t xC initcode +// assembled from ../user/initcode.S +// od -t xC ../user/initcode uchar initcode[] = { 0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x45, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x35, 0x02, @@ -230,9 +235,9 @@ userinit(void) p = allocproc(); initproc = p; - // allocate one user page and copy init's instructions + // allocate one user page and copy initcode's instructions // and data into it. - uvminit(p->pagetable, initcode, sizeof(initcode)); + uvmfirst(p->pagetable, initcode, sizeof(initcode)); p->sz = PGSIZE; // prepare for the very first "return" from kernel to user. diff --git a/kernel/vm.c b/kernel/vm.c index d5a12a0..3c6f295 100644 --- a/kernel/vm.c +++ b/kernel/vm.c @@ -43,7 +43,7 @@ kvmmake(void) // the highest virtual address in the kernel. 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); return kpgtbl; @@ -203,12 +203,12 @@ uvmcreate() // for the very first process. // sz must be less than a page. void -uvminit(pagetable_t pagetable, uchar *src, uint sz) +uvmfirst(pagetable_t pagetable, uchar *src, uint sz) { char *mem; if(sz >= PGSIZE) - panic("inituvm: more than a page"); + panic("uvmfirst: more than a page"); mem = kalloc(); memset(mem, 0, PGSIZE); mappages(pagetable, 0, PGSIZE, (uint64)mem, PTE_W|PTE_R|PTE_X|PTE_U);