From 2cca21750c022e22720a3a8a475848ff89945620 Mon Sep 17 00:00:00 2001 From: pantonshire Date: Sat, 6 Jul 2024 22:36:04 +0100 Subject: [PATCH] load stage 2 partition start and end --- boot0.s | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/boot0.s b/boot0.s index 7a631ea..8ce7140 100644 --- a/boot0.s +++ b/boot0.s @@ -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