summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-05-20 23:23:58 -0400
committerGravatar bunnei2014-05-20 23:23:58 -0400
commiteb537c560a33db9955413a96afd3b98203a729fe (patch)
tree6bb55926f3b811a578a2680b0cd454476a144244 /src
parentmutex: initial commit of HLE module (diff)
downloadyuzu-eb537c560a33db9955413a96afd3b98203a729fe.tar.gz
yuzu-eb537c560a33db9955413a96afd3b98203a729fe.tar.xz
yuzu-eb537c560a33db9955413a96afd3b98203a729fe.zip
mutex: refactored the interface to code to return a Mutex* handle
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/mutex.cpp14
-rw-r--r--src/core/hle/kernel/mutex.h2
-rw-r--r--src/core/hle/service/apt.cpp3
-rw-r--r--src/core/hle/svc.cpp2
4 files changed, 16 insertions, 5 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 2b2cff4ea..7cf3439e9 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -102,7 +102,7 @@ Result ReleaseMutex(Handle handle) {
102 * @param handle Reference to handle for the newly created mutex 102 * @param handle Reference to handle for the newly created mutex
103 * @param initial_locked Specifies if the mutex should be locked initially 103 * @param initial_locked Specifies if the mutex should be locked initially
104 */ 104 */
105Result CreateMutex(Handle& handle, bool initial_locked) { 105Mutex* CreateMutex(Handle& handle, bool initial_locked) {
106 Mutex* mutex = new Mutex; 106 Mutex* mutex = new Mutex;
107 handle = Kernel::g_object_pool.Create(mutex); 107 handle = Kernel::g_object_pool.Create(mutex);
108 108
@@ -116,7 +116,17 @@ Result CreateMutex(Handle& handle, bool initial_locked) {
116 } else { 116 } else {
117 mutex->lock_thread = -1; 117 mutex->lock_thread = -1;
118 } 118 }
119 return 0; 119 return mutex;
120}
121
122/**
123 * Creates a mutex
124 * @param initial_locked Specifies if the mutex should be locked initially
125 */
126Handle CreateMutex(bool initial_locked) {
127 Handle handle;
128 Mutex* mutex = CreateMutex(handle, initial_locked);
129 return handle;
120} 130}
121 131
122} // namespace 132} // namespace
diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h
index 1f843e979..871e2e562 100644
--- a/src/core/hle/kernel/mutex.h
+++ b/src/core/hle/kernel/mutex.h
@@ -21,6 +21,6 @@ Result ReleaseMutex(Handle handle);
21 * @param handle Reference to handle for the newly created mutex 21 * @param handle Reference to handle for the newly created mutex
22 * @param initial_locked Specifies if the mutex should be locked initially 22 * @param initial_locked Specifies if the mutex should be locked initially
23 */ 23 */
24Result CreateMutex(Handle& handle, bool initial_locked); 24Handle CreateMutex(bool initial_locked);
25 25
26} // namespace 26} // namespace
diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp
index ecec4da00..b01f35ac5 100644
--- a/src/core/hle/service/apt.cpp
+++ b/src/core/hle/service/apt.cpp
@@ -21,7 +21,8 @@ void Initialize(Service::Interface* self) {
21void GetLockHandle(Service::Interface* self) { 21void GetLockHandle(Service::Interface* self) {
22 u32* cmd_buff = Service::GetCommandBuffer(); 22 u32* cmd_buff = Service::GetCommandBuffer();
23 u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field 23 u32 flags = cmd_buff[1]; // TODO(bunnei): Figure out the purpose of the flag field
24 cmd_buff[1] = Kernel::CreateMutex(cmd_buff[5], false); 24 cmd_buff[1] = 0; // No error
25 cmd_buff[5] = Kernel::CreateMutex(false);
25} 26}
26 27
27const Interface::FunctionInfo FunctionTable[] = { 28const Interface::FunctionInfo FunctionTable[] = {
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 73ab073f5..ffacdfb86 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -188,7 +188,7 @@ Result CreateThread(void* thread, u32 priority, u32 entry_point, u32 arg, u32 st
188Result CreateMutex(void* _mutex, u32 initial_locked) { 188Result CreateMutex(void* _mutex, u32 initial_locked) {
189 Handle* mutex = (Handle*)_mutex; 189 Handle* mutex = (Handle*)_mutex;
190 DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s", initial_locked ? "true" : "false"); 190 DEBUG_LOG(SVC, "CreateMutex called initial_locked=%s", initial_locked ? "true" : "false");
191 Kernel::CreateMutex(*mutex, (bool)initial_locked); 191 *mutex = Kernel::CreateMutex((initial_locked != 0));
192 Core::g_app_core->SetReg(1, *mutex); 192 Core::g_app_core->SetReg(1, *mutex);
193 return 0; 193 return 0;
194} 194}