diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/hle.cpp | 49 | ||||
| -rw-r--r-- | src/core/hle/hle.h | 27 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 37 | ||||
| -rw-r--r-- | src/core/hle/svc.h | 2 |
5 files changed, 40 insertions, 79 deletions
diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 991da740b..5ee99e93a 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "common/profiler.h" | 11 | #include "common/profiler.h" |
| 12 | 12 | ||
| 13 | #include "core/mem_map.h" | 13 | #include "core/mem_map.h" |
| 14 | #include "core/hle/hle.h" | 14 | #include "core/hle/svc.h" |
| 15 | #include "core/arm/disassembler/arm_disasm.h" | 15 | #include "core/arm/disassembler/arm_disasm.h" |
| 16 | #include "core/arm/dyncom/arm_dyncom_interpreter.h" | 16 | #include "core/arm/dyncom/arm_dyncom_interpreter.h" |
| 17 | #include "core/arm/dyncom/arm_dyncom_thumb.h" | 17 | #include "core/arm/dyncom/arm_dyncom_thumb.h" |
| @@ -6234,7 +6234,7 @@ unsigned InterpreterMainLoop(ARMul_State* state) { | |||
| 6234 | SWI_INST: | 6234 | SWI_INST: |
| 6235 | { | 6235 | { |
| 6236 | if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { | 6236 | if (inst_base->cond == 0xE || CondPassed(cpu, inst_base->cond)) { |
| 6237 | HLE::CallSVC(Memory::Read32(cpu->Reg[15])); | 6237 | SVC::CallSVC(Memory::Read32(cpu->Reg[15])); |
| 6238 | } | 6238 | } |
| 6239 | 6239 | ||
| 6240 | cpu->Reg[15] += GET_INST_SIZE(cpu); | 6240 | cpu->Reg[15] += GET_INST_SIZE(cpu); |
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 | ||
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index 3f6f9a4b5..23de1aab7 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h | |||
| @@ -4,40 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <string> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | ||
| 10 | #include "core/core.h" | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 13 | |||
| 14 | namespace HLE { | 7 | namespace HLE { |
| 15 | 8 | ||
| 16 | extern bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread | 9 | extern bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread |
| 17 | 10 | ||
| 18 | typedef u32 Addr; | ||
| 19 | typedef void (*Func)(); | ||
| 20 | |||
| 21 | struct FunctionDef { | ||
| 22 | u32 id; | ||
| 23 | Func func; | ||
| 24 | std::string name; | ||
| 25 | }; | ||
| 26 | |||
| 27 | struct ModuleDef { | ||
| 28 | std::string name; | ||
| 29 | int num_funcs; | ||
| 30 | const FunctionDef* func_table; | ||
| 31 | }; | ||
| 32 | |||
| 33 | void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table); | ||
| 34 | |||
| 35 | void CallSVC(u32 opcode); | ||
| 36 | |||
| 37 | void Reschedule(const char *reason); | 11 | void Reschedule(const char *reason); |
| 38 | 12 | ||
| 39 | void Init(); | 13 | void Init(); |
| 40 | |||
| 41 | void Shutdown(); | 14 | void Shutdown(); |
| 42 | 15 | ||
| 43 | } // namespace | 16 | } // namespace |
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 |
diff --git a/src/core/hle/svc.h b/src/core/hle/svc.h index 5d020a5ba..4389aa73d 100644 --- a/src/core/hle/svc.h +++ b/src/core/hle/svc.h | |||
| @@ -41,6 +41,6 @@ enum ArbitrationType { | |||
| 41 | 41 | ||
| 42 | namespace SVC { | 42 | namespace SVC { |
| 43 | 43 | ||
| 44 | void Register(); | 44 | void CallSVC(u32 opcode); |
| 45 | 45 | ||
| 46 | } // namespace | 46 | } // namespace |