Add Kernel object
- Implement halt() - Call the system kernel halt() method at the end of kmain()
This commit is contained in:
parent
9bf27a3115
commit
abfcfd24cd
5 changed files with 86 additions and 1 deletions
|
@ -13,5 +13,6 @@
|
||||||
#define __ATTRIBUTES_HH__
|
#define __ATTRIBUTES_HH__
|
||||||
|
|
||||||
#define PACKED __attribute__((packed))
|
#define PACKED __attribute__((packed))
|
||||||
|
#define NORETURN __attribute((noreturn))
|
||||||
|
|
||||||
#endif /* __ATTRIBUTES_HH__ */
|
#endif /* __ATTRIBUTES_HH__ */
|
||||||
|
|
54
src/Kernel.cc
Normal file
54
src/Kernel.cc
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/* Kernel.cc
|
||||||
|
* vim: set tw=80:
|
||||||
|
* Eryn Wells <eryn@erynwells.me>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 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 */
|
28
src/Kernel.hh
Normal file
28
src/Kernel.hh
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/* Kernel.hh
|
||||||
|
* vim: set tw=80:
|
||||||
|
* Eryn Wells <eryn@erynwells.me>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* 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__ */
|
|
@ -10,6 +10,7 @@
|
||||||
#include "Console.hh"
|
#include "Console.hh"
|
||||||
#include "Descriptors.hh"
|
#include "Descriptors.hh"
|
||||||
#include "Interrupts.hh"
|
#include "Interrupts.hh"
|
||||||
|
#include "Kernel.hh"
|
||||||
#include "Multiboot.hh"
|
#include "Multiboot.hh"
|
||||||
#include "kstd/Types.hh"
|
#include "kstd/Types.hh"
|
||||||
|
|
||||||
|
@ -74,5 +75,5 @@ kmain(multiboot::Information *information)
|
||||||
interruptHandler.enableInterrupts();
|
interruptHandler.enableInterrupts();
|
||||||
console.printString("Interrupts enabled\n");
|
console.printString("Interrupts enabled\n");
|
||||||
|
|
||||||
for (;;) { }
|
kernel::Kernel::systemKernel()->halt();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ files = [
|
||||||
'ConsolePrintFormat.cc',
|
'ConsolePrintFormat.cc',
|
||||||
'Descriptors.cc',
|
'Descriptors.cc',
|
||||||
'Interrupts.cc',
|
'Interrupts.cc',
|
||||||
|
'Kernel.cc',
|
||||||
'Multiboot.cc',
|
'Multiboot.cc',
|
||||||
'PIC.cc',
|
'PIC.cc',
|
||||||
'cxa.cc',
|
'cxa.cc',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue