Question about GDT
Posted: Tue Sep 30, 2008 5:43 pm
Hey guys, I'm working on my operating system, using the James Molloy tutorials as a guide, but mainly trying to just use the Intel manuals.
I'm reading the section where he sets up the GDT with the following code:
I see where he sets the first part of the limit with the limit_low field, but what about the other 4 bits? Are those set with the granularity byte? This would make sense, since the gran byte is 8 bits, but I just wanted to make sure.
P.S.
It'd be cleaner to use a 4 bit data type, but I don't think those exist in C?
I'm reading the section where he sets up the GDT with the following code:
Code: Select all
static void gdt_set_gate(s32int num, u32int base, u32int limit, u8int access, u8int gran)
{
gdt_entries[num].base_low = (base & 0xFFFF);
gdt_entries[num].base_middle = (base >> 16) & 0xFF;
gdt_entries[num].base_high = (base >> 24) & 0xFF;
gdt_entries[num].limit_low = (limit & 0xFFFF);
gdt_entries[num].granularity = (limit >> 16) & 0x0F;
gdt_entries[num].granularity |= gran & 0xF0;
gdt_entries[num].access = access;
}
P.S.
It'd be cleaner to use a 4 bit data type, but I don't think those exist in C?