aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-05-06 00:04:25 -0300
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-05-06 00:24:39 -0300
commitecff2351a180e76967de7322ceb2d8e9064ae7a6 (patch)
tree0707ce5701d0c996a3ee131542e0f2178ba6e48e /src/core/hle/svc.cpp
parent9cdfe5d864dcd6a45704fb76d20fe0a8929eabcc (diff)
HLE: Clean up SVC dispatch mechanism
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 76e9b171..2da488d8 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -4,6 +4,7 @@
#include <map>
+#include "common/profiler.h"
#include "common/string_util.h"
#include "common/symbols.h"
@@ -606,7 +607,17 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
return RESULT_SUCCESS;
}
-const HLE::FunctionDef SVC_Table[] = {
+namespace {
+ struct FunctionDef {
+ using Func = void();
+
+ u32 id;
+ Func* func;
+ const char* name;
+ };
+}
+
+static const FunctionDef SVC_Table[] = {
{0x00, nullptr, "Unknown"},
{0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
{0x02, HLE::Wrap<QueryMemory>, "QueryMemory"},
@@ -735,8 +746,28 @@ const HLE::FunctionDef SVC_Table[] = {
{0x7D, nullptr, "QueryProcessMemory"},
};
-void Register() {
- HLE::RegisterModule("SVC_Table", ARRAY_SIZE(SVC_Table), SVC_Table);
+Common::Profiling::TimingCategory profiler_svc("SVC Calls");
+
+static const FunctionDef* GetSVCInfo(u32 opcode) {
+ u32 func_num = opcode & 0xFFFFFF; // 8 bits
+ if (func_num >= ARRAY_SIZE(SVC_Table)) {
+ LOG_ERROR(Kernel_SVC, "unknown svc=0x%02X", func_num);
+ return nullptr;
+ }
+ return &SVC_Table[func_num];
+}
+
+void CallSVC(u32 opcode) {
+ Common::Profiling::ScopeTimer timer_svc(profiler_svc);
+
+ const FunctionDef *info = GetSVCInfo(opcode);
+ if (info) {
+ if (info->func) {
+ info->func();
+ } else {
+ LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name);
+ }
+ }
}
} // namespace