Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Makefile b/Makefile
- index 20cb884..e2d9196 100644
- --- a/Makefile
- +++ b/Makefile
- @@ -121,8 +121,8 @@ kernel: $(OBJS) entry.o entryother initcode kernel.ld
- # great for testing the kernel on real hardware without
- # needing a scratch disk.
- MEMFSOBJS = $(filter-out ide.o,$(OBJS)) memide.o
- -kernelmemfs: $(MEMFSOBJS) entry.o entryother initcode fs.img
- - $(LD) $(LDFLAGS) -Ttext 0x100000 -e main -o kernelmemfs entry.o $(MEMFSOBJS) -b binary initcode entryother fs.img
- +kernelmemfs: $(MEMFSOBJS) entry.o entryother initcode kernel.ld fs.img
- + $(LD) $(LDFLAGS) -T kernel.ld -o kernelmemfs entry.o $(MEMFSOBJS) -b binary initcode entryother fs.img
- $(OBJDUMP) -S kernelmemfs > kernelmemfs.asm
- $(OBJDUMP) -t kernelmemfs | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernelmemfs.sym
- diff --git a/kernel.ld b/kernel.ld
- index e24c860..a02d5b4 100644
- --- a/kernel.ld
- +++ b/kernel.ld
- @@ -3,7 +3,7 @@
- OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
- OUTPUT_ARCH(i386)
- -ENTRY(_start)
- +ENTRY(entry)
- SECTIONS
- {
- diff --git a/vm.c b/vm.c
- index 4cffb58..2f4ba3e 100644
- --- a/vm.c
- +++ b/vm.c
- @@ -32,6 +32,10 @@ seginit(void)
- c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);
- lgdt(c->gdt, sizeof(c->gdt));
- +
- + loadcs(SEG_KCODE << 3);
- + loadds(SEG_KDATA << 3);
- + loades(SEG_KDATA << 3);
- loadgs(SEG_KCPU << 3);
- // Initialize cpu-local storage.
- diff --git a/x86.h b/x86.h
- index 3949900..7d4bcce 100644
- --- a/x86.h
- +++ b/x86.h
- @@ -99,6 +99,22 @@ readeflags(void)
- return eflags;
- }
- +#define loadcs(v) \
- + asm volatile("ljmp %0, $set_cs\n" \
- + "set_cs:" : : "n" (v));
- +
- +static inline void
- +loadds(ushort v)
- +{
- + asm volatile("movw %0, %%ds" : : "r" (v));
- +}
- +
- +static inline void
- +loades(ushort v)
- +{
- + asm volatile("movw %0, %%es" : : "r" (v));
- +}
- +
- static inline void
- loadgs(ushort v)
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement