Hey,
I've written a bootloader that sets up an enviroment for a kernel, but when i jump to the 32b kernel it dies? The 32bit sections in the BL itself execute perfectly but if i jump outside the BL it crashes!
I've tried two differnt kernels including a VERY basic ASM kernel which consited of about 3 lines. I'm positive I've messed something up, but i just can't see it!
the exact boch error message is
00000578368p[CPU ] >>PANIC<< exception(): 3rd (13) exception with no resolution
I can't seem to google my answer this time =(
Code:
[BITS 16] ; We need 16-bit intructions for Real mode
[ORG 0x7C00] ; The BIOS loads the boot sector into memory location 0x7C00
words db 'S O M E T E X T ',0000
loadkernel:
mov bx, 0x8000 ; segment
mov es, bx
mov bx, 0x0000 ; offset
mov ah, 0x02 ; read function
mov al, 0x25; sectors
mov ch, 0x00 ; cylinder
mov cl, 0x02 ; sector
mov dh, 0x00 ; head
mov dl, 0x00 ; drive
int 0x13 ; disk int
jc loadkernel;
cli ; Disable interrupts
xor ax, ax
mov ds, ax ; Set DS-register to 0 - used by lgdt
lgdt [gdt_desc] ; Load the GDT descriptor
mov eax, cr0 ; Copy the contents of CR0 into EAX
or eax, 1 ; Set bit 0
mov cr0, eax ; Copy the contents of EAX into CR0
jmp 08h:clear_pipe ; Jump to code segment, offset clear_pipe
;db 0eah
;dw 00000h ; offset
;dw 08000h ; segment
[BITS 32] ; We now need 32-bit instructions
clear_pipe:
mov ax, 10h ; Save data segment identifyer
mov ds, ax ; Move a valid data segment into the data segment register
mov ss, ax ; Move a valid data segment into the stack segment register
mov esp, 090000h ; Move the stack pointer to 090000h
mov esi,words
xor edx,edx
loop0: ;put message to screen
mov word cx,[esi]
mov word [ds:0B8000h+1920d+edx],cx ; M
inc edx
inc esi
cmp byte [esi],0
jnz loop0
;mov byte [ds:0B8001h], 1Bh ; Assign a color code
;execute kernel
call 08000h
gdt: ; Address for the GDT
gdt_null: ; Null Segment
dd 0
dd 0
gdt_code: ; Code segment, read/execute, nonconforming
dw 0FFFFh
dw 0
db 0
db 10011010b
db 11001111b
db 0
gdt_data: ; Data segment, read/write, expand down
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end: ; Used to calculate the size of the GDT
gdt_desc: ; The GDT descriptor
dw gdt_end - gdt - 1 ; Limit (size)
dd gdt ; Address of the GDT
times 510-($-$$) db 0 ; Fill up the file with zeros
dw 0AA55h ; Boot sector identifyer
I've also tried different jump methods to the kernel using CALL, JMP &
Code:
db 0eah
dw 00000h ; offset
dw 08000h ; segment