Page 1 of 1

Problems jumping to kernel code

Posted: Tue Jul 10, 2007 12:24 pm
by d4n1l0d
I'm writing my own bootloader ( it's for a floppy ).
I've tested it in 16 bits and I was able to load and jump to the code loaded ( and everything work ok )
But now I'm trying to load the code at the 1 MB mark and jump to it
So I enable A20 Line. Load the kernel code with BIOS int 0x13 ( where ES = 0xFFFF and BX = 0x0010 , so 0x100000 ). Set a small temporary GDT ( 3 segments: intel reserved, code and data) and go to protected mode.
Jump to kernel code ( jmp 0x08: 0x100000 ).

When I boot this code in my computer it resets.

So I removed the line that jumps to the kernel code and wrote this:

Code: Select all

;test if computer is really in PM
; and if going to PM is not the cause of the computer resets

mov byte [ds:0B8000h], 'P'      ; Move the ASCII-code of 'P' into first video memory
mov byte [ds:0B8001h], 1Bh      ; Assign a color code
And it worked! So the error was when the computer jumped to the kernel code. checking the kernel code I see that everything is ok ( The kernel code is the same as above, just try to write a character at the video). So , my question is what this error could be? ( if is the kernel code really being loaded at 0x100000, or another error )

Posted: Tue Jul 10, 2007 1:41 pm
by frank
Do you have interrupts disabled? If not then you could be experiencing a triple fault because an interrupt fired.

Have you tried placing a hlt or a jmp $ at the beginning of the kernel? That would narrow it down a little bit. If the computer simply locked up instead of rebooting you would know that the following statements have something to do with it.

Posted: Tue Jul 10, 2007 1:43 pm
by d4n1l0d
Yes I have interrupts disabled...
I'll try that at the kernel code ...
I'll be back soon

Posted: Tue Jul 10, 2007 2:34 pm
by d4n1l0d
lol
The bug was a line that I commented ( I don't know when , I don't know why ) at the disc read part.
So, now it's working ok.
Thank you for helping me.
bye