diff --git a/Makefile b/Makefile
index 655ab81..4611669 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,10 @@
EMULATOR = qemu-system-i386
AS = ${HOME}/opt/cross/bin/i686-elf-as
CC = ${HOME}/opt/cross/bin/i686-elf-gcc
-CFLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra
+CPP = ${HOME}/opt/cross/bin/i686-elf-g++
+CFLAGS = -ffreestanding -O2 -Wall -Wextra
-OFILES = $(BUILD_DIR)/boot.o $(BUILD_DIR)/kterm.o $(BUILD_DIR)/kernel.o
+OFILES = $(BUILD_DIR)/boot.o $(BUILD_DIR)/kterm.o $(BUILD_DIR)/kernel.o $(BUILD_DIR)/io.o $(BUILD_DIR)/MMU.o
SRC_DIR = src
BUILD_DIR = build
@@ -23,7 +24,8 @@ all: clean build
build: build_kernel run
run:
- $(EMULATOR) -kernel $(BUILD_DIR)/myos.bin
+ $(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio
+
build_kernel: $(OBJ_LINK_LIST)
$(CC) -T $(SRC_DIR)/kernel/arch/i386/linker.ld -o $(BUILD_DIR)/myos.bin \
@@ -37,10 +39,10 @@ clean:
rm -f $(BUILD_DIR)/myos.bin $(INTERNAL_OBJS)
$(BUILD_DIR)/kernel.o:
- $(CC) -c $(SRC_DIR)/kernel/kernel.c -o $(BUILD_DIR)/kernel.o $(CFLAGS)
+ $(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
$(BUILD_DIR)/kterm.o:
- $(CC) -c $(SRC_DIR)/kernel/arch/i386/tty/kterm.c -o $(BUILD_DIR)/kterm.o $(CFLAGS)
+ $(CC) -c $(SRC_DIR)/kernel/arch/i386/tty/kterm.c -o $(BUILD_DIR)/kterm.o $(CFLAGS) -std=gnu99
$(BUILD_DIR)/boot.o:
$(AS) $(SRC_DIR)/kernel/arch/i386/boot.s -o $(BUILD_DIR)/boot.o
@@ -50,3 +52,8 @@ $(BUILD_DIR)/crti.o:
$(BUILD_DIR)/crtn.o:
$(AS) $(SRC_DIR)/kernel/arch/i386/crtn.s -o $(BUILD_DIR)/crtn.o
+
+$(BUILD_DIR)/io.o:
+ $(CPP) -c $(SRC_DIR)/kernel/io.cpp -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
+$(BUILD_DIR)/MMU.o:
+ $(CPP) -c $(SRC_DIR)/kernel/MMU.cpp -o $(BUILD_DIR)/MMU.o $(CFLAGS) -fno-exceptions -fno-rtti
\ No newline at end of file
diff --git a/TODO.md b/TODO.md
index 4e545dc..662bad3 100644
--- a/TODO.md
+++ b/TODO.md
@@ -5,7 +5,7 @@
Printing string to the screen \
Printing values/numbers to the screen (a.k.k itoa) \
Extend Multiboot implementation \
- Output to serial port \
+ Output to serial port \
Move to protected mode \
Enabel CMOS clock \
Time measurement (PIC &| PIT) \
diff --git a/src/kernel/arch/i386/ports/serial.cpp b/src/kernel/arch/i386/ports/serial.cpp
new file mode 100644
index 0000000..9d2b981
--- /dev/null
+++ b/src/kernel/arch/i386/ports/serial.cpp
@@ -0,0 +1,19 @@
+#include "serial.h"
+
+Serial Serial::init() {
+ // No clue what to setup yet!
+
+ return Serial();
+}
+
+void Serial::print(){
+ // Do nothing!
+}
+
+Serial::Serial(){
+ // Do nothing!
+}
+
+Serial::~Serial(){
+ // Do nothing!
+}
\ No newline at end of file
diff --git a/src/kernel/arch/i386/ports/serial.h b/src/kernel/arch/i386/ports/serial.h
new file mode 100644
index 0000000..80101e5
--- /dev/null
+++ b/src/kernel/arch/i386/ports/serial.h
@@ -0,0 +1,19 @@
+#pragma once
+
+class Serial {
+
+ public:
+ static Serial init();
+
+ void print();
+
+ private:
+ const int COM1 = 0x3F8;
+ const int COM2 = 0x2F8;
+ const int COM3 = 0x3E8;
+ const int COM4 = 0x2E8;
+
+
+ Serial();
+ ~Serial();
+};
\ No newline at end of file
diff --git a/src/kernel/arch/i386/tty/kterm.c b/src/kernel/arch/i386/tty/kterm.c
index 8b3ec6b..2021e22 100644
--- a/src/kernel/arch/i386/tty/kterm.c
+++ b/src/kernel/arch/i386/tty/kterm.c
@@ -88,4 +88,5 @@ void kterm_write(const char* data, size_t size) {
void kterm_writestring(const char* data ){
AS_KERNEL();
kterm_write(data, strlen(data));
-}
\ No newline at end of file
+}
+
diff --git a/src/kernel/arch/i386/tty/kterm.h b/src/kernel/arch/i386/tty/kterm.h
index ebe54a5..6cf784e 100644
--- a/src/kernel/arch/i386/tty/kterm.h
+++ b/src/kernel/arch/i386/tty/kterm.h
@@ -3,6 +3,7 @@
#include
#include
#include
+
#include "../vga/colors.h"
void kterm_init();
diff --git a/src/kernel/io.cpp b/src/kernel/io.cpp
new file mode 100644
index 0000000..11dbc3b
--- /dev/null
+++ b/src/kernel/io.cpp
@@ -0,0 +1,59 @@
+#include "io.h"
+
+unsigned char inb_p(unsigned short ){
+
+}
+unsigned short inw(unsigned short ){
+
+}
+unsigned short inw_p(unsigned short ){
+
+}
+unsigned int inl(unsigned short ){
+
+}
+unsigned int inl_p(unsigned short ){
+
+}
+
+
+void outb_p(unsigned char , unsigned short ){
+
+}
+void outw(unsigned short , unsigned short ){
+
+}
+void outw_p(unsigned short , unsigned short ){
+
+}
+void outl(unsigned int , unsigned short ){
+
+}
+void outl_p(unsigned int , unsigned short ){
+
+}
+
+void insb(unsigned short , void *,
+ unsigned long ){
+
+ }
+void insw(unsigned short , void *,
+ unsigned long ){
+
+ }
+void insl(unsigned short , void *,
+ unsigned long ){
+
+ }
+void outsb(unsigned short , const void *,
+ unsigned long ){
+
+ }
+void outsw(unsigned short , const void *,
+ unsigned long ){
+
+ }
+void outsl(unsigned short , const void *,
+ unsigned long ){
+
+ }
\ No newline at end of file
diff --git a/src/kernel/io.h b/src/kernel/io.h
new file mode 100644
index 0000000..8b729f9
--- /dev/null
+++ b/src/kernel/io.h
@@ -0,0 +1,43 @@
+#pragma once
+#include
+
+static inline uint8_t inb(uint16_t port)
+{
+ uint8_t ret;
+ asm volatile ( "inb %1, %0"
+ : "=a"(ret)
+ : "Nd"(port) );
+ return ret;
+}
+unsigned char inb_p(unsigned short port);
+unsigned short inw(unsigned short port);
+unsigned short inw_p(unsigned short port);
+unsigned int inl(unsigned short port);
+unsigned int inl_p(unsigned short port);
+
+static inline void outb(uint16_t port, uint8_t val)
+{
+ asm volatile ( "outb %0, %1" : : "a"(val), "Nd"(port) );
+ /* There's an outb %al, $imm8 encoding, for compile-time constant port numbers that fit in 8b. (N constraint).
+ * Wider immediate constants would be truncated at assemble-time (e.g. "i" constraint).
+ * The outb %al, %dx encoding is the only option for all other cases.
+ * %1 expands to %dx because port is a uint16_t. %w1 could be used if we had the port number a wider C type */
+}
+void outb_p(unsigned char value, unsigned short port);
+void outw(unsigned short value, unsigned short port);
+void outw_p(unsigned short value, unsigned short port);
+void outl(unsigned int value, unsigned short port);
+void outl_p(unsigned int value, unsigned short port);
+
+void insb(unsigned short port, void *addr,
+ unsigned long count);
+void insw(unsigned short port, void *addr,
+ unsigned long count);
+void insl(unsigned short port, void *addr,
+ unsigned long count);
+void outsb(unsigned short port, const void *addr,
+ unsigned long count);
+void outsw(unsigned short port, const void *addr,
+ unsigned long count);
+void outsl(unsigned short port, const void *addr,
+ unsigned long count);
\ No newline at end of file
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
deleted file mode 100644
index 75efa04..0000000
--- a/src/kernel/kernel.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "kernel.h"
-/**
- * simple delay function
- **/
-void delay(int t){
- volatile int i,j;
- for(i=0;i