commit f30433dd27cc6959b0605a2e43a126da77d9d027 Author: Jarkko Toivanen Date: Mon Jun 12 11:46:47 2023 +0300 I guess it barely prints a thing diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e494714 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.elf +*.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..77b84cc --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +all: kernel-i386.elf +clean: + rm *.o *.elf + +start32.o: start32.asm + fasm start32.asm +kernel.o: kernel.c + ../tinycc/tcc -m32 -c kernel.c +kernel-i386.elf: kernel.o start32.o + ../tinycc/tcc -m32 -nostdlib -Wl,-Ttext,0x100000 start32.o kernel.o -o kernel-i386.elf + +qemu: kernel-i386.elf + qemu-system-i386 -kernel kernel-i386.elf diff --git a/README.md b/README.md new file mode 100644 index 0000000..3e1702f --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# KoalemOS +Multiboot compatible stupid useless OS-like project. +## Compatibility +32bit x86 legacy BIOS system +## Building +FASM and TinyCCompiler are used. +TCC might need manual compilation for 32bit crosscompilation +on 64bit systems. +Just download the source and `make cross` or something. diff --git a/kernel.c b/kernel.c new file mode 100644 index 0000000..7e87560 --- /dev/null +++ b/kernel.c @@ -0,0 +1,12 @@ +void kmain (void) { + *((unsigned char *) 0xB8000) = 'H'; + *((unsigned char *) 0xB8001) = 0x1F; + *((unsigned char *) 0xB8002) = 'E'; + *((unsigned char *) 0xB8003) = 0x1F; + *((unsigned char *) 0xB8004) = 'L'; + *((unsigned char *) 0xB8005) = 0x1F; + *((unsigned char *) 0xB8006) = 'L'; + *((unsigned char *) 0xB8007) = 0x1F; + *((unsigned char *) 0xB8008) = 'O'; + *((unsigned char *) 0xB8009) = 0x1F; +} diff --git a/start32.asm b/start32.asm new file mode 100644 index 0000000..257691d --- /dev/null +++ b/start32.asm @@ -0,0 +1,43 @@ +; Tutorial: A small kernel with Fasm & TCC +; By Tommy. + + format elf + use32 + +; +; Equates +; +MULTIBOOT_PAGE_ALIGN equ (1 shl 0) +MULTIBOOT_MEMORY_INFO equ (1 shl 1) +MULTIBOOT_AOUT_KLUDGE equ (1 shl 16) +MULTIBOOT_HEADER_MAGIC equ 0x1BADB002 +MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN or MULTIBOOT_MEMORY_INFO +MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) + + +; +; Multiboot header +; +.multiboot: align 4 + dd MULTIBOOT_HEADER_MAGIC + dd MULTIBOOT_HEADER_FLAGS + dd MULTIBOOT_CHECKSUM + + +section '.bss' writable align 16 + stack_bottom: + rb 16384 + stack_top: + + section '.text' executable +; +; Kernel entry point. +; + public _start + extrn kmain +_start: + ; Call the main kernel function. + call kmain + +@@: + jmp @b