diff --git a/src/Attributes.hh b/src/Attributes.hh index b6fc423..07f3594 100644 --- a/src/Attributes.hh +++ b/src/Attributes.hh @@ -13,5 +13,6 @@ #define __ATTRIBUTES_HH__ #define PACKED __attribute__((packed)) +#define NORETURN __attribute((noreturn)) #endif /* __ATTRIBUTES_HH__ */ diff --git a/src/Kernel.cc b/src/Kernel.cc new file mode 100644 index 0000000..374b2be --- /dev/null +++ b/src/Kernel.cc @@ -0,0 +1,54 @@ +/* Kernel.cc + * vim: set tw=80: + * Eryn Wells + */ +/** + * Kernel object. This is the highest level object in the system. + */ + +#include "Kernel.hh" +#include "Interrupts.hh" + +namespace { + +static kernel::Kernel sKernel; + +} /* anonymous namespace */ + +namespace kernel { + +/* + * Static + */ + +Kernel* +Kernel::systemKernel() +{ + return &sKernel; +} + +/* + * Public + */ + +void +Kernel::panic(const char* msg, + ...) +{ + +} + +/* + * Private + */ + +void +Kernel::halt() +{ + x86::InterruptHandler::systemInterruptHandler().disableInterrupts(); + for (;;) { + asm("hlt"); + } +} + +} /* namespace kernel */ diff --git a/src/Kernel.hh b/src/Kernel.hh new file mode 100644 index 0000000..ec61866 --- /dev/null +++ b/src/Kernel.hh @@ -0,0 +1,28 @@ +/* Kernel.hh + * vim: set tw=80: + * Eryn Wells + */ +/** + * Kernel object. This is the highest level object in the system. + */ + +#ifndef __KERNEL_HH__ +#define __KERNEL_HH__ + +#include "Attributes.hh" + + +namespace kernel { + +struct Kernel +{ + static Kernel* systemKernel(); + + void panic(const char* msg, ...); + + void halt() NORETURN; +}; + +} /* namespace kernel */ + +#endif /* __KERNEL_HH__ */ diff --git a/src/Main.cc b/src/Main.cc index 20ed765..df55c55 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -10,6 +10,7 @@ #include "Console.hh" #include "Descriptors.hh" #include "Interrupts.hh" +#include "Kernel.hh" #include "Multiboot.hh" #include "kstd/Types.hh" @@ -74,5 +75,5 @@ kmain(multiboot::Information *information) interruptHandler.enableInterrupts(); console.printString("Interrupts enabled\n"); - for (;;) { } + kernel::Kernel::systemKernel()->halt(); } diff --git a/src/SConscript b/src/SConscript index 68756ba..c6701cc 100644 --- a/src/SConscript +++ b/src/SConscript @@ -14,6 +14,7 @@ files = [ 'ConsolePrintFormat.cc', 'Descriptors.cc', 'Interrupts.cc', + 'Kernel.cc', 'Multiboot.cc', 'PIC.cc', 'cxa.cc',