diff options
| author | 2014-04-10 23:26:12 -0400 | |
|---|---|---|
| committer | 2014-04-10 23:26:12 -0400 | |
| commit | 2bde8f28561ea9436d13d990f6b129a0e80a325e (patch) | |
| tree | 4d5404d320f4c737ccc6fcbed3cc5549513689f1 /src | |
| parent | updated logging message (diff) | |
| download | yuzu-2bde8f28561ea9436d13d990f6b129a0e80a325e.tar.gz yuzu-2bde8f28561ea9436d13d990f6b129a0e80a325e.tar.xz yuzu-2bde8f28561ea9436d13d990f6b129a0e80a325e.zip | |
base code to call a syscall from ARM11 appcore
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/interpreter/armemu.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/hle.h | 6 | ||||
| -rw-r--r-- | src/core/hle/hle_syscall.cpp | 55 | ||||
| -rw-r--r-- | src/core/hle/hle_syscall.h | 2 |
5 files changed, 85 insertions, 9 deletions
diff --git a/src/core/arm/interpreter/armemu.cpp b/src/core/arm/interpreter/armemu.cpp index 46c51fbe8..6074ff480 100644 --- a/src/core/arm/interpreter/armemu.cpp +++ b/src/core/arm/interpreter/armemu.cpp | |||
| @@ -16,6 +16,8 @@ | |||
| 16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 18 | 18 | ||
| 19 | #include "core/hle/hle.h" | ||
| 20 | |||
| 19 | #include "arm_regformat.h" | 21 | #include "arm_regformat.h" |
| 20 | #include "armdefs.h" | 22 | #include "armdefs.h" |
| 21 | #include "armemu.h" | 23 | #include "armemu.h" |
| @@ -4558,6 +4560,7 @@ ARMul_Emulate26 (ARMul_State * state) | |||
| 4558 | // ARMul_OSHandleSWI (state, BITS (0, 23)); | 4560 | // ARMul_OSHandleSWI (state, BITS (0, 23)); |
| 4559 | // break; | 4561 | // break; |
| 4560 | //} | 4562 | //} |
| 4563 | HLE::CallSyscall(instr); | ||
| 4561 | ARMul_Abort (state, ARMul_SWIV); | 4564 | ARMul_Abort (state, ARMul_SWIV); |
| 4562 | break; | 4565 | break; |
| 4563 | } | 4566 | } |
diff --git a/src/core/hle.cpp b/src/core/hle.cpp index 8dad7695b..d62d2d0ce 100644 --- a/src/core/hle.cpp +++ b/src/core/hle.cpp | |||
| @@ -13,21 +13,45 @@ namespace HLE { | |||
| 13 | 13 | ||
| 14 | static std::vector<ModuleDef> g_module_db; | 14 | static std::vector<ModuleDef> g_module_db; |
| 15 | 15 | ||
| 16 | const FunctionDef* GetSyscallInfo(u32 opcode) { | ||
| 17 | u32 func_num = opcode & 0xFFFFFF; // 8 bits | ||
| 18 | if (func_num > 0xFF) { | ||
| 19 | ERROR_LOG(HLE,"Unknown syscall: 0x%02X", func_num); | ||
| 20 | return NULL; | ||
| 21 | } | ||
| 22 | return &g_module_db[0].func_table[func_num]; | ||
| 23 | } | ||
| 24 | |||
| 25 | void CallSyscall(u32 opcode) { | ||
| 26 | const FunctionDef *info = GetSyscallInfo(opcode); | ||
| 27 | |||
| 28 | if (!info) { | ||
| 29 | return; | ||
| 30 | } | ||
| 31 | if (info->func) { | ||
| 32 | info->func(); | ||
| 33 | } else { | ||
| 34 | ERROR_LOG(HLE, "Unimplemented HLE function %s", info->name); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 16 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { | 38 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { |
| 17 | ModuleDef module = {name, num_functions, func_table}; | 39 | ModuleDef module = {name, num_functions, func_table}; |
| 18 | g_module_db.push_back(module); | 40 | g_module_db.push_back(module); |
| 19 | } | 41 | } |
| 20 | 42 | ||
| 21 | void RegisterAllModules() { | 43 | void RegisterAllModules() { |
| 22 | Register_SysCall(); | 44 | Register_Syscall(); |
| 23 | } | 45 | } |
| 24 | 46 | ||
| 25 | void Init() { | 47 | void Init() { |
| 26 | RegisterAllModules(); | 48 | RegisterAllModules(); |
| 49 | NOTICE_LOG(HLE, "initialized OK"); | ||
| 27 | } | 50 | } |
| 28 | 51 | ||
| 29 | void Shutdown() { | 52 | void Shutdown() { |
| 30 | g_module_db.clear(); | 53 | g_module_db.clear(); |
| 54 | NOTICE_LOG(HLE, "shutdown OK"); | ||
| 31 | } | 55 | } |
| 32 | 56 | ||
| 33 | } // namespace | 57 | } // namespace |
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index 35c8a4621..e3b8d483a 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h | |||
| @@ -30,10 +30,12 @@ struct ModuleDef { | |||
| 30 | const FunctionDef* func_table; | 30 | const FunctionDef* func_table; |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table); | ||
| 34 | |||
| 35 | void CallSyscall(u32 opcode); | ||
| 36 | |||
| 33 | void Init(); | 37 | void Init(); |
| 34 | 38 | ||
| 35 | void Shutdown(); | 39 | void Shutdown(); |
| 36 | 40 | ||
| 37 | void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table); | ||
| 38 | |||
| 39 | } // namespace | 41 | } // namespace |
diff --git a/src/core/hle/hle_syscall.cpp b/src/core/hle/hle_syscall.cpp index fdcaa914f..53d721275 100644 --- a/src/core/hle/hle_syscall.cpp +++ b/src/core/hle/hle_syscall.cpp | |||
| @@ -10,15 +10,62 @@ | |||
| 10 | typedef u32 Handle; | 10 | typedef u32 Handle; |
| 11 | typedef s32 Result; | 11 | typedef s32 Result; |
| 12 | 12 | ||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 14 | |||
| 13 | Result SVC_ConnectToPort(void* out, const char* port_name) { | 15 | Result SVC_ConnectToPort(void* out, const char* port_name) { |
| 14 | NOTICE_LOG(OSHLE, "svcConnectToPort called, port_name: %s", port_name); | 16 | NOTICE_LOG(OSHLE, "svcConnectToPort called, port_name: %s", port_name); |
| 15 | return 0; | 17 | return 0; |
| 16 | } | 18 | } |
| 17 | 19 | ||
| 18 | const HLE::FunctionDef SysCall_Table[] = { | 20 | const HLE::FunctionDef Syscall_Table[] = { |
| 19 | {0x2D, WrapI_VC<SVC_ConnectToPort>, "svcConnectToPort"}, | 21 | {0x00, NULL, "Unknown"}, |
| 22 | {0x01, NULL, "svcControlMemory"}, | ||
| 23 | {0x02, NULL, "svcQueryMemory"}, | ||
| 24 | {0x03, NULL, "svcExitProcess"}, | ||
| 25 | {0x04, NULL, "svcGetProcessAffinityMask"}, | ||
| 26 | {0x05, NULL, "svcSetProcessAffinityMask"}, | ||
| 27 | {0x06, NULL, "svcGetProcessIdealProcessor"}, | ||
| 28 | {0x07, NULL, "svcSetProcessIdealProcessor"}, | ||
| 29 | {0x08, NULL, "svcCreateThread"}, | ||
| 30 | {0x09, NULL, "svcExitThread"}, | ||
| 31 | {0x0A, NULL, "svcSleepThread"}, | ||
| 32 | {0x0B, NULL, "svcGetThreadPriority"}, | ||
| 33 | {0x0C, NULL, "svcSetThreadPriority"}, | ||
| 34 | {0x0D, NULL, "svcGetThreadAffinityMask"}, | ||
| 35 | {0x0E, NULL, "svcSetThreadAffinityMask"}, | ||
| 36 | {0x0F, NULL, "svcGetThreadIdealProcessor"}, | ||
| 37 | {0x10, NULL, "svcSetThreadIdealProcessor"}, | ||
| 38 | {0x11, NULL, "svcGetCurrentProcessorNumber"}, | ||
| 39 | {0x12, NULL, "svcRun"}, | ||
| 40 | {0x13, NULL, "svcCreateMutex"}, | ||
| 41 | {0x14, NULL, "svcReleaseMutex"}, | ||
| 42 | {0x15, NULL, "svcCreateSemaphore"}, | ||
| 43 | {0x16, NULL, "svcReleaseSemaphore"}, | ||
| 44 | {0x17, NULL, "svcCreateEvent"}, | ||
| 45 | {0x18, NULL, "svcSignalEvent"}, | ||
| 46 | {0x19, NULL, "svcClearEvent"}, | ||
| 47 | {0x1A, NULL, "svcCreateTimer"}, | ||
| 48 | {0x1B, NULL, "svcSetTimer"}, | ||
| 49 | {0x1C, NULL, "svcCancelTimer"}, | ||
| 50 | {0x1D, NULL, "svcClearTimer"}, | ||
| 51 | {0x1E, NULL, "svcCreateMemoryBlock"}, | ||
| 52 | {0x1F, NULL, "svcMapMemoryBlock"}, | ||
| 53 | {0x20, NULL, "svcUnmapMemoryBlock"}, | ||
| 54 | {0x21, NULL, "svcCreateAddressArbiter"}, | ||
| 55 | {0x22, NULL, "svcArbitrateAddress"}, | ||
| 56 | {0x23, NULL, "svcCloseHandle"}, | ||
| 57 | {0x24, NULL, "svcWaitSynchronization1"}, | ||
| 58 | {0x25, NULL, "svcWaitSynchronizationN"}, | ||
| 59 | {0x26, NULL, "svcSignalAndWait"}, | ||
| 60 | {0x27, NULL, "svcDuplicateHandle"}, | ||
| 61 | {0x28, NULL, "svcGetSystemTick"}, | ||
| 62 | {0x29, NULL, "svcGetHandleInfo"}, | ||
| 63 | {0x2A, NULL, "svcGetSystemInfo"}, | ||
| 64 | {0x2B, NULL, "svcGetProcessInfo"}, | ||
| 65 | {0x2C, NULL, "svcGetThreadInfo"}, | ||
| 66 | {0x2D, WrapI_VC<SVC_ConnectToPort>, "svcConnectToPort"}, | ||
| 20 | }; | 67 | }; |
| 21 | 68 | ||
| 22 | void Register_SysCall() { | 69 | void Register_Syscall() { |
| 23 | HLE::RegisterModule("SysCallTable", ARRAY_SIZE(SysCall_Table), SysCall_Table); | 70 | HLE::RegisterModule("SyscallTable", ARRAY_SIZE(Syscall_Table), Syscall_Table); |
| 24 | } | 71 | } |
diff --git a/src/core/hle/hle_syscall.h b/src/core/hle/hle_syscall.h index 4faa14535..80b20c358 100644 --- a/src/core/hle/hle_syscall.h +++ b/src/core/hle/hle_syscall.h | |||
| @@ -34,4 +34,4 @@ | |||
| 34 | // } | 34 | // } |
| 35 | //}; | 35 | //}; |
| 36 | 36 | ||
| 37 | void Register_SysCall(); | 37 | void Register_Syscall(); |