hle: Remove a large amount of 3ds-specific service code.

This commit is contained in:
bunnei 2017-10-10 17:32:14 -04:00
parent b1d5db1cf6
commit 0906de9a14
200 changed files with 1 additions and 22392 deletions

View file

@ -1,166 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/logging/log.h"
#include "core/file_sys/errors.h"
#include "core/file_sys/file_backend.h"
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/ptm/ptm_gets.h"
#include "core/hle/service/ptm/ptm_play.h"
#include "core/hle/service/ptm/ptm_sets.h"
#include "core/hle/service/ptm/ptm_sysm.h"
#include "core/hle/service/ptm/ptm_u.h"
#include "core/hle/service/service.h"
#include "core/settings.h"
namespace Service {
namespace PTM {
/// Values for the default gamecoin.dat file
static const GameCoin default_game_coin = {0x4F00, 42, 0, 0, 0, 2014, 12, 29};
/// Id of the SharedExtData archive used by the PTM process
static const std::vector<u8> ptm_shared_extdata_id = {0, 0, 0, 0, 0x0B, 0, 0, 0xF0, 0, 0, 0, 0};
static bool shell_open;
static bool battery_is_charging;
static bool pedometer_is_counting;
void GetAdapterState(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(battery_is_charging);
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
void GetShellState(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x6, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(shell_open);
}
void GetBatteryLevel(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x7, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(static_cast<u32>(ChargeLevels::CompletelyFull)); // Set to a completely full battery
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
void GetBatteryChargeState(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x8, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(battery_is_charging);
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
void GetPedometerState(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x9, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(pedometer_is_counting);
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
void GetTotalStepCount(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xC, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push<u32>(0);
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
void GetSoftwareClosedFlag(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x80F, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(false);
LOG_WARNING(Service_PTM, "(STUBBED) called");
}
void CheckNew3DS(IPC::RequestBuilder& rb) {
const bool is_new_3ds = Settings::values.is_new_3ds;
if (is_new_3ds) {
LOG_CRITICAL(Service_PTM, "The option 'is_new_3ds' is enabled as part of the 'System' "
"settings. Citra does not fully support New 3DS emulation yet!");
}
rb.Push(RESULT_SUCCESS);
rb.Push(is_new_3ds);
LOG_WARNING(Service_PTM, "(STUBBED) called isNew3DS = 0x%08x", static_cast<u32>(is_new_3ds));
}
void CheckNew3DS(Service::Interface* self) {
IPC::RequestBuilder rb(Kernel::GetCommandBuffer(), 0x40A, 0, 0); // 0x040A0000
CheckNew3DS(rb);
}
void Init() {
AddService(new PTM_Gets);
AddService(new PTM_Play);
AddService(new PTM_S);
AddService(new PTM_Sets);
AddService(new PTM_Sysm);
AddService(new PTM_U);
shell_open = true;
battery_is_charging = true;
pedometer_is_counting = false;
// Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't
// exist
FileSys::Path archive_path(ptm_shared_extdata_id);
auto archive_result =
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
// If the archive didn't exist, create the files inside
if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
// Format the archive to create the directories
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
FileSys::ArchiveFormatInfo(), archive_path);
// Open it again to get a valid archive now that the folder exists
archive_result =
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
FileSys::Path gamecoin_path("/gamecoin.dat");
Service::FS::CreateFileInArchive(*archive_result, gamecoin_path, sizeof(GameCoin));
FileSys::Mode open_mode = {};
open_mode.write_flag.Assign(1);
// Open the file and write the default gamecoin information
auto gamecoin_result =
Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
if (gamecoin_result.Succeeded()) {
auto gamecoin = std::move(gamecoin_result).Unwrap();
gamecoin->backend->Write(0, sizeof(GameCoin), true,
reinterpret_cast<const u8*>(&default_game_coin));
gamecoin->backend->Close();
}
}
}
void Shutdown() {}
} // namespace PTM
} // namespace Service

View file

@ -1,118 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "common/common_types.h"
#include "core/hle/ipc_helpers.h"
namespace Service {
class Interface;
namespace PTM {
/// Charge levels used by PTM functions
enum class ChargeLevels : u32 {
CriticalBattery = 1,
LowBattery = 2,
HalfFull = 3,
MostlyFull = 4,
CompletelyFull = 5,
};
/**
* Represents the gamecoin file structure in the SharedExtData archive
* More information in 3dbrew
* (http://www.3dbrew.org/wiki/Extdata#Shared_Extdata_0xf000000b_gamecoin.dat)
*/
struct GameCoin {
u32 magic; ///< Magic number: 0x4F00
u16 total_coins; ///< Total Play Coins
u16 total_coins_on_date; ///< Total Play Coins obtained on the date stored below.
u32 step_count; ///< Total step count at the time a new Play Coin was obtained.
u32 last_step_count; ///< Step count for the day the last Play Coin was obtained
u16 year;
u8 month;
u8 day;
};
/**
* It is unknown if GetAdapterState is the same as GetBatteryChargeState,
* it is likely to just be a duplicate function of GetBatteryChargeState
* that controls another part of the HW.
* PTM::GetAdapterState service function
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Output of function, 0 = not charging, 1 = charging.
*/
void GetAdapterState(Interface* self);
/**
* PTM::GetShellState service function.
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Whether the 3DS's physical shell casing is open (1) or closed (0)
*/
void GetShellState(Interface* self);
/**
* PTM::GetBatteryLevel service function
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Battery level, 5 = completely full battery, 4 = mostly full battery,
* 3 = half full battery, 2 = low battery, 1 = critical battery.
*/
void GetBatteryLevel(Interface* self);
/**
* PTM::GetBatteryChargeState service function
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Output of function, 0 = not charging, 1 = charging.
*/
void GetBatteryChargeState(Interface* self);
/**
* PTM::GetPedometerState service function
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Output of function, 0 = not counting steps, 1 = counting steps.
*/
void GetPedometerState(Interface* self);
/**
* PTM::GetTotalStepCount service function
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Output of function, * = total step count
*/
void GetTotalStepCount(Interface* self);
/**
* PTM::GetSoftwareClosedFlag service function
* Outputs:
* 1: Result code, 0 on success, otherwise error code
* 2: Whether or not the "software closed" dialog was requested by the last FIRM
* and should be displayed.
*/
void GetSoftwareClosedFlag(Interface* self);
/**
* PTM::CheckNew3DS service function
* Outputs:
* 1: Result code, 0 on success, otherwise error code
* 2: u8 output: 0 = Old3DS, 1 = New3DS.
*/
void CheckNew3DS(Interface* self);
void CheckNew3DS(IPC::RequestBuilder& rb);
/// Initialize the PTM service
void Init();
/// Shutdown the PTM service
void Shutdown();
} // namespace PTM
} // namespace Service

View file

@ -1,37 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/ptm/ptm_gets.h"
namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
// ptm:u common commands
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, GetAdapterState, "GetAdapterState"},
{0x00060000, GetShellState, "GetShellState"},
{0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, nullptr, "GetStepHistory"},
{0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// ptm:gets
{0x04010000, nullptr, "GetSystemTime"},
};
PTM_Gets::PTM_Gets() {
Register(FunctionTable);
}
} // namespace PTM
} // namespace Service

