ugly Exception 14.....
Posted: Wed Jul 06, 2005 1:17 pm
Hello...
My kernel is in C++.I am having problem with my paging code. I am enabling paging in kstart.asm stub (the asm file which call _main function).I remap kernel from 0x100000 to 0xC0100000. now the problem comes, it crashes when 'call _main' instruction is executed. the kernel runs well if i dont remap it to 0xC0100000.
I have tried " .text 0xC0100000: {" in linker script but still it crashes. Bochs givin me EXCEPTION 14. The paging is enabled successfully as CR0 is showing correct value. I know the problem comes when call _main inst comes. I have map GDT to 4gb code and data descriptor.
; Loader.asm
[BITS 32] ; protected mode
[global start]
[extern __main] ; this is our C support code
start:
;/////////////////////////////////////////////////////////////////////; Change the base address of kernel from 0x0 to 0xC0000000 and enables paging
;///////////////////////////////////////////////////////////////////// mov eax, 0x9C000
clearpagedir:
mov dword [eax], 2
add eax, 4
;cmp eax, 0xA0000
cmp eax, 0x9D000
jne clearpagedir
mov eax, 0x9D400
mov ebx, 0x100000
bindkernel:
mov ecx, ebx
or ecx, 3
mov dword [eax], ecx
add eax, 4
add ebx, 4096
cmp eax, 0x9D800
jne bindkernel
bindothers:
mov dword [0x9D03C], 0xF003
mov dword [0x9D2E0], 0xB8003
mov dword [0x9E000], 0x9B003
mov dword [0x9C000], 0x9D003
mov dword [0x9CC00], 0x9D003
mov dword [0x9CD00], 0x9E003
mov dword [0x9CFFC], 0x9C003
mov dword [0x9CFF8], 0x9F003
mov eax, 0x9C000
mov cr3, eax
cli
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
;hlt
jmp 0xC0000000 + getsetup
getsetup:
;mov eax, 0xC0000000
;add esp, eax
add esp, 0xC0000000
unpage0x0:
mov dword [0xFFFFF000], 0x2
mov eax, cr3
mov cr3, eax
hlt
call _main
cli ; interrupts will disturb the halt
hlt ; halt the CPU
My kernel is in C++.I am having problem with my paging code. I am enabling paging in kstart.asm stub (the asm file which call _main function).I remap kernel from 0x100000 to 0xC0100000. now the problem comes, it crashes when 'call _main' instruction is executed. the kernel runs well if i dont remap it to 0xC0100000.
I have tried " .text 0xC0100000: {" in linker script but still it crashes. Bochs givin me EXCEPTION 14. The paging is enabled successfully as CR0 is showing correct value. I know the problem comes when call _main inst comes. I have map GDT to 4gb code and data descriptor.
; Loader.asm
[BITS 32] ; protected mode
[global start]
[extern __main] ; this is our C support code
start:
;/////////////////////////////////////////////////////////////////////; Change the base address of kernel from 0x0 to 0xC0000000 and enables paging
;///////////////////////////////////////////////////////////////////// mov eax, 0x9C000
clearpagedir:
mov dword [eax], 2
add eax, 4
;cmp eax, 0xA0000
cmp eax, 0x9D000
jne clearpagedir
mov eax, 0x9D400
mov ebx, 0x100000
bindkernel:
mov ecx, ebx
or ecx, 3
mov dword [eax], ecx
add eax, 4
add ebx, 4096
cmp eax, 0x9D800
jne bindkernel
bindothers:
mov dword [0x9D03C], 0xF003
mov dword [0x9D2E0], 0xB8003
mov dword [0x9E000], 0x9B003
mov dword [0x9C000], 0x9D003
mov dword [0x9CC00], 0x9D003
mov dword [0x9CD00], 0x9E003
mov dword [0x9CFFC], 0x9C003
mov dword [0x9CFF8], 0x9F003
mov eax, 0x9C000
mov cr3, eax
cli
mov eax, cr0
or eax, 0x80000000
mov cr0, eax
;hlt
jmp 0xC0000000 + getsetup
getsetup:
;mov eax, 0xC0000000
;add esp, eax
add esp, 0xC0000000
unpage0x0:
mov dword [0xFFFFF000], 0x2
mov eax, cr3
mov cr3, eax
hlt
call _main
cli ; interrupts will disturb the halt
hlt ; halt the CPU