diff options
| author | 2015-01-30 16:07:04 -0200 | |
|---|---|---|
| committer | 2015-02-02 15:36:59 -0200 | |
| commit | 8779b31fe60c728ace89a9b5128b68feffa9c7d7 (patch) | |
| tree | b83440cbe4187f1fe120a5a247919a1ecbb1c65d /src/core/hle/svc.cpp | |
| parent | Filesys: Move creation of Handles for File/Directory to service handlers (diff) | |
| download | yuzu-8779b31fe60c728ace89a9b5128b68feffa9c7d7.tar.gz yuzu-8779b31fe60c728ace89a9b5128b68feffa9c7d7.tar.xz yuzu-8779b31fe60c728ace89a9b5128b68feffa9c7d7.zip | |
Make Port/Service registration and querying more HW-accurate
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 88813c2ce..d253f4fe5 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -30,6 +30,11 @@ using Kernel::ERR_INVALID_HANDLE; | |||
| 30 | 30 | ||
| 31 | namespace SVC { | 31 | namespace SVC { |
| 32 | 32 | ||
| 33 | const ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel, | ||
| 34 | ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA | ||
| 35 | const ResultCode ERR_PORT_NAME_TOO_LONG(ErrorDescription(30), ErrorModule::OS, | ||
| 36 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E0181E | ||
| 37 | |||
| 33 | /// An invalid result code that is meant to be overwritten when a thread resumes from waiting | 38 | /// An invalid result code that is meant to be overwritten when a thread resumes from waiting |
| 34 | const ResultCode RESULT_INVALID(0xDEADC0DE); | 39 | const ResultCode RESULT_INVALID(0xDEADC0DE); |
| 35 | 40 | ||
| @@ -94,14 +99,21 @@ static ResultCode MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 o | |||
| 94 | } | 99 | } |
| 95 | 100 | ||
| 96 | /// Connect to an OS service given the port name, returns the handle to the port to out | 101 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 97 | static ResultCode ConnectToPort(Handle* out, const char* port_name) { | 102 | static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { |
| 98 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | 103 | if (port_name == nullptr) |
| 104 | return ERR_NOT_FOUND; | ||
| 105 | if (std::strlen(port_name) > 11) | ||
| 106 | return ERR_PORT_NAME_TOO_LONG; | ||
| 99 | 107 | ||
| 100 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); | 108 | LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name); |
| 101 | _assert_msg_(KERNEL, (service != nullptr), "called, but service is not implemented!"); | ||
| 102 | 109 | ||
| 103 | *out = service->GetHandle(); | 110 | auto it = Service::g_kernel_named_ports.find(port_name); |
| 111 | if (it == Service::g_kernel_named_ports.end()) { | ||
| 112 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name); | ||
| 113 | return ERR_NOT_FOUND; | ||
| 114 | } | ||
| 104 | 115 | ||
| 116 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(it->second)); | ||
| 105 | return RESULT_SUCCESS; | 117 | return RESULT_SUCCESS; |
| 106 | } | 118 | } |
| 107 | 119 | ||