[nx|nstool] Refactored Kernel Capability handling.

This commit is contained in:
jakcron 2018-06-29 12:24:39 +08:00
parent 9f0408d85a
commit 4d113b9a0b
46 changed files with 325 additions and 313 deletions

View file

@ -5,7 +5,7 @@
#include <nx/aci.h> #include <nx/aci.h>
#include <nx/FileSystemAccessControlBinary.h> #include <nx/FileSystemAccessControlBinary.h>
#include <nx/ServiceAccessControlBinary.h> #include <nx/ServiceAccessControlBinary.h>
#include <nx/KcBinary.h> #include <nx/KernelCapabilityBinary.h>
namespace nx namespace nx
{ {
@ -36,8 +36,8 @@ namespace nx
const nx::ServiceAccessControlBinary& getServiceAccessControl() const; const nx::ServiceAccessControlBinary& getServiceAccessControl() const;
void setServiceAccessControl(const ServiceAccessControlBinary& sac); void setServiceAccessControl(const ServiceAccessControlBinary& sac);
const nx::KcBinary& getKernelCapabilities() const; const nx::KernelCapabilityBinary& getKernelCapabilities() const;
void setKernelCapabilities(const KcBinary& kc); void setKernelCapabilities(const KernelCapabilityBinary& kc);
private: private:
const std::string kModuleName = "ACCESS_CONTROL_INFO_BINARY"; const std::string kModuleName = "ACCESS_CONTROL_INFO_BINARY";
@ -48,6 +48,6 @@ namespace nx
uint64_t mProgramId; uint64_t mProgramId;
nx::FileSystemAccessControlBinary mFileSystemAccessControl; nx::FileSystemAccessControlBinary mFileSystemAccessControl;
nx::ServiceAccessControlBinary mServiceAccessControl; nx::ServiceAccessControlBinary mServiceAccessControl;
nx::KcBinary mKernelCapabilities; nx::KernelCapabilityBinary mKernelCapabilities;
}; };
} }

View file

