1
0
Fork 0
mirror of https://gitlab.com/bztsrc/bootboot.git synced 2023-02-13 20:54:32 -05:00

Dynamically query CDROM drive on BIOS

This commit is contained in:
bzt 2021-01-21 18:24:03 +01:00
parent 934b90f2f9
commit 7c6a8ee72e
10 changed files with 60 additions and 35 deletions

View file

@ -354,13 +354,13 @@ Hibakeresés
-----------
```
BOOTBOOT-PANIC: LBA support not found
BOOTBOOT-PANIC: no LBA support
```
Nagyon régi hardver. A BIOSod nem támogatja az LBA-t. Ezt az üzenetet az első betöltő szektor (boot.bin) írja ki.
```
BOOTBOOT-PANIC: FS0:\BOOTBOOT.BIN not found
BOOTBOOT-PANIC: no FS0:\BOOTBOOT.BIN
```
A fő betöltő nem található a lemezen, vagy az induló szektorcíme nincs jól rögzítve az indítószektor 32 bites

View file

@ -355,13 +355,13 @@ Troubleshooting
---------------
```
BOOTBOOT-PANIC: LBA support not found
BOOTBOOT-PANIC: no LBA support
```
Really old hardware. Your BIOS does not support LBA. This message is generated by 1st stage loader (boot.bin).
```
BOOTBOOT-PANIC: FS0:\BOOTBOOT.BIN not found
BOOTBOOT-PANIC: no FS0:\BOOTBOOT.BIN
```
The loader is not on the disk or it's starting LBA address is not recorded in the boot sector at dword [0x1B0]

Binary file not shown.

Binary file not shown.

BIN
dist/boot.bin vendored

Binary file not shown.

BIN
dist/bootboot.bin vendored

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -3,7 +3,7 @@
extern unsigned char binary_boot_bin[512];
extern unsigned char binary_bootboot_bin[12288];
extern unsigned char binary_bootboot_efi[101490];
extern unsigned char binary_bootboot_img[34712];
extern unsigned char binary_bootboot_img[35032];
extern unsigned char binary_bootboot_rv64[8192];
extern unsigned char binary_LICENCE_broadcom[1594];
extern unsigned char binary_bootcode_bin[52456];

View file

@ -111,7 +111,6 @@ bootboot_record:
jl .nolba
.notfloppy: mov ah, byte 41h
mov bx, word 55AAh
clc
int 13h
jc .nolba
cmp bx, word 0AA55h
@ -120,25 +119,41 @@ bootboot_record:
jnz .lbaok
.nolba: mov si, lbanotf
jmp diefunc
.lbaok: ;try to load stage2 - it's a continous area on disk
.lbaok: ;get CDROM drive code
mov ax, word 4B01h
mov si, lba_packet
mov byte [si + 2], 0E0h
push si
int 13h
pop si
jc .read2stg
mov al, byte [si + 2]
mov byte [cdrom], al
;try to load stage2 - it's a continous area on disk
;started at given sector with maximum size of 7000h bytes
mov di, lba_packet
mov cx, 8
xor ax, ax
repnz stosw
.read2stg: mov di, lba_packet
mov si, stage2_addr
mov di, lbapacket.sect0
;set up for hard-drive
movsw
movsw
mov byte [lbapacket.size], 16
mov byte [lbapacket.addr0+1], 08h ;to address 800h
mov byte [lbapacket.count], 56
xor ah, ah
mov al, 16 ; size
stosw
mov al, 56 ; count
stosw
xor al, al
mov ah, 8 ; addr0 to address 800h
stosw
xor ax, ax ; addr1
stosw
movsw ; sect0
movsw ; sect1
xor ax, ax
stosw ; sect2
stosw ; sect3
mov dl, byte [drive]
;if it's a CDROM with 2048 byte sectors
cmp dl, 0E0h
cmp dl, byte [cdrom]
jl @f
sub di, 4
sub di, 8
;lba=lba/4
clc
rcr word [di+2], 1
@ -146,6 +161,7 @@ bootboot_record:
clc
rcr word [di+2], 1
rcr word [di], 1
;count=count/4
shr word [lbapacket.count], 2
;load sectors
@@: mov ah, byte 42h
@ -172,7 +188,7 @@ bootboot_record:
@@: mov byte [drive], al
inc byte [cnt]
cmp byte [cnt], 8
jl .lbaok
jl .read2stg
.nostage2err:
mov si, stage2notf
;fall into the diefunc code
@ -184,8 +200,6 @@ bootboot_record:
diefunc:
print panic
call printfunc
mov si, found
call printfunc
sti
xor ax, ax
int 16h
@ -208,17 +222,18 @@ printfunc:
;* data area *
;*********************************************************************
panic: db "BOOTBOOT-PANIC: ",0
panic: db "BOOTBOOT-PANIC: no ",0
lbanotf: db "LBA support",0
stage2notf: db "FS0:\BOOTBOOT.BIN",0
found: db " not found",0
cnt: db 0
drive: db 0
db 01B0h-($-$$) dup 0
;right before the partition table some data
stage2_addr:dd 0FFFFFFFFh,0 ;1B0h 2nd stage loader address
stage2_addr:dd 0FFFFFFFFh ;1B0h 2nd stage loader address
;this should be set by mkfs
cnt: db 0
drive: db 0
cdrom: db 0
db 0
diskid: dd 0 ;1B8h WinNT expects it here
dw 0

View file

@ -284,7 +284,17 @@ realmode_start:
jnz @f
.clrdl: mov dl, 80h
@@: mov byte [bootdev], dl
;get CDROM drive code
mov ax, word 4B01h
mov si, entrypoint ; bss area
mov byte [si + 2], 0E0h
push si
int 13h
pop si
jc @f
mov al, byte [si + 2]
mov byte [cdromdev], al
@@:
;-----initialize serial port COM1,115200,8N1------
mov ax, 0401h
xor bx, bx
@ -948,8 +958,7 @@ prot_readsectorfunc:
.again: mov ax, word [lbapacket.count]
mov word [origcount], ax
mov dl, byte [readdev]
;don't use INT 13h / AX=4B01h, that's buggy on many BIOSes
cmp dl, 0E0h
cmp dl, byte [cdromdev]
jl @f
;use 2048 byte sectors instead of 512 if it's a cdrom
mov al, byte [lbapacket.sect0]
@ -2697,11 +2706,12 @@ root_sec: dd 0 ;root directory's first sector
data_sec: dd 0 ;first data sector
clu_sec: dd 0 ;sector per cluster
origcount: dw 0
cdromdev: db 0
bootdev: db 0
readdev: db 0
cntdev: db 0
hasinitrd: db 0
hasconfig: db 0
hasconfig: db 0
iscdrom: db 0
nosmp: db 0
bsp_done: ;flag to indicate APs can run