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.
I am following Bran's Kernel Development Tutorial. I am using Ubuntu (as a guest os on virtualbox) and using qemu as my emulator to test the code. All's well up until I try to use the Programmable Interval Timer on this part of the tutorial - http://www.osdever.net/bkerndev/Docs/pit.htm
The problem is where I call "timer_phase" - namely the last line of that function (according to gdb):
outportb(0x40, divisor >> 8); /* Set high byte of divisor */
Once that code is run, I get a total crash on qemu with the following output on the console
Could not initialize KVM, will disable KVM support
QEMU 0.12.5 monitor - type 'help' for more information
(qemu) qemu: fatal: Trying to execute code outside RAM or ROM at 0x000a0000
I dont know if not having kvm is the problem. I cant seem to get it going and am wondering if it's because the OS I am using (Ubuntu) is itself a guest os running on Virtualbox (I am using a windows pc in work and use virtualbox to give me linux environment to code in). Again, not sure if this is the real problem or not.
That looked pretty obvious. I'm sure he loaded his kernel somewhere just below the Memory-mapped Video RAM and then when his kernel finally grew in size, execution at 0xA0000 crashed it.
@OP: If this really is the case, you need to load your kernel to somewhere else. Just make sure it's safe enough to deal with whatever size your kernel is.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
That looked pretty obvious. I'm sure he loaded his kernel somewhere just below the Memory-mapped Video RAM and then when his kernel finally grew in size, execution at 0xA0000 crashed it.
@OP: If this really is the case, you need to load your kernel to somewhere else. Just make sure it's safe enough to deal with whatever size your kernel is.
Since you are booted via GRUB, I'd assume your kernel is loaded at a safe address. Even then, from the dump you provided, your EIP looks definately wrong. And since the CRx register shows that paging is not yet enabled, there should be no issue with mapping. So I end up asking for the source and if possible the floppy image of your OS. That could help perhaps.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Just an update if anyone reads this thread in the future - the problem (AFAIK) was with qemu. If I boot it with the -kernel command I don't always get the bss zeroed. This might be my installation, but it has been mentioned on the web recently (http://lists.gnu.org/archive/html/qemu- ... 02524.html). I've tried all sorts of load scripts but no real success that lasted very long. Also, loading my kernel on a floppy image with grub doesn't lead to this problem so I think it's qemu when used in this way.
I found that my static irq_table was filled with junk and this was actually causing the crash. Writing some asm code that cleared the bss section fixed things and now I can move on learning more.