diff options
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/csnd_snd.cpp | 57 | ||||
-rw-r--r-- | src/core/hle/service/csnd_snd.h | 13 | ||||
-rw-r--r-- | src/core/hle/service/fs/archive.cpp | 7 | ||||
-rw-r--r-- | src/core/hle/service/fs/archive.h | 7 | ||||
-rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 29 | ||||
-rw-r--r-- | src/core/hle/service/ptm/ptm.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/ptm/ptm.h | 8 | ||||
-rw-r--r-- | src/core/hle/service/ptm/ptm_u.cpp | 2 |
8 files changed, 129 insertions, 6 deletions
diff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cpp index 6a1d961ac..ce2877f57 100644 --- a/src/core/hle/service/csnd_snd.cpp +++ b/src/core/hle/service/csnd_snd.cpp @@ -3,6 +3,8 @@ // Refer to the license.txt file included. #include "core/hle/hle.h" +#include "core/hle/kernel/mutex.h" +#include "core/hle/kernel/shared_memory.h" #include "core/hle/service/csnd_snd.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -11,11 +13,11 @@ namespace CSND_SND { const Interface::FunctionInfo FunctionTable[] = { - {0x00010140, nullptr, "Initialize"}, - {0x00020000, nullptr, "Shutdown"}, - {0x00030040, nullptr, "ExecuteType0Commands"}, + {0x00010140, Initialize, "Initialize"}, + {0x00020000, Shutdown, "Shutdown"}, + {0x00030040, ExecuteType0Commands, "ExecuteType0Commands"}, {0x00040080, nullptr, "ExecuteType1Commands"}, - {0x00050000, nullptr, "AcquireSoundChannels"}, + {0x00050000, AcquireSoundChannels, "AcquireSoundChannels"}, {0x00060000, nullptr, "ReleaseSoundChannels"}, {0x00070000, nullptr, "AcquireCaptureDevice"}, {0x00080040, nullptr, "ReleaseCaptureDevice"}, @@ -31,4 +33,51 @@ Interface::Interface() { Register(FunctionTable); } +static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr; +static Kernel::SharedPtr<Kernel::Mutex> mutex = nullptr; + +void Initialize(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + shared_memory = Kernel::SharedMemory::Create(cmd_buff[1], + Kernel::MemoryPermission::ReadWrite, + Kernel::MemoryPermission::ReadWrite, "CSNDSharedMem"); + + mutex = Kernel::Mutex::Create(false); + + cmd_buff[1] = 0; + cmd_buff[2] = 0x4000000; + cmd_buff[3] = Kernel::g_handle_table.Create(mutex).MoveFrom(); + cmd_buff[4] = Kernel::g_handle_table.Create(shared_memory).MoveFrom(); +} + +void ExecuteType0Commands(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + if (shared_memory != nullptr) { + struct Type0Command* command = reinterpret_cast<struct Type0Command*>( + shared_memory->GetPointer(cmd_buff[1])); + if (command == nullptr) { + cmd_buff[1] = 1; + }else{ + LOG_WARNING(Service, "(STUBBED) CSND_SND::ExecuteType0Commands"); + command->finished |= 1; + cmd_buff[1] = 0; + } + }else{ + cmd_buff[1] = 1; + } +} + +void AcquireSoundChannels(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + cmd_buff[1] = 0; + cmd_buff[2] = 0xFFFFFF00; +} + +void Shutdown(Service::Interface* self) { + shared_memory = nullptr; + mutex = nullptr; +} + } // namespace diff --git a/src/core/hle/service/csnd_snd.h b/src/core/hle/service/csnd_snd.h index a84752473..e861f3327 100644 --- a/src/core/hle/service/csnd_snd.h +++ b/src/core/hle/service/csnd_snd.h @@ -20,4 +20,17 @@ public: } }; +struct Type0Command { + // command id and next command offset + u32 command_id; + u32 finished; + u32 flags; + u8 parameters[20]; +}; + +void Initialize(Service::Interface* self); +void ExecuteType0Commands(Service::Interface* self); +void AcquireSoundChannels(Service::Interface* self); +void Shutdown(Service::Interface* self); + } // namespace diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 6c0df67c3..d64b3656a 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -403,6 +403,13 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a return MakeResult<Kernel::SharedPtr<Directory>>(std::move(directory)); } +ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) { + ArchiveBackend* archive = GetArchive(archive_handle); + if (archive == nullptr) + return ERR_INVALID_HANDLE; + return MakeResult<u64>(archive->GetFreeBytes()); +} + ResultCode FormatArchive(ArchiveIdCode id_code, const FileSys::Path& path) { auto archive_itr = id_code_map.find(id_code); if (archive_itr == id_code_map.end()) { diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index 6f7048710..952deb4d4 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -167,6 +167,13 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a const FileSys::Path& path); /** + * Get the free space in an Archive + * @param archive_handle Handle to an open Archive object + * @return The number of free bytes in the archive + */ +ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle); + +/** * Erases the contents of the physical folder that contains the archive * identified by the specified id code and path * @param id_code The id of the archive to format diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index ae52083f9..b3fa89302 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -497,6 +497,33 @@ static void FormatThisUserSaveData(Service::Interface* self) { } /** + * FS_User::GetFreeBytes service function + * Inputs: + * 0: 0x08120080 + * 1: Archive handle low word + * 2: Archive handle high word + * Outputs: + * 1: Result of function, 0 on success, otherwise error code + * 2: Free byte count low word + * 3: Free byte count high word + */ +static void GetFreeBytes(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[1], cmd_buff[2]); + ResultVal<u64> bytes_res = GetFreeBytesInArchive(archive_handle); + + cmd_buff[1] = bytes_res.Code().raw; + if (bytes_res.Succeeded()) { + cmd_buff[2] = (u32)*bytes_res; + cmd_buff[3] = *bytes_res >> 32; + } else { + cmd_buff[2] = 0; + cmd_buff[3] = 0; + } +} + +/** * FS_User::CreateExtSaveData service function * Inputs: * 0 : 0x08510242 @@ -700,7 +727,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x080F0180, FormatThisUserSaveData,"FormatThisUserSaveData"}, {0x08100200, nullptr, "CreateSystemSaveData"}, {0x08110040, nullptr, "DeleteSystemSaveData"}, - {0x08120080, nullptr, "GetFreeBytes"}, + {0x08120080, GetFreeBytes, "GetFreeBytes"}, {0x08130000, nullptr, "GetCardType"}, {0x08140000, nullptr, "GetSdmcArchiveResource"}, {0x08150000, nullptr, "GetNandArchiveResource"}, diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 2c7d49c9f..22c1093ff 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -68,6 +68,18 @@ void GetBatteryChargeState(Service::Interface* self) { LOG_WARNING(Service_PTM, "(STUBBED) called"); } +void GetTotalStepCount(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + // TODO: This function is only a stub, + // it returns 0 as the total step count + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0; + + LOG_WARNING(Service_PTM, "(STUBBED) called"); +} + void IsLegacyPowerOff(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index b690003cb..f2e76441f 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h @@ -72,6 +72,14 @@ void GetBatteryLevel(Interface* self); void GetBatteryChargeState(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::IsLegacyPowerOff service function * Outputs: * 1: Result code, 0 on success, otherwise error code diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp index 3f5e9c7c1..09dc38c3e 100644 --- a/src/core/hle/service/ptm/ptm_u.cpp +++ b/src/core/hle/service/ptm/ptm_u.cpp @@ -23,7 +23,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00090000, nullptr, "GetPedometerState"}, {0x000A0042, nullptr, "GetStepHistoryEntry"}, {0x000B00C2, nullptr, "GetStepHistory"}, - {0x000C0000, nullptr, "GetTotalStepCount"}, + {0x000C0000, GetTotalStepCount, "GetTotalStepCount"}, {0x000D0040, nullptr, "SetPedometerRecordingMode"}, {0x000E0000, nullptr, "GetPedometerRecordingMode"}, {0x000F0084, nullptr, "GetStepHistoryAll"}, |