summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-01-06 14:34:32 -0500
committerGravatar bunnei2018-01-06 14:34:32 -0500
commit0e978bdd50b109dbfd883ff903390240db6a0d5b (patch)
tree40df7bfb318a45e3a018c90447d201105101253a /src/core/hle/kernel/svc.cpp
parentsvc: Refactor LockMutex code to use WaitSynchronization1. (diff)
downloadyuzu-0e978bdd50b109dbfd883ff903390240db6a0d5b.tar.gz
yuzu-0e978bdd50b109dbfd883ff903390240db6a0d5b.tar.xz
yuzu-0e978bdd50b109dbfd883ff903390240db6a0d5b.zip
svc: Implement WaitSynchronization for a single handle.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index a24641399..66df42da2 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -164,10 +164,30 @@ static ResultCode WaitSynchronization1(
164 164
165/// Wait for the given handles to synchronize, timeout after the specified nanoseconds 165/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
166static ResultCode WaitSynchronization(VAddr handles_address, u64 handle_count, s64 nano_seconds) { 166static ResultCode WaitSynchronization(VAddr handles_address, u64 handle_count, s64 nano_seconds) {
167 LOG_WARNING(Kernel_SVC, 167 LOG_TRACE(Kernel_SVC, "called handles_address=0x%llx, handle_count=%d, nano_seconds=%d",
168 "(STUBBED) called handles_address=0x%llx, handle_count=%d, nano_seconds=%d", 168 handles_address, handle_count, nano_seconds);
169 handles_address, handle_count, nano_seconds); 169
170 return RESULT_SUCCESS; 170 if (!Memory::IsValidVirtualAddress(handles_address))
171 return ERR_INVALID_POINTER;
172
173 // Check if 'handle_count' is invalid
174 if (handle_count < 0)
175 return ERR_OUT_OF_RANGE;
176
177 using ObjectPtr = SharedPtr<WaitObject>;
178 std::vector<ObjectPtr> objects(handle_count);
179
180 for (int i = 0; i < handle_count; ++i) {
181 Handle handle = Memory::Read32(handles_address + i * sizeof(Handle));
182 auto object = g_handle_table.Get<WaitObject>(handle);
183 if (object == nullptr)
184 return ERR_INVALID_HANDLE;
185 objects[i] = object;
186 }
187
188 // Just implement for a single handle for now
189 ASSERT(handle_count == 1);
190 return WaitSynchronization1(objects[0], GetCurrentThread(), nano_seconds);
171} 191}
172 192
173/// Attempts to locks a mutex, creating it if it does not already exist 193/// Attempts to locks a mutex, creating it if it does not already exist