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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
JustJim
Posts: 5
Joined: Sun Nov 24, 2013 6:35 am

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

Post 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
Attachments
gdt.txt
(1.39 KiB) Downloaded 37 times
disk_load.txt
(1.01 KiB) Downloaded 31 times
boot_sect.txt
this is the main-asm.
(835 Bytes) Downloaded 68 times
JustJim
Posts: 5
Joined: Sun Nov 24, 2013 6:35 am

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

Post by JustJim »

As I can only add 3 files, I need to make 2 additional posts :/
Attachments
print_string.txt
(551 Bytes) Downloaded 37 times
print_hex.txt
(1.86 KiB) Downloaded 36 times
kernel.txt
the kernel.c
(83 Bytes) Downloaded 67 times
JustJim
Posts: 5
Joined: Sun Nov 24, 2013 6:35 am

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

Post by JustJim »

The last files. Hope it is okay, to do so?
Attachments
switch_to_pm.txt
(362 Bytes) Downloaded 34 times
print_string_pm.txt
(806 Bytes) Downloaded 55 times
mrstobbe
Member
Member
Posts: 62
Joined: Fri Nov 08, 2013 7:40 pm

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

Post 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
Post Reply