Ok, I am using the code from
http://wiki.osdev.org/Detecting_Memory_%28x86%29 to get a memory map with int 0x15 eax=0xE820. Yes I admit I copied it, but what's the point in reinventing the wheel? (I understand the code).
It locked my OS up, so I debugged it with GDB. (I am using QEMU).
The CPU ended up executing code at 0x000000FF in an infinite loop...
I did a few memory dumps and realised that something had modified the IVT!!! (Only 1 byte was changed, the first byte).
If I comment out the call to do_e820, the IVT is not modified, so something in the do_e820 function must be editing the IVT.
This is how I call do_e820:
Code: Select all
mov ax, 0x0000
mov es,ax
mov di, 0x2100
call do_e820
That should load the memory map to [es:di] (0x0000:0x2100 = 0x2100). However, my suspicion is that it is loading it to 0x0000 for some reason, therefore modifying the IVT. In that case, either QEMU's BIOS is ****ed, the code is wrong, or I am calling it wrong.