I'm having trouble setting my CS to a zero based selector after i enable paging.
In Bochs, once I execute the enable_paging section of code below, I get
this is the start stub code,written in NASM,that I link before k_main() to setup00031837437e[CPU ] WARNING: Any simulation after this point is completely bogus.
00031837437p[CPU ] >>PANIC<< exception(): 3rd (14) exception with no resolution
1. The PAGE_DIR at PHYSICAL ADDRESS 0xC000,PAGE_TABLE_1 at PHYSICAL
ADDRESS 0xD000 and PAGE_TABLE2 at PHYSICAL ADDRESS 0xE000
2. set PAGE_DIR[0x0000] to point to PAGE_TABLE_1
3. set PAGE_DIR[0x0300] to point to PAGE_TABLE_2
4. perform a 1:1 mapping of addresses from 0 to 1MB into PAGE_TABLE_1
5. map LINEAR ADDRESS 0xC0000000(page directory entry 0x0300) to PHYSICAL ADDRESS 0x200000
6.Create a new gdt with zero based selectors for data and code by copying it to LINEAR ADDRESS 0x10000(which is the same as PHYSICAL ADDRESS cause of 1:1 mapping)
7. Load segment regs with zero based data selector
8. enable paging
9. try to load CS with zero base code selector and jump to k_main at 0xC0000xxx
its step 9,thats crashing Bochs. Don't Know why :'(
I'm not sure if its the jump or if my memory mapping is incorrect. Could you guys please look at this code and tell me what i'm obviously missing(its always a small significant detail) the code is attached as a file. Thanks.
PS: the kernel works fine cause i've been using it without paging but wanted to add virtual memory by using paging.
[attachment deleted by admin]