From 649ff9636fe7289749c91141bbf32b2dcbe6dde4 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 19 May 2024 13:27:11 -0400 Subject: add serial logging for exceptions, fix virtualbox issue --- kernel/source/serial.asm | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 kernel/source/serial.asm (limited to 'kernel/source/serial.asm') diff --git a/kernel/source/serial.asm b/kernel/source/serial.asm new file mode 100644 index 0000000..071e525 --- /dev/null +++ b/kernel/source/serial.asm @@ -0,0 +1,58 @@ +bits 64 + +global serial_init +global serial_putchar + +section .text + +serial_init: + + xor al, al + mov dx, 0x03f9 + out dx, al + + mov al, 0x80 + mov dx, 0x03fb + out dx, al + + mov al, 0x03 + mov dx, 0x03f8 + out dx, al + + xor al, al + mov dx, 0x03f9 + out dx, al + + mov al, 0x03 + mov dx, 0x03fb + out dx, al + + mov al, 0xc7 + mov dx, 0x03fa + out dx, al + + ret + +serial_putchar: + + cmp dil, 0x0a + je .do_cr +.cr_ret: + + mov dx, 0x03fd + +.loop: + in al, dx + test al, 0x20 + jz .loop + + mov al, dil + mov dx, 0x03f8 + out dx, al + ret + +.do_cr: + mov dil, 0x0d + call serial_putchar + mov dil, 0x0a + jmp .cr_ret -- cgit v1.2.3