base code to call a syscall from ARM11 appcore
This commit is contained in:
parent
01bedbf956
commit
2bde8f2856
|
@ -16,6 +16,8 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include "core/hle/hle.h"
|
||||||
|
|
||||||
#include "arm_regformat.h"
|
#include "arm_regformat.h"
|
||||||
#include "armdefs.h"
|
#include "armdefs.h"
|
||||||
#include "armemu.h"
|
#include "armemu.h"
|
||||||
|
@ -4558,6 +4560,7 @@ ARMul_Emulate26 (ARMul_State * state)
|
||||||
// ARMul_OSHandleSWI (state, BITS (0, 23));
|
// ARMul_OSHandleSWI (state, BITS (0, 23));
|
||||||
// break;
|
// break;
|
||||||
//}
|
//}
|
||||||
|
HLE::CallSyscall(instr);
|
||||||
ARMul_Abort (state, ARMul_SWIV);
|
ARMul_Abort (state, ARMul_SWIV);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,21 +13,45 @@ namespace HLE {
|
||||||
|
|
||||||
static std::vector<ModuleDef> g_module_db;
|
static std::vector<ModuleDef> g_module_db;
|
||||||
|
|
||||||
|
const FunctionDef* GetSyscallInfo(u32 opcode) {
|
||||||
|
u32 func_num = opcode & 0xFFFFFF; // 8 bits
|
||||||
|
if (func_num > 0xFF) {
|
||||||
|
ERROR_LOG(HLE,"Unknown syscall: 0x%02X", func_num);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return &g_module_db[0].func_table[func_num];
|
||||||
|
}
|
||||||
|
|
||||||
|
void CallSyscall(u32 opcode) {
|
||||||
|
const FunctionDef *info = GetSyscallInfo(opcode);
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (info->func) {
|
||||||
|
info->func();
|
||||||
|
} else {
|
||||||
|
ERROR_LOG(HLE, "Unimplemented HLE function %s", info->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) {
|
void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) {
|
||||||
ModuleDef module = {name, num_functions, func_table};
|
ModuleDef module = {name, num_functions, func_table};
|
||||||
g_module_db.push_back(module);
|
g_module_db.push_back(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterAllModules() {
|
void RegisterAllModules() {
|
||||||
Register_SysCall();
|
Register_Syscall();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
RegisterAllModules();
|
RegisterAllModules();
|
||||||
|
NOTICE_LOG(HLE, "initialized OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Shutdown() {
|
void Shutdown() {
|
||||||
g_module_db.clear();
|
g_module_db.clear();
|
||||||
|
NOTICE_LOG(HLE, "shutdown OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -30,10 +30,12 @@ struct ModuleDef {
|
||||||
const FunctionDef* func_table;
|
const FunctionDef* func_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table);
|
||||||
|
|
||||||
|
void CallSyscall(u32 opcode);
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
|
||||||
void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table);
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -10,15 +10,62 @@
|
||||||
typedef u32 Handle;
|
typedef u32 Handle;
|
||||||
typedef s32 Result;
|
typedef s32 Result;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Result SVC_ConnectToPort(void* out, const char* port_name) {
|
Result SVC_ConnectToPort(void* out, const char* port_name) {
|
||||||
NOTICE_LOG(OSHLE, "svcConnectToPort called, port_name: %s", port_name);
|
NOTICE_LOG(OSHLE, "svcConnectToPort called, port_name: %s", port_name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HLE::FunctionDef SysCall_Table[] = {
|
const HLE::FunctionDef Syscall_Table[] = {
|
||||||
{0x2D, WrapI_VC<SVC_ConnectToPort>, "svcConnectToPort"},
|
{0x00, NULL, "Unknown"},
|
||||||
|
{0x01, NULL, "svcControlMemory"},
|
||||||
|
{0x02, NULL, "svcQueryMemory"},
|
||||||
|
{0x03, NULL, "svcExitProcess"},
|
||||||
|
{0x04, NULL, "svcGetProcessAffinityMask"},
|
||||||
|
{0x05, NULL, "svcSetProcessAffinityMask"},
|
||||||
|
{0x06, NULL, "svcGetProcessIdealProcessor"},
|
||||||
|
{0x07, NULL, "svcSetProcessIdealProcessor"},
|
||||||
|
{0x08, NULL, "svcCreateThread"},
|
||||||
|
{0x09, NULL, "svcExitThread"},
|
||||||
|
{0x0A, NULL, "svcSleepThread"},
|
||||||
|
{0x0B, NULL, "svcGetThreadPriority"},
|
||||||
|
{0x0C, NULL, "svcSetThreadPriority"},
|
||||||
|
{0x0D, NULL, "svcGetThreadAffinityMask"},
|
||||||
|
{0x0E, NULL, "svcSetThreadAffinityMask"},
|
||||||
|
{0x0F, NULL, "svcGetThreadIdealProcessor"},
|
||||||
|
{0x10, NULL, "svcSetThreadIdealProcessor"},
|
||||||
|
{0x11, NULL, "svcGetCurrentProcessorNumber"},
|
||||||
|
{0x12, NULL, "svcRun"},
|
||||||
|
{0x13, NULL, "svcCreateMutex"},
|
||||||
|
{0x14, NULL, "svcReleaseMutex"},
|
||||||
|
{0x15, NULL, "svcCreateSemaphore"},
|
||||||
|
{0x16, NULL, "svcReleaseSemaphore"},
|
||||||
|
{0x17, NULL, "svcCreateEvent"},
|
||||||
|
{0x18, NULL, "svcSignalEvent"},
|
||||||
|
{0x19, NULL, "svcClearEvent"},
|
||||||
|
{0x1A, NULL, "svcCreateTimer"},
|
||||||
|
{0x1B, NULL, "svcSetTimer"},
|
||||||
|
{0x1C, NULL, "svcCancelTimer"},
|
||||||
|
{0x1D, NULL, "svcClearTimer"},
|
||||||
|
{0x1E, NULL, "svcCreateMemoryBlock"},
|
||||||
|
{0x1F, NULL, "svcMapMemoryBlock"},
|
||||||
|
{0x20, NULL, "svcUnmapMemoryBlock"},
|
||||||
|
{0x21, NULL, "svcCreateAddressArbiter"},
|
||||||
|
{0x22, NULL, "svcArbitrateAddress"},
|
||||||
|
{0x23, NULL, "svcCloseHandle"},
|
||||||
|
{0x24, NULL, "svcWaitSynchronization1"},
|
||||||
|
{0x25, NULL, "svcWaitSynchronizationN"},
|
||||||
|
{0x26, NULL, "svcSignalAndWait"},
|
||||||
|
{0x27, NULL, "svcDuplicateHandle"},
|
||||||
|
{0x28, NULL, "svcGetSystemTick"},
|
||||||
|
{0x29, NULL, "svcGetHandleInfo"},
|
||||||
|
{0x2A, NULL, "svcGetSystemInfo"},
|
||||||
|
{0x2B, NULL, "svcGetProcessInfo"},
|
||||||
|
{0x2C, NULL, "svcGetThreadInfo"},
|
||||||
|
{0x2D, WrapI_VC<SVC_ConnectToPort>, "svcConnectToPort"},
|
||||||
};
|
};
|
||||||
|
|
||||||
void Register_SysCall() {
|
void Register_Syscall() {
|
||||||
HLE::RegisterModule("SysCallTable", ARRAY_SIZE(SysCall_Table), SysCall_Table);
|
HLE::RegisterModule("SyscallTable", ARRAY_SIZE(Syscall_Table), Syscall_Table);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,4 @@
|
||||||
// }
|
// }
|
||||||
//};
|
//};
|
||||||
|
|
||||||
void Register_SysCall();
|
void Register_Syscall();
|
||||||
|
|
Reference in New Issue