diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a8e9261 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,54 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build", + "type": "shell", + "command": "bash --login -c 'make'", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build (With ISO)", + "type": "shell", + "command": "bash --login -c 'make iso'", + "group": { + "kind": "test", + "isDefault": true, + }, + "problemMatcher": [] + }, + { + "label": "Run", + "type": "shell", + "command": "&('C:/Program Files/qemu/qemu-system-i386') -kernel bin/ThanOS.bin -serial mon:stdio -drive id=disk,file=hda.img,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0", + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "Run (With ISO)", + "type": "shell", + "command": "&('C:/Program Files/qemu/qemu-system-i386') -cdrom bin/ThanOS.iso -serial mon:stdio -drive file=hda.img,format=raw", + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "Run in BOCHS (Rqrs. ISO)", + "type": "shell", + "command": "&('C:/Program Files (x86)/Bochs-2.6.9/bochsdbg.exe') -f bochsrc.bxrc -q", + "group": { + "kind": "test", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/ISO/boot/grub/grub.cfg b/ISO/boot/grub/grub.cfg new file mode 100644 index 0000000..6567823 --- /dev/null +++ b/ISO/boot/grub/grub.cfg @@ -0,0 +1,6 @@ +set timeout=0 +set default=0 + +menuentry "UrMumOS" { + multiboot /boot/kernel +} diff --git a/ISO/boot/kernel b/ISO/boot/kernel new file mode 100644 index 0000000..5252d72 Binary files /dev/null and b/ISO/boot/kernel differ diff --git a/kernel.asm b/kernel.asm new file mode 100644 index 0000000..fc02b9f --- /dev/null +++ b/kernel.asm @@ -0,0 +1,21 @@ +;;kernel.asm +bits 32 ; tells nasm to use 32 bit +section .text + ;multiboot spec + align 4 + dd 0x1BADB002 ;magic + dd 0x00 ;flags + dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero + +global start +extern kmain + +start: + cli ; blocks interupts i think + mov ESP, stack_space ; sets stack pointer + call kmain ; calls kmain c++ function + hlt ; halts CPU + +section .bss +resb 8192 ; 8 kb stack +stack_space: diff --git a/kernel.c b/kernel.c new file mode 100644 index 0000000..2b32063 --- /dev/null +++ b/kernel.c @@ -0,0 +1,24 @@ +void kmain(void) { + const char* str = "Your mother gay lol"; + char* videoMemoryPtr = (char*)0xb8000; // Video memory start + + unsigned int i = 0; + unsigned int j = 0; + + while (j < 80 * 25 * 2) { + videoMemoryPtr[j] = ' '; + videoMemoryPtr[j+1] = 0x07; + j += 2; + } + + j = 0; + + while(str[j] != '\0') { + videoMemoryPtr[i] = str[j]; + videoMemoryPtr[i+1] = 0x07; + j++; + i += 2; + } + + return; +} diff --git a/link.ld b/link.ld new file mode 100644 index 0000000..dae6b25 --- /dev/null +++ b/link.ld @@ -0,0 +1,9 @@ +OUTPUT_FORMAT(elf32-i386) +ENTRY(start) +SECTIONS + { + . = 0x100000; + .text : { *(.text) } + .data : { *(.data) } + .bss : { *(.bss) } + } \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 0000000..6359744 --- /dev/null +++ b/makefile @@ -0,0 +1,64 @@ +# CONFIGURATION +DELETE = rm -f + +# DIRECTORIES +SRC_DIR = ./ +LIB_DIR = ./libs +SHELL_DIR = ./shell +OBJ_DIR = ./obj +INC_DIR = ./libs/includes + +# C++ +SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp) +LIB_FILES = $(wildcard $(LIB_DIR)/*.cpp) +SHELL_FILES = $(wildcard $(SHELL_DIR)/*.cpp) +CPP_OBJ = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(LIB_FILES)) $(patsubst $(SHELL_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SHELL_FILES)) + +# ASSEMBLY +ASM_SRC = $(wildcard $(SRC_DIR)/*.asm) +ASM_LIB = $(wildcard $(LIB_DIR)/*.asm) +ASM_OBJ = $(patsubst $(SRC_DIR)/%.asm,$(OBJ_DIR)/%.o,$(ASM_SRC)) $(patsubst $(LIB_DIR)/%.asm,$(OBJ_DIR)/%.o,$(ASM_LIB)) + +# COMPILER STUFF +# unused: -Wall -Wextra +GPP_CMD = i686-elf-g++ +GAS_CMD = i686-elf-as +LDFLAGS = -T linker.ld -ffreestanding -O2 -nostdlib -lgcc -Wwrite-strings +CPPFLAGS = -I $(INC_DIR) -ffreestanding -O2 -fno-rtti -Wno-write-strings -Wno-unused-variable -Wno-multichar -Wno-unused-parameter -Wno-overflow -Wno-narrowing -fno-exceptions +CXXFLAGS = +GASFLAGS = +OBJ_FILES = $(CPP_OBJ) $(ASM_OBJ) +OUTPUT = ./bin/MemeOS.bin +ISO_OUTPUT = ./bin/MemeOS.iso + +all: $(OUTPUT) + +clean: + $(DELETE) ./obj/* + $(DELETE) ./bin/* + +iso: all + cp $(OUTPUT) ./ISO/boot/MemeOS + grub-mkrescue -o $(ISO_OUTPUT) ./ISO + +folders: + mkdir -p ./bin + mkdir -p ./obj + +$(OUTPUT): $(OBJ_FILES) + $(GPP_CMD) $(LDFLAGS) -o $@ $^ + +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp + $(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< + +$(OBJ_DIR)/%.o: $(LIB_DIR)/%.cpp + $(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< + +$(OBJ_DIR)/%.o: $(SHELL_DIR)/%.cpp + $(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< + +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm + $(GAS_CMD) $(GASFLAGS) -o $@ $< + +$(OBJ_DIR)/%.o: $(LIB_DIR)/%.asm + $(GAS_CMD) $(GASFLAGS) -o $@ $< \ No newline at end of file