feat(boot/loader): fetch memory map from e820 bios call
This commit is contained in:
parent
4a63e27d4b
commit
cf8449ce13
|
@ -46,10 +46,8 @@ boot_info_add_memmap:
|
|||
pop ebx
|
||||
ret
|
||||
|
||||
|
||||
;; Function: boot_info_print_mmap
|
||||
boot_info_print_mmap:
|
||||
xchg bx, bx
|
||||
xor ecx, ecx
|
||||
.loop:
|
||||
mov eax, [boot_structure.mmap + ecx * 8 + 4]
|
||||
|
@ -61,7 +59,6 @@ boot_info_print_mmap:
|
|||
mov si, szMsgMemMap
|
||||
call bios_log
|
||||
pop ecx
|
||||
xchg bx, bx
|
||||
@@:
|
||||
inc ecx
|
||||
cmp ecx, 40
|
||||
|
|
|
@ -2,6 +2,7 @@ TARGET = stpdldr.sys
|
|||
|
||||
LOADER_SRCS = loader.asm \
|
||||
../common/const.inc \
|
||||
../common/bootinfo.inc \
|
||||
video.inc \
|
||||
memory.inc \
|
||||
logger.inc \
|
||||
|
|
|
@ -12,7 +12,7 @@ ADDRESS_RANGE_MEMORY = 1
|
|||
ADDRESS_RANGE_RESERVED = 2
|
||||
|
||||
;; Struct: AddressRange
|
||||
struc AddressRange
|
||||
struc E820AddressRange
|
||||
{
|
||||
;; Variable: BaseAddrLow
|
||||
;; Low 32 Bits of Base Address
|
||||
|
@ -28,9 +28,9 @@ struc AddressRange
|
|||
.LengthHigh dd ?
|
||||
;; Variable: Type
|
||||
;; Address type of this range. <Address type>
|
||||
.Type db ?
|
||||
.Type dd ?
|
||||
|
||||
}
|
||||
defn AddressRange
|
||||
|
||||
;; Function: memory_e820_get_mmap_entry
|
||||
;;
|
||||
|
@ -48,16 +48,43 @@ defn AddressRange
|
|||
;; ECX - Buffer Size
|
||||
;; EBX - Continuation
|
||||
memory_e820_get_map:
|
||||
xor ebx, ebx
|
||||
@@:
|
||||
clc
|
||||
@@:
|
||||
xchg bx, bx
|
||||
xor eax, eax
|
||||
mov es, ax
|
||||
mov di, pE280AddrRange
|
||||
mov ecx, 20
|
||||
mov eax, 0xE820
|
||||
mov ebx, 0x0
|
||||
mov edx, 'SMAP'
|
||||
jc @f
|
||||
cmp eax, 'SMAP'
|
||||
jne @f
|
||||
@@:
|
||||
mov edx, 0x534D4150
|
||||
int 0x15
|
||||
xchg bx, bx
|
||||
jc .error
|
||||
cmp eax, 0x534D4150
|
||||
jne .error
|
||||
or ebx, ebx
|
||||
jz .end
|
||||
|
||||
cmp [pE280AddrRange.Type], 0x1
|
||||
jne @b
|
||||
|
||||
mov ecx, [pE280AddrRange.BaseAddrHigh]
|
||||
or ecx, ecx
|
||||
jnz @b
|
||||
|
||||
mov ecx, [pE280AddrRange.LengthHigh]
|
||||
or ecx, ecx
|
||||
jnz @b
|
||||
|
||||
mov edx, [pE280AddrRange.LengthLow]
|
||||
mov eax, [pE280AddrRange.BaseAddrLow]
|
||||
call boot_info_add_memmap
|
||||
|
||||
jmp @b
|
||||
.error:
|
||||
stc
|
||||
.end:
|
||||
ret
|
||||
|
||||
;; Function: memory_get_for_large_conf
|
||||
|
@ -115,3 +142,5 @@ memory_get_map:
|
|||
.end:
|
||||
ret
|
||||
|
||||
|
||||
pE280AddrRange E820AddressRange
|
||||
|
|
Loading…
Reference in a new issue