Merge pull request #178 from wheremyfoodat/timerz

HLE fixes
This commit is contained in:
wheremyfoodat 2023-08-13 15:20:25 +03:00 committed by GitHub
commit c8fe52e4ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 6 deletions

View file

@ -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

View file

@ -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;

View file

@ -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();

View file

@ -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);

View file

@ -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;

View file

@ -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"); }

View file

@ -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) {