mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
[Kernel/APT] Stub some APT and threading stuff to make OoT go further
This commit is contained in:
parent
df4cd0642d
commit
cd13ba6271
7 changed files with 44 additions and 2 deletions
|
@ -103,11 +103,13 @@ class Kernel {
|
|||
void getResourceLimitCurrentValues();
|
||||
void getSystemTick();
|
||||
void getThreadID();
|
||||
void releaseMutex();
|
||||
void sendSyncRequest();
|
||||
void svcCloseHandle();
|
||||
void connectToPort();
|
||||
void outputDebugString();
|
||||
void waitSynchronization1();
|
||||
void waitSynchronizationN();
|
||||
|
||||
// File operations
|
||||
void handleFileOperation(u32 messagePointer, Handle file);
|
||||
|
|
|
@ -12,6 +12,8 @@ class APTService {
|
|||
// Service commands
|
||||
void getLockHandle(u32 messagePointer);
|
||||
void checkNew3DS(u32 messagePointer);
|
||||
void enable(u32 messagePointer);
|
||||
void notifyToWait(u32 messagePointer);
|
||||
|
||||
public:
|
||||
APTService(Memory& mem) : mem(mem) {}
|
||||
|
|
|
@ -55,7 +55,6 @@ std::optional<u32> SelfNCCHArchive::readFile(FileSession* file, u64 offset, u32
|
|||
|
||||
for (u64 i = 0; i < bytesRead; i++) {
|
||||
mem.write8(dataPointer + i, data[i]);
|
||||
printf("%x\n", data[i]);
|
||||
}
|
||||
|
||||
return bytesRead;
|
||||
|
|
|
@ -58,4 +58,18 @@ void Kernel::waitSynchronization1() {
|
|||
|
||||
logSVC("WaitSynchronization1(handle = %X, ns = %lld) (STUBBED)\n", handle, ns);
|
||||
regs[0] = SVCResult::Success;
|
||||
}
|
||||
|
||||
// Result WaitSynchronizationN(s32* out, Handle* handles, s32 handlecount, bool waitAll, s64 timeout_nanoseconds)
|
||||
void Kernel::waitSynchronizationN() {
|
||||
// TODO: Are these arguments even correct?
|
||||
u32 ns1 = regs[0];
|
||||
u32 handles = regs[1];
|
||||
u32 handleCount = regs[2];
|
||||
bool waitAll = regs[3] != 0;
|
||||
u32 ns2 = regs[4];
|
||||
u32 out = regs[5];
|
||||
|
||||
logSVC("WaitSynchronizationN (STUBBED)\n");
|
||||
regs[0] = SVCResult::Success;
|
||||
}
|
|
@ -22,6 +22,7 @@ void Kernel::serviceSVC(u32 svc) {
|
|||
case 0x01: controlMemory(); break;
|
||||
case 0x02: queryMemory(); break;
|
||||
case 0x08: createThread(); break;
|
||||
case 0x14: releaseMutex(); break;
|
||||
case 0x17: createEvent(); break;
|
||||
case 0x19: clearEvent(); break;
|
||||
case 0x1F: mapMemoryBlock(); break;
|
||||
|
@ -29,6 +30,7 @@ void Kernel::serviceSVC(u32 svc) {
|
|||
case 0x22: arbitrateAddress(); break;
|
||||
case 0x23: svcCloseHandle(); break;
|
||||
case 0x24: waitSynchronization1(); break;
|
||||
case 0x25: waitSynchronizationN(); break;
|
||||
case 0x27: duplicateHandle(); break;
|
||||
case 0x28: getSystemTick(); break;
|
||||
case 0x2B: getProcessInfo(); break;
|
||||
|
|
|
@ -115,4 +115,11 @@ void Kernel::getThreadID() {
|
|||
|
||||
regs[0] = SVCResult::Success;
|
||||
regs[1] = thread->getData<Thread>()->index;
|
||||
}
|
||||
|
||||
void Kernel::releaseMutex() {
|
||||
const Handle handle = regs[0];
|
||||
|
||||
logSVC("ReleaseMutex (handle = %x) (STUBBED)\n", handle);
|
||||
regs[0] = SVCResult::Success;
|
||||
}
|
|
@ -3,7 +3,9 @@
|
|||
namespace APTCommands {
|
||||
enum : u32 {
|
||||
GetLockHandle = 0x00010040,
|
||||
CheckNew3DS = 0x01020000
|
||||
Enable = 0x00030040,
|
||||
CheckNew3DS = 0x01020000,
|
||||
NotifyToWait = 0x00430040
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -27,18 +29,32 @@ void APTService::handleSyncRequest(u32 messagePointer) {
|
|||
const u32 command = mem.read32(messagePointer);
|
||||
switch (command) {
|
||||
case APTCommands::CheckNew3DS: checkNew3DS(messagePointer); break;
|
||||
case APTCommands::Enable: enable(messagePointer); break;
|
||||
case APTCommands::GetLockHandle: getLockHandle(messagePointer); break;
|
||||
case APTCommands::NotifyToWait: notifyToWait(messagePointer); break;
|
||||
default: Helpers::panic("APT service requested. Command: %08X\n", command);
|
||||
}
|
||||
}
|
||||
|
||||
void APTService::checkNew3DS(u32 messagePointer) {
|
||||
log("APT::CheckNew3DS\n");
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
mem.write8(messagePointer + 8, Model::Old3DS); // u8, Status (0 = Old 3DS, 1 = New 3DS)
|
||||
}
|
||||
|
||||
void APTService::enable(u32 messagePointer) {
|
||||
log("APT::Enable\n");
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
}
|
||||
|
||||
void APTService::getLockHandle(u32 messagePointer) {
|
||||
log("APT::GetLockHandle (Failure)\n");
|
||||
mem.write32(messagePointer + 4, Result::Failure); // Result code
|
||||
mem.write32(messagePointer + 16, 0); // Translation descriptor
|
||||
}
|
||||
|
||||
// This apparently does nothing on the original kernel either?
|
||||
void APTService::notifyToWait(u32 messagePointer) {
|
||||
log("APT::NotifyToWat\n");
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
}
|
Loading…
Add table
Reference in a new issue