Update the ML4 class to reflect changes in functionality.

alentours-dev
q3k 2012-10-30 12:08:11 +01:00
parent 39fe121cb7
commit 19c5812c71
1 changed files with 16 additions and 39 deletions

View File

@ -6,50 +6,27 @@ extern "C" {
#include "Tier0/paging.h"
};
// This is more-or less just a C++ wrapper for T_PAGING_ML4.
// This is more-or less just a C++ wrapper for T_PAGING_ML4. For use for pure-kernel processes only
namespace cb {
class CKernelML4 {
protected:
private:
// The paging direcotry structure
T_PAGING_ML4 *m_Directory;
// A bitmap precising whether a table is owned by the page directory
// (== can we delete it when we delete the directory itself)
volatile u32 m_OwnerBitmap[32];
// Check whether a table is owned by us
bool IsTableOurs(u32 Virtual);
// Creates a new table in the address space. Do not use these in
// other directories, as they will e automatically deleted when the
// page directory is deleted - sorry, no reference counting yet!
void CreateTable(u32 Virtual, u8 User = 1, u8 RW = 1);
// Whether it was created empty
bool m_bCreatedEmpty;
// allocator and destructor for segments
void *(*m_SegmentAllocator)(u64);
void (*m_SegmentDestructor)(void *);
public:
// Creates a new page directory for a kernel task
CPageDirectory(bool Empty = false);
~CPageDirectory(void);
// Mapping
void MapTable(u32 Virtual, u32 Physical, u8 User = 1, u8 RW = 1);
void MapPage(u32 Virtual, u32 Physical, u8 User = 1, u8 RW = 1);
void MapRange(u32 Virtual, u32 Physical, u32 Size, u8 User = 1,
u8 RW = 1);
void UnmapPage(u32 Virtual);
// Linking (usually to the kernel directory)
void LinkTable(u32 Virtual, CPageDirectory *Source);
// Copying (from any other page directory)
void CopyTable(u32 Virtual, CPageDirectory *Source,
bool Deep = false, u8 User = 1, u8 RW = 1);
void CopyPage(u32 Virtual, CPageDirectory *Destination, u8 User = 1,
u8 RW = 1);
// Translates a virtual adddress
u32 Translate(u32 Virtual);
// Creates a new page directory for a kernel task, with new stack and other private segments
// 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);
};
};