diff options
Diffstat (limited to 'src/core/hle/service')
| -rw-r--r-- | src/core/hle/service/fs_user.cpp | 66 | ||||
| -rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 17 | ||||
| -rw-r--r-- | src/core/hle/service/hid_user.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 22 | ||||
| -rw-r--r-- | src/core/hle/service/srv.cpp | 6 |
6 files changed, 46 insertions, 72 deletions
diff --git a/src/core/hle/service/fs_user.cpp b/src/core/hle/service/fs_user.cpp index 2aec1a52a..435be5b5d 100644 --- a/src/core/hle/service/fs_user.cpp +++ b/src/core/hle/service/fs_user.cpp | |||
| @@ -4,26 +4,24 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/common.h" | 5 | #include "common/common.h" |
| 6 | 6 | ||
| 7 | #include "fs_user.h" | ||
| 8 | #include "common/string_util.h" | 7 | #include "common/string_util.h" |
| 9 | #include "core/settings.h" | ||
| 10 | #include "core/hle/kernel/archive.h" | 8 | #include "core/hle/kernel/archive.h" |
| 9 | #include "core/hle/kernel/archive.h" | ||
| 10 | #include "core/hle/result.h" | ||
| 11 | #include "core/hle/service/fs_user.h" | ||
| 12 | #include "core/settings.h" | ||
| 11 | 13 | ||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 13 | // Namespace FS_User | 15 | // Namespace FS_User |
| 14 | 16 | ||
| 15 | namespace FS_User { | 17 | namespace FS_User { |
| 16 | 18 | ||
| 17 | // We currently return 0 for success and -1 for failure in cmd_buff[1]. -1 was chosen because it | ||
| 18 | // puts all the sections of the http://3dbrew.org/wiki/Error_codes to something non-zero, to make | ||
| 19 | // sure we don't mislead the application into thinking something worked. | ||
| 20 | |||
| 21 | static void Initialize(Service::Interface* self) { | 19 | static void Initialize(Service::Interface* self) { |
| 22 | u32* cmd_buff = Service::GetCommandBuffer(); | 20 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 23 | 21 | ||
| 24 | // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per | 22 | // TODO(Link Mauve): check the behavior when cmd_buff[1] isn't 32, as per |
| 25 | // http://3dbrew.org/wiki/FS:Initialize#Request | 23 | // http://3dbrew.org/wiki/FS:Initialize#Request |
| 26 | cmd_buff[1] = 0; | 24 | cmd_buff[1] = RESULT_SUCCESS.raw; |
| 27 | 25 | ||
| 28 | DEBUG_LOG(KERNEL, "called"); | 26 | DEBUG_LOG(KERNEL, "called"); |
| 29 | } | 27 | } |
| @@ -59,14 +57,12 @@ static void OpenFile(Service::Interface* self) { | |||
| 59 | 57 | ||
| 60 | DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%d", file_path.DebugStr().c_str(), mode, attributes); | 58 | DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%d", file_path.DebugStr().c_str(), mode, attributes); |
| 61 | 59 | ||
| 62 | Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); | 60 | ResultVal<Handle> handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); |
| 63 | if (handle) { | 61 | cmd_buff[1] = handle.Code().raw; |
| 64 | cmd_buff[1] = 0; | 62 | if (handle.Succeeded()) { |
| 65 | cmd_buff[3] = handle; | 63 | cmd_buff[3] = *handle; |
| 66 | } else { | 64 | } else { |
| 67 | ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); | 65 | ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); |
| 68 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 69 | cmd_buff[1] = -1; | ||
| 70 | } | 66 | } |
| 71 | 67 | ||
| 72 | DEBUG_LOG(KERNEL, "called"); | 68 | DEBUG_LOG(KERNEL, "called"); |
| @@ -111,27 +107,27 @@ static void OpenFileDirectly(Service::Interface* self) { | |||
| 111 | 107 | ||
| 112 | if (archive_path.GetType() != FileSys::Empty) { | 108 | if (archive_path.GetType() != FileSys::Empty) { |
| 113 | ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); | 109 | ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); |
| 114 | cmd_buff[1] = -1; | 110 | cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw; |
| 115 | return; | 111 | return; |
| 116 | } | 112 | } |
| 117 | 113 | ||
| 118 | // TODO(Link Mauve): Check if we should even get a handle for the archive, and don't leak it | 114 | // TODO(Link Mauve): Check if we should even get a handle for the archive, and don't leak it |
| 119 | Handle archive_handle = Kernel::OpenArchive(archive_id); | 115 | // TODO(yuriks): Why is there all this duplicate (and seemingly useless) code up here? |
| 120 | if (!archive_handle) { | 116 | ResultVal<Handle> archive_handle = Kernel::OpenArchive(archive_id); |
| 117 | cmd_buff[1] = archive_handle.Code().raw; | ||
| 118 | if (archive_handle.Failed()) { | ||
| 121 | ERROR_LOG(KERNEL, "failed to get a handle for archive"); | 119 | ERROR_LOG(KERNEL, "failed to get a handle for archive"); |
| 122 | // TODO(Link Mauve): Check for the actual error values, this one was just chosen arbitrarily | ||
| 123 | cmd_buff[1] = -1; | ||
| 124 | return; | 120 | return; |
| 125 | } | 121 | } |
| 122 | // cmd_buff[2] isn't used according to 3dmoo's implementation. | ||
| 123 | cmd_buff[3] = *archive_handle; | ||
| 126 | 124 | ||
| 127 | Handle handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); | 125 | ResultVal<Handle> handle = Kernel::OpenFileFromArchive(*archive_handle, file_path, mode); |
| 128 | if (handle) { | 126 | cmd_buff[1] = handle.Code().raw; |
| 129 | cmd_buff[1] = 0; | 127 | if (handle.Succeeded()) { |
| 130 | cmd_buff[3] = handle; | 128 | cmd_buff[3] = *handle; |
| 131 | } else { | 129 | } else { |
| 132 | ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); | 130 | ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); |
| 133 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 134 | cmd_buff[1] = -1; | ||
| 135 | } | 131 | } |
| 136 | 132 | ||
| 137 | DEBUG_LOG(KERNEL, "called"); | 133 | DEBUG_LOG(KERNEL, "called"); |
| @@ -243,14 +239,12 @@ static void OpenDirectory(Service::Interface* self) { | |||
| 243 | 239 | ||
| 244 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); | 240 | DEBUG_LOG(KERNEL, "type=%d size=%d data=%s", dirname_type, dirname_size, dir_path.DebugStr().c_str()); |
| 245 | 241 | ||
| 246 | Handle handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path); | 242 | ResultVal<Handle> handle = Kernel::OpenDirectoryFromArchive(archive_handle, dir_path); |
| 247 | if (handle) { | 243 | cmd_buff[1] = handle.Code().raw; |
| 248 | cmd_buff[1] = 0; | 244 | if (handle.Succeeded()) { |
| 249 | cmd_buff[3] = handle; | 245 | cmd_buff[3] = *handle; |
| 250 | } else { | 246 | } else { |
| 251 | ERROR_LOG(KERNEL, "failed to get a handle for directory"); | 247 | ERROR_LOG(KERNEL, "failed to get a handle for directory"); |
| 252 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 253 | cmd_buff[1] = -1; | ||
| 254 | } | 248 | } |
| 255 | 249 | ||
| 256 | DEBUG_LOG(KERNEL, "called"); | 250 | DEBUG_LOG(KERNEL, "called"); |
| @@ -282,19 +276,17 @@ static void OpenArchive(Service::Interface* self) { | |||
| 282 | 276 | ||
| 283 | if (archive_path.GetType() != FileSys::Empty) { | 277 | if (archive_path.GetType() != FileSys::Empty) { |
| 284 | ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); | 278 | ERROR_LOG(KERNEL, "archive LowPath type other than empty is currently unsupported"); |
| 285 | cmd_buff[1] = -1; | 279 | cmd_buff[1] = UnimplementedFunction(ErrorModule::FS).raw; |
| 286 | return; | 280 | return; |
| 287 | } | 281 | } |
| 288 | 282 | ||
| 289 | Handle handle = Kernel::OpenArchive(archive_id); | 283 | ResultVal<Handle> handle = Kernel::OpenArchive(archive_id); |
| 290 | if (handle) { | 284 | cmd_buff[1] = handle.Code().raw; |
| 291 | cmd_buff[1] = 0; | 285 | if (handle.Succeeded()) { |
| 292 | // cmd_buff[2] isn't used according to 3dmoo's implementation. | 286 | // cmd_buff[2] isn't used according to 3dmoo's implementation. |
| 293 | cmd_buff[3] = handle; | 287 | cmd_buff[3] = *handle; |
| 294 | } else { | 288 | } else { |
| 295 | ERROR_LOG(KERNEL, "failed to get a handle for archive"); | 289 | ERROR_LOG(KERNEL, "failed to get a handle for archive"); |
| 296 | // TODO(Link Mauve): check for the actual error values, this one was just chosen arbitrarily. | ||
| 297 | cmd_buff[1] = -1; | ||
| 298 | } | 290 | } |
| 299 | 291 | ||
| 300 | DEBUG_LOG(KERNEL, "called"); | 292 | DEBUG_LOG(KERNEL, "called"); |
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 66daded94..de1bd3f61 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp | |||
| @@ -28,28 +28,23 @@ u32 g_thread_id = 1; ///< Thread index into interrupt relay queue, 1 | |||
| 28 | 28 | ||
| 29 | /// Gets a pointer to a thread command buffer in GSP shared memory | 29 | /// Gets a pointer to a thread command buffer in GSP shared memory |
| 30 | static inline u8* GetCommandBuffer(u32 thread_id) { | 30 | static inline u8* GetCommandBuffer(u32 thread_id) { |
| 31 | if (0 == g_shared_memory) | 31 | ResultVal<u8*> ptr = Kernel::GetSharedMemoryPointer(g_shared_memory, 0x800 + (thread_id * sizeof(CommandBuffer))); |
| 32 | return nullptr; | 32 | return ptr.ValueOr(nullptr); |
| 33 | |||
| 34 | return Kernel::GetSharedMemoryPointer(g_shared_memory, | ||
| 35 | 0x800 + (thread_id * sizeof(CommandBuffer))); | ||
| 36 | } | 33 | } |
| 37 | 34 | ||
| 38 | static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { | 35 | static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { |
| 39 | if (0 == g_shared_memory) | ||
| 40 | return nullptr; | ||
| 41 | |||
| 42 | _dbg_assert_msg_(GSP, screen_index < 2, "Invalid screen index"); | 36 | _dbg_assert_msg_(GSP, screen_index < 2, "Invalid screen index"); |
| 43 | 37 | ||
| 44 | // For each thread there are two FrameBufferUpdate fields | 38 | // For each thread there are two FrameBufferUpdate fields |
| 45 | u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate); | 39 | u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate); |
| 46 | return (FrameBufferUpdate*)Kernel::GetSharedMemoryPointer(g_shared_memory, offset); | 40 | ResultVal<u8*> ptr = Kernel::GetSharedMemoryPointer(g_shared_memory, offset); |
| 41 | return reinterpret_cast<FrameBufferUpdate*>(ptr.ValueOr(nullptr)); | ||
| 47 | } | 42 | } |
| 48 | 43 | ||
| 49 | /// Gets a pointer to the interrupt relay queue for a given thread index | 44 | /// Gets a pointer to the interrupt relay queue for a given thread index |
| 50 | static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) { | 45 | static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) { |
| 51 | return (InterruptRelayQueue*)Kernel::GetSharedMemoryPointer(g_shared_memory, | 46 | ResultVal<u8*> ptr = Kernel::GetSharedMemoryPointer(g_shared_memory, sizeof(InterruptRelayQueue) * thread_id); |
| 52 | sizeof(InterruptRelayQueue) * thread_id); | 47 | return reinterpret_cast<InterruptRelayQueue*>(ptr.ValueOr(nullptr)); |
| 53 | } | 48 | } |
| 54 | 49 | ||
| 55 | static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) { | 50 | static void WriteHWRegs(u32 base_address, u32 size_in_bytes, const u32* data) { |
diff --git a/src/core/hle/service/hid_user.cpp b/src/core/hle/service/hid_user.cpp index 5f6bf1eff..d29de1a52 100644 --- a/src/core/hle/service/hid_user.cpp +++ b/src/core/hle/service/hid_user.cpp | |||
| @@ -34,10 +34,7 @@ static s16 next_circle_y = 0; | |||
| 34 | * Gets a pointer to the PadData structure inside HID shared memory | 34 | * Gets a pointer to the PadData structure inside HID shared memory |
| 35 | */ | 35 | */ |
| 36 | static inline PadData* GetPadData() { | 36 | static inline PadData* GetPadData() { |
| 37 | if (0 == shared_mem) | 37 | return reinterpret_cast<PadData*>(Kernel::GetSharedMemoryPointer(shared_mem, 0).ValueOr(nullptr)); |
| 38 | return nullptr; | ||
| 39 | |||
| 40 | return reinterpret_cast<PadData*>(Kernel::GetSharedMemoryPointer(shared_mem, 0)); | ||
| 41 | } | 38 | } |
| 42 | 39 | ||
| 43 | /** | 40 | /** |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index abc8d5edb..fed2268a0 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -62,7 +62,7 @@ void Manager::DeleteService(const std::string& port_name) { | |||
| 62 | 62 | ||
| 63 | /// Get a Service Interface from its Handle | 63 | /// Get a Service Interface from its Handle |
| 64 | Interface* Manager::FetchFromHandle(Handle handle) { | 64 | Interface* Manager::FetchFromHandle(Handle handle) { |
| 65 | return Kernel::g_object_pool.GetFast<Interface>(handle); | 65 | return Kernel::g_object_pool.Get<Interface>(handle); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | /// Get a Service Interface from its port | 68 | /// Get a Service Interface from its port |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 55aa84e83..20e7fb4d3 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -75,12 +75,7 @@ public: | |||
| 75 | m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end()); | 75 | m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end()); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | /** | 78 | ResultVal<bool> SyncRequest() override { |
| 79 | * Synchronize kernel object | ||
| 80 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | ||
| 81 | * @return Result of operation, 0 on success, otherwise error code | ||
| 82 | */ | ||
| 83 | Result SyncRequest(bool* wait) override { | ||
| 84 | u32* cmd_buff = GetCommandBuffer(); | 79 | u32* cmd_buff = GetCommandBuffer(); |
| 85 | auto itr = m_functions.find(cmd_buff[0]); | 80 | auto itr = m_functions.find(cmd_buff[0]); |
| 86 | 81 | ||
| @@ -91,7 +86,7 @@ public: | |||
| 91 | // TODO(bunnei): Hack - ignore error | 86 | // TODO(bunnei): Hack - ignore error |
| 92 | u32* cmd_buff = Service::GetCommandBuffer(); | 87 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 93 | cmd_buff[1] = 0; | 88 | cmd_buff[1] = 0; |
| 94 | return 0; | 89 | return MakeResult<bool>(false); |
| 95 | } | 90 | } |
| 96 | if (itr->second.func == nullptr) { | 91 | if (itr->second.func == nullptr) { |
| 97 | ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s", | 92 | ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s", |
| @@ -100,23 +95,18 @@ public: | |||
| 100 | // TODO(bunnei): Hack - ignore error | 95 | // TODO(bunnei): Hack - ignore error |
| 101 | u32* cmd_buff = Service::GetCommandBuffer(); | 96 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 102 | cmd_buff[1] = 0; | 97 | cmd_buff[1] = 0; |
| 103 | return 0; | 98 | return MakeResult<bool>(false); |
| 104 | } | 99 | } |
| 105 | 100 | ||
| 106 | itr->second.func(this); | 101 | itr->second.func(this); |
| 107 | 102 | ||
| 108 | return 0; // TODO: Implement return from actual function | 103 | return MakeResult<bool>(false); // TODO: Implement return from actual function |
| 109 | } | 104 | } |
| 110 | 105 | ||
| 111 | /** | 106 | ResultVal<bool> WaitSynchronization() override { |
| 112 | * Wait for kernel object to synchronize | ||
| 113 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | ||
| 114 | * @return Result of operation, 0 on success, otherwise error code | ||
| 115 | */ | ||
| 116 | Result WaitSynchronization(bool* wait) override { | ||
| 117 | // TODO(bunnei): ImplementMe | 107 | // TODO(bunnei): ImplementMe |
| 118 | ERROR_LOG(OSHLE, "unimplemented function"); | 108 | ERROR_LOG(OSHLE, "unimplemented function"); |
| 119 | return 0; | 109 | return UnimplementedFunction(ErrorModule::OS); |
| 120 | } | 110 | } |
| 121 | 111 | ||
| 122 | protected: | 112 | protected: |
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index df38bd93c..0e7fa9e3b 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp | |||
| @@ -35,7 +35,7 @@ static void GetProcSemaphore(Service::Interface* self) { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | static void GetServiceHandle(Service::Interface* self) { | 37 | static void GetServiceHandle(Service::Interface* self) { |
| 38 | Result res = 0; | 38 | ResultCode res = RESULT_SUCCESS; |
| 39 | u32* cmd_buff = Service::GetCommandBuffer(); | 39 | u32* cmd_buff = Service::GetCommandBuffer(); |
| 40 | 40 | ||
| 41 | std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); | 41 | std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); |
| @@ -46,9 +46,9 @@ static void GetServiceHandle(Service::Interface* self) { | |||
| 46 | DEBUG_LOG(OSHLE, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]); | 46 | DEBUG_LOG(OSHLE, "called port=%s, handle=0x%08X", port_name.c_str(), cmd_buff[3]); |
| 47 | } else { | 47 | } else { |
| 48 | ERROR_LOG(OSHLE, "(UNIMPLEMENTED) called port=%s", port_name.c_str()); | 48 | ERROR_LOG(OSHLE, "(UNIMPLEMENTED) called port=%s", port_name.c_str()); |
| 49 | res = -1; | 49 | res = UnimplementedFunction(ErrorModule::SRV); |
| 50 | } | 50 | } |
| 51 | cmd_buff[1] = res; | 51 | cmd_buff[1] = res.raw; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | const Interface::FunctionInfo FunctionTable[] = { | 54 | const Interface::FunctionInfo FunctionTable[] = { |