diff options
| author | 2014-05-27 20:16:13 -0400 | |
|---|---|---|
| committer | 2014-05-27 20:16:13 -0400 | |
| commit | fd69fd03259b71be521aeb69d3f73761b598be8a (patch) | |
| tree | b61308daa248cd485aa76c7beaa340c6e6035504 /src/core/hle/kernel/event.cpp | |
| parent | mutex: removed docstring comment that is no longer relevant (diff) | |
| download | yuzu-fd69fd03259b71be521aeb69d3f73761b598be8a.tar.gz yuzu-fd69fd03259b71be521aeb69d3f73761b598be8a.tar.xz yuzu-fd69fd03259b71be521aeb69d3f73761b598be8a.zip | |
kernel: added event module to support creation of CTR "Event" objects
Diffstat (limited to 'src/core/hle/kernel/event.cpp')
| -rw-r--r-- | src/core/hle/kernel/event.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp new file mode 100644 index 000000000..cc15ba9bc --- /dev/null +++ b/src/core/hle/kernel/event.cpp | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <map> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | #include "common/common.h" | ||
| 9 | |||
| 10 | #include "core/hle/kernel/kernel.h" | ||
| 11 | #include "core/hle/kernel/event.h" | ||
| 12 | |||
| 13 | namespace Kernel { | ||
| 14 | |||
| 15 | class Event : public Object { | ||
| 16 | public: | ||
| 17 | const char* GetTypeName() { return "Event"; } | ||
| 18 | |||
| 19 | static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; } | ||
| 20 | Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; } | ||
| 21 | |||
| 22 | ResetType intitial_reset_type; ///< ResetType specified at Event initialization | ||
| 23 | ResetType reset_type; ///< Current ResetType | ||
| 24 | |||
| 25 | bool locked; ///< Current locked state | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Synchronize kernel object | ||
| 29 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | ||
| 30 | * @return Result of operation, 0 on success, otherwise error code | ||
| 31 | */ | ||
| 32 | Result SyncRequest(bool* wait) { | ||
| 33 | // TODO(bunnei): ImplementMe | ||
| 34 | ERROR_LOG(KERNEL, "Unimplemented function Event::SyncRequest"); | ||
| 35 | return 0; | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Wait for kernel object to synchronize | ||
| 40 | * @param wait Boolean wait set if current thread should wait as a result of sync operation | ||
| 41 | * @return Result of operation, 0 on success, otherwise error code | ||
| 42 | */ | ||
| 43 | Result WaitSynchronization(bool* wait) { | ||
| 44 | // TODO(bunnei): ImplementMe | ||
| 45 | *wait = locked; | ||
| 46 | if (reset_type != RESETTYPE_STICKY) { | ||
| 47 | locked = true; | ||
| 48 | } | ||
| 49 | return 0; | ||
| 50 | } | ||
| 51 | }; | ||
| 52 | |||
| 53 | /** | ||
| 54 | * Clears an event | ||
| 55 | * @param handle Handle to event to clear | ||
| 56 | * @return Result of operation, 0 on success, otherwise error code | ||
| 57 | */ | ||
| 58 | Result ClearEvent(Handle handle) { | ||
| 59 | ERROR_LOG(KERNEL, "Unimplemented function ClearEvent"); | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Creates an event | ||
| 65 | * @param handle Reference to handle for the newly created mutex | ||
| 66 | * @param reset_type ResetType describing how to create event | ||
| 67 | * @return Handle to newly created object | ||
| 68 | */ | ||
| 69 | Event* CreateEvent(Handle& handle, const ResetType reset_type) { | ||
| 70 | Event* evt = new Event; | ||
| 71 | |||
| 72 | handle = Kernel::g_object_pool.Create(evt); | ||
| 73 | |||
| 74 | evt->reset_type = evt->intitial_reset_type = reset_type; | ||
| 75 | evt->locked = false; | ||
| 76 | |||
| 77 | return evt; | ||
| 78 | } | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Creates an event | ||
| 82 | * @param reset_type ResetType describing how to create event | ||
| 83 | * @return Handle to newly created object | ||
| 84 | */ | ||
| 85 | Handle CreateEvent(const ResetType reset_type) { | ||
| 86 | Handle handle; | ||
| 87 | Event* evt = CreateEvent(handle, reset_type); | ||
| 88 | return handle; | ||
| 89 | } | ||
| 90 | |||
| 91 | } // namespace | ||