Page 1 of 1

Errors after switching to PM-Mode and jmp to Kernel-Seg

Posted: Sun Nov 24, 2013 6:49 am
by JustJim
Hey. I'm really new to OS-Development.
Just started a few days ago, playing around with boot sector.
Everything worked fine. Printing a String or converting an address to print it, switching to Protecte-Mode and print
with VGA.
But the last step threw away my motivation.
What i tried to, was to start in 16-Bit RealMode, Load the Kernel from offset 0x1000, switch to Protected-Mode and jump to
the Start-Address of the Kernel.
Firstly I need to say, I am using a 64bit Ubuntu-Ver. I'm using Qemu. Bochs won't start working at all, always dying.
I'm using .asm files, building with nasm.
At first I used gcc and ld without the 32bit-Flag.
It didn't work out, for sure. It just landed in an loop. When I wrote:
times 1000-($-$$) db 0
times 1000 dw 0
after padding to the magic number 55aa, it worked and it printed an 'X' to the upper left. After giving several StatusMessages which I implemented.
Altering the C-Code of the Kernel results again in an Loop or Crash.

Using gcc and ld with 32-Bit-Flag will result in an loop too. I'm confused.
Sometimes it gives Status "Failed to load all Sectors" or "Error while loading". I used this messages as information and error-catcher.

I'll attach the code (its well commented by me)

Hope you can help me.
Thank you,
JustJim

Re: Errors after switching to PM-Mode and jmp to Kernel-Seg

Posted: Sun Nov 24, 2013 6:50 am
by JustJim
As I can only add 3 files, I need to make 2 additional posts :/

Re: Errors after switching to PM-Mode and jmp to Kernel-Seg

Posted: Sun Nov 24, 2013 6:52 am
by JustJim
The last files. Hope it is okay, to do so?

Re: Errors after switching to PM-Mode and jmp to Kernel-Seg

Posted: Sun Nov 24, 2013 11:23 am
by mrstobbe
JustJim wrote:As I can only add 3 files, I need to make 2 additional posts :/
Next time you can just place them inline into the post surrounded by

Code: Select all

[code]
[/code] blocks. Makes it easier for us to help as well.

Right off the bat though I don't see where you setup your initial segments in real-mode, but then you call the disk_read stuff only specifying BX. This could easily mean that your actually reading into 0x07C0:1000 (which is 0x8C00 linear rather than 0x1000 like it looks like you expect).

EDIT: errr, sorry. Meant 0x8C00