diff --git a/include/kernel/kernel.hpp b/include/kernel/kernel.hpp index 68fc4147..c0097fc4 100644 --- a/include/kernel/kernel.hpp +++ b/include/kernel/kernel.hpp @@ -63,6 +63,7 @@ class Kernel { void getResourceLimit(); void getResourceLimitLimitValues(); void getResourceLimitCurrentValues(); + void sendSyncRequest(); void svcCloseHandle(); void connectToPort(); diff --git a/src/core/kernel/kernel.cpp b/src/core/kernel/kernel.cpp index 2e0a5a18..8f3dd940 100644 --- a/src/core/kernel/kernel.cpp +++ b/src/core/kernel/kernel.cpp @@ -8,6 +8,7 @@ void Kernel::serviceSVC(u32 svc) { case 0x21: createAddressArbiter(); break; case 0x23: svcCloseHandle(); break; case 0x2D: connectToPort(); break; + case 0x32: sendSyncRequest(); break; case 0x38: getResourceLimit(); break; case 0x39: getResourceLimitLimitValues(); break; case 0x3A: getResourceLimitCurrentValues(); break; diff --git a/src/core/kernel/ports.cpp b/src/core/kernel/ports.cpp index 4b523d11..df4c45cc 100644 --- a/src/core/kernel/ports.cpp +++ b/src/core/kernel/ports.cpp @@ -43,7 +43,7 @@ void Kernel::connectToPort() { } const auto portHandle = getPortHandle(port); - if (!portHandle.has_value()) { + if (!portHandle.has_value()) [[unlikely]] { Helpers::panic("ConnectToPort: Port doesn't exist\n"); regs[0] = SVCResult::ObjectNotFound; return; @@ -52,6 +52,26 @@ void Kernel::connectToPort() { // TODO: Actually create session Handle sessionHandle = makeObject(KernelObjectType::Session); + // TODO: Should the result be written back to [r0]? regs[0] = SVCResult::Success; regs[1] = sessionHandle; +} + +// Result SendSyncRequest(Handle session) +void Kernel::sendSyncRequest() { + const auto handle = regs[0]; + const auto session = getObject(handle, KernelObjectType::Session); + printf("SendSyncRequest(session handle = %d)\n", handle); + + if (session == nullptr) [[unlikely]] { + Helpers::panic("SendSyncRequest: Invalid session handle"); + regs[0] = SVCResult::BadHandle; + return; + } + + const auto sessionData = static_cast(session->data); + const u32 messagePointer = VirtualAddrs::TLSBase + 0x80; + + Helpers::panic("SendSyncRequest: Message header: %08X", mem.read32(messagePointer)); + regs[0] = SVCResult::Success; } \ No newline at end of file