[Kernel] Hopefully implement the QueryMemory svc remotely correctly

This commit is contained in:
wheremyfoodat 2022-09-19 01:33:12 +03:00
parent 6bb2bd67df
commit 45c016d12e
7 changed files with 92 additions and 3 deletions

View file

@ -67,4 +67,26 @@ void Kernel::controlMemory() {
}
regs[0] = SVCResult::Success;
}
// Result QueryMemory(MemoryInfo* memInfo, PageInfo* pageInfo, u32 addr)
void Kernel::queryMemory() {
const u32 memInfo = regs[0];
const u32 pageInfo = regs[1];
const u32 addr = regs[2];
if (addr & 0xfff) {
Helpers::panic("QueryMemory: Address not page aligned\n");
}
printf("QueryMemory(mem info pointer = %08X, page info pointer = %08X, addr = %08X)\n", memInfo, pageInfo, addr);
const auto info = mem.queryMemory(addr);
regs[0] = SVCResult::Success;
mem.write32(memInfo, info.baseVaddr); // Set memInfo->baseVaddr
mem.write32(memInfo + 4, info.size); // Set memInfo->size
mem.write32(memInfo + 8, info.baseVaddr); // Set memInfo->perms
mem.write32(memInfo + 12, info.state); // Set memInfo->state
mem.write32(pageInfo, 0); // Set pageInfo->flags to 0
}