nstool/lib/libhac/include/nn/hac/MemoryPageEntry.h

62 lines
1.5 KiB
C
Raw Normal View History

#pragma once
#include <string>
#include <fnd/types.h>
2018-08-07 07:17:51 +00:00
#include <nn/hac/KernelCapabilityEntry.h>
2018-08-07 07:17:51 +00:00
namespace nn
{
namespace hac
{
class MemoryPageEntry
{
public:
MemoryPageEntry();
MemoryPageEntry(const KernelCapabilityEntry& kernel_cap);
2018-03-22 05:26:22 +00:00
MemoryPageEntry(uint32_t page);
MemoryPageEntry(uint32_t page, bool flag);
void operator=(const MemoryPageEntry& other);
bool operator==(const MemoryPageEntry& other) const;
bool operator!=(const MemoryPageEntry& other) const;
// kernel capability
const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables
2018-03-22 05:26:22 +00:00
uint32_t getPage() const;
void setPage(uint32_t page);
bool getFlag() const;
void setFlag(bool flag);
bool isMultiplePages() const;
void setMapMultiplePages(bool useFlag);
private:
const std::string kModuleName = "MEMORY_PAGE_ENTRY";
2018-03-22 05:26:22 +00:00
static const uint32_t kPageBits = 24;
static const uint32_t kMaxPage = BIT(kPageBits) - 1;
KernelCapabilityEntry mCap;
2018-03-22 05:26:22 +00:00
uint32_t mPage;
bool mFlag;
bool mUseFlag;
inline void updateCapField()
{
2018-03-22 05:26:22 +00:00
uint32_t field = 0;
field |= (uint32_t)(mPage & kMaxPage) << 0;
field |= (uint32_t)(mFlag) << kPageBits;
mCap.setField(field);
mCap.setType(mUseFlag ? kc::KC_MEMORY_MAP : kc::KC_IO_MEMORY_MAP);
}
inline void processCapField()
{
2018-03-22 05:26:22 +00:00
uint32_t field = mCap.getField();
mPage = (field >> 0) & kMaxPage;
mFlag = (field >> kPageBits);
mUseFlag = mCap.getType() == kc::KC_MEMORY_MAP;
}
};
}
2018-08-07 07:17:51 +00:00
}