summaryrefslogtreecommitdiff
path: root/stage2/mmap.asm
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2022-10-06 16:45:17 +0200
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2022-10-06 16:45:17 +0200
commitf8397815545adb7d0da36614e0065aa68453a2e4 (patch)
treea771f526970c6724b2511577dceece8783450a49 /stage2/mmap.asm
downloadcuddles-f8397815545adb7d0da36614e0065aa68453a2e4.tar.xz
Initial commit
Diffstat (limited to 'stage2/mmap.asm')
-rw-r--r--stage2/mmap.asm56
1 files changed, 56 insertions, 0 deletions
diff --git a/stage2/mmap.asm b/stage2/mmap.asm
new file mode 100644
index 0000000..b5cbe79
--- /dev/null
+++ b/stage2/mmap.asm
@@ -0,0 +1,56 @@
+%define MAPMAGIC 0x534D4150
+
+mmap:
+ mov ebx, .msg
+ call print_str
+
+ xor ebx, ebx ; counter for interrupt
+ mov di, MEMMAP
+
+.loop:
+ ; issue an INT 0x15, EAX = 0xE820 interrupt
+ mov eax, 0xE820
+ mov ecx, 24
+ mov edx, MAPMAGIC
+ int 0x15
+
+ cmp eax, MAPMAGIC ; detect failure
+ jne .fail
+
+ cmp dword[di+16], 1
+ jne .next
+
+ cmp dword[di+4], 0
+ jne .keep
+
+ cmp dword[di+0], 0x100000
+ jb .next
+
+.keep:
+ mov dword[di+20], 0
+ add di, 24
+
+.next:
+ cmp ebx, 0
+ jne .loop
+
+ mov dword[di+0], 0
+ mov dword[di+4], 0
+
+ ;mov ax, di
+ ;sub ax, MEMMAP
+ ;xor dx, dx
+ ;mov bx, 24
+ ;div bx
+ ;mov [MEMMAPCNT], ax
+
+ ret
+
+.fail:
+ mov ebx, .fail_msg
+ call print_str
+ jmp $
+
+.msg: db "getting extended memory map", 10, 13, 0
+.fail_msg: db "memory map failure", 10, 13, 0
+