From ef72082b2df5da98de13bbc8c35b66d891bd4b78 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 26 Dec 2019 14:04:41 -0500 Subject: serial ports, echo vga output over COM2 --- src/kernel/serial.asm | 71 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'src/kernel/serial.asm') diff --git a/src/kernel/serial.asm b/src/kernel/serial.asm index 9ebf84c..9077d99 100644 --- a/src/kernel/serial.asm +++ b/src/kernel/serial.asm @@ -18,12 +18,71 @@ global send_byte global read_byte -section .text -;COM1: COM2: COM3: COM4: -;0x03f8, 0x02f8, 0x03e8, 0x02e8 - send_byte:;void send_byte(uint8_t value, uint8_t port) - ;TODO + push ebp + mov ebp, esp + + mov cl, byte [ebp + 8] ;value + xor edx, edx + mov dl, byte [ebp + 12];port + + test dl, 0xfc + jnz .leave + + xchg ebx, edx + shl bl, 1 + mov ax, word [ebx + com_ports] + mov ebx, edx + mov dx, ax + + or dx, 5 + +.check_ready: + in al, dx + test al, 0x20 + jz .check_ready + + and dx, 0xfff8 + + mov al, cl + out dx, al + +.leave: + leave + ret read_byte:;uint8_t read_byte(uint8_t port) - ;TODO \ No newline at end of file + push ebp + mov ebp, esp + + xor eax, eax + + xor edx, edx + mov dl, byte [ebp + 8];port + + test dl, 0xfc + jnz .leave + + xchg ebx, edx + shl bl, 1 + mov cx, word [ebx + com_ports] + mov ebx, edx + mov dx, cx + + or dx, 5 + +.check_ready: + in al, dx + test al, 0x01 + jz .check_ready + + and dx, 0xfff8 + + in al, dx + +.leave: + leave + ret + +section .rodata +com_ports dw 0x03f8, 0x02f8, 0x03e8, 0x02e8 \ No newline at end of file -- cgit v1.2.3