Project structure and standard library string and VGA and terminal drivers
This commit is contained in:
@@ -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")
|
||||
|
||||
BIN
build/OwOS.bin
Normal file → Executable file
BIN
build/OwOS.bin
Normal file → Executable file
Binary file not shown.
BIN
build/OwOS.iso
BIN
build/OwOS.iso
Binary file not shown.
Binary file not shown.
46
kernel.cpp
46
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 <kernel/drivers/VGA/vga.h>
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
9
kernel/drivers/VGA/vga.cpp
Normal file
9
kernel/drivers/VGA/vga.cpp
Normal file
@@ -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;
|
||||
}
|
||||
10
kernel/drivers/VGA/vga.h
Normal file
10
kernel/drivers/VGA/vga.h
Normal file
@@ -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);
|
||||
0
kernel/drivers/terminal/terminal.cpp
Normal file
0
kernel/drivers/terminal/terminal.cpp
Normal file
5
kernel/drivers/terminal/terminal.h
Normal file
5
kernel/drivers/terminal/terminal.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <kernel/drivers/VGA/vga.h>
|
||||
|
||||
void clear();
|
||||
template <typename T>
|
||||
void print(T input);
|
||||
0
kernel/gdt.cpp
Normal file
0
kernel/gdt.cpp
Normal file
0
kernel/gdt.h
Normal file
0
kernel/gdt.h
Normal file
0
lib/std/stdio.cpp
Normal file
0
lib/std/stdio.cpp
Normal file
0
lib/std/stdio.h
Normal file
0
lib/std/stdio.h
Normal file
5
lib/std/string.cpp
Normal file
5
lib/std/string.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "string.h"
|
||||
|
||||
uint32_t strlen(char* str) {
|
||||
|
||||
}
|
||||
3
lib/std/string.h
Normal file
3
lib/std/string.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <lib/stdint.h>
|
||||
|
||||
uint32_t strlen(char* str);
|
||||
10
lib/stdint.h
Normal file
10
lib/stdint.h
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user