inital commit
This commit is contained in:
54
.vscode/tasks.json
vendored
Normal file
54
.vscode/tasks.json
vendored
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
6
ISO/boot/grub/grub.cfg
Normal file
6
ISO/boot/grub/grub.cfg
Normal file
@@ -0,0 +1,6 @@
|
||||
set timeout=0
|
||||
set default=0
|
||||
|
||||
menuentry "UrMumOS" {
|
||||
multiboot /boot/kernel
|
||||
}
|
||||
BIN
ISO/boot/kernel
Normal file
BIN
ISO/boot/kernel
Normal file
Binary file not shown.
21
kernel.asm
Normal file
21
kernel.asm
Normal file
@@ -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:
|
||||
24
kernel.c
Normal file
24
kernel.c
Normal file
@@ -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;
|
||||
}
|
||||
9
link.ld
Normal file
9
link.ld
Normal file
@@ -0,0 +1,9 @@
|
||||
OUTPUT_FORMAT(elf32-i386)
|
||||
ENTRY(start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x100000;
|
||||
.text : { *(.text) }
|
||||
.data : { *(.data) }
|
||||
.bss : { *(.bss) }
|
||||
}
|
||||
64
makefile
Normal file
64
makefile
Normal file
@@ -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 $@ $<
|
||||
Reference in New Issue
Block a user