diff --git a/Makefile b/Makefile index 86a3b5e..bb8f1b5 100644 --- a/Makefile +++ b/Makefile @@ -14,15 +14,17 @@ ferglos.bin: linker.ld $(objs) ld $(LDPARAMS) -T $< -o $@ $(objs) ferglos.iso: ferglos.bin - mkdir -p iso/boot/grub + mkdir iso + mkdir iso/boot + mkdir iso/boot/grub cp ferglos.bin iso/boot/ferglos.bin - echo 'set timeout=0' > iso/boot/grub/grub.cfg - echo 'set default=0' >> iso/boot/grub/grub.cfg - echo '' >> iso/boot/grub/grub.cfg - echo 'menuentry "FerglOS" {' >> iso/boot/grub/grub.cfg - echo ' multiboot /boot/ferglos.bin' >> iso/boot/grub/grub.cfg - echo ' boot' >> iso/boot/grub/grub.cfg - echo '}' >> iso/boot/grub/grub.cfg + echo 'set timeout=0' > iso/boot/grub/grub.cfg + echo 'set default=0' >> iso/boot/grub/grub.cfg + echo '' >> iso/boot/grub/grub.cfg + echo 'menuentry "My Operating System" {' >> iso/boot/grub/grub.cfg + echo ' multiboot /boot/ferglos.bin' >> iso/boot/grub/grub.cfg + echo ' boot' >> iso/boot/grub/grub.cfg + echo '}' >> iso/boot/grub/grub.cfg grub-mkrescue --output=ferglos.iso iso rm -rf iso diff --git a/kernel.cpp b/kernel.cpp index 9724705..dba7938 100644 --- a/kernel.cpp +++ b/kernel.cpp @@ -1,28 +1,21 @@ -// yip - ya'boy is writing his own printf -// libc doesn't exist yet so got no choice +#include "types.h" void printf(char* str) { - unsigned short* vid_mem = (unsigned short*)0xb8000; - for (int i = 0; str[i] != '\0'; i++) { - //high byte is colour, so just need to copy to text address - vid_mem[i] = (vid_mem[i] * 0xFF00) | str[i]; - } + static uint16_t* VideoMemory = (uint16_t*)0xb8000; + + for (int i = 0; str[i] != '\0'; ++i) + VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i]; } typedef void (*constructor)(); extern "C" constructor start_ctors; extern "C" constructor end_ctors; extern "C" void call_constructors() { - for (constructor* i = &start_ctors; i != (constructor*)end_ctors; i++) { + for (constructor* i = &start_ctors; i != &end_ctors; i++) (*i)(); - } } -/* - take in the multiboot structure and the GRUB magic number - not sure I actually need magic_num though -*/ -extern "C" void ferglos_Main(void* mb_struct, unsigned int magic_num) { +extern "C" void ferglos_Main(const void* multiboot_structure, uint32_t /*mb_mag*/) { printf("Hello, Sailor!"); while (1) diff --git a/types.h b/types.h new file mode 100644 index 0000000..cfa2465 --- /dev/null +++ b/types.h @@ -0,0 +1,13 @@ +#ifndef __TYPES_H +#define __TYPES_H + +typedef char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; + +#endif \ No newline at end of file