diff options
| author | 2018-09-02 11:58:58 -0400 | |
|---|---|---|
| committer | 2018-09-02 12:35:30 -0400 | |
| commit | 1242c1ec0aab88d91b0bb4faf6200e4f20e4bdc2 (patch) | |
| tree | f540b9cbc6db29bb5d41668f7efa8fc5c4e44469 /src/core/hle/kernel/svc.cpp | |
| parent | Merge pull request #1213 from DarkLordZach/octopath-fs (diff) | |
| download | yuzu-1242c1ec0aab88d91b0bb4faf6200e4f20e4bdc2.tar.gz yuzu-1242c1ec0aab88d91b0bb4faf6200e4f20e4bdc2.tar.xz yuzu-1242c1ec0aab88d91b0bb4faf6200e4f20e4bdc2.zip | |
service: Migrate global named port map to the KernelCore class
Now that we have a class representing the kernel in some capacity, we
now have a place to put the named port map, so we move it over and get
rid of another piece of global state within the core.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 5da71cff0..1c9373ed8 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -68,19 +68,22 @@ static ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | |||
| 68 | 68 | ||
| 69 | /// Connect to an OS service given the port name, returns the handle to the port to out | 69 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 70 | static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address) { | 70 | static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address) { |
| 71 | if (!Memory::IsValidVirtualAddress(port_name_address)) | 71 | if (!Memory::IsValidVirtualAddress(port_name_address)) { |
| 72 | return ERR_NOT_FOUND; | 72 | return ERR_NOT_FOUND; |
| 73 | } | ||
| 73 | 74 | ||
| 74 | static constexpr std::size_t PortNameMaxLength = 11; | 75 | static constexpr std::size_t PortNameMaxLength = 11; |
| 75 | // Read 1 char beyond the max allowed port name to detect names that are too long. | 76 | // Read 1 char beyond the max allowed port name to detect names that are too long. |
| 76 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); | 77 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); |
| 77 | if (port_name.size() > PortNameMaxLength) | 78 | if (port_name.size() > PortNameMaxLength) { |
| 78 | return ERR_PORT_NAME_TOO_LONG; | 79 | return ERR_PORT_NAME_TOO_LONG; |
| 80 | } | ||
| 79 | 81 | ||
| 80 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); | 82 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); |
| 81 | 83 | ||
| 82 | auto it = Service::g_kernel_named_ports.find(port_name); | 84 | auto& kernel = Core::System::GetInstance().Kernel(); |
| 83 | if (it == Service::g_kernel_named_ports.end()) { | 85 | auto it = kernel.FindNamedPort(port_name); |
| 86 | if (!kernel.IsValidNamedPort(it)) { | ||
| 84 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); | 87 | LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: {}", port_name); |
| 85 | return ERR_NOT_FOUND; | 88 | return ERR_NOT_FOUND; |
| 86 | } | 89 | } |
| @@ -91,7 +94,6 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address | |||
| 91 | CASCADE_RESULT(client_session, client_port->Connect()); | 94 | CASCADE_RESULT(client_session, client_port->Connect()); |
| 92 | 95 | ||
| 93 | // Return the client session | 96 | // Return the client session |
| 94 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 95 | CASCADE_RESULT(*out_handle, kernel.HandleTable().Create(client_session)); | 97 | CASCADE_RESULT(*out_handle, kernel.HandleTable().Create(client_session)); |
| 96 | return RESULT_SUCCESS; | 98 | return RESULT_SUCCESS; |
| 97 | } | 99 | } |