From: DeaDDooMER Date: Wed, 5 Aug 2020 20:57:22 +0000 (+0300) Subject: boot0: add alternative method to get memory size for older machines X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=06864281d6bbf60614183a73f6efdab838221f09;p=bmbb.git boot0: add alternative method to get memory size for older machines --- diff --git a/Boot486/boot0.S b/Boot486/boot0.S index ef70f6b..efc93c9 100644 --- a/Boot486/boot0.S +++ b/Boot486/boot0.S @@ -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