diff --git a/Kernel/include/Tier1/CKernelML4.h b/Kernel/include/Tier1/CKernelML4.h index bc267f5..3641012 100644 --- a/Kernel/include/Tier1/CKernelML4.h +++ b/Kernel/include/Tier1/CKernelML4.h @@ -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); }; };