What entries should i have in my Global Descriptor Table?
Posted: Sun Jan 04, 2009 5:42 pm
I currently have these entries in my table:
1. Null
2. code segment
3. data segment
What other entries should be in my table? A paper i read from Intel said most modern Operating Systems have 6 entries.
Here is my GDT code if you are curious as to how i have it set up. (i also have my pointer in my header file)
Thanks,
Chris
1. Null
2. code segment
3. data segment
What other entries should be in my table? A paper i read from Intel said most modern Operating Systems have 6 entries.
Here is my GDT code if you are curious as to how i have it set up. (i also have my pointer in my header file)
Code: Select all
#include <system.h>
#include <gdt.h>
extern void gdt_flush();
gdt_entry_struct gdt[6];
gdt_ptr_struct gp;
void gdt_set(unsigned int index, unsigned long base, unsigned long limit, unsigned char access, unsigned char granularity)
{
setBase(index, base);
gdt[index].limit_low = limit & 0xFFFF;
gdt[index].granularity = granularity;
gdt[index].access = access;
}
void gdt_install()
{
// Setup the GDT pointer and limit
gp.limit = (sizeof(gdt_entry_struct) * 6) - 1;
gp.base = (unsigned int)&gdt;
gdt_set(0, 0, 0, 0, 0);
gdt_set(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
gdt_set(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
//thanks to Bran's Kernel Development for these access and granularity values!
//Flush out the old GDT and install the new changes!
gdt_flush();
}
void setBase(unsigned int index, unsigned long base)
{
gdt[index].base_low = base;
gdt[index].base_middle = base >> BASE_MIDDLE_SHIFT;
gdt[index].base_high = base >> BASE_HIGH_SHIFT;
}
Chris