Add MemoryManager class
This will be the top-level class for the memory manager subsystem. Copy in some code from kmain()
This commit is contained in:
parent
ddb4c30c62
commit
b9ece9bbcb
3 changed files with 68 additions and 0 deletions
37
src/Memory.cc
Normal file
37
src/Memory.cc
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* Memory.cc
|
||||
* vim: set tw=80:
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
/**
|
||||
* Top-level classes for managing system memory.
|
||||
*/
|
||||
|
||||
#include "Memory.hh"
|
||||
|
||||
namespace kernel {
|
||||
|
||||
/*
|
||||
* Public
|
||||
*/
|
||||
|
||||
void
|
||||
MemoryManager::initialize(Console& console)
|
||||
{
|
||||
initializeGDT();
|
||||
console.printString("GDT loaded\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Private
|
||||
*/
|
||||
|
||||
void
|
||||
MemoryManager::initializeGDT()
|
||||
{
|
||||
mGDT.setNullDescriptor(0);
|
||||
mGDT.setDescriptor(1, x86::GDT::DescriptorSpec::kernelSegment(0, 0xFFFFFFFF, x86::GDT::Type::CodeEXR));
|
||||
mGDT.setDescriptor(2, x86::GDT::DescriptorSpec::kernelSegment(0, 0xFFFFFFFF, x86::GDT::Type::DataRW));
|
||||
mGDT.load();
|
||||
}
|
||||
|
||||
} /* namespace kernel */
|
30
src/Memory.hh
Normal file
30
src/Memory.hh
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Memory.hh
|
||||
* vim: set tw=80:
|
||||
* Eryn Wells <eryn@erynwells.me>
|
||||
*/
|
||||
/**
|
||||
* Declaration of top-level classes for managing system memory.
|
||||
*/
|
||||
|
||||
#ifndef __MEMORY_HH__
|
||||
#define __MEMORY_HH__
|
||||
|
||||
#include "Console.hh"
|
||||
#include "Descriptors.hh"
|
||||
|
||||
|
||||
namespace kernel {
|
||||
|
||||
struct MemoryManager
|
||||
{
|
||||
void initialize(Console& console);
|
||||
|
||||
private:
|
||||
x86::GDT mGDT;
|
||||
|
||||
void initializeGDT();
|
||||
};
|
||||
|
||||
} /* namespace kernel */
|
||||
|
||||
#endif /* __MEMORY_HH__ */
|
|
@ -15,6 +15,7 @@ files = [
|
|||
'Descriptors.cc',
|
||||
'Interrupts.cc',
|
||||
'Kernel.cc',
|
||||
'Memory.cc',
|
||||
'Multiboot.cc',
|
||||
'PIC.cc',
|
||||
'cxa.cc',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue