diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c73f294..4231ff53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,7 @@ set(KERNEL_SOURCE_FILES src/core/kernel/kernel.cpp src/core/kernel/resource_limi src/core/kernel/events.cpp src/core/kernel/threads.cpp src/core/kernel/address_arbiter.cpp src/core/kernel/error.cpp src/core/kernel/file_operations.cpp src/core/kernel/directory_operations.cpp - src/core/kernel/idle_thread.cpp + src/core/kernel/idle_thread.cpp src/core/kernel/timers.cpp ) set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services/apt.cpp src/core/services/hid.cpp src/core/services/fs.cpp src/core/services/gsp_gpu.cpp src/core/services/gsp_lcd.cpp diff --git a/include/fs/archive_save_data.hpp b/include/fs/archive_save_data.hpp index 9b25f008..5b1ba489 100644 --- a/include/fs/archive_save_data.hpp +++ b/include/fs/archive_save_data.hpp @@ -5,7 +5,7 @@ class SaveDataArchive : public ArchiveBase { public: SaveDataArchive(Memory& mem) : ArchiveBase(mem) {} - u64 getFreeBytes() override { Helpers::panic("SaveData::GetFreeBytes unimplemented"); return 0; } + u64 getFreeBytes() override { return 32_MB; } std::string name() override { return "SaveData"; } HorizonResult createDirectory(const FSPath& path) override; diff --git a/include/kernel/kernel.hpp b/include/kernel/kernel.hpp index e1d521c7..163b19e1 100644 --- a/include/kernel/kernel.hpp +++ b/include/kernel/kernel.hpp @@ -67,6 +67,7 @@ public: Handle makeEvent(ResetType resetType); // Needs to be public to be accessible to the APT/HID services Handle makeMutex(bool locked = false); // Needs to be public to be accessible to the APT/DSP services Handle makeSemaphore(u32 initialCount, u32 maximumCount); // Needs to be public to be accessible to the service manager port + Handle makeTimer(ResetType resetType); // Signals an event, returns true on success or false if the event does not exist bool signalEvent(Handle e); @@ -135,14 +136,18 @@ private: void getThreadPriority(); void sendSyncRequest(); void setThreadPriority(); + void svcCancelTimer(); void svcClearEvent(); + void svcClearTimer(); void svcCloseHandle(); void svcCreateEvent(); void svcCreateMutex(); void svcCreateSemaphore(); + void svcCreateTimer(); void svcReleaseMutex(); void svcReleaseSemaphore(); void svcSignalEvent(); + void svcSetTimer(); void svcSleepThread(); void connectToPort(); void outputDebugString(); diff --git a/include/services/boss.hpp b/include/services/boss.hpp index f47c5ae4..b2347829 100644 --- a/include/services/boss.hpp +++ b/include/services/boss.hpp @@ -17,7 +17,8 @@ class BOSSService { void getOptoutFlag(u32 messagePointer); void getStorageEntryInfo(u32 messagePointer); // Unknown what this is, name taken from Citra void getTaskIdList(u32 messagePointer); - void getTaskInfo(u32 messagePOinter); + void getTaskInfo(u32 messagePointer); + void getTaskState(u32 messagePointer); void getTaskStorageInfo(u32 messagePointer); void receiveProperty(u32 messagePointer); void registerStorageEntry(u32 messagePointer); diff --git a/src/core/kernel/kernel.cpp b/src/core/kernel/kernel.cpp index 6f3cf081..900ad559 100644 --- a/src/core/kernel/kernel.cpp +++ b/src/core/kernel/kernel.cpp @@ -42,6 +42,10 @@ void Kernel::serviceSVC(u32 svc) { case 0x17: svcCreateEvent(); break; case 0x18: svcSignalEvent(); break; case 0x19: svcClearEvent(); break; + case 0x1A: svcCreateTimer(); break; + case 0x1B: svcSetTimer(); break; + case 0x1C: svcCancelTimer(); break; + case 0x1D: svcClearTimer(); break; case 0x1E: createMemoryBlock(); break; case 0x1F: mapMemoryBlock(); break; case 0x21: createAddressArbiter(); break; diff --git a/src/core/kernel/timers.cpp b/src/core/kernel/timers.cpp new file mode 100644 index 00000000..f4a89407 --- /dev/null +++ b/src/core/kernel/timers.cpp @@ -0,0 +1,6 @@ +#include "kernel.hpp" + +void Kernel::svcCreateTimer() { Helpers::panic("Kernel::CreateTimer"); } +void Kernel::svcSetTimer() { Helpers::panic("Kernel::SetTimer"); } +void Kernel::svcClearTimer() { Helpers::panic("Kernel::ClearTimer"); } +void Kernel::svcCancelTimer() { Helpers::panic("Kernel::CancelTimer"); } \ No newline at end of file diff --git a/src/core/services/boss.cpp b/src/core/services/boss.cpp index 10342de9..86b937c1 100644 --- a/src/core/services/boss.cpp +++ b/src/core/services/boss.cpp @@ -12,9 +12,10 @@ namespace BOSSCommands { GetNsDataIdList = 0x00100102, ReceiveProperty = 0x00160082, CancelTask = 0x001E0042, + GetTaskState = 0x00200082, GetTaskInfo = 0x00250082, RegisterStorageEntry = 0x002F0140, - GetStorageEntryInfo = 0x00300000 + GetStorageEntryInfo = 0x00300000, }; } @@ -31,6 +32,7 @@ void BOSSService::handleSyncRequest(u32 messagePointer) { case BOSSCommands::GetStorageEntryInfo: getStorageEntryInfo(messagePointer); break; case BOSSCommands::GetTaskIdList: getTaskIdList(messagePointer); break; case BOSSCommands::GetTaskInfo: getTaskInfo(messagePointer); break; + case BOSSCommands::GetTaskState: getTaskState(messagePointer); break; case BOSSCommands::GetTaskStorageInfo: getTaskStorageInfo(messagePointer); break; case BOSSCommands::InitializeSession: initializeSession(messagePointer); break; case BOSSCommands::ReceiveProperty: receiveProperty(messagePointer); break; @@ -48,17 +50,29 @@ void BOSSService::initializeSession(u32 messagePointer) { } void BOSSService::getOptoutFlag(u32 messagePointer) { - log("BOSS::getOptoutFlag\n"); + log("BOSS::GetOptoutFlag\n"); mem.write32(messagePointer, IPC::responseHeader(0xA, 2, 0)); mem.write32(messagePointer + 4, Result::Success); mem.write8(messagePointer + 8, optoutFlag); } +void BOSSService::getTaskState(u32 messagePointer) { + const u32 taskIDBufferSize = mem.read32(messagePointer + 4); + const u32 taskIDDataPointer = mem.read32(messagePointer + 16); + log("BOSS::GetTaskStatus (task buffer size: %08X, task data pointer: %08X) (stubbed)\n", taskIDBufferSize, taskIDDataPointer); + + mem.write32(messagePointer, IPC::responseHeader(0x20, 2, 2)); + mem.write32(messagePointer + 4, Result::Success); + mem.write8(messagePointer + 8, 0); // TaskStatus: Report the task finished successfully + mem.write32(messagePointer + 12, 0); // Current state value for task PropertyID 0x4 + mem.write8(messagePointer + 16, 0); // TODO: Figure out what this should be +} + void BOSSService::getTaskStorageInfo(u32 messagePointer) { log("BOSS::GetTaskStorageInfo (stubbed)\n"); mem.write32(messagePointer, IPC::responseHeader(0x4, 2, 0)); mem.write32(messagePointer + 4, Result::Success); - mem.write32(messagePointer + 8, 0); // Seems to be unknown what this is? + mem.write32(messagePointer + 8, 0); } void BOSSService::getTaskIdList(u32 messagePointer) {