diff options
author | Marvin Borner | 2020-08-09 17:27:08 +0200 |
---|---|---|
committer | Marvin Borner | 2020-08-09 17:27:08 +0200 |
commit | 544acef0986977ef9d3a05d87bb9f55163b1280a (patch) | |
tree | 764d28f454b818c3ac19d59df17ecd914f9d7ecf /kernel/drivers | |
parent | 162d024a53e1e31e00ff0b6f47dd4590edebc551 (diff) |
Temporary cpu and serial drivers in libc
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/cpu.c | 69 | ||||
-rw-r--r-- | kernel/drivers/serial.c | 32 |
2 files changed, 0 insertions, 101 deletions
diff --git a/kernel/drivers/cpu.c b/kernel/drivers/cpu.c deleted file mode 100644 index 5c27c51..0000000 --- a/kernel/drivers/cpu.c +++ /dev/null @@ -1,69 +0,0 @@ -// MIT License, Copyright (c) 2020 Marvin Borner -// This file is a wrapper around some CPU asm calls - -#include <def.h> - -u8 inb(u16 port) -{ - u8 value; - __asm__ volatile("inb %1, %0" : "=a"(value) : "Nd"(port)); - return value; -} - -u16 inw(u16 port) -{ - u16 value; - __asm__ volatile("inw %1, %0" : "=a"(value) : "Nd"(port)); - return value; -} - -u32 inl(u16 port) -{ - u32 value; - __asm__ volatile("inl %1, %0" : "=a"(value) : "Nd"(port)); - return value; -} - -void insl(u16 port, void *addr, int n) -{ - __asm__ volatile("cld; rep insl" - : "=D"(addr), "=c"(n) - : "d"(port), "0"(addr), "1"(n) - : "memory", "cc"); -} - -void outb(u16 port, u8 data) -{ - __asm__ volatile("outb %0, %1" ::"a"(data), "Nd"(port)); -} - -void outw(u16 port, u16 data) -{ - __asm__ volatile("outw %0, %1" ::"a"(data), "Nd"(port)); -} - -void outl(u16 port, u32 data) -{ - __asm__ volatile("outl %0, %1" ::"a"(data), "Nd"(port)); -} - -void cli() -{ - __asm__ volatile("cli"); -} - -void sti() -{ - __asm__ volatile("sti"); -} - -void hlt() -{ - __asm__ volatile("hlt"); -} - -void idle() -{ - while (1) - hlt(); -} diff --git a/kernel/drivers/serial.c b/kernel/drivers/serial.c deleted file mode 100644 index dcee4dd..0000000 --- a/kernel/drivers/serial.c +++ /dev/null @@ -1,32 +0,0 @@ -#include <cpu.h> -#include <def.h> -#include <str.h> - -void serial_install() -{ - outb(0x3f8 + 1, 0x00); - outb(0x3f8 + 3, 0x80); - outb(0x3f8 + 0, 0x03); - outb(0x3f8 + 1, 0x00); - outb(0x3f8 + 3, 0x03); - outb(0x3f8 + 2, 0xC7); - outb(0x3f8 + 4, 0x0B); -} - -int is_transmit_empty() -{ - return inb(0x3f8 + 5) & 0x20; -} - -void serial_put(char ch) -{ - while (is_transmit_empty() == 0) - ; - outb(0x3f8, (u8)ch); -} - -void serial_print(const char *data) -{ - for (u32 i = 0; i < strlen(data); i++) - serial_put(data[i]); -} |