mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
Split PTM services
This commit is contained in:
parent
1332488326
commit
712be4ce72
4 changed files with 62 additions and 16 deletions
|
@ -38,7 +38,9 @@ namespace KernelHandles {
|
|||
NDM, // ?????
|
||||
NWM_UDS, // Local multiplayer
|
||||
NEWS_U, // This service literally has 1 command (AddNotification) and I don't even understand what it does
|
||||
PTM, // PTM service (Used for accessing various console info, such as battery, shell and pedometer state)
|
||||
PTM_U, // PTM service (Used for accessing various console info, such as battery, shell and pedometer state)
|
||||
PTM_SYSM, // PTM system service
|
||||
PTM_PLAY, // PTM Play service, ues for retrieving play history
|
||||
SOC, // Socket service
|
||||
SSL, // SSL service (Totally didn't expect that)
|
||||
Y2R, // Also does camera stuff
|
||||
|
@ -96,7 +98,9 @@ namespace KernelHandles {
|
|||
case NWM_UDS: return "nwm::UDS";
|
||||
case NFC: return "NFC";
|
||||
case NIM: return "NIM";
|
||||
case PTM: return "PTM";
|
||||
case PTM_U: return "PTM:U";
|
||||
case PTM_SYSM: return "PTM:SYSM";
|
||||
case PTM_PLAY: return "PTM:PLAY";
|
||||
case SOC: return "SOC";
|
||||
case SSL: return "SSL";
|
||||
case Y2R: return "Y2R";
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "result/result.hpp"
|
||||
|
||||
class PTMService {
|
||||
Handle handle = KernelHandles::PTM;
|
||||
Memory& mem;
|
||||
MAKE_LOG_FUNCTION(log, ptmLogger)
|
||||
|
||||
|
@ -19,12 +18,19 @@ class PTMService {
|
|||
void getBatteryChargeState(u32 messagePointer);
|
||||
void getBatteryLevel(u32 messagePointer);
|
||||
void getStepHistory(u32 messagePointer);
|
||||
void getStepHistoryAll(u32 messagePointer);
|
||||
void getTotalStepCount(u32 messagePointer);
|
||||
|
||||
public:
|
||||
enum class Type {
|
||||
U, // ptm:u
|
||||
SYSM, // ptm:sysm
|
||||
PLAY, // ptm:play
|
||||
};
|
||||
|
||||
PTMService(Memory& mem, const EmulatorConfig& config) : mem(mem), config(config) {}
|
||||
void reset();
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
void handleSyncRequest(u32 messagePointer, Type type);
|
||||
|
||||
// 0% -> 0 (shutting down)
|
||||
// 1-5% -> 1
|
||||
|
|
|
@ -8,23 +8,50 @@ namespace PTMCommands {
|
|||
GetBatteryChargeState = 0x00080000,
|
||||
GetStepHistory = 0x000B00C2,
|
||||
GetTotalStepCount = 0x000C0000,
|
||||
GetStepHistoryAll = 0x000F0084,
|
||||
ConfigureNew3DSCPU = 0x08180040,
|
||||
|
||||
// ptm:play functions
|
||||
GetPlayHistory = 0x08070082,
|
||||
GetPlayHistoryStart = 0x08080000,
|
||||
GetPlayHistoryLength = 0x08090000,
|
||||
CalcPlayHistoryStart = 0x080B0080,
|
||||
};
|
||||
}
|
||||
|
||||
void PTMService::reset() {}
|
||||
|
||||
void PTMService::handleSyncRequest(u32 messagePointer) {
|
||||
void PTMService::handleSyncRequest(u32 messagePointer, PTMService::Type type) {
|
||||
const u32 command = mem.read32(messagePointer);
|
||||
|
||||
// ptm:play functions
|
||||
switch (command) {
|
||||
case PTMCommands::ConfigureNew3DSCPU: configureNew3DSCPU(messagePointer); break;
|
||||
case PTMCommands::GetAdapterState: getAdapterState(messagePointer); break;
|
||||
case PTMCommands::GetBatteryChargeState: getBatteryChargeState(messagePointer); break;
|
||||
case PTMCommands::GetBatteryLevel: getBatteryLevel(messagePointer); break;
|
||||
case PTMCommands::GetStepHistory: getStepHistory(messagePointer); break;
|
||||
case PTMCommands::GetTotalStepCount: getTotalStepCount(messagePointer); break;
|
||||
default: Helpers::panic("PTM service requested. Command: %08X\n", command);
|
||||
}
|
||||
case PTMCommands::ConfigureNew3DSCPU: configureNew3DSCPU(messagePointer); break;
|
||||
case PTMCommands::GetAdapterState: getAdapterState(messagePointer); break;
|
||||
case PTMCommands::GetBatteryChargeState: getBatteryChargeState(messagePointer); break;
|
||||
case PTMCommands::GetBatteryLevel: getBatteryLevel(messagePointer); break;
|
||||
case PTMCommands::GetStepHistory: getStepHistory(messagePointer); break;
|
||||
case PTMCommands::GetStepHistoryAll: getStepHistoryAll(messagePointer); break;
|
||||
case PTMCommands::GetTotalStepCount: getTotalStepCount(messagePointer); break;
|
||||
|
||||
default:
|
||||
// ptm:play-only functions
|
||||
if (type == Type::PLAY) {
|
||||
switch (command) {
|
||||
case PTMCommands::GetPlayHistory:
|
||||
case PTMCommands::GetPlayHistoryStart:
|
||||
case PTMCommands::GetPlayHistoryLength:
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
mem.write64(messagePointer + 8, 0);
|
||||
Helpers::warn("Stubbed PTM:PLAY service requested. Command: %08X\n", command);
|
||||
break;
|
||||
|
||||
default: Helpers::panic("PTM PLAY service requested. Command: %08X\n", command); break;
|
||||
}
|
||||
} else {
|
||||
Helpers::panic("PTM service requested. Command: %08X\n", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PTMService::getAdapterState(u32 messagePointer) {
|
||||
|
@ -59,6 +86,12 @@ void PTMService::getStepHistory(u32 messagePointer) {
|
|||
mem.write32(messagePointer + 4, Result::Success);
|
||||
}
|
||||
|
||||
void PTMService::getStepHistoryAll(u32 messagePointer) {
|
||||
log("PTM::GetStepHistoryAll [stubbed]\n");
|
||||
mem.write32(messagePointer, IPC::responseHeader(0xF, 1, 2));
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
}
|
||||
|
||||
void PTMService::getTotalStepCount(u32 messagePointer) {
|
||||
log("PTM::GetTotalStepCount\n");
|
||||
mem.write32(messagePointer, IPC::responseHeader(0xC, 2, 0));
|
||||
|
|
|
@ -124,8 +124,9 @@ static std::map<std::string, Handle> serviceMap = {
|
|||
{ "nfc:u", KernelHandles::NFC },
|
||||
{ "nwm::UDS", KernelHandles::NWM_UDS },
|
||||
{ "nim:aoc", KernelHandles::NIM },
|
||||
{ "ptm:u", KernelHandles::PTM }, // TODO: ptm:u and ptm:sysm have very different command sets
|
||||
{ "ptm:sysm", KernelHandles::PTM },
|
||||
{ "ptm:u", KernelHandles::PTM_U }, // TODO: ptm:u and ptm:sysm have very different command sets
|
||||
{ "ptm:sysm", KernelHandles::PTM_SYSM },
|
||||
{ "ptm:play", KernelHandles::PTM_PLAY },
|
||||
{ "soc:U", KernelHandles::SOC },
|
||||
{ "ssl:C", KernelHandles::SSL },
|
||||
{ "y2r:u", KernelHandles::Y2R },
|
||||
|
@ -223,7 +224,9 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) {
|
|||
case KernelHandles::NDM: ndm.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::NEWS_U: news_u.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::NWM_UDS: nwm_uds.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::PTM: ptm.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::PTM_PLAY: ptm.handleSyncRequest(messagePointer, PTMService::Type::PLAY); break;
|
||||
case KernelHandles::PTM_SYSM: ptm.handleSyncRequest(messagePointer, PTMService::Type::SYSM); break;
|
||||
case KernelHandles::PTM_U: ptm.handleSyncRequest(messagePointer, PTMService::Type::U); break;
|
||||
case KernelHandles::SOC: soc.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::SSL: ssl.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::Y2R: y2r.handleSyncRequest(messagePointer); break;
|
||||
|
|
Loading…
Add table
Reference in a new issue