kern: refactor to use m_ for member variables

This commit is contained in:
Michael Scire
2020-12-17 17:18:47 -08:00
parent b8471bcd4e
commit 92f1e2d100
135 changed files with 3727 additions and 3734 deletions

View File

@@ -24,103 +24,103 @@ namespace ams::kern {
private:
static constexpr u32 Magic = util::FourCC<'K','I','P','1'>::Code;
private:
u32 magic;
u8 name[12];
u64 program_id;
u32 version;
u8 priority;
u8 ideal_core_id;
u8 _1E;
u8 flags;
u32 rx_address;
u32 rx_size;
u32 rx_compressed_size;
u32 affinity_mask;
u32 ro_address;
u32 ro_size;
u32 ro_compressed_size;
u32 stack_size;
u32 rw_address;
u32 rw_size;
u32 rw_compressed_size;
u32 _4C;
u32 bss_address;
u32 bss_size;
u32 pad[(0x80 - 0x58) / sizeof(u32)];
u32 capabilities[0x80 / sizeof(u32)];
u32 m_magic;
u8 m_name[12];
u64 m_program_id;
u32 m_version;
u8 m_priority;
u8 m_ideal_core_id;
u8 m_1E;
u8 m_flags;
u32 m_rx_address;
u32 m_rx_size;
u32 m_rx_compressed_size;
u32 m_affinity_mask;
u32 m_ro_address;
u32 m_ro_size;
u32 m_ro_compressed_size;
u32 m_stack_size;
u32 m_rw_address;
u32 m_rw_size;
u32 m_rw_compressed_size;
u32 m_4C;
u32 m_bss_address;
u32 m_bss_size;
u32 m_pad[(0x80 - 0x58) / sizeof(u32)];
u32 m_capabilities[0x80 / sizeof(u32)];
public:
constexpr bool IsValid() const { return this->magic == Magic; }
constexpr bool IsValid() const { return m_magic == Magic; }
constexpr void GetName(char *dst, size_t size) const {
std::memset(dst, 0, size);
std::memcpy(dst, this->name, std::min(sizeof(this->name), size));
std::memcpy(dst, m_name, std::min(sizeof(m_name), size));
}
constexpr const u32 *GetCapabilities() const { return this->capabilities; }
constexpr size_t GetNumCapabilities() const { return util::size(this->capabilities); }
constexpr const u32 *GetCapabilities() const { return m_capabilities; }
constexpr size_t GetNumCapabilities() const { return util::size(m_capabilities); }
constexpr u64 GetProgramId() const { return this->program_id; }
constexpr u32 GetVersion() const { return this->version; }
constexpr u8 GetPriority() const { return this->priority; }
constexpr u8 GetIdealCoreId() const { return this->ideal_core_id; }
constexpr u64 GetProgramId() const { return m_program_id; }
constexpr u32 GetVersion() const { return m_version; }
constexpr u8 GetPriority() const { return m_priority; }
constexpr u8 GetIdealCoreId() const { return m_ideal_core_id; }
constexpr bool IsRxCompressed() const { return (this->flags & (1 << 0)); }
constexpr bool IsRoCompressed() const { return (this->flags & (1 << 1)); }
constexpr bool IsRwCompressed() const { return (this->flags & (1 << 2)); }
constexpr bool Is64Bit() const { return (this->flags & (1 << 3)); }
constexpr bool Is64BitAddressSpace() const { return (this->flags & (1 << 4)); }
constexpr bool UsesSecureMemory() const { return (this->flags & (1 << 5)); }
constexpr bool IsRxCompressed() const { return (m_flags & (1 << 0)); }
constexpr bool IsRoCompressed() const { return (m_flags & (1 << 1)); }
constexpr bool IsRwCompressed() const { return (m_flags & (1 << 2)); }
constexpr bool Is64Bit() const { return (m_flags & (1 << 3)); }
constexpr bool Is64BitAddressSpace() const { return (m_flags & (1 << 4)); }
constexpr bool UsesSecureMemory() const { return (m_flags & (1 << 5)); }
constexpr u32 GetRxAddress() const { return this->rx_address; }
constexpr u32 GetRxSize() const { return this->rx_size; }
constexpr u32 GetRxCompressedSize() const { return this->rx_compressed_size; }
constexpr u32 GetRoAddress() const { return this->ro_address; }
constexpr u32 GetRoSize() const { return this->ro_size; }
constexpr u32 GetRoCompressedSize() const { return this->ro_compressed_size; }
constexpr u32 GetRwAddress() const { return this->rw_address; }
constexpr u32 GetRwSize() const { return this->rw_size; }
constexpr u32 GetRwCompressedSize() const { return this->rw_compressed_size; }
constexpr u32 GetBssAddress() const { return this->bss_address; }
constexpr u32 GetBssSize() const { return this->bss_size; }
constexpr u32 GetRxAddress() const { return m_rx_address; }
constexpr u32 GetRxSize() const { return m_rx_size; }
constexpr u32 GetRxCompressedSize() const { return m_rx_compressed_size; }
constexpr u32 GetRoAddress() const { return m_ro_address; }
constexpr u32 GetRoSize() const { return m_ro_size; }
constexpr u32 GetRoCompressedSize() const { return m_ro_compressed_size; }
constexpr u32 GetRwAddress() const { return m_rw_address; }
constexpr u32 GetRwSize() const { return m_rw_size; }
constexpr u32 GetRwCompressedSize() const { return m_rw_compressed_size; }
constexpr u32 GetBssAddress() const { return m_bss_address; }
constexpr u32 GetBssSize() const { return m_bss_size; }
constexpr u32 GetAffinityMask() const { return this->affinity_mask; }
constexpr u32 GetStackSize() const { return this->stack_size; }
constexpr u32 GetAffinityMask() const { return m_affinity_mask; }
constexpr u32 GetStackSize() const { return m_stack_size; }
};
static_assert(sizeof(KInitialProcessHeader) == 0x100);
class KInitialProcessReader {
private:
KInitialProcessHeader *kip_header;
KInitialProcessHeader *m_kip_header;
public:
constexpr KInitialProcessReader() : kip_header() { /* ... */ }
constexpr KInitialProcessReader() : m_kip_header() { /* ... */ }
constexpr const u32 *GetCapabilities() const { return this->kip_header->GetCapabilities(); }
constexpr size_t GetNumCapabilities() const { return this->kip_header->GetNumCapabilities(); }
constexpr const u32 *GetCapabilities() const { return m_kip_header->GetCapabilities(); }
constexpr size_t GetNumCapabilities() const { return m_kip_header->GetNumCapabilities(); }
constexpr size_t GetBinarySize() const {
return sizeof(*kip_header) + this->kip_header->GetRxCompressedSize() + this->kip_header->GetRoCompressedSize() + this->kip_header->GetRwCompressedSize();
return sizeof(*m_kip_header) + m_kip_header->GetRxCompressedSize() + m_kip_header->GetRoCompressedSize() + m_kip_header->GetRwCompressedSize();
}
constexpr size_t GetSize() const {
if (const size_t bss_size = this->kip_header->GetBssSize(); bss_size != 0) {
return this->kip_header->GetBssAddress() + this->kip_header->GetBssSize();
if (const size_t bss_size = m_kip_header->GetBssSize(); bss_size != 0) {
return m_kip_header->GetBssAddress() + m_kip_header->GetBssSize();
} else {
return this->kip_header->GetRwAddress() + this->kip_header->GetRwSize();
return m_kip_header->GetRwAddress() + m_kip_header->GetRwSize();
}
}
constexpr u8 GetPriority() const { return this->kip_header->GetPriority(); }
constexpr u8 GetIdealCoreId() const { return this->kip_header->GetIdealCoreId(); }
constexpr u32 GetAffinityMask() const { return this->kip_header->GetAffinityMask(); }
constexpr u32 GetStackSize() const { return this->kip_header->GetStackSize(); }
constexpr u8 GetPriority() const { return m_kip_header->GetPriority(); }
constexpr u8 GetIdealCoreId() const { return m_kip_header->GetIdealCoreId(); }
constexpr u32 GetAffinityMask() const { return m_kip_header->GetAffinityMask(); }
constexpr u32 GetStackSize() const { return m_kip_header->GetStackSize(); }
constexpr bool Is64Bit() const { return this->kip_header->Is64Bit(); }
constexpr bool Is64BitAddressSpace() const { return this->kip_header->Is64BitAddressSpace(); }
constexpr bool UsesSecureMemory() const { return this->kip_header->UsesSecureMemory(); }
constexpr bool Is64Bit() const { return m_kip_header->Is64Bit(); }
constexpr bool Is64BitAddressSpace() const { return m_kip_header->Is64BitAddressSpace(); }
constexpr bool UsesSecureMemory() const { return m_kip_header->UsesSecureMemory(); }
bool Attach(u8 *bin) {
if (KInitialProcessHeader *header = reinterpret_cast<KInitialProcessHeader *>(bin); header->IsValid()) {
this->kip_header = header;
m_kip_header = header;
return true;
} else {
return false;