2011-10-14 23:38:50 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2024-05-22 17:15:14 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2009-2024. All rights reserved. ;;
|
2011-10-14 23:38:50 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2014-04-17 23:19:45 +02:00
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
; Query physical memory map from BIOS.
|
|
|
|
; diamond, 2009
|
|
|
|
|
|
|
|
push ds
|
|
|
|
; first call to fn E820
|
|
|
|
mov eax, 0xE820
|
|
|
|
xor ebx, ebx
|
|
|
|
mov es, bx
|
|
|
|
mov ds, bx
|
2017-12-17 03:12:53 +01:00
|
|
|
mov di, BOOT_LO.memmap_blocks
|
|
|
|
mov [BOOT_LO.memmap_block_cnt], ebx ; no blocks yet
|
2011-10-14 23:38:50 +02:00
|
|
|
mov ecx, 20
|
2017-11-29 23:03:58 +01:00
|
|
|
mov edx, 'PAMS' ; 'SMAP'
|
2011-10-14 23:38:50 +02:00
|
|
|
int 15h
|
|
|
|
jc no_E820
|
2017-11-29 23:03:58 +01:00
|
|
|
cmp eax, 'PAMS'
|
2011-10-14 23:38:50 +02:00
|
|
|
jnz no_E820
|
|
|
|
e820_mem_loop:
|
2012-03-15 14:05:45 +01:00
|
|
|
; cmp byte [di+16], 1 ; ignore non-free areas
|
|
|
|
; jnz e820_mem_next
|
2017-12-17 03:12:53 +01:00
|
|
|
inc byte [BOOT_LO.memmap_block_cnt]
|
2017-11-29 23:03:58 +01:00
|
|
|
add di, sizeof.e820entry
|
2011-10-14 23:38:50 +02:00
|
|
|
e820_mem_next:
|
|
|
|
; consequent calls to fn E820
|
|
|
|
test ebx, ebx
|
|
|
|
jz e820_test_done
|
2017-12-17 03:12:53 +01:00
|
|
|
cmp byte [BOOT_LO.memmap_block_cnt], MAX_MEMMAP_BLOCKS
|
2017-11-29 23:03:58 +01:00
|
|
|
jz e820_test_done
|
2011-10-14 23:38:50 +02:00
|
|
|
mov eax, 0xE820
|
|
|
|
int 15h
|
|
|
|
jc e820_test_done
|
|
|
|
jmp e820_mem_loop
|
|
|
|
no_E820:
|
|
|
|
; let's hope for mem_test from init.inc
|
|
|
|
e820_test_done:
|
|
|
|
pop ds
|