StupidOS/boot/common/bootinfo.inc

82 lines
1.2 KiB
PHP
Raw Normal View History

2024-07-05 05:46:04 +00:00
;; File: bootinfo.inc
2024-07-02 08:32:11 +00:00
2024-07-05 06:16:40 +00:00
;; Struct: BootInfoRange
2024-07-02 08:32:11 +00:00
struc BootInfoRange {
.base dd ?
.legth dd ?
}
2024-07-05 06:16:40 +00:00
;; Struct: BootInfo
;;
;; StupidOS boot protocol structure
2024-07-02 08:32:11 +00:00
struc BootInfo {
2024-07-05 05:46:04 +00:00
.mmap dd 4*2*40 dup(0)
.kernel_start dd ?
.kernel_size dd ?
2024-07-02 08:32:11 +00:00
}
2024-07-05 06:16:40 +00:00
;; Section: Globals
;; Constant: BOOTINFO_MEMORY_LIMIT
2024-07-02 08:32:11 +00:00
BOOTINFO_MEMORY_LIMIT = 0xFFFFF000
;; Function: boot_info_add_memmap
;;
;; In:
;; EAX - base
;; EDX - length
;;
boot_info_add_memmap:
cmp eax, BOOTINFO_MEMORY_LIMIT
jbe @f
ret
@@:
mov ecx, BOOTINFO_MEMORY_LIMIT
sub ecx, edx
cmp eax, ecx
jbe @f
ret
@@:
push ebx
xor ecx, ecx
.loop:
mov ebx, [boot_structure.mmap + ecx * 8 + 4]
or ebx, ebx
jnz @f
mov [boot_structure.mmap + ecx * 8], eax
mov [boot_structure.mmap + ecx * 8 + 4], edx
jmp .end
@@:
inc ecx
cmp ecx, 40
jne .loop
.end:
pop ebx
ret
2024-07-05 05:46:04 +00:00
boot_sanitize_memory_map:
ret
2024-07-02 08:32:11 +00:00
;; Function: boot_info_print_mmap
boot_info_print_mmap:
xor ecx, ecx
.loop:
mov eax, [boot_structure.mmap + ecx * 8 + 4]
or eax, eax
jz @f
push ecx
push dword [boot_structure.mmap + ecx * 8 + 4]
push dword [boot_structure.mmap + ecx * 8]
mov si, szMsgMemMap
call bios_log
pop ecx
@@:
inc ecx
cmp ecx, 40
jbe .loop
ret
2024-07-05 05:46:04 +00:00
szMsgMemMap db 'Address: %x - Length: %x', 0