I started implementing my own OS a couple days ago and this is my first post on the forum!
I've been stuck most of those days trying to get the INT 0x15 0xe820 memory detection working, as described on the Detecting Memory (x86) wiki page of osdev.org.
I'm using basically the same assembly code as is listed on the page, but no matter what I try, I seem to get a triple fault in both qemu and VirtualBox.
In case it makes any difference, here is the exact code I've been using. I commented out the 'int 0x15' instruction and the machine doesn't triple fault, so I know it's something to do with how I'm calling the interrupt function. I call the following code from C code in a separate file. I left the rest of the assembly code out because I have it commented out for now, until I can get at least one interrupt call to work.
After much Googling, I can't seem to figure out what I'm doing wrong! Any help would be appreciated.
Code: Select all
.text
detectMemory:
mov ebx, 0x100
mov es, ebx
xor edi, edi
xor ebx, ebx # ebx must be 0 to start
xor ebp, ebp # keep an entry count in ebp
mov edx, 0x534D4150 # Place "SMAP" into edx
mov eax, 0xe820
mov dword ptr [es:[di] + 20], 1 # force a valid ACPI 3.X entry
mov ecx, 24 # ask for 24 bytes
int 0x15 # TRIPLE FAULT!