From 57bed4d704b9bc2984a24e6af03ff766834c9d37 Mon Sep 17 00:00:00 2001 From: IPlayZed Date: Sat, 19 Feb 2022 23:15:49 +0100 Subject: [PATCH] Added and cleaned up type definitions. Added quemu run target. --- src/Makefile | 3 +++ src/kernel.cpp | 21 +++++++-------------- src/types.h | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Makefile b/src/Makefile index 17e1398..e917ce0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -37,3 +37,6 @@ sunix.iso: sunix.bin grub-mkrescue --output=$@ ${ISO_DIR} rm -rf iso mv $@ ../out + +run: sunix.iso + qemu-system-i386 ../out/$< \ No newline at end of file diff --git a/src/kernel.cpp b/src/kernel.cpp index 340815b..ae3f2c5 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -1,16 +1,9 @@ -typedef unsigned short uint16_t; -typedef void (*ctor)(); +#include "types.h" -#define HIGH_BYTE 0xFF00 -#define VRAM_ADDRS (uint16_t*)0xb8000 -#define MESSAGE (char*)"Kernel main test" -#define TRUE 1==1 -#define FALSE !TRUE -#define LANG_C "C" +#define MESSAGE (char*)"Kernel main test " - -extern LANG_C ctor start_ctors; -extern LANG_C ctor end_ctors; +extern LANG_C f_ctor start_ctors; +extern LANG_C f_ctor end_ctors; /* As we do not use glibc, we must write our very basic implementation of print. @@ -36,7 +29,7 @@ void printf(char* str) * */ extern LANG_C void call_ctors() { - for(ctor* i = &start_ctors; i != &end_ctors; i++) + for(f_ctor* i = &start_ctors; i != &end_ctors; i++) { (*i)(); } @@ -48,7 +41,7 @@ extern LANG_C void call_ctors() * to the stack. The multiboot structure can be used for kernel operation, while * the multiboot flag can be used to make sure the enviroment is indeed multiboot. * */ -extern LANG_C void kernel_main(void* multiboot_struct, unsigned int multiboot_flag) { +extern LANG_C void kernel_main(void* multiboot_struct, uint32_t multiboot_flags) { printf(MESSAGE); - while(TRUE); + while(_TRUE); } diff --git a/src/types.h b/src/types.h index 969df98..08e34cd 100644 --- a/src/types.h +++ b/src/types.h @@ -1,11 +1,26 @@ #ifndef __TYPES_H__ #define __TYPES_H__ +#define _TRUE 1==1 +#define _FALSE !_TRUE +#define LANG_C "C" +#define HIGH_BYTE 0xFF00 +#define VRAM_ADDRS (uint16_t*)0xB8000 + +typedef void (*f_ctor)(); + +typedef unsigned char _boolean; + 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 uin64_t; #endif