diff options
author | Danny Holman <dholman@gymli.xyz> | 2021-01-24 21:10:57 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.xyz> | 2021-01-24 21:10:57 -0600 |
commit | a4534660fecb1b571c24ad82e67bc6c2fb814cb9 (patch) | |
tree | 149984cb0e9a32765e63df0f696091817c2b6dd5 /arch/i386/serial.c | |
parent | dd6656f7132d1727a055035ca94945fa4fbaae58 (diff) |
x86: reorganize the i386 directory
Add structure to the internals of the x86 directory.
Signed-off-by: Danny Holman <dholman@gymli.xyz>
Diffstat (limited to 'arch/i386/serial.c')
-rw-r--r-- | arch/i386/serial.c | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/arch/i386/serial.c b/arch/i386/serial.c deleted file mode 100644 index 20bd8f9..0000000 --- a/arch/i386/serial.c +++ /dev/null @@ -1,47 +0,0 @@ -#include <kernel/serial.h> -#include <kernel/string.h> -#include <stddef.h> -#include "pic.h" - -#define PORT 0x3f8 - -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); -} - -void serial_writestring(const char *str) { - for (size_t i = 0; i < strlen(str); i++) - write_serial(str[i]); -} |