View file

@ -1,22 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
namespace Service {
namespace PTM {
class PTM_Gets final : public Interface {
public:
PTM_Gets();
std::string GetPortName() const override {
return "ptm:gets";
}
};
} // namespace PTM
} // namespace Service

View file

@ -1,40 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/ptm/ptm_play.h"
namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
// ptm:u common commands
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, GetAdapterState, "GetAdapterState"},
{0x00060000, GetShellState, "GetShellState"},
{0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, nullptr, "GetStepHistory"},
{0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// ptm:play
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
};
PTM_Play::PTM_Play() {
Register(FunctionTable);
}
} // namespace PTM
} // namespace Service

View file

@ -1,22 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
namespace Service {
namespace PTM {
class PTM_Play final : public Interface {
public:
PTM_Play();
std::string GetPortName() const override {
return "ptm:play";
}
};
} // namespace PTM
} // namespace Service

View file

@ -1,20 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ptm/ptm_sets.h"
namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
// Note that this service does not have access to ptm:u's common commands
{0x00010080, nullptr, "SetSystemTime"},
};
PTM_Sets::PTM_Sets() {
Register(FunctionTable);
}
} // namespace PTM
} // namespace Service

View file

@ -1,22 +0,0 @@
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
namespace Service {
namespace PTM {
class PTM_Sets final : public Interface {
public:
PTM_Sets();
std::string GetPortName() const override {
return "ptm:sets";
}
};
} // namespace PTM
} // namespace Service

View file

