diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2025-12-28 01:48:50 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2025-12-28 01:48:50 +0800 |
| commit | f3c8918b13a5226f53e7870d60436f812e5d9015 (patch) | |
| tree | 5a934b82f23916e67e8cac9d230af93645611f3a /src/kernel | |
| parent | a82ab8ad6d277ededc128678aebabf5fbdb01c45 (diff) | |
| download | lume-f3c8918b13a5226f53e7870d60436f812e5d9015.tar.gz lume-f3c8918b13a5226f53e7870d60436f812e5d9015.tar.xz | |
feat(user): add user-space build system and init process to test fork/wait
Diffstat (limited to 'src/kernel')
| -rw-r--r-- | src/kernel/initcode.S | 8 | ||||
| -rw-r--r-- | src/kernel/proc/proc.cc | 15 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/kernel/initcode.S b/src/kernel/initcode.S new file mode 100644 index 0000000..8b56ce6 --- /dev/null +++ b/src/kernel/initcode.S @@ -0,0 +1,8 @@ +.section .rodata +.global initcode_start +.global initcode_end +.align 4 + +initcode_start: + .incbin "build/user/initcode" +initcode_end: diff --git a/src/kernel/proc/proc.cc b/src/kernel/proc/proc.cc index 15a28b4..008f740 100644 --- a/src/kernel/proc/proc.cc +++ b/src/kernel/proc/proc.cc @@ -23,13 +23,8 @@ struct spinlock proc_lock; int nextpid = 1; - -uchar initcode[] = { - 0x13, 0x05, 0x50, 0x05, // li a0, 85 ('U') - 0x93, 0x08, 0x10, 0x00, // li a7, 1 (SYS_putc) - 0x73, 0x00, 0x00, 0x00, // ecall - 0x6f, 0xf0, 0x5f, 0xff // j loop (-12) -}; +extern char initcode_start[]; +extern char initcode_end[]; struct Proc *myproc() { @@ -277,7 +272,9 @@ namespace ProcManager } p->pagetable = VM::uvmcreate(); - VM::uvminit(p->pagetable, initcode, sizeof(initcode)); + + uint64 initcode_sz = initcode_end - initcode_start; + VM::uvminit(p->pagetable, (uchar *)initcode_start, initcode_sz); p->sz = PGSIZE; if (VM::mappages(p->pagetable, TRAPFRAME, PGSIZE, @@ -402,6 +399,6 @@ namespace ProcManager } } - + }
\ No newline at end of file |
