From f6c328cf37fe6e0250c20fcbf128f301b3d71d36 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 11 Apr 2014 18:07:49 -0400 Subject: moved hle.cpp into hle folder (due to mistake earlier) --- src/core/hle/hle.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/core/hle/hle.cpp (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp new file mode 100644 index 000000000..d62d2d0ce --- /dev/null +++ b/src/core/hle/hle.cpp @@ -0,0 +1,57 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include + +#include "core/hle/hle.h" +#include "core/hle/hle_syscall.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace HLE { + +static std::vector 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) { + ModuleDef module = {name, num_functions, func_table}; + g_module_db.push_back(module); +} + +void RegisterAllModules() { + Register_Syscall(); +} + +void Init() { + RegisterAllModules(); + NOTICE_LOG(HLE, "initialized OK"); +} + +void Shutdown() { + g_module_db.clear(); + NOTICE_LOG(HLE, "shutdown OK"); +} + +} // namespace -- cgit v1.2.3 From 02fbd42e7f006236199698c61ca917092afa1f7d Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 11 Apr 2014 18:44:21 -0400 Subject: - renamed hle_syscall to just syscall - added service.h as an initial service interface --- src/core/hle/hle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index d62d2d0ce..32aff0eb5 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -5,7 +5,7 @@ #include #include "core/hle/hle.h" -#include "core/hle/hle_syscall.h" +#include "core/hle/syscall.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -41,7 +41,7 @@ void RegisterModule(std::string name, int num_functions, const FunctionDef* func } void RegisterAllModules() { - Register_Syscall(); + Syscall::Register(); } void Init() { -- cgit v1.2.3 From 68e198476f17a026fed88f3c9a271aa768694354 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 12 Apr 2014 21:55:36 -0400 Subject: - added HLE to connect to "srv:" service - added a manager for keeping track of services/ports - added a memory mapped region for memory accessed by HLE - added HLE for GetThreadCommandBuffer function --- src/core/hle/hle.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 32aff0eb5..3d2c53954 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -4,8 +4,10 @@ #include +#include "core/mem_map.h" #include "core/hle/hle.h" #include "core/hle/syscall.h" +#include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -35,6 +37,14 @@ void CallSyscall(u32 opcode) { } } +/// Returns the coprocessor (in this case, syscore) command buffer pointer +Addr CallGetThreadCommandBuffer() { + // Called on insruction: mrc p15, 0, r0, c13, c0, 3 + // Returns an address in OSHLE memory for the CPU to read/write to + RETURN(OS_THREAD_COMMAND_BUFFER_ADDR); + return OS_THREAD_COMMAND_BUFFER_ADDR; +} + void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { ModuleDef module = {name, num_functions, func_table}; g_module_db.push_back(module); @@ -45,7 +55,10 @@ void RegisterAllModules() { } void Init() { + Service::Init(); + RegisterAllModules(); + NOTICE_LOG(HLE, "initialized OK"); } -- cgit v1.2.3 From 6f6d5158de18a7ca134406d55446c27f6db48a1a Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 12 Apr 2014 23:31:39 -0400 Subject: added OS memory read/write for thread command buffer --- src/core/hle/hle.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 3d2c53954..51432dc87 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -15,6 +15,40 @@ namespace HLE { static std::vector g_module_db; +u8* g_command_buffer = NULL; ///< Command buffer used for sharing between appcore and syscore + +// Read from memory used by CTROS HLE functions +template +inline void Read(T &var, const u32 addr) { + if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { + var = *((const T*)&g_command_buffer[addr & CMD_BUFFER_MASK]); + } else { + ERROR_LOG(HLE, "unknown read from address %08X", addr); + } +} + +// Write to memory used by CTROS HLE functions +template +inline void Write(u32 addr, const T data) { + if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { + *(T*)&g_command_buffer[addr & CMD_BUFFER_MASK] = data; + } else { + ERROR_LOG(HLE, "unknown write to address %08X", addr); + } +} + +// Explicitly instantiate template functions because we aren't defining this in the header: + +template void Read(u64 &var, const u32 addr); +template void Read(u32 &var, const u32 addr); +template void Read(u16 &var, const u32 addr); +template void Read(u8 &var, const u32 addr); + +template void Write(u32 addr, const u64 data); +template void Write(u32 addr, const u32 data); +template void Write(u32 addr, const u16 data); +template void Write(u32 addr, const u8 data); + const FunctionDef* GetSyscallInfo(u32 opcode) { u32 func_num = opcode & 0xFFFFFF; // 8 bits if (func_num > 0xFF) { @@ -41,8 +75,8 @@ void CallSyscall(u32 opcode) { Addr CallGetThreadCommandBuffer() { // Called on insruction: mrc p15, 0, r0, c13, c0, 3 // Returns an address in OSHLE memory for the CPU to read/write to - RETURN(OS_THREAD_COMMAND_BUFFER_ADDR); - return OS_THREAD_COMMAND_BUFFER_ADDR; + RETURN(CMD_BUFFER_ADDR); + return CMD_BUFFER_ADDR; } void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { @@ -56,6 +90,8 @@ void RegisterAllModules() { void Init() { Service::Init(); + + g_command_buffer = new u8[CMD_BUFFER_SIZE]; RegisterAllModules(); @@ -63,7 +99,12 @@ void Init() { } void Shutdown() { + Service::Shutdown(); + + delete g_command_buffer; + g_module_db.clear(); + NOTICE_LOG(HLE, "shutdown OK"); } -- cgit v1.2.3 From 67f6e414702cbb83a53392e1cca229875a186cea Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 13 Apr 2014 00:37:10 -0400 Subject: added a GetPointer function for reading from HLE command buffer --- src/core/hle/hle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 51432dc87..a4ab61c0c 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -37,6 +37,14 @@ inline void Write(u32 addr, const T data) { } } +u8 *GetPointer(const u32 addr) { + if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { + return g_command_buffer + (addr & CMD_BUFFER_MASK); + } else { + ERROR_LOG(HLE, "unknown pointer from address %08X", addr); + } +} + // Explicitly instantiate template functions because we aren't defining this in the header: template void Read(u64 &var, const u32 addr); -- cgit v1.2.3 From 9f4d677cdf1fcc937d2e68cae3f52f53c24582f8 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 13 Apr 2014 16:33:45 -0400 Subject: added framework for APT service (application and title launching service) --- src/core/hle/hle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index a4ab61c0c..c173b82de 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -42,6 +42,7 @@ u8 *GetPointer(const u32 addr) { return g_command_buffer + (addr & CMD_BUFFER_MASK); } else { ERROR_LOG(HLE, "unknown pointer from address %08X", addr); + return 0; } } -- cgit v1.2.3 From de3dcd38f6572da88a67e625e6aa98c2a2f786d7 Mon Sep 17 00:00:00 2001 From: bunnei Date: Wed, 16 Apr 2014 20:41:33 -0400 Subject: - fixed tabs in function_wrappers.h - fixed log message wording in hle.cpp - added syscall stubs for CloseHandle and WaitSynchronization1 --- src/core/hle/hle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/hle.cpp') diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index c173b82de..5672a659f 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp @@ -76,7 +76,7 @@ void CallSyscall(u32 opcode) { if (info->func) { info->func(); } else { - ERROR_LOG(HLE, "Unimplemented HLE function %s", info->name); + ERROR_LOG(HLE, "Unimplemented SysCall function %s(..)", info->name.c_str()); } } -- cgit v1.2.3