Link and load init at 0x1000 instead of 0x0

上级 b87607db
...@@ -72,7 +72,7 @@ $(O)/kernel/%.o: lib/%.cc ...@@ -72,7 +72,7 @@ $(O)/kernel/%.o: lib/%.cc
$(O)/kernel/incbin.o: ASFLAGS+=-DMAKE_OUT=$(O) $(O)/kernel/incbin.o: ASFLAGS+=-DMAKE_OUT=$(O)
$(O)/kernel/incbin.o: $(O)/kernel/initcode $(O)/kernel/bootother $(O)/fs.img $(O)/kernel/incbin.o: $(O)/kernel/initcode $(O)/kernel/bootother $(O)/fs.img
$(O)/kernel/initcode: TTEXT = 0x0 $(O)/kernel/initcode: TTEXT = 0x1000
$(O)/kernel/bootother: TTEXT = 0x7000 $(O)/kernel/bootother: TTEXT = 0x7000
$(O)/kernel/%: kernel/%.S $(O)/kernel/%: kernel/%.S
@echo " CC $@" @echo " CC $@"
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "bits.hh" #include "bits.hh"
#include "vm.hh" #include "vm.hh"
#define INIT_START 0x1000
extern struct proc *bootproc; extern struct proc *bootproc;
// Set up first user process. // Set up first user process.
...@@ -30,9 +32,9 @@ inituser(void) ...@@ -30,9 +32,9 @@ inituser(void)
vmnode *vmn = new vmnode(PGROUNDUP(_initcode_size) / PGSIZE); vmnode *vmn = new vmnode(PGROUNDUP(_initcode_size) / PGSIZE);
if(vmn == 0) if(vmn == 0)
panic("userinit: vmn_allocpg"); panic("userinit: vmn_allocpg");
if(p->vmap->insert(vmn, 0, 1) < 0) if(p->vmap->insert(vmn, INIT_START, 1) < 0)
panic("userinit: vmap_insert"); panic("userinit: vmap_insert");
if(p->vmap->copyout(0, _initcode_start, _initcode_size) < 0) if(p->vmap->copyout(INIT_START, _initcode_start, _initcode_size) < 0)
panic("userinit: copyout"); panic("userinit: copyout");
memset(p->tf, 0, sizeof(*p->tf)); memset(p->tf, 0, sizeof(*p->tf));
p->tf->cs = UCSEG | 0x3; p->tf->cs = UCSEG | 0x3;
...@@ -40,7 +42,7 @@ inituser(void) ...@@ -40,7 +42,7 @@ inituser(void)
p->tf->ss = p->tf->ds; p->tf->ss = p->tf->ds;
p->tf->rflags = FL_IF; p->tf->rflags = FL_IF;
p->tf->rsp = PGSIZE; p->tf->rsp = PGSIZE;
p->tf->rip = 0x0; // beginning of initcode.S p->tf->rip = INIT_START; // beginning of initcode.S
safestrcpy(p->name, "initcode", sizeof(p->name)); safestrcpy(p->name, "initcode", sizeof(p->name));
p->cwd = 0; // forkret will fix in the process's context p->cwd = 0; // forkret will fix in the process's context
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论