Bona Fide OS Development http://forums.osdever.net/ |
|
Kernel Wont Execute? http://forums.osdever.net/viewtopic.php?f=6&t=402 |
Page 1 of 1 |
Author: | TheNoOne [ Mon Aug 16, 2010 7:49 pm ] |
Post subject: | Kernel Wont Execute? |
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 |
Author: | ctimko [ Tue Aug 17, 2010 4:49 pm ] |
Post subject: | Re: Kernel Wont Execute? |
I think, but I am not sure since I haven't done this before, but have you told the CPU to switch from 16-bit to 32-bit? |
Author: | TheNoOne [ Wed Aug 18, 2010 6:42 am ] |
Post subject: | Re: Kernel Wont Execute? |
I found the problem - I'm a bit of an idiot actually =) I have it jumping to 08000h but in the linker scripts i set it to 01000h. |
Author: | ctimko [ Sat Aug 21, 2010 10:53 am ] |
Post subject: | Re: Kernel Wont Execute? |
That would do it! |
Page 1 of 1 | All times are UTC - 6 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |