blob: b172e8237069e045c4f845b47dbdfbf71d553faf (
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
30
31
32
33
34
35
36
37
38
39
40
|
#include <kernel/serial.h>
#include "pic.h"
#define PORT 0x3f8
static int serial_init(void) {
outb(PORT + 1, 0x00);
outb(PORT + 3, 0x80);
outb(PORT + 0, 0x03);
outb(PORT + 1, 0x00);
outb(PORT + 3, 0x03);
outb(PORT + 2, 0xC7);
outb(PORT + 4, 0x0B);
outb(PORT + 4, 0x1E);
outb(PORT + 0, 0xAE);
if (inb(PORT + 0) != 0xAE)
return -1;
outb(PORT + 4, 0x0F);
return 0;
}
int serial_recieved(void) {
return inb(PORT + 5) & 1;
}
char read_serial(void) {
while (serial_recieved() == 0);
return inb(PORT);
}
int is_transmit_empty(void) {
return inb(PORT + 5) & 0x20;
}
void write_serial(char a) {
while (is_transmit_empty() == 0);
outb(PORT, a);
}
|