@ -1,71 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/ptm/ptm_sysm.h"
namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
// ptm:u common commands
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, GetAdapterState, "GetAdapterState"},
{0x00060000, GetShellState, "GetShellState"},
{0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, nullptr, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, nullptr, "GetStepHistory"},
{0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
// ptm:sysm
{0x040100C0, nullptr, "SetRtcAlarmEx"},
{0x04020042, nullptr, "ReplySleepQuery"},
{0x04030042, nullptr, "NotifySleepPreparationComplete"},
{0x04040102, nullptr, "SetWakeupTrigger"},
{0x04050000, nullptr, "GetAwakeReason"},
{0x04060000, nullptr, "RequestSleep"},
{0x040700C0, nullptr, "ShutdownAsync"},
{0x04080000, nullptr, "Awake"},
{0x04090080, nullptr, "RebootAsync"},
{0x040A0000, CheckNew3DS, "CheckNew3DS"},
{0x08010640, nullptr, "SetInfoLEDPattern"},
{0x08020040, nullptr, "SetInfoLEDPatternHeader"},
{0x08030000, nullptr, "GetInfoLEDStatus"},
{0x08040040, nullptr, "SetBatteryEmptyLEDPattern"},
{0x08050000, nullptr, "ClearStepHistory"},
{0x080600C2, nullptr, "SetStepHistory"},
{0x08070082, nullptr, "GetPlayHistory"},
{0x08080000, nullptr, "GetPlayHistoryStart"},
{0x08090000, nullptr, "GetPlayHistoryLength"},
{0x080A0000, nullptr, "ClearPlayHistory"},
{0x080B0080, nullptr, "CalcPlayHistoryStart"},
{0x080C0080, nullptr, "SetUserTime"},
{0x080D0000, nullptr, "InvalidateSystemTime"},
{0x080E0140, nullptr, "NotifyPlayEvent"},
{0x080F0000, GetSoftwareClosedFlag, "GetSoftwareClosedFlag"},
{0x08100000, nullptr, "ClearSoftwareClosedFlag"},
{0x08110000, GetShellState, "GetShellState"},
{0x08120000, nullptr, "IsShutdownByBatteryEmpty"},
{0x08130000, nullptr, "FormatSavedata"},
{0x08140000, nullptr, "GetLegacyJumpProhibitedFlag"},
{0x08180040, nullptr, "ConfigureNew3DSCPU"},
};
PTM_S::PTM_S() {
Register(FunctionTable);
}
PTM_Sysm::PTM_Sysm() {
Register(FunctionTable);
}
} // namespace PTM
} // namespace Service

View file

@ -1,31 +0,0 @@
// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
namespace Service {
namespace PTM {
class PTM_S final : public Interface {
public:
PTM_S();
std::string GetPortName() const override {
return "ptm:s";
}
};
class PTM_Sysm final : public Interface {
public:
PTM_Sysm();
std::string GetPortName() const override {
return "ptm:sysm";
}
};
} // namespace PTM
} // namespace Service

View file

@ -1,34 +0,0 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "core/hle/service/ptm/ptm.h"
#include "core/hle/service/ptm/ptm_u.h"
namespace Service {
namespace PTM {
const Interface::FunctionInfo FunctionTable[] = {
{0x00010002, nullptr, "RegisterAlarmClient"},
{0x00020080, nullptr, "SetRtcAlarm"},
{0x00030000, nullptr, "GetRtcAlarm"},
{0x00040000, nullptr, "CancelRtcAlarm"},
{0x00050000, GetAdapterState, "GetAdapterState"},
{0x00060000, GetShellState, "GetShellState"},
{0x00070000, GetBatteryLevel, "GetBatteryLevel"},
{0x00080000, GetBatteryChargeState, "GetBatteryChargeState"},
{0x00090000, GetPedometerState, "GetPedometerState"},
{0x000A0042, nullptr, "GetStepHistoryEntry"},
{0x000B00C2, nullptr, "GetStepHistory"},
{0x000C0000, GetTotalStepCount, "GetTotalStepCount"},
{0x000D0040, nullptr, "SetPedometerRecordingMode"},
{0x000E0000, nullptr, "GetPedometerRecordingMode"},
{0x000F0084, nullptr, "GetStepHistoryAll"},
};
PTM_U::PTM_U() {
Register(FunctionTable);
}
} // namespace PTM
} // namespace Service

View file

@ -1,22 +0,0 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
namespace Service {
namespace PTM {
class PTM_U final : public Interface {
public:
PTM_U();
std::string GetPortName() const override {
return "ptm:u";
}
};
} // namespace PTM
} // namespace Service