diff options
| author | 2015-01-14 23:33:37 -0500 | |
|---|---|---|
| committer | 2015-01-21 18:42:04 -0500 | |
| commit | 14cbbf4d9b8e07f9f2d679bcf66c2180463ae57c (patch) | |
| tree | f4a942c3b72d8df5186ad8bfe0a99fdbe2644dd5 /src/core/hle/kernel/event.cpp | |
| parent | WaitObject: Added RemoveWaitingThread, fixed a bug, and cleanup. (diff) | |
| download | yuzu-14cbbf4d9b8e07f9f2d679bcf66c2180463ae57c.tar.gz yuzu-14cbbf4d9b8e07f9f2d679bcf66c2180463ae57c.tar.xz yuzu-14cbbf4d9b8e07f9f2d679bcf66c2180463ae57c.zip | |
Event: Get rid of permanent_lock hack.
Diffstat (limited to 'src/core/hle/kernel/event.cpp')
| -rw-r--r-- | src/core/hle/kernel/event.cpp | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index bf71e9edb..9dd3d0f5d 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp | |||
| @@ -26,7 +26,6 @@ public: | |||
| 26 | ResetType reset_type; ///< Current ResetType | 26 | ResetType reset_type; ///< Current ResetType |
| 27 | 27 | ||
| 28 | bool locked; ///< Event signal wait | 28 | bool locked; ///< Event signal wait |
| 29 | bool permanent_locked; ///< Hack - to set event permanent state (for easy passthrough) | ||
| 30 | std::string name; ///< Name of event (optional) | 29 | std::string name; ///< Name of event (optional) |
| 31 | 30 | ||
| 32 | ResultVal<bool> WaitSynchronization() override { | 31 | ResultVal<bool> WaitSynchronization() override { |
| @@ -35,7 +34,7 @@ public: | |||
| 35 | AddWaitingThread(GetCurrentThread()); | 34 | AddWaitingThread(GetCurrentThread()); |
| 36 | Kernel::WaitCurrentThread(WAITTYPE_EVENT, this); | 35 | Kernel::WaitCurrentThread(WAITTYPE_EVENT, this); |
| 37 | } | 36 | } |
| 38 | if (reset_type != RESETTYPE_STICKY && !permanent_locked) { | 37 | if (reset_type != RESETTYPE_STICKY) { |
| 39 | locked = true; | 38 | locked = true; |
| 40 | } | 39 | } |
| 41 | return MakeResult<bool>(wait); | 40 | return MakeResult<bool>(wait); |
| @@ -43,20 +42,6 @@ public: | |||
| 43 | }; | 42 | }; |
| 44 | 43 | ||
| 45 | /** | 44 | /** |
| 46 | * Hackish function to set an events permanent lock state, used to pass through synch blocks | ||
| 47 | * @param handle Handle to event to change | ||
| 48 | * @param permanent_locked Boolean permanent locked value to set event | ||
| 49 | * @return Result of operation, 0 on success, otherwise error code | ||
| 50 | */ | ||
| 51 | ResultCode SetPermanentLock(Handle handle, const bool permanent_locked) { | ||
| 52 | Event* evt = g_handle_table.Get<Event>(handle).get(); | ||
| 53 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); | ||
| 54 | |||
| 55 | evt->permanent_locked = permanent_locked; | ||
| 56 | return RESULT_SUCCESS; | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Changes whether an event is locked or not | 45 | * Changes whether an event is locked or not |
| 61 | * @param handle Handle to event to change | 46 | * @param handle Handle to event to change |
| 62 | * @param locked Boolean locked value to set event | 47 | * @param locked Boolean locked value to set event |
| @@ -66,9 +51,8 @@ ResultCode SetEventLocked(const Handle handle, const bool locked) { | |||
| 66 | Event* evt = g_handle_table.Get<Event>(handle).get(); | 51 | Event* evt = g_handle_table.Get<Event>(handle).get(); |
| 67 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); | 52 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); |
| 68 | 53 | ||
| 69 | if (!evt->permanent_locked) { | 54 | evt->locked = locked; |
| 70 | evt->locked = locked; | 55 | |
| 71 | } | ||
| 72 | return RESULT_SUCCESS; | 56 | return RESULT_SUCCESS; |
| 73 | } | 57 | } |
| 74 | 58 | ||
| @@ -81,16 +65,13 @@ ResultCode SignalEvent(const Handle handle) { | |||
| 81 | Event* evt = g_handle_table.Get<Event>(handle).get(); | 65 | Event* evt = g_handle_table.Get<Event>(handle).get(); |
| 82 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); | 66 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); |
| 83 | 67 | ||
| 84 | // Resume threads waiting for event to signal | ||
| 85 | bool event_caught = evt->ResumeAllWaitingThreads(); | ||
| 86 | |||
| 87 | // If any thread is signalled awake by this event, assume the event was "caught" and reset | 68 | // If any thread is signalled awake by this event, assume the event was "caught" and reset |
| 88 | // the event. This will result in the next thread waiting on the event to block. Otherwise, | 69 | // the event. This will result in the next thread waiting on the event to block. Otherwise, |
| 89 | // the event will not be reset, and the next thread to call WaitSynchronization on it will | 70 | // the event will not be reset, and the next thread to call WaitSynchronization on it will |
| 90 | // not block. Not sure if this is correct behavior, but it seems to work. | 71 | // not block. Not sure if this is correct behavior, but it seems to work. |
| 91 | if (!evt->permanent_locked) { | 72 | // TODO(bunnei): Test how this works on hardware |
| 92 | evt->locked = event_caught; | 73 | evt->locked = evt->ResumeAllWaitingThreads(); |
| 93 | } | 74 | |
| 94 | return RESULT_SUCCESS; | 75 | return RESULT_SUCCESS; |
| 95 | } | 76 | } |
| 96 | 77 | ||
| @@ -103,9 +84,8 @@ ResultCode ClearEvent(Handle handle) { | |||
| 103 | Event* evt = g_handle_table.Get<Event>(handle).get(); | 84 | Event* evt = g_handle_table.Get<Event>(handle).get(); |
| 104 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); | 85 | if (evt == nullptr) return InvalidHandle(ErrorModule::Kernel); |
| 105 | 86 | ||
| 106 | if (!evt->permanent_locked) { | 87 | evt->locked = true; |
| 107 | evt->locked = true; | 88 | |
| 108 | } | ||
| 109 | return RESULT_SUCCESS; | 89 | return RESULT_SUCCESS; |
| 110 | } | 90 | } |
| 111 | 91 | ||
| @@ -123,7 +103,6 @@ Event* CreateEvent(Handle& handle, const ResetType reset_type, const std::string | |||
| 123 | handle = Kernel::g_handle_table.Create(evt).ValueOr(INVALID_HANDLE); | 103 | handle = Kernel::g_handle_table.Create(evt).ValueOr(INVALID_HANDLE); |
| 124 | 104 | ||
| 125 | evt->locked = true; | 105 | evt->locked = true; |
| 126 | evt->permanent_locked = false; | ||
| 127 | evt->reset_type = evt->intitial_reset_type = reset_type; | 106 | evt->reset_type = evt->intitial_reset_type = reset_type; |
| 128 | evt->name = name; | 107 | evt->name = name; |
| 129 | 108 | ||