diff options
| author | 2015-05-06 09:45:42 -0400 | |
|---|---|---|
| committer | 2015-05-06 09:45:42 -0400 | |
| commit | c4abfe893bf23e7937a29263a68451c24b349fd9 (patch) | |
| tree | 0707ce5701d0c996a3ee131542e0f2178ba6e48e /src/core/hle/hle.cpp | |
| parent | Merge pull request #719 from yuriks/unused-stuff (diff) | |
| parent | HLE: Clean up SVC dispatch mechanism (diff) | |
| download | yuzu-c4abfe893bf23e7937a29263a68451c24b349fd9.tar.gz yuzu-c4abfe893bf23e7937a29263a68451c24b349fd9.tar.xz yuzu-c4abfe893bf23e7937a29263a68451c24b349fd9.zip | |
Merge pull request #720 from yuriks/svc-cleanup
HLE: Clean up SVC dispatch mechanism
Diffstat (limited to 'src/core/hle/hle.cpp')
| -rw-r--r-- | src/core/hle/hle.cpp | 49 |
1 files changed, 3 insertions, 46 deletions
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 191d0411e..fdeb9a028 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp | |||
| @@ -2,53 +2,23 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <vector> | 5 | #include "common/assert.h" |
| 6 | 6 | #include "common/logging/log.h" | |
| 7 | #include "common/profiler.h" | ||
| 8 | 7 | ||
| 9 | #include "core/arm/arm_interface.h" | 8 | #include "core/arm/arm_interface.h" |
| 10 | #include "core/mem_map.h" | 9 | #include "core/core.h" |
| 11 | #include "core/hle/hle.h" | 10 | #include "core/hle/hle.h" |
| 12 | #include "core/hle/config_mem.h" | 11 | #include "core/hle/config_mem.h" |
| 13 | #include "core/hle/shared_page.h" | 12 | #include "core/hle/shared_page.h" |
| 14 | #include "core/hle/kernel/thread.h" | 13 | #include "core/hle/kernel/thread.h" |
| 15 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 16 | #include "core/hle/svc.h" | ||
| 17 | 15 | ||
| 18 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 19 | 17 | ||
| 20 | namespace HLE { | 18 | namespace HLE { |
| 21 | 19 | ||
| 22 | Common::Profiling::TimingCategory profiler_svc("SVC Calls"); | ||
| 23 | |||
| 24 | static std::vector<ModuleDef> g_module_db; | ||
| 25 | |||
| 26 | bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread | 20 | bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread |
| 27 | 21 | ||
| 28 | static const FunctionDef* GetSVCInfo(u32 opcode) { | ||
| 29 | u32 func_num = opcode & 0xFFFFFF; // 8 bits | ||
| 30 | if (func_num > 0xFF) { | ||
| 31 | LOG_ERROR(Kernel_SVC,"unknown svc=0x%02X", func_num); | ||
| 32 | return nullptr; | ||
| 33 | } | ||
| 34 | return &g_module_db[0].func_table[func_num]; | ||
| 35 | } | ||
| 36 | |||
| 37 | void CallSVC(u32 opcode) { | ||
| 38 | Common::Profiling::ScopeTimer timer_svc(profiler_svc); | ||
| 39 | |||
| 40 | const FunctionDef *info = GetSVCInfo(opcode); | ||
| 41 | |||
| 42 | if (!info) { | ||
| 43 | return; | ||
| 44 | } | ||
| 45 | if (info->func) { | ||
| 46 | info->func(); | ||
| 47 | } else { | ||
| 48 | LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name.c_str()); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | void Reschedule(const char *reason) { | 22 | void Reschedule(const char *reason) { |
| 53 | DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); | 23 | DEBUG_ASSERT_MSG(reason != nullptr && strlen(reason) < 256, "Reschedule: Invalid or too long reason."); |
| 54 | 24 | ||
| @@ -63,18 +33,7 @@ void Reschedule(const char *reason) { | |||
| 63 | g_reschedule = true; | 33 | g_reschedule = true; |
| 64 | } | 34 | } |
| 65 | 35 | ||
| 66 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { | ||
| 67 | ModuleDef module = {name, num_functions, func_table}; | ||
| 68 | g_module_db.push_back(module); | ||
| 69 | } | ||
| 70 | |||
| 71 | static void RegisterAllModules() { | ||
| 72 | SVC::Register(); | ||
| 73 | } | ||
| 74 | |||
| 75 | void Init() { | 36 | void Init() { |
| 76 | RegisterAllModules(); | ||
| 77 | |||
| 78 | Service::Init(); | 37 | Service::Init(); |
| 79 | ConfigMem::Init(); | 38 | ConfigMem::Init(); |
| 80 | SharedPage::Init(); | 39 | SharedPage::Init(); |
| @@ -89,8 +48,6 @@ void Shutdown() { | |||
| 89 | SharedPage::Shutdown(); | 48 | SharedPage::Shutdown(); |
| 90 | Service::Shutdown(); | 49 | Service::Shutdown(); |
| 91 | 50 | ||
| 92 | g_module_db.clear(); | ||
| 93 | |||
| 94 | LOG_DEBUG(Kernel, "shutdown OK"); | 51 | LOG_DEBUG(Kernel, "shutdown OK"); |
| 95 | } | 52 | } |
| 96 | 53 | ||