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

Do not rely on BIOS, initialize the serial port ourselves

This commit is contained in:
bzt 2022-12-27 11:12:15 +01:00
parent 190375cfd6
commit ef5aa234c5
4 changed files with 41 additions and 9 deletions

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 @@
#define sizeof_boot_bin 512
extern unsigned char binary_boot_bin[512];
#define sizeof_bootboot_bin 13312
extern unsigned char binary_bootboot_bin[9299];
extern unsigned char binary_bootboot_bin[9329];
#define sizeof_bootboot_efi 103614
extern unsigned char binary_bootboot_efi[46348];
#define sizeof_bootboot_img 35344

View file

@ -302,15 +302,21 @@ realmode_start:
mov byte [cdromdev], al
@@:
;-----initialize serial port COM1,115200,8N1------
mov ax, 0401h
xor bx, bx
mov cx, 030Bh
xor dx, dx
int 14h
; if there's no serial, but BIOS incorrectly sets the IO port for it
; mov ax, 0401h
; xor bx, bx
; mov cx, 030Bh
; xor dx, dx
; int 14h
mov dx, word [400h]
or dx, dx
jz @f
jnz @f
; if the IO port isn't set, try the default one of COM1
mov dx, 3f8h
mov word [400h], dx
; initialize the serial outselves, because Bochs BIOS is buggy
@@: call serialsetup
; if there's no serial, but BIOS incorrectly sets the IO port for it
mov dx, word [400h]
add dx, 5
in al, dx
cmp al, 0FFh
@ -438,6 +444,32 @@ start_of_setup:
jmp 9000h:realmode_start-loader
; --- end of Linux boot protocol header ---
serialsetup:
inc dx
xor al, al
out dx, al ; IER int off
mov al, 80h
add dx, 2
out dx, al ; LCR set divisor mode
mov al, 1
sub dx, 3
out dx, al ; DLL divisor lo 115200
xor al, al
inc dx
out dx, al ; DLH divisor hi
inc dx
out dx, al ; FCR fifo off
mov al, 43h
inc dx
out dx, al ; LCR 8N1, break on
mov al, 8
inc dx
out dx, al ; MCR Aux out 2
xor al, al
sub dx, 4
in al, dx ; clear receiver/transmitter
ret
cpuok: DBG dbg_A20
;-----enable A20-----