From a9043ebf7209fb4dc9adafa6c71e6482dd4c8794 Mon Sep 17 00:00:00 2001 From: stefan Date: Thu, 5 Aug 2010 12:41:38 +0000 Subject: [PATCH] - create GDTs for user applications (ring 3) - rename section osstart to multiboot git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@43 315a16e6-25f9-4109-90ae-ca3045a26c18 --- arch/x86/kernel/entry.asm | 2 +- arch/x86/kernel/gdt.c | 12 +++++++++++- link.ld | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) 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);