summaryrefslogtreecommitdiff
path: root/src/kernel/serial.asm
diff options
context:
space:
mode:
authorBenji Dial <Benji3.141@gmail.com>2019-12-26 14:04:41 -0500
committerBenji Dial <Benji3.141@gmail.com>2019-12-26 14:04:41 -0500
commitef72082b2df5da98de13bbc8c35b66d891bd4b78 (patch)
treecda43fb6f9a0a34040c90825b29395ef253710b3 /src/kernel/serial.asm
parent336cfa313d0ebd435690610e8006b90dc8bd0e56 (diff)
downloadportland-os-ef72082b2df5da98de13bbc8c35b66d891bd4b78.tar.gz
serial ports, echo vga output over COM2
Diffstat (limited to 'src/kernel/serial.asm')
-rw-r--r--src/kernel/serial.asm71
1 files changed, 65 insertions, 6 deletions
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