From f157f826570b051afb36822dee3a7d50cd810b5d Mon Sep 17 00:00:00 2001 From: Thomas Oltmann Date: Fri, 4 Jul 2025 16:17:38 +0200 Subject: [PATCH] Print to COM1 port --- lboot.S | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lboot.S b/lboot.S index 1fb6565..0636bdc 100644 --- a/lboot.S +++ b/lboot.S @@ -11,6 +11,8 @@ _start: cli xor %ax, %ax mov %ax, %ds + call init_com1 + mov $msg_start, %si call print @@ -27,6 +29,20 @@ _start: cli 1: hlt jmp 1b +.set COM1, 0x3F8 +.macro com1_write offset=0, byte + mov $COM1+\offset, %dx + mov $\byte, %al + outb %al, %dx +.endm + +init_com1: com1_write 1, 0x00 // clear interrupts + com1_write 3, 0x80 // set DLAB to 1 + com1_write 0, 0x0C // 9600 baud rate + com1_write 1, 0x00 + com1_write 3, 0x07 // 8 bit data + 1 parity bit + ret + enable_a20: // TODO more thorough implementation inb $0x92, %al or $2, %al @@ -53,9 +69,18 @@ unreal: push %ds print: xor %bx, %bx -1: lodsb +1: mov $COM1+5, %dx + inb %dx, %al + test $0x20, %al + jz 1b + + lodsb or %al, %al jz 2f + + mov $COM1, %dx + outb %al, %dx + mov $0x0E, %ah int $0x10 jmp 1b