mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
[nx] Unbroke MemoryMappingHandler forloop bugfix. Fixed typo in KcBinary::importBinary().
This commit is contained in:
parent
5af8ec72ae
commit
7dd27fd5c8
|
@ -123,7 +123,7 @@ void nx::KcBinary::importBinary(const u8 * bytes, size_t len)
|
||||||
mSystemCalls.importKernelCapabilityList(systemCallCaps);
|
mSystemCalls.importKernelCapabilityList(systemCallCaps);
|
||||||
mMemoryMap.importKernelCapabilityList(memoryMapCaps);
|
mMemoryMap.importKernelCapabilityList(memoryMapCaps);
|
||||||
mInterupts.importKernelCapabilityList(interuptCaps);
|
mInterupts.importKernelCapabilityList(interuptCaps);
|
||||||
mMiscParams.importKernelCapabilityList(memoryMapCaps);
|
mMiscParams.importKernelCapabilityList(miscParamCaps);
|
||||||
mKernelVersion.importKernelCapabilityList(kernelVersionCaps);
|
mKernelVersion.importKernelCapabilityList(kernelVersionCaps);
|
||||||
mHandleTableSize.importKernelCapabilityList(handleTableSizeCaps);
|
mHandleTableSize.importKernelCapabilityList(handleTableSizeCaps);
|
||||||
mMiscFlags.importKernelCapabilityList(miscFlagsCaps);
|
mMiscFlags.importKernelCapabilityList(miscFlagsCaps);
|
||||||
|
|
|
@ -35,15 +35,16 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
|
||||||
|
|
||||||
mMemRange.clear();
|
mMemRange.clear();
|
||||||
mMemPage.clear();
|
mMemPage.clear();
|
||||||
for (size_t i = 0; i < entries.getSize(); i++)
|
for (size_t i = 0; i < entries.getSize();)
|
||||||
{
|
{
|
||||||
// has flag means "MemMap"
|
// has flag means "MemMap"
|
||||||
if (entries[i].isMultiplePages())
|
if (entries[i].isMultiplePages())
|
||||||
{
|
{
|
||||||
|
|
||||||
// this entry is the last one or the next one isn't a memory map
|
// this entry is the last one or the next one isn't a memory map
|
||||||
if ((i + 1) == entries.getSize() || entries[i+1].isMultiplePages() == false)
|
if ((i + 1) == entries.getSize() || entries[i+1].isMultiplePages() == false)
|
||||||
{
|
{
|
||||||
throw fnd::Exception(kModuleName, "Illegal page address");
|
throw fnd::Exception(kModuleName, "No paired entry");
|
||||||
}
|
}
|
||||||
|
|
||||||
// check valid page address
|
// check valid page address
|
||||||
|
@ -59,7 +60,7 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to list
|
// add to list
|
||||||
mMemRange.addElement({ entries[i].getPage(), entries[i+1].getPage(), !entries[i].getFlag(), !entries[i+1].getFlag() });
|
mMemRange.addElement({ entries[i].getPage(), entries[i+1].getPage(), entries[i].getFlag() ? MEM_RO : MEM_RW, entries[i+1].getFlag() ? MAP_STATIC : MAP_IO });
|
||||||
|
|
||||||
// increment i by two
|
// increment i by two
|
||||||
i += 2;
|
i += 2;
|
||||||
|
@ -74,7 +75,7 @@ void nx::MemoryMappingHandler::importKernelCapabilityList(const fnd::List<Kernel
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to list
|
// add to list
|
||||||
mMemPage.addElement({ entries[i].getPage(), 1, true, true });
|
mMemPage.addElement({ entries[i].getPage(), 1, MEM_RW, MAP_IO });
|
||||||
|
|
||||||
// increment i by one
|
// increment i by one
|
||||||
i += 1;
|
i += 1;
|
||||||
|
@ -96,11 +97,11 @@ void nx::MemoryMappingHandler::exportKernelCapabilityList(fnd::List<KernelCapabi
|
||||||
for (size_t i = 0; i < mMemRange.getSize(); i++)
|
for (size_t i = 0; i < mMemRange.getSize(); i++)
|
||||||
{
|
{
|
||||||
cap.setPage(mMemRange[i].addr & kMaxPageAddr);
|
cap.setPage(mMemRange[i].addr & kMaxPageAddr);
|
||||||
cap.setFlag(!mMemRange[i].isRW);
|
cap.setFlag(mMemRange[i].perm == MEM_RO);
|
||||||
caps.addElement(cap.getKernelCapability());
|
caps.addElement(cap.getKernelCapability());
|
||||||
|
|
||||||
cap.setPage(mMemRange[i].size & kMaxPageNum);
|
cap.setPage(mMemRange[i].size & kMaxPageNum);
|
||||||
cap.setFlag(!mMemRange[i].isIO);
|
cap.setFlag(mMemRange[i].type == MAP_STATIC);
|
||||||
caps.addElement(cap.getKernelCapability());
|
caps.addElement(cap.getKernelCapability());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,31 @@ namespace nx
|
||||||
public IKernelCapabilityHandler
|
public IKernelCapabilityHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum MemoryPerm
|
||||||
|
{
|
||||||
|
MEM_RW,
|
||||||
|
MEM_RO
|
||||||
|
};
|
||||||
|
|
||||||
|
enum MappingType
|
||||||
|
{
|
||||||
|
MAP_IO,
|
||||||
|
MAP_STATIC
|
||||||
|
};
|
||||||
|
|
||||||
struct sMemoryMapping
|
struct sMemoryMapping
|
||||||
{
|
{
|
||||||
u32 addr; // page index
|
u32 addr; // page index
|
||||||
u32 size; // page num
|
u32 size; // page num
|
||||||
bool isRW;
|
MemoryPerm perm;
|
||||||
bool isIO;
|
MappingType type;
|
||||||
|
|
||||||
bool operator==(const sMemoryMapping& other) const
|
bool operator==(const sMemoryMapping& other) const
|
||||||
{
|
{
|
||||||
return (addr == other.addr) \
|
return (addr == other.addr) \
|
||||||
&& (size == other.size) \
|
&& (size == other.size) \
|
||||||
&& (isRW == other.isRW) \
|
&& (perm == other.perm) \
|
||||||
&& (isIO == other.isIO);
|
&& (type == other.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const sMemoryMapping& other) const
|
bool operator!=(const sMemoryMapping& other) const
|
||||||
|
@ -31,8 +43,8 @@ namespace nx
|
||||||
{
|
{
|
||||||
addr = other.addr;
|
addr = other.addr;
|
||||||
size = other.size;
|
size = other.size;
|
||||||
isRW = other.isRW;
|
perm = other.perm;
|
||||||
isIO = other.isIO;
|
type = other.type;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue