diff options
Diffstat (limited to 'kernel/gdt.c')
| -rw-r--r-- | kernel/gdt.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/kernel/gdt.c b/kernel/gdt.c index d1ed382..c91524a 100644 --- a/kernel/gdt.c +++ b/kernel/gdt.c @@ -5,18 +5,16 @@ #include <stdint.h> #define GDT_SIZE 6 -static uint8_t gdt_struct[GDT_SIZE*8]; // GLOBAL DESCRIPTOR TABLE -uint64_t gdt_descriptor; //https://wiki.osdev.org/Task_State_Segment -tss_struct sys_tss; //Define the TSS as a global structure +tss_struct sys_tss[SMP_MAX_PROC]; //Define the TSS as a global structure void install_tss(uint32_t esp0){ // now fill each value // set values necessary - sys_tss.ss0 = 0x10; //kernel data - sys_tss.esp0 = esp0; + sys_tss[0].ss0 = 0x10; //kernel data + sys_tss[0].esp0 = esp0; // now set the IO bitmap (not necessary, so set above limit) // sys_tss.iomap = ( unsigned short ) sizeof( tss_struct ); @@ -97,6 +95,8 @@ void encodeGdtEntry(uint8_t *target, GDT source) void gdt_init() { + + static int last_cpu=0; /* Pr=1 Privl 1 Exec DC RW Ac 0x9A == 1001 1010 == 1 00 1 1 0 1 0 @@ -105,6 +105,8 @@ void gdt_init() 0xF2 == 1111 0010 == 1 11 1 0 0 1 0 */ +//static uint8_t gdt_struct[GDT_SIZE*8]; // GLOBAL DESCRIPTOR TABLE + uint8_t *gdt_struct=kballoc(1); //[GDT_SIZE*8]; // GLOBAL DESCRIPTOR TABLE GDT myGDT[GDT_SIZE]; //selector 0x0 @@ -133,7 +135,7 @@ void gdt_init() myGDT[4].type=0xF2; //TSS 0x28 - myGDT[5].base=&sys_tss; //tss start + myGDT[5].base=&sys_tss[last_cpu++]; //tss start myGDT[5].limit=sizeof(tss_struct); //tss end myGDT[5].type=0x89; @@ -144,5 +146,10 @@ void gdt_init() // update tss entry install_tss(0); + setup_gdt(gdt_struct); + +} +void setup_gdt(uint8_t *gdt_struct) +{ asm_setup_gdt(&gdt_struct[0],8*GDT_SIZE); } |
