jump to stage 2 bootloader

main
pantonshire 1 year ago
parent b45ee48c90
commit fbdbbc5345

@ -222,7 +222,7 @@ STAGE2_GPT_ENTRY_ADDR equ 0x1a
; Compare entry GUID to our stage 2 partition GUID.
mov cx, GUID_LEN
mov si, guid_linux
mov si, guid_stage2
mov di, ax
repe cmpsb
je .found_stage2
@ -257,22 +257,13 @@ STAGE2_GPT_ENTRY_ADDR equ 0x1a
mov bx, 0x8200
call .read_lba
; TODO: jump to the sector we just read
mov al, [0x7e00]
mov byte fs:[0x0000], al
mov al, [0x8000]
mov byte fs:[0x0002], al
hlt
jmp bx
; Load a single boot disk sector. Panic on failure.
; Inputs:
; - ax: LBA to load
; - bx: address to read sector to
; Clobber: ax, cx, dx. Possibly bx? TODO: double check
; ngl probably best to assume everything is clobbered because it's a bios interrupt
; Clobber: ax, cx, dx
.read_lba:
; sector - 1 = LBA % sectors_per_track
; temp = LBA / sectors_per_track
@ -305,29 +296,13 @@ STAGE2_GPT_ENTRY_ADDR equ 0x1a
mov word fs:[0x0000], 0x4f21
hlt
; TODO: enable A20
; TODO: load a second stage
; TODO: grab all the info we can from bios interrupts and deliver it to ths OS nicely
; e.g. in a fixed memory location
; TODO:
; - Generate GPT in justfile
; - Parse global parition table
; - Load second stage from GPT partition with a particular UUID / name like GRUB does
; (it's Hah!IdontNeedEFI in GRUB)
; - https://en.wikipedia.org/wiki/BIOS_boot_partition
; - Future work:
; - Boot from UEFI
; - Boot on non-GPT partitioned disk
gpt_magic db "EFI PART"
GPT_MAGIC_LEN equ $ - gpt_magic
guid_linux db 0xaf, 0x3d, 0xc6, 0x0f, 0x83, 0x84, 0x72, 0x47, \
0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4
GUID_LEN equ $ - guid_linux
; Our stage2 guid: fdffea69-3651-442f-a11d-88a09bf372dd
guid_stage2 db 0x69, 0xea, 0xff, 0xfd, 0x51, 0x36, 0x2f, 0x44, \
0xa1, 0x1d, 0x88, 0xa0, 0x9b, 0xf3, 0x72, 0xdd
GUID_LEN equ $ - guid_stage2
; MBR bootstrap field is 440 bytes long
%if ($ - $$) > 440

Loading…
Cancel
Save