Higher half kernel using GDT [SOLVED]

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
ellipsis
Posts: 5
Joined: Sat Aug 14, 2010 11:36 am

Higher half kernel using GDT [SOLVED]

Post by ellipsis »

I'm trying to map my kernel to virtual address 0xC0000000 using the GDT method described on the wiki, but I'm running into some problems. Even if I copy/paste the code directly from Higher Half With GDT into a clean project, it consistently crashes QEMU and VirtualBox as soon as I select my kernel on the GRUB OS select screen. Bochs doesn't crash, but it stops execution right where it would normally crash and triple-faults if I continue it. After looking at it in the Bochs debugger, it seems like it's crashing while GRUB is trying to load the kernel. If I revert the codebase to an older version of the kernel that doesn't even try to enable paging or load in the higher half, it works fine. Any ideas on why this is happening?

EDIT: Added build script and Bochs log
Attachments
build.sh.txt
Build script
(679 Bytes) Downloaded 61 times
bochs_log.txt
Bochs log
(33.51 KiB) Downloaded 36 times
Last edited by ellipsis on Tue Sep 07, 2010 2:37 am, edited 2 times in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Higher half kernel using GDT

Post by Combuster »

Given the amount of info provided, the most accurate conclusion we can give is that it's happening because of you :wink:

Bochs' log and building commands, please?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
ellipsis
Posts: 5
Joined: Sat Aug 14, 2010 11:36 am

Re: Higher half kernel using GDT [SOLVED]

Post by ellipsis »

I found the problem. There were 2 things wrong.

1. I was initializing the stack pointer before initializing the GDT
2. I was corrupting eax (0x2BADB002) making my kernel fail on boot. Solved by transferring into ecx before fixing segments after lgdt.
Post Reply