blob: f3fecf3b5e51c79c4bb19a6e58b2c5132f058a5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <kernel/arch/i386/interrupts/irq.h>
#include <kernel/arch/i386/tty/keyboard.h>
#include <kernel/arch/i386/tty/serial.h>
#include <kernel/arch/i386/tty/vga.h>
#include <kernel/arch/io.h>
void tty_init(void) {
vga_clear();
serial_init();
// write hearts
vga_write("\x03 ", 2);
serial_write("<3 ", 3);
}
void tty_read(char *buf, size_t len) {
irq_interrupt_flag(true);
for (size_t i = 0; i < len; i++) {
for (;;) {
if (serial_poll_read(&buf[i])) break;
if (keyboard_poll_read(&buf[i])) break;
}
}
}
void tty_write(const char *buf, size_t len) {
vga_write(buf, len);
serial_write(buf, len);
}
|