Cucumber/include/Tier1/CPageDirectory.h

60 lines
2.2 KiB
C
Raw Normal View History

2011-03-31 10:21:32 +00:00
#ifndef __CPAGEDIRECTORY_H__
#define __CPAGEDIRECTORY_H__
#include "types.h"
2011-04-01 13:21:31 +00:00
extern "C" {
#include "Tier0/paging.h"
};
2011-03-31 10:21:32 +00:00
// This is more-or less just a C++ wrapper for T_PGAE_DIRECTORY.
namespace cb {
class CPageDirectory {
2011-04-03 16:49:04 +00:00
friend class CKernel;
friend class CScheduler;
friend class CTask;
2011-04-01 19:51:14 +00:00
protected:
2011-04-01 13:21:31 +00:00
// The paging direcotry structure
2011-04-01 19:51:14 +00:00
T_PAGING_DIRECTORY *m_Directory;
2011-04-01 13:21:31 +00:00
2011-04-01 19:51:14 +00:00
// A bitmap precising whether a table is owned by the page directory
2011-04-01 13:21:31 +00:00
// (== can we delete it when we delete the directory itself)
2011-04-30 17:08:46 +00:00
volatile u32 m_OwnerBitmap[32];
2011-04-01 19:51:14 +00:00
// Check whether a table is owned by us
bool IsTableOurs(u32 Virtual);
2011-04-01 13:21:31 +00:00
// 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!
2011-04-01 19:51:14 +00:00
void CreateTable(u32 Virtual, u8 User = 1, u8 RW = 1);
2011-04-03 16:49:04 +00:00
// Whether it was created empty
bool m_CreatedEmpty;
2011-03-31 10:21:32 +00:00
public:
// Creates a new page directory for a kernel task
2011-04-03 16:49:04 +00:00
CPageDirectory(bool Empty = false);
2011-04-01 13:21:31 +00:00
~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);
2011-04-03 16:49:04 +00:00
void UnmapPage(u32 Virtual);
2011-04-01 13:21:31 +00:00
// Linking (usually to the kernel directory)
void LinkTable(u32 Virtual, CPageDirectory *Source);
// Copying (from any other page directory)
2011-04-03 16:49:04 +00:00
void CopyTable(u32 Virtual, CPageDirectory *Source,
bool Deep = false, u8 User = 1, u8 RW = 1);
void CopyPage(u32 Virtual, CPageDirectory *Destination, u8 User = 1,
2011-04-01 19:51:14 +00:00
u8 RW = 1);
// Translates a virtual adddress
u32 Translate(u32 Virtual);
2011-03-31 10:21:32 +00:00
};
};
#endif