"Segment not present" on some machines
Posted: Sat Jun 02, 2007 5:40 pm
Hi, i do have a basic GDT code working nice on my test enviroment like bochs, qemu and vmware. The code & kernel just runs fine. Also on my laptop with 1GB ram, it just run well too. But when i try the kernel on my desktop system with 2GB ram, i do just get segment not present exception.
My current GDT code:
anyone hit this problem before?
thanks
My current GDT code:
Code: Select all
#include "include/gdt.h"
void set_gdt_entry(int num, unsigned long base,unsigned long limit, unsigned char access, unsigned char gran)
{
gdt[num].base=(base & 0xFFFF); /* lowest 2 bytes of base */
gdt[num].base_middle=(base >> 16) & 0xFF; /* third third byte */
gdt[num].base_high=(base >> 24 ) & 0xFF; /* highest byte */
gdt[num].limit=(limit & 0xFFFF); /* lowest 2 bytes of limit */
gdt[num].granularity=((limit >> 16) & 0x0F); /* 1 byte */
gdt[num].granularity|=(gran & 0xF0); /* 1 byte */
gdt[num].access=access;
}
gp.base=(unsigned int)&gdt; /* set base address to our descriptor table */
gp.limit=(sizeof(struct gdt_entry) * 3)-1; /* (size of our gdt table)-1 */
/* NULL descriptor table - CPU needs it */
set_gdt_entry(0,0,0,0,0);
set_gdt_entry(1,0x0,0xFFFFF,0x9A,0xC0);
set_gdt_entry(2,0x0,0xFFFFF,0x92,0xC0);
gdt_flush();
thanks