diff options
| author | 2014-05-27 20:16:13 -0400 | |
|---|---|---|
| committer | 2014-05-27 20:16:13 -0400 | |
| commit | fd69fd03259b71be521aeb69d3f73761b598be8a (patch) | |
| tree | b61308daa248cd485aa76c7beaa340c6e6035504 /src | |
| 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')
| -rw-r--r-- | src/core/core.vcxproj | 2 | ||||
| -rw-r--r-- | src/core/core.vcxproj.filters | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/event.cpp | 91 | ||||
| -rw-r--r-- | src/core/hle/kernel/event.h | 28 |
4 files changed, 127 insertions, 0 deletions
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index f271d336e..efcd30d77 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj | |||
| @@ -168,6 +168,7 @@ | |||
| 168 | <ClCompile Include="hle\config_mem.cpp" /> | 168 | <ClCompile Include="hle\config_mem.cpp" /> |
| 169 | <ClCompile Include="hle\coprocessor.cpp" /> | 169 | <ClCompile Include="hle\coprocessor.cpp" /> |
| 170 | <ClCompile Include="hle\hle.cpp" /> | 170 | <ClCompile Include="hle\hle.cpp" /> |
| 171 | <ClCompile Include="hle\kernel\event.cpp" /> | ||
| 171 | <ClCompile Include="hle\kernel\kernel.cpp" /> | 172 | <ClCompile Include="hle\kernel\kernel.cpp" /> |
| 172 | <ClCompile Include="hle\kernel\mutex.cpp" /> | 173 | <ClCompile Include="hle\kernel\mutex.cpp" /> |
| 173 | <ClCompile Include="hle\kernel\thread.cpp" /> | 174 | <ClCompile Include="hle\kernel\thread.cpp" /> |
| @@ -217,6 +218,7 @@ | |||
| 217 | <ClInclude Include="hle\coprocessor.h" /> | 218 | <ClInclude Include="hle\coprocessor.h" /> |
| 218 | <ClInclude Include="hle\function_wrappers.h" /> | 219 | <ClInclude Include="hle\function_wrappers.h" /> |
| 219 | <ClInclude Include="hle\hle.h" /> | 220 | <ClInclude Include="hle\hle.h" /> |
| 221 | <ClInclude Include="hle\kernel\event.h" /> | ||
| 220 | <ClInclude Include="hle\kernel\kernel.h" /> | 222 | <ClInclude Include="hle\kernel\kernel.h" /> |
| 221 | <ClInclude Include="hle\kernel\mutex.h" /> | 223 | <ClInclude Include="hle\kernel\mutex.h" /> |
| 222 | <ClInclude Include="hle\kernel\thread.h" /> | 224 | <ClInclude Include="hle\kernel\thread.h" /> |
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index b6c1d5b93..135e4c89c 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters | |||
| @@ -165,6 +165,9 @@ | |||
| 165 | <ClCompile Include="arm\interpreter\armcopro.cpp"> | 165 | <ClCompile Include="arm\interpreter\armcopro.cpp"> |
| 166 | <Filter>arm\interpreter</Filter> | 166 | <Filter>arm\interpreter</Filter> |
| 167 | </ClCompile> | 167 | </ClCompile> |
| 168 | <ClCompile Include="hle\kernel\event.cpp"> | ||
| 169 | <Filter>hle\kernel</Filter> | ||
| 170 | </ClCompile> | ||
| 168 | </ItemGroup> | 171 | </ItemGroup> |
| 169 | <ItemGroup> | 172 | <ItemGroup> |
| 170 | <ClInclude Include="arm\disassembler\arm_disasm.h"> | 173 | <ClInclude Include="arm\disassembler\arm_disasm.h"> |
| @@ -295,6 +298,9 @@ | |||
| 295 | <ClInclude Include="hle\kernel\mutex.h"> | 298 | <ClInclude Include="hle\kernel\mutex.h"> |
| 296 | <Filter>hle\kernel</Filter> | 299 | <Filter>hle\kernel</Filter> |
| 297 | </ClInclude> | 300 | </ClInclude> |
| 301 | <ClInclude Include="hle\kernel\event.h"> | ||
| 302 | <Filter>hle\kernel</Filter> | ||
| 303 | </ClInclude> | ||
| 298 | </ItemGroup> | 304 | </ItemGroup> |
| 299 | <ItemGroup> | 305 | <ItemGroup> |
| 300 | <Text Include="CMakeLists.txt" /> | 306 | <Text Include="CMakeLists.txt" /> |
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 | ||
diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h new file mode 100644 index 000000000..2ef1bd65b --- /dev/null +++ b/src/core/hle/kernel/event.h | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | #include "core/hle/kernel/kernel.h" | ||
| 10 | #include "core/hle/svc.h" | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Clears an event | ||
| 16 | * @param handle Handle to event to clear | ||
| 17 | * @return Result of operation, 0 on success, otherwise error code | ||
| 18 | */ | ||
| 19 | Result ClearEvent(Handle handle); | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Creates an event | ||
| 23 | * @param reset_type ResetType describing how to create event | ||
| 24 | * @return Handle to newly created object | ||
| 25 | */ | ||
| 26 | Handle CreateEvent(const ResetType reset_type); | ||
| 27 | |||
| 28 | } // namespace | ||