summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-12 23:31:39 -0400
committerGravatar bunnei2014-04-12 23:31:39 -0400
commit6f6d5158de18a7ca134406d55446c27f6db48a1a (patch)
tree82c3b60b5584618207e748e714cc9da30a7962e4 /src/core/hle
parentcleanups to service HLE (diff)
downloadyuzu-6f6d5158de18a7ca134406d55446c27f6db48a1a.tar.gz
yuzu-6f6d5158de18a7ca134406d55446c27f6db48a1a.tar.xz
yuzu-6f6d5158de18a7ca134406d55446c27f6db48a1a.zip
added OS memory read/write for thread command buffer
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/hle.cpp45
-rw-r--r--src/core/hle/hle.h13
2 files changed, 55 insertions, 3 deletions
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 {
15 15
16static std::vector<ModuleDef> g_module_db; 16static std::vector<ModuleDef> g_module_db;
17 17
18u8* g_command_buffer = NULL; ///< Command buffer used for sharing between appcore and syscore
19
20// Read from memory used by CTROS HLE functions
21template <typename T>
22inline void Read(T &var, const u32 addr) {
23 if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) {
24 var = *((const T*)&g_command_buffer[addr & CMD_BUFFER_MASK]);
25 } else {
26 ERROR_LOG(HLE, "unknown read from address %08X", addr);
27 }
28}
29
30// Write to memory used by CTROS HLE functions
31template <typename T>
32inline void Write(u32 addr, const T data) {
33 if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) {
34 *(T*)&g_command_buffer[addr & CMD_BUFFER_MASK] = data;
35 } else {
36 ERROR_LOG(HLE, "unknown write to address %08X", addr);
37 }
38}
39
40// Explicitly instantiate template functions because we aren't defining this in the header:
41
42template void Read<u64>(u64 &var, const u32 addr);
43template void Read<u32>(u32 &var, const u32 addr);
44template void Read<u16>(u16 &var, const u32 addr);
45template void Read<u8>(u8 &var, const u32 addr);
46
47template void Write<u64>(u32 addr, const u64 data);
48template void Write<u32>(u32 addr, const u32 data);
49template void Write<u16>(u32 addr, const u16 data);
50template void Write<u8>(u32 addr, const u8 data);
51
18const FunctionDef* GetSyscallInfo(u32 opcode) { 52const FunctionDef* GetSyscallInfo(u32 opcode) {
19 u32 func_num = opcode & 0xFFFFFF; // 8 bits 53 u32 func_num = opcode & 0xFFFFFF; // 8 bits
20 if (func_num > 0xFF) { 54 if (func_num > 0xFF) {
@@ -41,8 +75,8 @@ void CallSyscall(u32 opcode) {
41Addr CallGetThreadCommandBuffer() { 75Addr CallGetThreadCommandBuffer() {
42 // Called on insruction: mrc p15, 0, r0, c13, c0, 3 76 // Called on insruction: mrc p15, 0, r0, c13, c0, 3
43 // Returns an address in OSHLE memory for the CPU to read/write to 77 // Returns an address in OSHLE memory for the CPU to read/write to
44 RETURN(OS_THREAD_COMMAND_BUFFER_ADDR); 78 RETURN(CMD_BUFFER_ADDR);
45 return OS_THREAD_COMMAND_BUFFER_ADDR; 79 return CMD_BUFFER_ADDR;
46} 80}
47 81
48void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { 82void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) {
@@ -56,6 +90,8 @@ void RegisterAllModules() {
56 90
57void Init() { 91void Init() {
58 Service::Init(); 92 Service::Init();
93
94 g_command_buffer = new u8[CMD_BUFFER_SIZE];
59 95
60 RegisterAllModules(); 96 RegisterAllModules();
61 97
@@ -63,7 +99,12 @@ void Init() {
63} 99}
64 100
65void Shutdown() { 101void Shutdown() {
102 Service::Shutdown();
103
104 delete g_command_buffer;
105
66 g_module_db.clear(); 106 g_module_db.clear();
107
67 NOTICE_LOG(HLE, "shutdown OK"); 108 NOTICE_LOG(HLE, "shutdown OK");
68} 109}
69 110
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h
index 2bd1f99a2..5ee90bcdc 100644
--- a/src/core/hle/hle.h
+++ b/src/core/hle/hle.h
@@ -17,7 +17,10 @@
17namespace HLE { 17namespace HLE {
18 18
19enum { 19enum {
20 OS_THREAD_COMMAND_BUFFER_ADDR = 0xA0004000, 20 CMD_BUFFER_ADDR = 0xA0010000, ///< Totally arbitrary unused address space
21 CMD_BUFFER_SIZE = 0x10000,
22 CMD_BUFFER_MASK = (CMD_BUFFER_SIZE - 1),
23 CMD_BUFFER_ADDR_END = (CMD_BUFFER_ADDR + CMD_BUFFER_SIZE),
21}; 24};
22 25
23typedef u32 Addr; 26typedef u32 Addr;
@@ -35,6 +38,14 @@ struct ModuleDef {
35 const FunctionDef* func_table; 38 const FunctionDef* func_table;
36}; 39};
37 40
41// Read from memory used by CTROS HLE functions
42template <typename T>
43inline void Read(T &var, const u32 addr);
44
45// Write to memory used by CTROS HLE functions
46template <typename T>
47inline void Write(u32 addr, const T data);
48
38void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table); 49void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table);
39 50
40void CallSyscall(u32 opcode); 51void CallSyscall(u32 opcode);