trying out a new version of gdt initialization
This commit is contained in:
parent
c94252c3f2
commit
d68f4b5264
10
gdt.c
10
gdt.c
@ -28,12 +28,16 @@ void gdt_configure() {
|
||||
// Granularity: 4KB
|
||||
// 32-bit opcodes
|
||||
// Code segment selector
|
||||
gdt_configure_entry(1, 0, 0xffffffff, 0x9a, 0xcf);
|
||||
gdt_configure_entry(1, 0, 0xffffffff, 0x9a, 0xcf); // code segment
|
||||
|
||||
// Finally the data segment
|
||||
// All the same except the desriptor type specifies that its data
|
||||
gdt_configure_entry(2, 0, 0xffffffff, 0x92, 0xcf);
|
||||
gdt_configure_entry(2, 0, 0xffffffff, 0x92, 0xcf); // data segment
|
||||
|
||||
// user mode segments
|
||||
gdt_configure_entry(3, 0, 0xffffffff, 0xfa, 0xcf);
|
||||
gdt_configure_entry(4, 0, 0xffffffff, 0xf2, 0xcf);
|
||||
|
||||
// Load in the new changes to the gdt
|
||||
load_gdt();
|
||||
load_gdt(&gdt_ptr);
|
||||
}
|
||||
|
4
gdt.h
4
gdt.h
@ -1,7 +1,7 @@
|
||||
#include "types.h"
|
||||
|
||||
|
||||
#define NO_GDT_ENTRIES 3
|
||||
#define NO_GDT_ENTRIES 5
|
||||
|
||||
struct GDT_Entry {
|
||||
u16 low_limit;
|
||||
@ -22,7 +22,7 @@ struct GDT_Entry gdt_entries[NO_GDT_ENTRIES];
|
||||
struct GDT_PTR gdt_ptr;
|
||||
|
||||
// this func is actually taken care of in gdt_seg.s
|
||||
extern void load_gdt();
|
||||
extern void load_gdt(struct GDT_PTR* ptr);
|
||||
|
||||
void gdt_configure_entry(u32 entry, u32 base, u32 limit, u8 access, u8 gran);
|
||||
|
||||
|
@ -2,16 +2,16 @@ global load_gdt
|
||||
extern gdt_ptr
|
||||
|
||||
load_gdt:
|
||||
lgdt [gdt_ptr]
|
||||
lgdt [esp+4]
|
||||
mov ax, 0x10 ; offset in the gdt to our data segment
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov fs, ax
|
||||
mov gs, ax
|
||||
mov ss, ax
|
||||
jmp 0x08:flush_cs ; far jump to the code segment
|
||||
jmp 0x08:.flush_cs ; far jump to the code segment
|
||||
|
||||
flush_cs:
|
||||
ret ; here we go back to the caller code but with our segments configured
|
||||
.flush_cs:
|
||||
ret
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user