org
This commit is contained in:
parent
ce2b373313
commit
9114529153
46 changed files with 126016 additions and 125522 deletions
36
kernel/drivers/serial/serial.c
Normal file
36
kernel/drivers/serial/serial.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "serial.h"
|
||||
#include "../../../arch/i386/asm/asm.h"
|
||||
|
||||
#define COM1 (0x3F8)
|
||||
|
||||
int serial_init() {
|
||||
outb(COM1 + 1, 0x01);
|
||||
outb(COM1 + 3, 0x80);
|
||||
outb(COM1 + 0, 0x03);
|
||||
outb(COM1 + 1, 0x00);
|
||||
outb(COM1 + 3, 0x03);
|
||||
outb(COM1 + 2, 0xC7);
|
||||
outb(COM1 + 4, 0x0B);
|
||||
outb(COM1 + 4, 0x0F);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int serial_has_tx() { return inb(COM1 + 5) & 0x20; }
|
||||
|
||||
int serial_has_rx() { return inb(COM1 + 5) & 1; }
|
||||
|
||||
void serial_tx(char a) {
|
||||
while (serial_has_tx() == 0)
|
||||
;
|
||||
|
||||
outb(COM1, a);
|
||||
}
|
||||
|
||||
char serial_rx() {
|
||||
while (serial_has_rx() == 0)
|
||||
;
|
||||
|
||||
return inb(COM1);
|
||||
}
|
5
kernel/drivers/serial/serial.h
Normal file
5
kernel/drivers/serial/serial.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
int serial_init();
|
||||
void serial_tx(char);
|
||||
char serial_rx();
|
Loading…
Add table
Add a link
Reference in a new issue