aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/drivers/cpu.c69
-rw-r--r--kernel/drivers/serial.c32
-rw-r--r--kernel/inc/cpu.h29
-rw-r--r--kernel/inc/serial.h9
-rw-r--r--kernel/main.c5
6 files changed, 2 insertions, 144 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index bbf13af..ed422a5 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -2,8 +2,6 @@
COBJS = main.o \
drivers/vesa.o \
- drivers/cpu.o \
- drivers/serial.o \
drivers/interrupts.o \
drivers/interrupts_asm.o \
drivers/keyboard.o \
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]);
-}
diff --git a/kernel/inc/cpu.h b/kernel/inc/cpu.h
deleted file mode 100644
index eb09291..0000000
--- a/kernel/inc/cpu.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#ifndef CPU_H
-#define CPU_H
-
-#include <def.h>
-
-u8 inb(u16 port);
-u16 inw(u16 port);
-u32 inl(u16 port);
-void insl(u16 port, void *addr, int n);
-
-void outb(u16 port, u8 data);
-void outw(u16 port, u16 data);
-void outl(u16 port, u32 data);
-void cli();
-void sti();
-void hlt();
-void idle();
-
-static inline void spinlock(int *ptr)
-{
- int prev;
- do
- __asm__ volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1));
- while (prev);
-}
-
-#endif
diff --git a/kernel/inc/serial.h b/kernel/inc/serial.h
deleted file mode 100644
index 6511952..0000000
--- a/kernel/inc/serial.h
+++ /dev/null
@@ -1,9 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#ifndef SERIAL_H
-#define SERIAL_H
-
-void serial_install();
-void serial_print(const char *data);
-
-#endif
diff --git a/kernel/main.c b/kernel/main.c
index 17d6267..85c1103 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -9,16 +9,15 @@
#include <interrupts.h>
#include <keyboard.h>
#include <load.h>
+#include <mem.h>
#include <print.h>
#include <serial.h>
#include <syscall.h>
#include <timer.h>
-u32 HEAP = 0x00200000;
-u32 HEAP_START;
-
void kernel_main(struct vid_info *vid_info)
{
+ HEAP = 0x00200000;
HEAP_START = HEAP; // For malloc function
// Initialize VESA video