@ -6,7 +6,7 @@
#include <nx/aci.h> #include <nx/aci.h>
#include <nx/FileSystemAccessControlBinary.h> #include <nx/FileSystemAccessControlBinary.h>
#include <nx/ServiceAccessControlBinary.h> #include <nx/ServiceAccessControlBinary.h>
#include <nx/KcBinary.h> #include <nx/KernelCapabilityBinary.h>
namespace nx namespace nx
{ {
@ -69,8 +69,8 @@ namespace nx
const nx::ServiceAccessControlBinary& getServiceAccessControl() const; const nx::ServiceAccessControlBinary& getServiceAccessControl() const;
void setServiceAccessControl(const ServiceAccessControlBinary& sac); void setServiceAccessControl(const ServiceAccessControlBinary& sac);
const nx::KcBinary& getKernelCapabilities() const; const nx::KernelCapabilityBinary& getKernelCapabilities() const;
void setKernelCapabilities(const KcBinary& kc); void setKernelCapabilities(const KernelCapabilityBinary& kc);
private: private:
const std::string kModuleName = "ACCESS_CONTROL_INFO_DESC_BINARY"; const std::string kModuleName = "ACCESS_CONTROL_INFO_DESC_BINARY";
@ -83,6 +83,6 @@ namespace nx
sProgramIdRestrict mProgramIdRestrict; sProgramIdRestrict mProgramIdRestrict;
nx::FileSystemAccessControlBinary mFileSystemAccessControl; nx::FileSystemAccessControlBinary mFileSystemAccessControl;
nx::ServiceAccessControlBinary mServiceAccessControl; nx::ServiceAccessControlBinary mServiceAccessControl;
nx::KcBinary mKernelCapabilities; nx::KernelCapabilityBinary mKernelCapabilities;
}; };
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
HandleTableSizeEntry(); HandleTableSizeEntry();
HandleTableSizeEntry(const KernelCapability& kernel_cap); HandleTableSizeEntry(const KernelCapabilityEntry& kernel_cap);
HandleTableSizeEntry(uint16_t size); HandleTableSizeEntry(uint16_t size);
void operator=(const HandleTableSizeEntry& other); void operator=(const HandleTableSizeEntry& other);
@ -17,19 +17,19 @@ namespace nx
bool operator!=(const HandleTableSizeEntry& other) const; bool operator!=(const HandleTableSizeEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint16_t getHandleTableSize() const; uint16_t getHandleTableSize() const;
void setHandleTableSize(uint16_t size); void setHandleTableSize(uint16_t size);
private: private:
const std::string kModuleName = "HANDLE_TABLE_SIZE_ENTRY"; const std::string kModuleName = "HANDLE_TABLE_SIZE_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_HANDLE_TABLE_SIZE; static const kc::KernelCapId kCapId = kc::KC_HANDLE_TABLE_SIZE;
static const uint16_t kValBits = 10; static const uint16_t kValBits = 10;
static const uint16_t kMaxHandleTableSize = BIT(kValBits) - 1; static const uint16_t kMaxHandleTableSize = BIT(kValBits) - 1;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint16_t mHandleTableSize; uint16_t mHandleTableSize;
inline void updateCapField() inline void updateCapField()

View file

@ -15,8 +15,8 @@ namespace nx
bool operator!=(const HandleTableSizeHandler& other) const; bool operator!=(const HandleTableSizeHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -1,15 +1,15 @@
#pragma once #pragma once
#include <fnd/types.h> #include <fnd/types.h>
#include <fnd/List.h> #include <fnd/List.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
class IKernelCapabilityHandler class IKernelCapabilityHandler
{ {
public: public:
virtual void importKernelCapabilityList(const fnd::List<KernelCapability>& caps) = 0; virtual void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps) = 0;
virtual void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const = 0; virtual void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const = 0;
virtual void clear() = 0; virtual void clear() = 0;
virtual bool isSet() const = 0; virtual bool isSet() const = 0;
}; };

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -13,7 +13,7 @@ namespace nx
static const uint32_t kInteruptNum = 2; static const uint32_t kInteruptNum = 2;
InteruptEntry(); InteruptEntry();
InteruptEntry(const KernelCapability& kernel_cap); InteruptEntry(const KernelCapabilityEntry& kernel_cap);
InteruptEntry(uint32_t interupt0, uint32_t interupt1); InteruptEntry(uint32_t interupt0, uint32_t interupt1);
void operator=(const InteruptEntry& other); void operator=(const InteruptEntry& other);
@ -21,8 +21,8 @@ namespace nx
bool operator!=(const InteruptEntry& other) const; bool operator!=(const InteruptEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint32_t operator[](size_t index) const; uint32_t operator[](size_t index) const;
@ -32,9 +32,9 @@ namespace nx
private: private:
const std::string kModuleName = "INTERUPT_ENTRY"; const std::string kModuleName = "INTERUPT_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_ENABLE_INTERUPTS; static const kc::KernelCapId kCapId = kc::KC_ENABLE_INTERUPTS;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint32_t mInterupt[kInteruptNum]; uint32_t mInterupt[kInteruptNum];
inline void updateCapField() inline void updateCapField()

View file

@ -15,8 +15,8 @@ namespace nx
bool operator!=(const InteruptHandler& other) const; bool operator!=(const InteruptHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -1,62 +0,0 @@
#pragma once
#include <fnd/types.h>
namespace nx
{
class KernelCapability
{
public:
enum KernelCapId
{
KC_INVALID = 0,
KC_THREAD_INFO = 3,
KC_ENABLE_SYSTEM_CALLS = 4,
KC_MEMORY_MAP = 6,
KC_IO_MEMORY_MAP = 7,
KC_ENABLE_INTERUPTS = 11,
KC_MISC_PARAMS = 13,
KC_KERNEL_VERSION = 14,
KC_HANDLE_TABLE_SIZE = 15,
KC_MISC_FLAGS = 16
};
KernelCapability();
KernelCapability(KernelCapId type);
KernelCapability(KernelCapId type, uint32_t field);
void operator=(const KernelCapability& other);
bool operator==(const KernelCapability& other) const;
bool operator!=(const KernelCapability& other) const;
uint32_t getCap() const;
void setCap(uint32_t cap);
KernelCapId getType() const;
void setType(KernelCapId type);
uint32_t getField() const;
void setField(uint32_t field);
private:
KernelCapId mType;
uint32_t mField;
inline uint32_t getFieldShift() const { return mType + 1; }
inline uint32_t getFieldMask() const { return BIT(31 - mType) - 1; }
inline uint32_t getCapMask() const { return BIT(mType) - 1; }
inline KernelCapId getCapId(uint32_t cap) const
{
KernelCapId id = KC_INVALID;
for (byte_t tmp = 0; tmp < 31; tmp++)
{
if (((cap >> tmp) & 1) == 0)
{
id = (KernelCapId)tmp;
break;
}
}
return id;
}
};
}

View file

@ -14,16 +14,16 @@
namespace nx namespace nx
{ {
class KcBinary : class KernelCapabilityBinary :
public fnd::ISerialisable public fnd::ISerialisable
{ {
public: public:
KcBinary(); KernelCapabilityBinary();
KcBinary(const KcBinary& other); KernelCapabilityBinary(const KernelCapabilityBinary& other);
void operator=(const KcBinary& other); void operator=(const KernelCapabilityBinary& other);
bool operator==(const KcBinary& other) const; bool operator==(const KernelCapabilityBinary& other) const;
bool operator!=(const KcBinary& other) const; bool operator!=(const KernelCapabilityBinary& other) const;
// export/import binary // export/import binary
void toBytes(); void toBytes();

View file

@ -0,0 +1,50 @@
#pragma once
#include <fnd/types.h>
#include <nx/kc.h>
namespace nx
{
class KernelCapabilityEntry
{
public:
KernelCapabilityEntry();
KernelCapabilityEntry(kc::KernelCapId type);
KernelCapabilityEntry(kc::KernelCapId type, uint32_t field);
void operator=(const KernelCapabilityEntry& other);
bool operator==(const KernelCapabilityEntry& other) const;
bool operator!=(const KernelCapabilityEntry& other) const;
uint32_t getCap() const;
void setCap(uint32_t cap);
kc::KernelCapId getType() const;
void setType(kc::KernelCapId type);
uint32_t getField() const;
void setField(uint32_t field);
private:
kc::KernelCapId mType;
uint32_t mField;
inline uint32_t getFieldShift() const { return mType + 1; }
inline uint32_t getFieldMask() const { return BIT(31 - mType) - 1; }
inline uint32_t getCapMask() const { return BIT(mType) - 1; }
inline kc::KernelCapId getCapId(uint32_t cap) const
{
kc::KernelCapId id = kc::KC_INVALID;
for (byte_t tmp = 0; tmp < 31; tmp++)
{
if (((cap >> tmp) & 1) == 0)
{
id = (kc::KernelCapId)tmp;
break;
}
}
return id;
}
};
}

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
KernelVersionEntry(); KernelVersionEntry();
KernelVersionEntry(const KernelCapability& kernel_cap); KernelVersionEntry(const KernelCapabilityEntry& kernel_cap);
KernelVersionEntry(uint16_t major, uint8_t minor); KernelVersionEntry(uint16_t major, uint8_t minor);
void operator=(const KernelVersionEntry& other); void operator=(const KernelVersionEntry& other);
@ -17,8 +17,8 @@ namespace nx
bool operator!=(const KernelVersionEntry& other) const; bool operator!=(const KernelVersionEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint16_t getVerMajor() const; uint16_t getVerMajor() const;
@ -27,13 +27,13 @@ namespace nx
void setVerMinor(uint8_t minor); void setVerMinor(uint8_t minor);
private: private:
const std::string kModuleName = "KERNEL_VERSION_ENTRY"; const std::string kModuleName = "KERNEL_VERSION_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_KERNEL_VERSION; static const kc::KernelCapId kCapId = kc::KC_KERNEL_VERSION;
static const uint32_t kVerMajorBits = 13; static const uint32_t kVerMajorBits = 13;
static const uint32_t kVerMajorMax = BIT(kVerMajorBits) - 1; static const uint32_t kVerMajorMax = BIT(kVerMajorBits) - 1;
static const uint32_t kVerMinorBits = 4; static const uint32_t kVerMinorBits = 4;
static const uint32_t kVerMinorMax = BIT(kVerMinorBits) - 1; static const uint32_t kVerMinorMax = BIT(kVerMinorBits) - 1;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint16_t mVerMajor; uint16_t mVerMajor;
uint8_t mVerMinor; uint8_t mVerMinor;

View file

@ -15,8 +15,8 @@ namespace nx
bool operator!=(const KernelVersionHandler& other) const; bool operator!=(const KernelVersionHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -57,8 +57,8 @@ namespace nx
bool operator!=(const MemoryMappingHandler& other) const; bool operator!=(const MemoryMappingHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
MemoryPageEntry(); MemoryPageEntry();
MemoryPageEntry(const KernelCapability& kernel_cap); MemoryPageEntry(const KernelCapabilityEntry& kernel_cap);
MemoryPageEntry(uint32_t page); MemoryPageEntry(uint32_t page);
MemoryPageEntry(uint32_t page, bool flag); MemoryPageEntry(uint32_t page, bool flag);
@ -18,8 +18,8 @@ namespace nx
bool operator!=(const MemoryPageEntry& other) const; bool operator!=(const MemoryPageEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint32_t getPage() const; uint32_t getPage() const;
@ -34,7 +34,7 @@ namespace nx
static const uint32_t kPageBits = 24; static const uint32_t kPageBits = 24;
static const uint32_t kMaxPage = BIT(kPageBits) - 1; static const uint32_t kMaxPage = BIT(kPageBits) - 1;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint32_t mPage; uint32_t mPage;
bool mFlag; bool mFlag;
bool mUseFlag; bool mUseFlag;
@ -45,7 +45,7 @@ namespace nx
field |= (uint32_t)(mPage & kMaxPage) << 0; field |= (uint32_t)(mPage & kMaxPage) << 0;
field |= (uint32_t)(mFlag) << kPageBits; field |= (uint32_t)(mFlag) << kPageBits;
mCap.setField(field); mCap.setField(field);
mCap.setType(mUseFlag ? KernelCapability::KC_MEMORY_MAP : KernelCapability::KC_IO_MEMORY_MAP); mCap.setType(mUseFlag ? kc::KC_MEMORY_MAP : kc::KC_IO_MEMORY_MAP);
} }
inline void processCapField() inline void processCapField()
@ -53,7 +53,7 @@ namespace nx
uint32_t field = mCap.getField(); uint32_t field = mCap.getField();
mPage = (field >> 0) & kMaxPage; mPage = (field >> 0) & kMaxPage;
mFlag = (field >> kPageBits); mFlag = (field >> kPageBits);
mUseFlag = mCap.getType() == KernelCapability::KC_MEMORY_MAP; mUseFlag = mCap.getType() == kc::KC_MEMORY_MAP;
} }
}; };

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
MiscFlagsEntry(); MiscFlagsEntry();
MiscFlagsEntry(const KernelCapability& kernel_cap); MiscFlagsEntry(const KernelCapabilityEntry& kernel_cap);
MiscFlagsEntry(uint32_t flags); MiscFlagsEntry(uint32_t flags);
void operator=(const MiscFlagsEntry& other); void operator=(const MiscFlagsEntry& other);
@ -17,19 +17,19 @@ namespace nx
bool operator!=(const MiscFlagsEntry& other) const; bool operator!=(const MiscFlagsEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint32_t getFlags() const; uint32_t getFlags() const;
void setFlags(uint32_t flags); void setFlags(uint32_t flags);
private: private:
const std::string kModuleName = "MISC_FLAG_ENTRY"; const std::string kModuleName = "MISC_FLAG_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_MISC_FLAGS; static const kc::KernelCapId kCapId = kc::KC_MISC_FLAGS;
static const uint32_t kValueBits = 15; static const uint32_t kValueBits = 15;
static const uint32_t kMaxVal = BIT(kValueBits)-1; static const uint32_t kMaxVal = BIT(kValueBits)-1;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint32_t mFlags; uint32_t mFlags;
inline void updateCapField() inline void updateCapField()

View file

@ -35,8 +35,8 @@ namespace nx
bool operator!=(const MiscFlagsHandler& other) const; bool operator!=(const MiscFlagsHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
MiscParamsEntry(); MiscParamsEntry();
MiscParamsEntry(const KernelCapability& kernel_cap); MiscParamsEntry(const KernelCapabilityEntry& kernel_cap);
MiscParamsEntry(byte_t program_type); MiscParamsEntry(byte_t program_type);
void operator=(const MiscParamsEntry& other); void operator=(const MiscParamsEntry& other);
@ -17,19 +17,19 @@ namespace nx
bool operator!=(const MiscParamsEntry& other) const; bool operator!=(const MiscParamsEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
byte_t getProgramType() const; byte_t getProgramType() const;
void setProgramType(byte_t type); void setProgramType(byte_t type);
private: private:
const std::string kModuleName = "MISC_PARAMS_ENTRY"; const std::string kModuleName = "MISC_PARAMS_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_MISC_PARAMS; static const kc::KernelCapId kCapId = kc::KC_MISC_PARAMS;
static const byte_t kValBits = 3; static const byte_t kValBits = 3;
static const byte_t kMaxProgramType = BIT(kValBits)-1; static const byte_t kMaxProgramType = BIT(kValBits)-1;
KernelCapability mCap; KernelCapabilityEntry mCap;
byte_t mProgramType; byte_t mProgramType;
inline void updateCapField() inline void updateCapField()

View file

@ -15,8 +15,8 @@ namespace nx
bool operator!=(const MiscParamsHandler& other) const; bool operator!=(const MiscParamsHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
SystemCallEntry(); SystemCallEntry();
SystemCallEntry(const KernelCapability& kernel_cap); SystemCallEntry(const KernelCapabilityEntry& kernel_cap);
SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits); SystemCallEntry(uint32_t upper_bits, uint32_t lower_bits);
void operator=(const SystemCallEntry& other); void operator=(const SystemCallEntry& other);
@ -17,8 +17,8 @@ namespace nx
bool operator!=(const SystemCallEntry& other) const; bool operator!=(const SystemCallEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint32_t getSystemCallUpperBits() const; uint32_t getSystemCallUpperBits() const;
@ -28,13 +28,13 @@ namespace nx
private: private:
const std::string kModuleName = "SYSTEM_CALL_ENTRY"; const std::string kModuleName = "SYSTEM_CALL_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_ENABLE_SYSTEM_CALLS; static const kc::KernelCapId kCapId = kc::KC_ENABLE_SYSTEM_CALLS;
static const uint32_t kSysCallUpperBits = 3; static const uint32_t kSysCallUpperBits = 3;
static const uint32_t kSysCallLowerBits = 24; static const uint32_t kSysCallLowerBits = 24;
static const uint32_t kSysCallUpperMax = BIT(kSysCallUpperBits) - 1; static const uint32_t kSysCallUpperMax = BIT(kSysCallUpperBits) - 1;
static const uint32_t kSysCallLowerMax = BIT(kSysCallLowerBits) - 1; static const uint32_t kSysCallLowerMax = BIT(kSysCallLowerBits) - 1;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint32_t mSystemCallUpper; uint32_t mSystemCallUpper;
uint32_t mSystemCallLower; uint32_t mSystemCallLower;

View file

@ -16,8 +16,8 @@ namespace nx
bool operator!=(const SystemCallHandler& other) const; bool operator!=(const SystemCallHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <fnd/types.h> #include <fnd/types.h>
#include <nx/KernelCapability.h> #include <nx/KernelCapabilityEntry.h>
namespace nx namespace nx
{ {
@ -9,7 +9,7 @@ namespace nx
{ {
public: public:
ThreadInfoEntry(); ThreadInfoEntry();
ThreadInfoEntry(const KernelCapability& kernel_cap); ThreadInfoEntry(const KernelCapabilityEntry& kernel_cap);
ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_cpu_id, uint8_t max_cpu_id); ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_cpu_id, uint8_t max_cpu_id);
void operator=(const ThreadInfoEntry& other); void operator=(const ThreadInfoEntry& other);
@ -17,8 +17,8 @@ namespace nx
bool operator!=(const ThreadInfoEntry& other) const; bool operator!=(const ThreadInfoEntry& other) const;
// kernel capability // kernel capability
const KernelCapability& getKernelCapability() const; const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapability& kernel_cap); void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables // variables
uint8_t getMinPriority() const; uint8_t getMinPriority() const;
@ -32,13 +32,13 @@ namespace nx
private: private:
const std::string kModuleName = "THREAD_INFO_ENTRY"; const std::string kModuleName = "THREAD_INFO_ENTRY";
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_THREAD_INFO; static const kc::KernelCapId kCapId = kc::KC_THREAD_INFO;
static const uint8_t kValBits = 6; static const uint8_t kValBits = 6;
static const uint8_t kMaxVal = BIT(kValBits)-1; static const uint8_t kMaxVal = BIT(kValBits)-1;
static const uint8_t kDefaultPriority = 6; static const uint8_t kDefaultPriority = 6;
static const uint8_t kDefaultCpuId = 8; static const uint8_t kDefaultCpuId = 8;
KernelCapability mCap; KernelCapabilityEntry mCap;
uint8_t mMinPriority; uint8_t mMinPriority;
uint8_t mMaxPriority; uint8_t mMaxPriority;
uint8_t mMinCpuId; uint8_t mMinCpuId;

View file

@ -15,8 +15,8 @@ namespace nx
bool operator!=(const ThreadInfoHandler& other) const; bool operator!=(const ThreadInfoHandler& other) const;
// kernel capabilty list in/out // kernel capabilty list in/out
void importKernelCapabilityList(const fnd::List<KernelCapability>& caps); void importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps);
void exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const; void exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const;
void clear(); void clear();
bool isSet() const; bool isSet() const;

24
lib/libnx/include/nx/kc.h Normal file
View file

@ -0,0 +1,24 @@
#pragma once
#include <fnd/types.h>
#include <crypto/rsa.h>
#include <nx/macro.h>
namespace nx
{
namespace kc
{
enum KernelCapId
{
KC_INVALID = 0,
KC_THREAD_INFO = 3,
KC_ENABLE_SYSTEM_CALLS = 4,
KC_MEMORY_MAP = 6,
KC_IO_MEMORY_MAP = 7,
KC_ENABLE_INTERUPTS = 11,
KC_MISC_PARAMS = 13,
KC_KERNEL_VERSION = 14,
KC_HANDLE_TABLE_SIZE = 15,
KC_MISC_FLAGS = 16
};
}
}

View file

@ -161,12 +161,12 @@ void nx::AccessControlInfoBinary::setServiceAccessControl(const nx::ServiceAcces
mServiceAccessControl = sac; mServiceAccessControl = sac;
} }
const nx::KcBinary& nx::AccessControlInfoBinary::getKernelCapabilities() const const nx::KernelCapabilityBinary& nx::AccessControlInfoBinary::getKernelCapabilities() const
{ {
return mKernelCapabilities; return mKernelCapabilities;
} }
void nx::AccessControlInfoBinary::setKernelCapabilities(const nx::KcBinary& kc) void nx::AccessControlInfoBinary::setKernelCapabilities(const nx::KernelCapabilityBinary& kc)
{ {
mKernelCapabilities = kc; mKernelCapabilities = kc;
} }

View file

@ -239,12 +239,12 @@ void nx::AccessControlInfoDescBinary::setServiceAccessControl(const nx::ServiceA
mServiceAccessControl = sac; mServiceAccessControl = sac;
} }
const nx::KcBinary& nx::AccessControlInfoDescBinary::getKernelCapabilities() const const nx::KernelCapabilityBinary& nx::AccessControlInfoDescBinary::getKernelCapabilities() const
{ {
return mKernelCapabilities; return mKernelCapabilities;
} }
void nx::AccessControlInfoDescBinary::setKernelCapabilities(const nx::KcBinary& kc) void nx::AccessControlInfoDescBinary::setKernelCapabilities(const nx::KernelCapabilityBinary& kc)
{ {
mKernelCapabilities = kc; mKernelCapabilities = kc;
} }

View file

@ -5,7 +5,7 @@ nx::HandleTableSizeEntry::HandleTableSizeEntry() :
mHandleTableSize(0) mHandleTableSize(0)
{} {}
nx::HandleTableSizeEntry::HandleTableSizeEntry(const KernelCapability & kernel_cap) : nx::HandleTableSizeEntry::HandleTableSizeEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mHandleTableSize(0) mHandleTableSize(0)
{ {
@ -36,16 +36,16 @@ bool nx::HandleTableSizeEntry::operator!=(const HandleTableSizeEntry& other) con
} }
const nx::KernelCapability & nx::HandleTableSizeEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::HandleTableSizeEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::HandleTableSizeEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::HandleTableSizeEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'HandleTableSize'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'HandleTableSize'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -22,7 +22,7 @@ bool nx::HandleTableSizeHandler::operator!=(const HandleTableSizeHandler & other
return !(*this == other); return !(*this == other);
} }
void nx::HandleTableSizeHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::HandleTableSizeHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() > kMaxKernelCapNum) if (caps.size() > kMaxKernelCapNum)
{ {
@ -36,7 +36,7 @@ void nx::HandleTableSizeHandler::importKernelCapabilityList(const fnd::List<Kern
mIsSet = true; mIsSet = true;
} }
void nx::HandleTableSizeHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::HandleTableSizeHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -7,7 +7,7 @@ nx::InteruptEntry::InteruptEntry() :
} }
nx::InteruptEntry::InteruptEntry(const KernelCapability & kernel_cap) : nx::InteruptEntry::InteruptEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mInterupt{ 0,0 } mInterupt{ 0,0 }
{ {
@ -40,16 +40,16 @@ bool nx::InteruptEntry::operator!=(const InteruptEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::InteruptEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::InteruptEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::InteruptEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::InteruptEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'EnableInterupts'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'EnableInterupts'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -22,7 +22,7 @@ bool nx::InteruptHandler::operator!=(const InteruptHandler & other) const
return !(*this == other); return !(*this == other);
} }
void nx::InteruptHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::InteruptHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() == 0) if (caps.size() == 0)
return; return;
@ -58,7 +58,7 @@ void nx::InteruptHandler::importKernelCapabilityList(const fnd::List<KernelCapab
mIsSet = true; mIsSet = true;
} }
void nx::InteruptHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::InteruptHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -1,63 +0,0 @@
#include <nx/KernelCapability.h>
nx::KernelCapability::KernelCapability() :
mType(KC_INVALID)
{}
nx::KernelCapability::KernelCapability(KernelCapId type) :
mType(type),
mField(0)
{}
nx::KernelCapability::KernelCapability(KernelCapId type, uint32_t field) :
mType(type),
mField(field)
{}
void nx::KernelCapability::operator=(const KernelCapability & other)
{
mType = other.mType;
mField = other.mField;
}
bool nx::KernelCapability::operator==(const KernelCapability & other) const
{
return (mType == other.mType) \
&& (mField == other.mField);
}
bool nx::KernelCapability::operator!=(const KernelCapability & other) const
{
return !operator==(other);
}
uint32_t nx::KernelCapability::getCap() const
{
return (mField & getFieldMask()) << getFieldShift() | getCapMask();
}
void nx::KernelCapability::setCap(uint32_t cap)
{
mType = getCapId(cap);
mField = (cap >> getFieldShift()) & getFieldMask();
}
nx::KernelCapability::KernelCapId nx::KernelCapability::getType() const
{
return mType;
}
void nx::KernelCapability::setType(KernelCapId type)
{
mType = type;
}
uint32_t nx::KernelCapability::getField() const
{
return mField & getFieldMask();
}
void nx::KernelCapability::setField(uint32_t field)
{
mField = field;
}

View file

@ -1,14 +1,14 @@
#include <nx/KcBinary.h> #include <nx/KernelCapabilityBinary.h>
nx::KcBinary::KcBinary() nx::KernelCapabilityBinary::KernelCapabilityBinary()
{} {}
nx::KcBinary::KcBinary(const KcBinary & other) nx::KernelCapabilityBinary::KernelCapabilityBinary(const KernelCapabilityBinary & other)
{ {
*this = other; *this = other;
} }
void nx::KcBinary::operator=(const KcBinary & other) void nx::KernelCapabilityBinary::operator=(const KernelCapabilityBinary & other)
{ {
clear(); clear();
mThreadInfo = other.mThreadInfo; mThreadInfo = other.mThreadInfo;
@ -21,7 +21,7 @@ void nx::KcBinary::operator=(const KcBinary & other)
mMiscFlags = other.mMiscFlags; mMiscFlags = other.mMiscFlags;
} }
bool nx::KcBinary::operator==(const KcBinary & other) const bool nx::KernelCapabilityBinary::operator==(const KernelCapabilityBinary & other) const
{ {
return (mThreadInfo == other.mThreadInfo) \ return (mThreadInfo == other.mThreadInfo) \
&& (mSystemCalls == other.mSystemCalls) \ && (mSystemCalls == other.mSystemCalls) \
@ -33,14 +33,14 @@ bool nx::KcBinary::operator==(const KcBinary & other) const
&& (mMiscFlags == other.mMiscFlags); && (mMiscFlags == other.mMiscFlags);
} }
bool nx::KcBinary::operator!=(const KcBinary & other) const bool nx::KernelCapabilityBinary::operator!=(const KernelCapabilityBinary & other) const
{ {
return !(*this == other); return !(*this == other);
} }
void nx::KcBinary::toBytes() void nx::KernelCapabilityBinary::toBytes()
{ {
fnd::List<KernelCapability> caps; fnd::List<KernelCapabilityEntry> caps;
// get kernel capabiliteis // get kernel capabiliteis
mThreadInfo.exportKernelCapabilityList(caps); mThreadInfo.exportKernelCapabilityList(caps);
@ -63,57 +63,57 @@ void nx::KcBinary::toBytes()
} }
} }
void nx::KcBinary::fromBytes(const byte_t * data, size_t len) void nx::KernelCapabilityBinary::fromBytes(const byte_t * data, size_t len)
{ {
if ((len % sizeof(uint32_t)) != 0) if ((len % sizeof(uint32_t)) != 0)
{ {
throw fnd::Exception(kModuleName, "KernelCapability list must be aligned to 4 bytes"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry list must be aligned to 4 bytes");
} }
// save copy of KcBinary // save copy of KernelCapabilityBinary
mRawBinary.alloc(len); mRawBinary.alloc(len);
memcpy(mRawBinary.data(), data, len); memcpy(mRawBinary.data(), data, len);
fnd::List<KernelCapability> threadInfoCaps; fnd::List<KernelCapabilityEntry> threadInfoCaps;
fnd::List<KernelCapability> systemCallCaps; fnd::List<KernelCapabilityEntry> systemCallCaps;
fnd::List<KernelCapability> memoryMapCaps; fnd::List<KernelCapabilityEntry> memoryMapCaps;
fnd::List<KernelCapability> interuptCaps; fnd::List<KernelCapabilityEntry> interuptCaps;
fnd::List<KernelCapability> miscParamCaps; fnd::List<KernelCapabilityEntry> miscParamCaps;
fnd::List<KernelCapability> kernelVersionCaps; fnd::List<KernelCapabilityEntry> kernelVersionCaps;
fnd::List<KernelCapability> handleTableSizeCaps; fnd::List<KernelCapabilityEntry> handleTableSizeCaps;
fnd::List<KernelCapability> miscFlagsCaps; fnd::List<KernelCapabilityEntry> miscFlagsCaps;
const uint32_t* raw_caps = (const uint32_t*)mRawBinary.data(); const uint32_t* raw_caps = (const uint32_t*)mRawBinary.data();
size_t cap_num = mRawBinary.size() / sizeof(uint32_t); size_t cap_num = mRawBinary.size() / sizeof(uint32_t);
KernelCapability cap; KernelCapabilityEntry cap;
for (size_t i = 0; i < cap_num; i++) for (size_t i = 0; i < cap_num; i++)
{ {
cap.setCap(le_word(raw_caps[i])); cap.setCap(le_word(raw_caps[i]));
switch (cap.getType()) switch (cap.getType())
{ {
case (KernelCapability::KC_THREAD_INFO) : case (kc::KC_THREAD_INFO) :
threadInfoCaps.addElement(cap); threadInfoCaps.addElement(cap);
break; break;
case (KernelCapability::KC_ENABLE_SYSTEM_CALLS): case (kc::KC_ENABLE_SYSTEM_CALLS):
systemCallCaps.addElement(cap); systemCallCaps.addElement(cap);
break; break;
case (KernelCapability::KC_MEMORY_MAP): case (kc::KC_MEMORY_MAP):
case (KernelCapability::KC_IO_MEMORY_MAP): case (kc::KC_IO_MEMORY_MAP):
memoryMapCaps.addElement(cap); memoryMapCaps.addElement(cap);
break; break;
case (KernelCapability::KC_ENABLE_INTERUPTS): case (kc::KC_ENABLE_INTERUPTS):
interuptCaps.addElement(cap); interuptCaps.addElement(cap);
break; break;
case (KernelCapability::KC_MISC_PARAMS): case (kc::KC_MISC_PARAMS):
miscParamCaps.addElement(cap); miscParamCaps.addElement(cap);
break; break;
case (KernelCapability::KC_KERNEL_VERSION): case (kc::KC_KERNEL_VERSION):
kernelVersionCaps.addElement(cap); kernelVersionCaps.addElement(cap);
break; break;
case (KernelCapability::KC_HANDLE_TABLE_SIZE): case (kc::KC_HANDLE_TABLE_SIZE):
handleTableSizeCaps.addElement(cap); handleTableSizeCaps.addElement(cap);
break; break;
case (KernelCapability::KC_MISC_FLAGS): case (kc::KC_MISC_FLAGS):
miscFlagsCaps.addElement(cap); miscFlagsCaps.addElement(cap);
break; break;
default: default:
@ -131,12 +131,12 @@ void nx::KcBinary::fromBytes(const byte_t * data, size_t len)
mMiscFlags.importKernelCapabilityList(miscFlagsCaps); mMiscFlags.importKernelCapabilityList(miscFlagsCaps);
} }
const fnd::Vec<byte_t>& nx::KcBinary::getBytes() const const fnd::Vec<byte_t>& nx::KernelCapabilityBinary::getBytes() const
{ {
return mRawBinary; return mRawBinary;
} }
void nx::KcBinary::clear() void nx::KernelCapabilityBinary::clear()
{ {
mRawBinary.clear(); mRawBinary.clear();
mThreadInfo.clear(); mThreadInfo.clear();
@ -149,82 +149,82 @@ void nx::KcBinary::clear()
mMiscFlags.clear(); mMiscFlags.clear();
} }
const nx::ThreadInfoHandler & nx::KcBinary::getThreadInfo() const const nx::ThreadInfoHandler & nx::KernelCapabilityBinary::getThreadInfo() const
{ {
return mThreadInfo; return mThreadInfo;
} }
nx::ThreadInfoHandler & nx::KcBinary::getThreadInfo() nx::ThreadInfoHandler & nx::KernelCapabilityBinary::getThreadInfo()
{ {
return mThreadInfo; return mThreadInfo;
} }
const nx::SystemCallHandler & nx::KcBinary::getSystemCalls() const const nx::SystemCallHandler & nx::KernelCapabilityBinary::getSystemCalls() const
{ {
return mSystemCalls; return mSystemCalls;
} }
nx::SystemCallHandler & nx::KcBinary::getSystemCalls() nx::SystemCallHandler & nx::KernelCapabilityBinary::getSystemCalls()
{ {
return mSystemCalls; return mSystemCalls;
} }
const nx::MemoryMappingHandler & nx::KcBinary::getMemoryMaps() const const nx::MemoryMappingHandler & nx::KernelCapabilityBinary::getMemoryMaps() const
{ {
return mMemoryMap; return mMemoryMap;
} }
nx::MemoryMappingHandler & nx::KcBinary::getMemoryMaps() nx::MemoryMappingHandler & nx::KernelCapabilityBinary::getMemoryMaps()
{ {
return mMemoryMap; return mMemoryMap;
} }
const nx::InteruptHandler & nx::KcBinary::getInterupts() const const nx::InteruptHandler & nx::KernelCapabilityBinary::getInterupts() const
{ {
return mInterupts; return mInterupts;
} }
nx::InteruptHandler & nx::KcBinary::getInterupts() nx::InteruptHandler & nx::KernelCapabilityBinary::getInterupts()
{ {
return mInterupts; return mInterupts;
} }
const nx::MiscParamsHandler & nx::KcBinary::getMiscParams() const const nx::MiscParamsHandler & nx::KernelCapabilityBinary::getMiscParams() const
{ {
return mMiscParams; return mMiscParams;
} }
nx::MiscParamsHandler & nx::KcBinary::getMiscParams() nx::MiscParamsHandler & nx::KernelCapabilityBinary::getMiscParams()
{ {
return mMiscParams; return mMiscParams;
} }
const nx::KernelVersionHandler & nx::KcBinary::getKernelVersion() const const nx::KernelVersionHandler & nx::KernelCapabilityBinary::getKernelVersion() const
{ {
return mKernelVersion; return mKernelVersion;
} }
nx::KernelVersionHandler & nx::KcBinary::getKernelVersion() nx::KernelVersionHandler & nx::KernelCapabilityBinary::getKernelVersion()
{ {
return mKernelVersion; return mKernelVersion;
} }
const nx::HandleTableSizeHandler & nx::KcBinary::getHandleTableSize() const const nx::HandleTableSizeHandler & nx::KernelCapabilityBinary::getHandleTableSize() const
{ {
return mHandleTableSize; return mHandleTableSize;
} }
nx::HandleTableSizeHandler & nx::KcBinary::getHandleTableSize() nx::HandleTableSizeHandler & nx::KernelCapabilityBinary::getHandleTableSize()
{ {
return mHandleTableSize; return mHandleTableSize;
} }
const nx::MiscFlagsHandler & nx::KcBinary::getMiscFlags() const const nx::MiscFlagsHandler & nx::KernelCapabilityBinary::getMiscFlags() const
{ {
return mMiscFlags; return mMiscFlags;
} }
nx::MiscFlagsHandler & nx::KcBinary::getMiscFlags() nx::MiscFlagsHandler & nx::KernelCapabilityBinary::getMiscFlags()
{ {
return mMiscFlags; return mMiscFlags;
} }

View file

@ -0,0 +1,63 @@
#include <nx/KernelCapabilityEntry.h>
nx::KernelCapabilityEntry::KernelCapabilityEntry() :
mType(kc::KC_INVALID)
{}
nx::KernelCapabilityEntry::KernelCapabilityEntry(kc::KernelCapId type) :
mType(type),
mField(0)
{}
nx::KernelCapabilityEntry::KernelCapabilityEntry(kc::KernelCapId type, uint32_t field) :
mType(type),
mField(field)
{}
void nx::KernelCapabilityEntry::operator=(const KernelCapabilityEntry & other)
{
mType = other.mType;
mField = other.mField;
}
bool nx::KernelCapabilityEntry::operator==(const KernelCapabilityEntry & other) const
{
return (mType == other.mType) \
&& (mField == other.mField);
}
bool nx::KernelCapabilityEntry::operator!=(const KernelCapabilityEntry & other) const
{
return !operator==(other);
}
uint32_t nx::KernelCapabilityEntry::getCap() const
{
return (mField & getFieldMask()) << getFieldShift() | getCapMask();
}
void nx::KernelCapabilityEntry::setCap(uint32_t cap)
{
mType = getCapId(cap);
mField = (cap >> getFieldShift()) & getFieldMask();
}
nx::kc::KernelCapId nx::KernelCapabilityEntry::getType() const
{
return mType;
}
void nx::KernelCapabilityEntry::setType(kc::KernelCapId type)
{
mType = type;
}
uint32_t nx::KernelCapabilityEntry::getField() const
{
return mField & getFieldMask();
}
void nx::KernelCapabilityEntry::setField(uint32_t field)
{
mField = field;
}

View file

@ -6,7 +6,7 @@ nx::KernelVersionEntry::KernelVersionEntry() :
mVerMinor(0) mVerMinor(0)
{} {}
nx::KernelVersionEntry::KernelVersionEntry(const KernelCapability & kernel_cap) : nx::KernelVersionEntry::KernelVersionEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mVerMajor(0), mVerMajor(0),
mVerMinor(0) mVerMinor(0)
@ -41,16 +41,16 @@ bool nx::KernelVersionEntry::operator!=(const KernelVersionEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::KernelVersionEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::KernelVersionEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::KernelVersionEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::KernelVersionEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'KernelVersion'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'KernelVersion'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -22,7 +22,7 @@ bool nx::KernelVersionHandler::operator!=(const KernelVersionHandler & other) co
return !(*this == other); return !(*this == other);
} }
void nx::KernelVersionHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::KernelVersionHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() > kMaxKernelCapNum) if (caps.size() > kMaxKernelCapNum)
{ {
@ -37,7 +37,7 @@ void nx::KernelVersionHandler::importKernelCapabilityList(const fnd::List<Kernel
mIsSet = true; mIsSet = true;
} }
void nx::KernelVersionHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::KernelVersionHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -24,7 +24,7 @@ bool nx::MemoryMappingHandler::operator!=(const MemoryMappingHandler & other) co
return !(*this == other); return !(*this == other);
} }
void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() == 0) if (caps.size() == 0)
return; return;
@ -87,7 +87,7 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
mIsSet = true; mIsSet = true;
} }
void nx::MemoryMappingHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::MemoryMappingHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -1,14 +1,14 @@
#include <nx/MemoryPageEntry.h> #include <nx/MemoryPageEntry.h>
nx::MemoryPageEntry::MemoryPageEntry() : nx::MemoryPageEntry::MemoryPageEntry() :
mCap(KernelCapability::KC_INVALID), mCap(kc::KC_INVALID),
mPage(0), mPage(0),
mFlag(false), mFlag(false),
mUseFlag(false) mUseFlag(false)
{} {}
nx::MemoryPageEntry::MemoryPageEntry(const KernelCapability & kernel_cap) : nx::MemoryPageEntry::MemoryPageEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(KernelCapability::KC_INVALID), mCap(kc::KC_INVALID),
mPage(0), mPage(0),
mFlag(false), mFlag(false),
mUseFlag(false) mUseFlag(false)
@ -17,7 +17,7 @@ nx::MemoryPageEntry::MemoryPageEntry(const KernelCapability & kernel_cap) :
} }
nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) : nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) :
mCap(KernelCapability::KC_INVALID), mCap(kc::KC_INVALID),
mPage(0), mPage(0),
mFlag(false), mFlag(false),
mUseFlag(false) mUseFlag(false)
@ -26,7 +26,7 @@ nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) :
} }
nx::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) : nx::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) :
mCap(KernelCapability::KC_INVALID), mCap(kc::KC_INVALID),
mPage(0), mPage(0),
mFlag(false), mFlag(false),
mUseFlag(true) mUseFlag(true)
@ -55,16 +55,16 @@ bool nx::MemoryPageEntry::operator!=(const MemoryPageEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::MemoryPageEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::MemoryPageEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::MemoryPageEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::MemoryPageEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != KernelCapability::KC_MEMORY_MAP && kernel_cap.getType() != KernelCapability::KC_IO_MEMORY_MAP) if (kernel_cap.getType() != kc::KC_MEMORY_MAP && kernel_cap.getType() != kc::KC_IO_MEMORY_MAP)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'MemoryMap' or 'IOMemoryMap"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'MemoryMap' or 'IOMemoryMap");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -5,7 +5,7 @@ nx::MiscFlagsEntry::MiscFlagsEntry() :
mFlags(0) mFlags(0)
{} {}
nx::MiscFlagsEntry::MiscFlagsEntry(const KernelCapability & kernel_cap) : nx::MiscFlagsEntry::MiscFlagsEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mFlags(0) mFlags(0)
{ {
@ -35,16 +35,16 @@ bool nx::MiscFlagsEntry::operator!=(const MiscFlagsEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::MiscFlagsEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::MiscFlagsEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::MiscFlagsEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::MiscFlagsEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'MiscFlags'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'MiscFlags'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -21,7 +21,7 @@ bool nx::MiscFlagsHandler::operator!=(const MiscFlagsHandler & other) const
return !(*this == other); return !(*this == other);
} }
void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() > kMaxKernelCapNum) if (caps.size() > kMaxKernelCapNum)
{ {
@ -46,7 +46,7 @@ void nx::MiscFlagsHandler::importKernelCapabilityList(const fnd::List<KernelCapa
mIsSet = true; mIsSet = true;
} }
void nx::MiscFlagsHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::MiscFlagsHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -5,7 +5,7 @@ nx::MiscParamsEntry::MiscParamsEntry() :
mProgramType(0) mProgramType(0)
{} {}
nx::MiscParamsEntry::MiscParamsEntry(const KernelCapability & kernel_cap) : nx::MiscParamsEntry::MiscParamsEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mProgramType(0) mProgramType(0)
{ {
@ -35,16 +35,16 @@ bool nx::MiscParamsEntry::operator!=(const MiscParamsEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::MiscParamsEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::MiscParamsEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::MiscParamsEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::MiscParamsEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'ThreadInfo'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'ThreadInfo'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -22,7 +22,7 @@ bool nx::MiscParamsHandler::operator!=(const MiscParamsHandler & other) const
return !(*this == other); return !(*this == other);
} }
void nx::MiscParamsHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::MiscParamsHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() > kMaxKernelCapNum) if (caps.size() > kMaxKernelCapNum)
{ {
@ -37,7 +37,7 @@ void nx::MiscParamsHandler::importKernelCapabilityList(const fnd::List<KernelCap
mIsSet = true; mIsSet = true;
} }
void nx::MiscParamsHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::MiscParamsHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -8,7 +8,7 @@ nx::SystemCallEntry::SystemCallEntry() :
} }
nx::SystemCallEntry::SystemCallEntry(const KernelCapability & kernel_cap) : nx::SystemCallEntry::SystemCallEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mSystemCallUpper(0), mSystemCallUpper(0),
mSystemCallLower(0) mSystemCallLower(0)
@ -43,16 +43,16 @@ bool nx::SystemCallEntry::operator!=(const SystemCallEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::SystemCallEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::SystemCallEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::SystemCallEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::SystemCallEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'EnableSystemCalls'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'EnableSystemCalls'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -23,7 +23,7 @@ bool nx::SystemCallHandler::operator!=(const SystemCallHandler & other) const
return !(*this == other); return !(*this == other);
} }
void nx::SystemCallHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::SystemCallHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() == 0) if (caps.size() == 0)
return; return;
@ -49,7 +49,7 @@ void nx::SystemCallHandler::importKernelCapabilityList(const fnd::List<KernelCap
mIsSet = true; mIsSet = true;
} }
void nx::SystemCallHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::SystemCallHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -8,7 +8,7 @@ nx::ThreadInfoEntry::ThreadInfoEntry() :
mMaxCpuId(kDefaultCpuId) mMaxCpuId(kDefaultCpuId)
{} {}
nx::ThreadInfoEntry::ThreadInfoEntry(const KernelCapability & kernel_cap) : nx::ThreadInfoEntry::ThreadInfoEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId), mCap(kCapId),
mMinPriority(kDefaultPriority), mMinPriority(kDefaultPriority),
mMaxPriority(kDefaultPriority), mMaxPriority(kDefaultPriority),
@ -53,16 +53,16 @@ bool nx::ThreadInfoEntry::operator!=(const ThreadInfoEntry& other) const
return !(*this == other); return !(*this == other);
} }
const nx::KernelCapability & nx::ThreadInfoEntry::getKernelCapability() const const nx::KernelCapabilityEntry & nx::ThreadInfoEntry::getKernelCapability() const
{ {
return mCap; return mCap;
} }
void nx::ThreadInfoEntry::setKernelCapability(const KernelCapability & kernel_cap) void nx::ThreadInfoEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{ {
if (kernel_cap.getType() != kCapId) if (kernel_cap.getType() != kCapId)
{ {
throw fnd::Exception(kModuleName, "KernelCapability is not type 'ThreadInfo'"); throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'ThreadInfo'");
} }
mCap = kernel_cap; mCap = kernel_cap;

View file

@ -22,7 +22,7 @@ bool nx::ThreadInfoHandler::operator!=(const ThreadInfoHandler & other) const
return !(*this == other); return !(*this == other);
} }
void nx::ThreadInfoHandler::importKernelCapabilityList(const fnd::List<KernelCapability>& caps) void nx::ThreadInfoHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{ {
if (caps.size() > kMaxKernelCapNum) if (caps.size() > kMaxKernelCapNum)
{ {
@ -36,7 +36,7 @@ void nx::ThreadInfoHandler::importKernelCapabilityList(const fnd::List<KernelCap
mIsSet = true; mIsSet = true;
} }
void nx::ThreadInfoHandler::exportKernelCapabilityList(fnd::List<KernelCapability>& caps) const void nx::ThreadInfoHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{ {
if (isSet() == false) if (isSet() == false)
return; return;

View file

@ -628,7 +628,7 @@ void NpdmProcess::displaySac(const nx::ServiceAccessControlBinary& sac)
} }
} }
void NpdmProcess::displayKernelCap(const nx::KcBinary& kern) void NpdmProcess::displayKernelCap(const nx::KernelCapabilityBinary& kern)
{ {
printf("[Kernel Capabilities]\n"); printf("[Kernel Capabilities]\n");
if (kern.getThreadInfo().isSet()) if (kern.getThreadInfo().isSet())

View file

@ -40,5 +40,5 @@ private:
void displayAciDescHdr(const nx::AccessControlInfoDescBinary& aci); void displayAciDescHdr(const nx::AccessControlInfoDescBinary& aci);
void displayFac(const nx::FileSystemAccessControlBinary& fac); void displayFac(const nx::FileSystemAccessControlBinary& fac);
void displaySac(const nx::ServiceAccessControlBinary& sac); void displaySac(const nx::ServiceAccessControlBinary& sac);
void displayKernelCap(const nx::KcBinary& kern); void displayKernelCap(const nx::KernelCapabilityBinary& kern);
}; };