load stage 2 partition start and end

main
pantonshire 1 year ago
parent 4433200e23
commit 2cca21750c

@ -203,8 +203,31 @@ bits 16
jmp .loop_find_stage2
.found_stage2:
; TODO: we've found the right entry, now we need to parse it, load the sector and jump to it
push ax ; address of the GPT entry for stage 2
mov si, ax
; Load partition LBA start.
mov eax, [si + 0x20]
mov ebx, [si + 0x24]
; Ensure it fits in 16 bits.
or ebx, ebx
jnz .panic
cmp ebx, 0xffff
ja .panic
; Load partition LBA end.
mov ecx, [si + 0x28]
mov edx, [si + 0x2c]
; Assert that the end LBA is greater than the start LBA, so we have at least one sector to load.
; TODO: is the end LBA inclusive?
or edx, edx
jnz .stage2_end_lba_ok
cmp eax, ecx
jae .panic
.stage2_end_lba_ok:
mov bx, 0x8200
call .read_lba
; TODO: jump to the sector we just read
mov al, [0x7e00]
mov byte fs:[0x0000], al

Loading…
Cancel
Save