From 11e6c2a34db0ea3cd26d8b4061ca1061d008af0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergiusz=20Baza=C5=84ski?= Date: Tue, 30 Oct 2012 13:21:40 +0100 Subject: [PATCH] Basic idea about virtual memory... Now we need a physical memory manager beforehand. --- Kernel/include/Tier1/CKernelML4.h | 24 ++++++++++++++++++++---- Kernel/src/Tier1/CKernelML4.cpp | 3 +++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Kernel/src/Tier1/CKernelML4.cpp diff --git a/Kernel/include/Tier1/CKernelML4.h b/Kernel/include/Tier1/CKernelML4.h index 3641012..2562d36 100644 --- a/Kernel/include/Tier1/CKernelML4.h +++ b/Kernel/include/Tier1/CKernelML4.h @@ -7,23 +7,39 @@ extern "C" { }; // This is more-or less just a C++ wrapper for T_PAGING_ML4. For use for pure-kernel processes only +// It implements the following address space, virtually: +// +// name | start | end | mapping +// -------- -------------------- --------------------- ------------------------------------------------------------------ +// LOWMEM - 0x0000000000000000 - 0x0000000000100000 -> lower 1MiB of physical memory, common, fits in 1/2 of a Table +// SCRATCH - 0xFFFFFFFF00000000 - 0xFFFFFFFF3FFFFFFF -> kernel scratch space & heap. 4GiB, common, fits in 1/1 of a Directory +// STACK - 0xFFFFFFFF40000000 - 0xFFFFFFFF4FFFFFFF -> kernel stack, unique per ML4, 256MiB, fits in 1/16 of a Directory, +// TEXT - 0xFFFFFFFF80000000 - 0xFFFFFFFF8xxxxxxx -> kernel code physical location, common, fits in x/16 of a Directory + namespace cb { class CKernelML4 { private: // The paging direcotry structure T_PAGING_ML4 *m_Directory; + bool m_ShouldFreeML4; // allocator and destructor for segments void *(*m_SegmentAllocator)(u64); void (*m_SegmentDestructor)(void *); + + // kernel stack segment physical memory + u64 m_StackStartPhysical; + u64 m_StackSize; + + // static pointers to common areas + static T_PAGING_TAB *m_LOWMEM; + static T_PAGING_DIR *m_SCRATCH; + static T_PAGING_DIR *m_TEXT; public: - // Creates a new page directory for a kernel task, with new stack and other private segments + // Creates a new page directory for a kernel task, with new stack and other internal stuff // Allocator is a function pointer to an allocator to use, Destructor is the same but for // deallocation CKernelML4(void *(*Allocator)(u64), void (*Destructor)(void *)); - // Creates a new page directory for a kernel task, with existing stack - // This constructor also makes the destructor not free anything. - CKernelML4(void *StackStart, u64 StackSize); // Destroys the structures and frees the segments, if needed ~CKernelML4(void); diff --git a/Kernel/src/Tier1/CKernelML4.cpp b/Kernel/src/Tier1/CKernelML4.cpp new file mode 100644 index 0000000..3256f76 --- /dev/null +++ b/Kernel/src/Tier1/CKernelML4.cpp @@ -0,0 +1,3 @@ +#include "Tier1/CKernelML4.h" + +using namespace cb;