diff options
author | Marvin Borner | 2020-07-22 00:50:41 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-22 00:50:41 +0200 |
commit | 16604c4ea0ebe44f12741d3d6efed0dc1867204f (patch) | |
tree | 7560d30955b7619ca53b2b69b4bc8332054e37f5 | |
parent | a06e4d3a2e0c00210b54f5c060e90c8e5b425646 (diff) |
Okidoki, seems to work!
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | apps/test.c | 2 | ||||
-rwxr-xr-x | run | 6 | ||||
-rw-r--r-- | src/entry.asm | 2 | ||||
-rw-r--r-- | src/lib/def.h | 18 | ||||
-rw-r--r-- | src/main.c | 19 |
6 files changed, 40 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 524c679..1ad8dbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,8 @@ set(CMAKE_ASM_LINKER_PREFERENCE ${CMAKE_LINKER}) set(CMAKE_C_LINKER_PREFERENCE ${CMAKE_LINKER}) # Compiler and linker flags -set(CMAKE_C_FLAGS "-Wall -Wextra -nostdlib -nostdinc -ffreestanding -std=gnu99 -pedantic-errors -c -I${CMAKE_CURRENT_SOURCE_DIR}/src/lib/") -set(CMAKE_EXE_LINKER_FLAGS "-ffreestanding -O2 -nostdlib -nostdinc") +set(CMAKE_C_FLAGS "-Wall -Wextra -nostdlib -nostdinc -ffreestanding -std=c99 -pedantic-errors -c -I${CMAKE_CURRENT_SOURCE_DIR}/src/lib/") +set(CMAKE_EXE_LINKER_FLAGS "-ffreestanding -O2 -nostdlib -nostdinc -emain") set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> -o <OBJECT> -f bin -O0") set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_ASM_LINK_EXECUTABLE "<CMAKE_LINKER> ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") diff --git a/apps/test.c b/apps/test.c index 40ba715..bce7343 100644 --- a/apps/test.c +++ b/apps/test.c @@ -1,4 +1,4 @@ -int main(int argc, char *argv[]) +int main() { int a = 42 >> 6; return a; @@ -80,9 +80,9 @@ make_build() { # Create disk image dd if=/dev/zero of=build/disk.img bs=1k count=16k - sudo mke2fs build/disk.img + sudo mke2fs build/disk.img >/dev/null dd if=disk/boot.bin of=build/disk.img conv=notrunc - ./ext2util/ext2util -x build/disk.img -wf disk/melvix.bin -i 5 + ./ext2util/ext2util -x build/disk.img -wf disk/melvix.bin -i 5 >/dev/null printf "Build finshed successfully!\n\n" } @@ -100,7 +100,7 @@ make_disasm() { } make_sync() { - rm tags compile_commands.json + #rm tags compile_commands.json ctags -R --exclude=.git --exclude=build --exclude=iso --exclude=cross . mkdir -p build cd build diff --git a/src/entry.asm b/src/entry.asm index 487e4b4..d17246d 100644 --- a/src/entry.asm +++ b/src/entry.asm @@ -51,7 +51,7 @@ %define A20_EXCLUDE_BIT 0xfe ; Bit 0 may be write-only, causing a crash ; GDT constants (bitmap) -%define GDT_MAX_LIMIT 0xffff +%define GDT_MAX_LIMIT 0xffff ; I just use the max limit lel %define GDT_PRESENT 0b10000000 ; Is present %define GDT_DESCRIPTOR 0b00010000 ; Descriptor type, set for code/data %define GDT_EXECUTABLE 0b00001000 ; Can be executed diff --git a/src/lib/def.h b/src/lib/def.h new file mode 100644 index 0000000..dc3cc55 --- /dev/null +++ b/src/lib/def.h @@ -0,0 +1,18 @@ +#ifndef DEF_H +#define DEF_H + +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +#define NULL ((void *)0) + +#endif @@ -1,11 +1,22 @@ -int main() +#include <def.h> + +void clear(); + +// This must kinda be at the top +int main(u32 *mem_info) +{ + mem_info++; // TODO: Use the mmap! + clear(); + while (1) { + }; + return 0; +} + +void clear() { char *vga = (char *)0x000B8000; for (long i = 0; i < 80 * 25; i++) { *vga++ = 0; *vga++ = 0; } - while (1) { - }; - return 0; } |