diff options
| author | 2015-05-06 00:04:25 -0300 | |
|---|---|---|
| committer | 2015-05-06 00:24:39 -0300 | |
| commit | ecff2351a180e76967de7322ceb2d8e9064ae7a6 (patch) | |
| tree | 0707ce5701d0c996a3ee131542e0f2178ba6e48e /src/core/hle/svc.cpp | |
| parent | Merge pull request #719 from yuriks/unused-stuff (diff) | |
| download | yuzu-ecff2351a180e76967de7322ceb2d8e9064ae7a6.tar.gz yuzu-ecff2351a180e76967de7322ceb2d8e9064ae7a6.tar.xz yuzu-ecff2351a180e76967de7322ceb2d8e9064ae7a6.zip | |
HLE: Clean up SVC dispatch mechanism
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 76e9b171a..2da488d83 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <map> | 5 | #include <map> |
| 6 | 6 | ||
| 7 | #include "common/profiler.h" | ||
| 7 | #include "common/string_util.h" | 8 | #include "common/string_util.h" |
| 8 | #include "common/symbols.h" | 9 | #include "common/symbols.h" |
| 9 | 10 | ||
| @@ -606,7 +607,17 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 | |||
| 606 | return RESULT_SUCCESS; | 607 | return RESULT_SUCCESS; |
| 607 | } | 608 | } |
| 608 | 609 | ||
| 609 | const HLE::FunctionDef SVC_Table[] = { | 610 | namespace { |
| 611 | struct FunctionDef { | ||
| 612 | using Func = void(); | ||
| 613 | |||
| 614 | u32 id; | ||
| 615 | Func* func; | ||
| 616 | const char* name; | ||
| 617 | }; | ||
| 618 | } | ||
| 619 | |||
| 620 | static const FunctionDef SVC_Table[] = { | ||
| 610 | {0x00, nullptr, "Unknown"}, | 621 | {0x00, nullptr, "Unknown"}, |
| 611 | {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"}, | 622 | {0x01, HLE::Wrap<ControlMemory>, "ControlMemory"}, |
| 612 | {0x02, HLE::Wrap<QueryMemory>, "QueryMemory"}, | 623 | {0x02, HLE::Wrap<QueryMemory>, "QueryMemory"}, |
| @@ -735,8 +746,28 @@ const HLE::FunctionDef SVC_Table[] = { | |||
| 735 | {0x7D, nullptr, "QueryProcessMemory"}, | 746 | {0x7D, nullptr, "QueryProcessMemory"}, |
| 736 | }; | 747 | }; |
| 737 | 748 | ||
| 738 | void Register() { | 749 | Common::Profiling::TimingCategory profiler_svc("SVC Calls"); |
| 739 | HLE::RegisterModule("SVC_Table", ARRAY_SIZE(SVC_Table), SVC_Table); | 750 | |
| 751 | static const FunctionDef* GetSVCInfo(u32 opcode) { | ||
| 752 | u32 func_num = opcode & 0xFFFFFF; // 8 bits | ||
| 753 | if (func_num >= ARRAY_SIZE(SVC_Table)) { | ||
| 754 | LOG_ERROR(Kernel_SVC, "unknown svc=0x%02X", func_num); | ||
| 755 | return nullptr; | ||
| 756 | } | ||
| 757 | return &SVC_Table[func_num]; | ||
| 758 | } | ||
| 759 | |||
| 760 | void CallSVC(u32 opcode) { | ||
| 761 | Common::Profiling::ScopeTimer timer_svc(profiler_svc); | ||
| 762 | |||
| 763 | const FunctionDef *info = GetSVCInfo(opcode); | ||
| 764 | if (info) { | ||
| 765 | if (info->func) { | ||
| 766 | info->func(); | ||
| 767 | } else { | ||
| 768 | LOG_ERROR(Kernel_SVC, "unimplemented SVC function %s(..)", info->name); | ||
| 769 | } | ||
| 770 | } | ||
| 740 | } | 771 | } |
| 741 | 772 | ||
| 742 | } // namespace | 773 | } // namespace |