I'm new to the forum and this is my first post.
I've been trying to write my own simple kernel, and I'm following BrokenThorn Entertainment tutorial.
Right now I'm somewhere after FDC programming, and on Bochs (VirtualBox too) everything works fine.
I managed to implement Virtual Memory Manager, and mapped my kernel address (0xc0000000) to 4MB in RAM (0x400000).
Right now I have two page tables in memory: one for addresses [0x0 - 0x400000] identity mapped, and the other one for addresses [0xc0000000 - 0xc0400000] mapped to 0x400000 - 0x800000 (next 4MB).
The problem is, this does not work on real hardware. Immediately after I do sti() (enable interrupts) I get General Protection Fault.
The problem does not occur when I map addresses [0xc0000000 - 0xc0400000] to 0x100000 - 0x500000 which is, for me, quite strange.
I set up everything (after far jump) like that:
Code: Select all
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs,ax
mov gs,ax
mov ss, ax
mov esp, 0xC0300000
Code: Select all
//! 1st 4mb are idenitity mapped
for( i=0, frame=0x0, virt=0x00000000; i<1024; i++, frame+=4096, virt+=4096) {
//! create a new page
unsigned int page=0;
st_wpis_dodaj_atryb (&page, I86_PTE_PRESENT);
st_wpis_ustaw_ramke (&page, frame);
//! ...and add it to the page table
table2->m_entries [INDEKS_TABLICY_STRON (virt) ] = page;
}
// mapping for my kernel
for( i=0, frame=0x400000, virt=0xc0000000; i<1024; i++, frame+=4096, virt+=4096) {
//! create a new page
unsigned int page=0;
st_wpis_dodaj_atryb (&page, I86_PTE_PRESENT);
st_wpis_ustaw_ramke (&page, frame);
//! ...and add it to the page table
table->m_entries [INDEKS_TABLICY_STRON (virt) ] = page;
}