Skip to content

Commit

Permalink
Added and cleaned up type definitions. Added quemu run target.
Browse files Browse the repository at this point in the history
  • Loading branch information
IPlayZed committed Feb 19, 2022
1 parent dfd2a27 commit 57bed4d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/$<
21 changes: 7 additions & 14 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)();
}
Expand All @@ -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);
}
15 changes: 15 additions & 0 deletions src/types.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 57bed4d

Please sign in to comment.