33 lines
645 B
C
33 lines
645 B
C
#include <serial.h>
|
|
#include <com1.h>
|
|
|
|
#define COM1 0x3f8
|
|
|
|
void com1_init(void) {
|
|
serial_outb(COM1 + 1, 0x00); // no intr
|
|
serial_outb(COM1 + 3, 0x80); // enable DLAB
|
|
serial_outb(COM1 + 0, 0x01); // 115200 baudrate
|
|
serial_outb(COM1 + 1, 0x00);
|
|
serial_outb(COM1 + 3, 0x03); // 8N1
|
|
serial_outb(COM1 + 2, 0xc7); // fifo
|
|
serial_outb(COM1 + 4, 0x0b); // irqs enabled, rts/dsr set
|
|
}
|
|
|
|
int32 com1_is_ready(void) {
|
|
return serial_inb(COM1 + 5) & 0x20;
|
|
}
|
|
|
|
void com1_putch(char c) {
|
|
while (!com1_is_ready());
|
|
serial_outb(COM1, c);
|
|
}
|
|
|
|
void com1_puts(char *s) {
|
|
while (*s) com1_putch(*s++);
|
|
}
|
|
|
|
void putchar_(char c) {
|
|
com1_putch(c);
|
|
}
|
|
|