aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-01-30 16:07:04 -0200
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-02-02 15:36:59 -0200
commit8779b31fe60c728ace89a9b5128b68feffa9c7d7 (patch)
treeb83440cbe4187f1fe120a5a247919a1ecbb1c65d /src/core/hle/svc.cpp
parent5e91fc0d1aa806a9635e06e047d5367988f21093 (diff)
Make Port/Service registration and querying more HW-accurate
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 88813c2c..d253f4fe 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -30,6 +30,11 @@ using Kernel::ERR_INVALID_HANDLE;
namespace SVC {
+const ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
+ ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
+const ResultCode ERR_PORT_NAME_TOO_LONG(ErrorDescription(30), ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E0181E
+
/// An invalid result code that is meant to be overwritten when a thread resumes from waiting
const ResultCode RESULT_INVALID(0xDEADC0DE);
@@ -94,14 +99,21 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o
}
/// Connect to an OS service given the port name, returns the handle to the port to out
-static ResultCode ConnectToPort(Handle* out, const char* port_name) {
- Service::Interface* service = Service::g_manager->FetchFromPortName(port_name);
+static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) {
+ if (port_name == nullptr)
+ return ERR_NOT_FOUND;
+ if (std::strlen(port_name) > 11)
+ return ERR_PORT_NAME_TOO_LONG;
LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name);
- _assert_msg_(KERNEL, (service != nullptr), "called, but service is not implemented!");
- *out = service->GetHandle();
+ auto it = Service::g_kernel_named_ports.find(port_name);
+ if (it == Service::g_kernel_named_ports.end()) {
+ LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name);
+ return ERR_NOT_FOUND;
+ }
+ CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(it->second));
return RESULT_SUCCESS;
}