summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/initcode.S8
-rw-r--r--src/kernel/proc/proc.cc15
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