diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 84f179ec..fa90d597 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -24,7 +24,7 @@ [BITS 32] ; We use a special name to map this section at the begin of our kernel ; => Multiboot needs its magic number at the begin of the kernel -SECTION .osstart +SECTION multiboot global start start: mov esp, _sys_stack ; This points the stack to our new stack area diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index 1b0b1651..78fe7730 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -34,7 +34,7 @@ struct gdt_ptr { unsigned int base; } __attribute__ ((packed)); -#define GDT_ENTRIES 3 +#define GDT_ENTRIES 5 struct gdt_entry gdt[GDT_ENTRIES]; struct gdt_ptr gp; @@ -94,6 +94,16 @@ void gdt_install(void) */ gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); + /* + * Create code segement for userspace applications (ring 3) + */ + gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF); + + /* + * Create data segement for userspace applications (ring 3) + */ + gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF); + /* Flush out the old GDT and install the new changes! */ gdt_flush(); } diff --git a/link.ld b/link.ld index e8573ddb..ab752f97 100644 --- a/link.ld +++ b/link.ld @@ -6,7 +6,7 @@ SECTIONS { .text phys : AT(phys) { code = .; - *(.osstart) + *(multiboot) *(.text) *(.rodata) . = ALIGN(4096);