diff --git a/build/CMakeLists.txt b/CMakeLists.txt similarity index 63% rename from build/CMakeLists.txt rename to CMakeLists.txt index e6d1da2..569b2ac 100644 --- a/build/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,19 +10,23 @@ set(CMAKE_CXX_COMPILER "i686-elf-g++") set(CMAKE_CXX_FLAGS "-ffreestanding -O2 -fno-rtti -Wno-write-strings -Wno-multichar -Wno-unused-parameter -Wno-overflow -Wno-narrowing -fno-exceptions -Wno-trigraphs ${CMAKE_CXX_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "-T ../linker.ld -ffreestanding -O2 -nostdlib -lgcc -Wwrite-strings ${CMAKE_EXE_LINKER_FLAGS}") -include_directories(OwOS "../src") +include_directories(OwOS "./") + # Kernel source -file(GLOB KERN_SRC - "../src/*.cpp" - "../src/*.asm" - "../*.asm" - "../*.cpp" -) +file(GLOB KERN_SRC "*.asm" "*.cpp" "kernel/*.asm" "kernel/*.cpp") + +# Driver source +file(GLOB DRIV_DISP_VGA "kernel/drivers/VGA/*.asm" "kernel/drivers/VGA/*.cpp") +file(GLOB DRIV_DISP_TERM "kernel/drivers/terminal/*.asm" "kernel/drivers/terminal/*.cpp") + +# Lib source +file(GLOB LIB_STD "lib/std/*.asm" "lib/std/*.cpp") + set(SRCS ${KERN_SRC}) -add_executable(OwOS ${SRCS}) +add_executable(OwOS ${SRCS} ${DRIV_DISP_VGA} ${LIB_STD}) set_target_properties(OwOS PROPERTIES OUTPUT_NAME "OwOS.bin") diff --git a/build/OwOS.bin b/build/OwOS.bin old mode 100644 new mode 100755 index 22516b5..b99ede5 Binary files a/build/OwOS.bin and b/build/OwOS.bin differ diff --git a/build/OwOS.iso b/build/OwOS.iso index a970ce7..795f1a6 100644 Binary files a/build/OwOS.iso and b/build/OwOS.iso differ diff --git a/iso/boot/OwOS.bin b/iso/boot/OwOS.bin index 22516b5..334be57 100644 Binary files a/iso/boot/OwOS.bin and b/iso/boot/OwOS.bin differ diff --git a/kernel.cpp b/kernel.cpp index 8bc41a1..0016ee8 100644 --- a/kernel.cpp +++ b/kernel.cpp @@ -1,41 +1,23 @@ -#define TERM_WIDTH 80 -#define TERM_HEIGHT 25 - -struct VGAChar_t { - char c; - char foreground:4; - char background:4; -}__attribute__((packed)); - -VGAChar_t* framebuffer = (VGAChar_t*)0xB8000; - -void putcar(int x, int y, char c, char foreground, char background) { - framebuffer[(y * TERM_WIDTH) + x].c = c; - framebuffer[(y * TERM_WIDTH) + x].foreground = foreground; - framebuffer[(y * TERM_WIDTH) + x].background = background; -} +#include extern "C" int kernel_main() { - for (int x = 0; x < TERM_WIDTH; x++) - for (int y = 0; y < TERM_HEIGHT; y++) - putcar(x, y, ' ', 0x00, 0x00); - - putcar(0, 0, 'H', 0x01, 0x07); - putcar(1, 0, 'A', 0x01, 0x07); - putcar(2, 0, 'H', 0x01, 0x07); - putcar(3, 0, 'A', 0x01, 0x07); - putcar(4, 0, '!', 0x01, 0x07); - putcar(5, 0, ' ', 0x01, 0x07); - putcar(6, 0, 'P', 0x01, 0x07); - putcar(7, 0, 'E', 0x01, 0x07); - putcar(8, 0, 'N', 0x01, 0x07); - putcar(9, 0, 'I', 0x01, 0x07); - putcar(10, 0, 'S', 0x01, 0x07); - putcar(11, 0, '!', 0x01, 0x07); + putchar(0, 0, 'H', 0x01, 0x07); + putchar(1, 0, 'A', 0x01, 0x07); + putchar(2, 0, 'H', 0x01, 0x07); + putchar(3, 0, 'A', 0x01, 0x07); + putchar(4, 0, '!', 0x01, 0x07); + putchar(5, 0, ' ', 0x01, 0x07); + putchar(6, 0, 'P', 0x01, 0x07); + putchar(7, 0, 'E', 0x01, 0x07); + putchar(8, 0, 'N', 0x01, 0x07); + putchar(9, 0, 'I', 0x01, 0x07); + putchar(10, 0, 'S', 0x01, 0x07); + putchar(11, 0, '!', 0x01, 0x07); for (;;) asm("hlt"); + } diff --git a/kernel/drivers/VGA/vga.cpp b/kernel/drivers/VGA/vga.cpp new file mode 100644 index 0000000..18d1001 --- /dev/null +++ b/kernel/drivers/VGA/vga.cpp @@ -0,0 +1,9 @@ +#include "vga.h" + +VGAChar_t* framebuffer = (VGAChar_t*)0xB8000; + +void putchar(int x, int y, char c, char foreground, char background) { + framebuffer[(y * TERM_WIDTH) + x].c = c; + framebuffer[(y * TERM_WIDTH) + x].foreground = foreground; + framebuffer[(y * TERM_WIDTH) + x].background = background; +} diff --git a/kernel/drivers/VGA/vga.h b/kernel/drivers/VGA/vga.h new file mode 100644 index 0000000..34076c2 --- /dev/null +++ b/kernel/drivers/VGA/vga.h @@ -0,0 +1,10 @@ +#define TERM_WIDTH 80 +#define TERM_HEIGHT 25 + +struct VGAChar_t { + char c; + char foreground:4; + char background:4; +}__attribute__((packed)); + +void putchar(int x, int y, char c, char foreground, char background); diff --git a/kernel/drivers/terminal/terminal.cpp b/kernel/drivers/terminal/terminal.cpp new file mode 100644 index 0000000..e69de29 diff --git a/kernel/drivers/terminal/terminal.h b/kernel/drivers/terminal/terminal.h new file mode 100644 index 0000000..7c64c9d --- /dev/null +++ b/kernel/drivers/terminal/terminal.h @@ -0,0 +1,5 @@ +#include + +void clear(); +template +void print(T input); diff --git a/kernel/gdt.cpp b/kernel/gdt.cpp new file mode 100644 index 0000000..e69de29 diff --git a/kernel/gdt.h b/kernel/gdt.h new file mode 100644 index 0000000..e69de29 diff --git a/lib/std/stdio.cpp b/lib/std/stdio.cpp new file mode 100644 index 0000000..e69de29 diff --git a/lib/std/stdio.h b/lib/std/stdio.h new file mode 100644 index 0000000..e69de29 diff --git a/lib/std/string.cpp b/lib/std/string.cpp new file mode 100644 index 0000000..285d0dc --- /dev/null +++ b/lib/std/string.cpp @@ -0,0 +1,5 @@ +#include "string.h" + +uint32_t strlen(char* str) { + +} diff --git a/lib/std/string.h b/lib/std/string.h new file mode 100644 index 0000000..6a885f6 --- /dev/null +++ b/lib/std/string.h @@ -0,0 +1,3 @@ +#include + +uint32_t strlen(char* str); diff --git a/lib/stdint.h b/lib/stdint.h new file mode 100644 index 0000000..58828df --- /dev/null +++ b/lib/stdint.h @@ -0,0 +1,10 @@ +#pragma once + +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +typedef long long int int64_t; +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long int uint64_t;