DEADSOFTWARE

boot0: add alternative method to get memory size for older machines
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Wed, 5 Aug 2020 20:57:22 +0000 (23:57 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Wed, 5 Aug 2020 20:57:22 +0000 (23:57 +0300)
Boot486/boot0.S

index ef70f6b024d135b74de734c7cc0cfab290471872..efc93c93af85ff4de898bc4409353cf0df509c57 100644 (file)
@@ -131,30 +131,67 @@ print:
 .code16
 mapmem:
        pusha
+
        movl $0, MemoryMapAdr
        xor %ebx, %ebx
        mov $(MemoryMapAdr + 4), %di
-       mapmem__loop:
-               mov $0xe820, %eax
-               mov $20, %ecx
-               mov $0x0534D4150, %edx
-               int $0x15
-               jc mapmem__failed
-               cmp %edx, %eax
-               jne mapmem__failed
-               cmp $0, %ebx
-               je mapmem__done
-               add $20, %di
-               incl MemoryMapAdr
-               jmp mapmem__loop
-       mapmem__done:
-               popa
-               ret # <============
-       mapmem__failed:
-               mov $msg_mapmem_failed, %si
-               call print
-               cli
-               hlt
+
+mapmem_loop:
+       mov $0xe820, %eax
+       mov $20, %ecx
+       mov $0x0534D4150, %edx
+       int $0x15
+       jc mapmem_method_88
+       cmp %edx, %eax
+       jne mapmem_method_88
+       cmp $0, %ebx
+       je mapmem_done
+       add $20, %di
+       incl MemoryMapAdr
+       jmp mapmem_loop
+
+mapmem_method_88:
+       #####
+       ### function:
+       ###   int 0x15 + %ah = 0x88
+       ### input:
+       ###   none
+       ### output:
+       ###   cf clear:
+       ###     %ax = available memory starting at 0x100000 in KB
+       ###   cf set:
+       ###     %ah = error code
+       ### note:
+       ###   some bioses do not clear cf, do it manually
+        #####
+
+       movl $1,        (MemoryMapAdr + 0)  # num
+       movl $0x100000, (MemoryMapAdr + 4)  # base (low)
+       movl $0,        (MemoryMapAdr + 8)  # base (high)
+       movl $0,        (MemoryMapAdr + 12) # len (low)
+       movl $0,        (MemoryMapAdr + 16) # len (high)
+       movl $1,        (MemoryMapAdr + 20) # type
+
+        clc
+       mov $0x88, %ah
+       int $0x15
+       jc mapmem_failed
+       test %ax, %ax
+       je mapmem_failed
+       movzx %ax, %eax
+       shl $10, %eax
+       movl %eax, (MemoryMapAdr + 12) # len (low)
+       #jmp mapmem_done
+
+mapmem_done:
+       popa
+       ret # <============
+
+mapmem_failed:
+       mov $msg_mapmem_failed, %si
+       call print
+       cli
+       hlt
 
 # =========================================================================== #
 # Convert LBA to CHS