summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-05-31 11:45:42 -0400
committerRobert Morris <[email protected]>2019-05-31 11:45:42 -0400
commit5d34fa2a489940f19ee6c4728e4b11b6d8ffad01 (patch)
tree98bb91986da866684aa0159d3e44991ea8a1a87c /proc.c
parent2ec1959fd1016a18ef3b2d154ce7076be8f237e4 (diff)
downloadxv6-labs-5d34fa2a489940f19ee6c4728e4b11b6d8ffad01.tar.gz
xv6-labs-5d34fa2a489940f19ee6c4728e4b11b6d8ffad01.tar.bz2
xv6-labs-5d34fa2a489940f19ee6c4728e4b11b6d8ffad01.zip
-initrd fs.img, ramdisk.c, file system
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/proc.c b/proc.c
index e574db0..a099e98 100644
--- a/proc.c
+++ b/proc.c
@@ -116,16 +116,13 @@ found:
return p;
}
-// XXX hack because I don't know how to incorporate initcode
-// into the kernel binary. just the exec system call, no arguments.
-// manually copied from initcode.asm.
+// a user program that calls exec("/init")
+// od -t xC initcode
unsigned char initcode[] = {
- 0x85, 0x48, // li a7, 1 -- SYS_fork
- 0x73, 0x00, 0x00, 0x00, // ecall
- 0x8d, 0x48, // li a7, 3 -- SYS_wait
- 0x73, 0x00, 0x00, 0x00, // ecall
- 0x89, 0x48, // li a7, 2 -- SYS_exit
- 0x73, 0x00, 0x00, 0x00, // ecall
+ 0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x05, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x05, 0x02,
+ 0x9d, 0x48, 0x73, 0x00, 0x00, 0x00, 0x89, 0x48, 0x73, 0x00, 0x00, 0x00, 0xef, 0xf0, 0xbf, 0xff,
+ 0x2f, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00
};
//PAGEBREAK: 32
@@ -146,8 +143,7 @@ userinit(void)
p->tf->sp = PGSIZE;
safestrcpy(p->name, "initcode", sizeof(p->name));
- // XXX riscv
- //p->cwd = namei("/");
+ p->cwd = namei("/");
// this assignment to p->state lets other cores
// run this process. the acquire forces the above
@@ -210,13 +206,11 @@ fork(void)
// Cause fork to return 0 in the child.
np->tf->a0 = 0;
-#if 0 // XXX riscv
// increment reference counts on open file descriptors.
for(i = 0; i < NOFILE; i++)
if(p->ofile[i])
np->ofile[i] = filedup(p->ofile[i]);
np->cwd = idup(p->cwd);
-#endif
safestrcpy(np->name, p->name, sizeof(p->name));
@@ -244,7 +238,6 @@ exit(void)
if(p == initproc)
panic("init exiting");
-#if 0 // XXX riscv
// Close all open files.
for(fd = 0; fd < NOFILE; fd++){
if(p->ofile[fd]){
@@ -256,7 +249,6 @@ exit(void)
begin_op();
iput(p->cwd);
end_op();
-#endif
p->cwd = 0;
acquire(&ptable.lock);
@@ -423,9 +415,8 @@ forkret(void)
// of a regular process (e.g., they call sleep), and thus cannot
// be run from main().
first = 0;
- // XXX riscv
- //iinit(ROOTDEV);
- //initlog(ROOTDEV);
+ iinit(ROOTDEV);
+ initlog(ROOTDEV);
}
usertrapret();