diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/interpreter/armsupp.cpp | 68 | ||||
| -rw-r--r-- | src/core/core.vcxproj | 1 | ||||
| -rw-r--r-- | src/core/core.vcxproj.filters | 3 | ||||
| -rw-r--r-- | src/core/hle/hle.cpp | 13 | ||||
| -rw-r--r-- | src/core/hle/hle.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 115 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 57 | ||||
| -rw-r--r-- | src/core/hle/syscall.cpp | 266 | ||||
| -rw-r--r-- | src/core/mem_map.cpp | 3 | ||||
| -rw-r--r-- | src/core/mem_map.h | 3 | ||||
| -rw-r--r-- | src/core/mem_map_funcs.cpp | 18 |
11 files changed, 386 insertions, 168 deletions
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp index a0c866c15..101b9807a 100644 --- a/src/core/arm/interpreter/armsupp.cpp +++ b/src/core/arm/interpreter/armsupp.cpp | |||
| @@ -19,6 +19,8 @@ | |||
| 19 | #include "armemu.h" | 19 | #include "armemu.h" |
| 20 | //#include "ansidecl.h" | 20 | //#include "ansidecl.h" |
| 21 | #include "skyeye_defs.h" | 21 | #include "skyeye_defs.h" |
| 22 | #include "core/hle/hle.h" | ||
| 23 | |||
| 22 | unsigned xscale_cp15_cp_access_allowed (ARMul_State * state, unsigned reg, | 24 | unsigned xscale_cp15_cp_access_allowed (ARMul_State * state, unsigned reg, |
| 23 | unsigned cpnum); | 25 | unsigned cpnum); |
| 24 | //extern int skyeye_instr_debug; | 26 | //extern int skyeye_instr_debug; |
| @@ -734,39 +736,39 @@ ARMword | |||
| 734 | ARMul_MRC (ARMul_State * state, ARMword instr) | 736 | ARMul_MRC (ARMul_State * state, ARMword instr) |
| 735 | { | 737 | { |
| 736 | unsigned cpab; | 738 | unsigned cpab; |
| 737 | ARMword result = 0; | 739 | ARMword result = HLE::CallGetThreadCommandBuffer(); |
| 738 | 740 | ||
| 739 | //printf("SKYEYE ARMul_MRC, CPnum is %x, instr %x\n",CPNum, instr); | 741 | ////printf("SKYEYE ARMul_MRC, CPnum is %x, instr %x\n",CPNum, instr); |
| 740 | if (!CP_ACCESS_ALLOWED (state, CPNum)) { | 742 | //if (!CP_ACCESS_ALLOWED (state, CPNum)) { |
| 741 | //chy 2004-07-19 should fix in the future????!!!! | 743 | // //chy 2004-07-19 should fix in the future????!!!! |
| 742 | //printf("SKYEYE ARMul_MRC,NOT ALLOWed UndefInstr CPnum is %x, instr %x\n",CPNum, instr); | 744 | // //printf("SKYEYE ARMul_MRC,NOT ALLOWed UndefInstr CPnum is %x, instr %x\n",CPNum, instr); |
| 743 | ARMul_UndefInstr (state, instr); | 745 | // ARMul_UndefInstr (state, instr); |
| 744 | return -1; | 746 | // return -1; |
| 745 | } | 747 | //} |
| 746 | 748 | ||
| 747 | cpab = (state->MRC[CPNum]) (state, ARMul_FIRST, instr, &result); | 749 | //cpab = (state->MRC[CPNum]) (state, ARMul_FIRST, instr, &result); |
| 748 | while (cpab == ARMul_BUSY) { | 750 | //while (cpab == ARMul_BUSY) { |
| 749 | ARMul_Icycles (state, 1, 0); | 751 | // ARMul_Icycles (state, 1, 0); |
| 750 | if (IntPending (state)) { | 752 | // if (IntPending (state)) { |
| 751 | cpab = (state->MRC[CPNum]) (state, ARMul_INTERRUPT, | 753 | // cpab = (state->MRC[CPNum]) (state, ARMul_INTERRUPT, |
| 752 | instr, 0); | 754 | // instr, 0); |
| 753 | return (0); | 755 | // return (0); |
| 754 | } | 756 | // } |
| 755 | else | 757 | // else |
| 756 | cpab = (state->MRC[CPNum]) (state, ARMul_BUSY, instr, | 758 | // cpab = (state->MRC[CPNum]) (state, ARMul_BUSY, instr, |
| 757 | &result); | 759 | // &result); |
| 758 | } | 760 | //} |
| 759 | if (cpab == ARMul_CANT) { | 761 | //if (cpab == ARMul_CANT) { |
| 760 | printf ("SKYEYE ARMul_MRC,CANT UndefInstr CPnum is %x, instr %x\n", CPNum, instr); | 762 | // printf ("SKYEYE ARMul_MRC,CANT UndefInstr CPnum is %x, instr %x\n", CPNum, instr); |
| 761 | ARMul_Abort (state, ARMul_UndefinedInstrV); | 763 | // ARMul_Abort (state, ARMul_UndefinedInstrV); |
| 762 | /* Parent will destroy the flags otherwise. */ | 764 | // /* Parent will destroy the flags otherwise. */ |
| 763 | result = ECC; | 765 | // result = ECC; |
| 764 | } | 766 | //} |
| 765 | else { | 767 | //else { |
| 766 | BUSUSEDINCPCN; | 768 | // BUSUSEDINCPCN; |
| 767 | ARMul_Ccycles (state, 1, 0); | 769 | // ARMul_Ccycles (state, 1, 0); |
| 768 | ARMul_Icycles (state, 1, 0); | 770 | // ARMul_Icycles (state, 1, 0); |
| 769 | } | 771 | //} |
| 770 | 772 | ||
| 771 | return result; | 773 | return result; |
| 772 | } | 774 | } |
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index 10ecca596..b10ae8684 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj | |||
| @@ -153,6 +153,7 @@ | |||
| 153 | <ClCompile Include="file_sys\directory_file_system.cpp" /> | 153 | <ClCompile Include="file_sys\directory_file_system.cpp" /> |
| 154 | <ClCompile Include="file_sys\meta_file_system.cpp" /> | 154 | <ClCompile Include="file_sys\meta_file_system.cpp" /> |
| 155 | <ClCompile Include="hle\hle.cpp" /> | 155 | <ClCompile Include="hle\hle.cpp" /> |
| 156 | <ClCompile Include="hle\service\service.cpp" /> | ||
| 156 | <ClCompile Include="hle\syscall.cpp" /> | 157 | <ClCompile Include="hle\syscall.cpp" /> |
| 157 | <ClCompile Include="hw\hw.cpp" /> | 158 | <ClCompile Include="hw\hw.cpp" /> |
| 158 | <ClCompile Include="hw\hw_lcd.cpp" /> | 159 | <ClCompile Include="hw\hw_lcd.cpp" /> |
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index d450224a4..4844e78b8 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters | |||
| @@ -87,6 +87,9 @@ | |||
| 87 | <ClCompile Include="hle\syscall.cpp"> | 87 | <ClCompile Include="hle\syscall.cpp"> |
| 88 | <Filter>hle</Filter> | 88 | <Filter>hle</Filter> |
| 89 | </ClCompile> | 89 | </ClCompile> |
| 90 | <ClCompile Include="hle\service\service.cpp"> | ||
| 91 | <Filter>hle\service</Filter> | ||
| 92 | </ClCompile> | ||
| 90 | </ItemGroup> | 93 | </ItemGroup> |
| 91 | <ItemGroup> | 94 | <ItemGroup> |
| 92 | <ClInclude Include="arm\disassembler\arm_disasm.h"> | 95 | <ClInclude Include="arm\disassembler\arm_disasm.h"> |
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 @@ | |||
| 4 | 4 | ||
| 5 | #include <vector> | 5 | #include <vector> |
| 6 | 6 | ||
| 7 | #include "core/mem_map.h" | ||
| 7 | #include "core/hle/hle.h" | 8 | #include "core/hle/hle.h" |
| 8 | #include "core/hle/syscall.h" | 9 | #include "core/hle/syscall.h" |
| 10 | #include "core/hle/service/service.h" | ||
| 9 | 11 | ||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | 13 | ||
| @@ -35,6 +37,14 @@ void CallSyscall(u32 opcode) { | |||
| 35 | } | 37 | } |
| 36 | } | 38 | } |
| 37 | 39 | ||
| 40 | /// Returns the coprocessor (in this case, syscore) command buffer pointer | ||
| 41 | Addr CallGetThreadCommandBuffer() { | ||
| 42 | // Called on insruction: mrc p15, 0, r0, c13, c0, 3 | ||
| 43 | // Returns an address in OSHLE memory for the CPU to read/write to | ||
| 44 | RETURN(OS_THREAD_COMMAND_BUFFER_ADDR); | ||
| 45 | return OS_THREAD_COMMAND_BUFFER_ADDR; | ||
| 46 | } | ||
| 47 | |||
| 38 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { | 48 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { |
| 39 | ModuleDef module = {name, num_functions, func_table}; | 49 | ModuleDef module = {name, num_functions, func_table}; |
| 40 | g_module_db.push_back(module); | 50 | g_module_db.push_back(module); |
| @@ -45,7 +55,10 @@ void RegisterAllModules() { | |||
| 45 | } | 55 | } |
| 46 | 56 | ||
| 47 | void Init() { | 57 | void Init() { |
| 58 | Service::Init(); | ||
| 59 | |||
| 48 | RegisterAllModules(); | 60 | RegisterAllModules(); |
| 61 | |||
| 49 | NOTICE_LOG(HLE, "initialized OK"); | 62 | NOTICE_LOG(HLE, "initialized OK"); |
| 50 | } | 63 | } |
| 51 | 64 | ||
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index 9466be540..2bd1f99a2 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h | |||
| @@ -16,6 +16,11 @@ | |||
| 16 | 16 | ||
| 17 | namespace HLE { | 17 | namespace HLE { |
| 18 | 18 | ||
| 19 | enum { | ||
| 20 | OS_THREAD_COMMAND_BUFFER_ADDR = 0xA0004000, | ||
| 21 | }; | ||
| 22 | |||
| 23 | typedef u32 Addr; | ||
| 19 | typedef void (*Func)(); | 24 | typedef void (*Func)(); |
| 20 | 25 | ||
| 21 | struct FunctionDef { | 26 | struct FunctionDef { |
| @@ -34,6 +39,8 @@ void RegisterModule(std::string name, int num_functions, const FunctionDef *func | |||
| 34 | 39 | ||
| 35 | void CallSyscall(u32 opcode); | 40 | void CallSyscall(u32 opcode); |
| 36 | 41 | ||
| 42 | Addr CallGetThreadCommandBuffer(); | ||
| 43 | |||
| 37 | void Init(); | 44 | void Init(); |
| 38 | 45 | ||
| 39 | void Shutdown(); | 46 | void Shutdown(); |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp new file mode 100644 index 000000000..4bc96cc18 --- /dev/null +++ b/src/core/hle/service/service.cpp | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common.h" | ||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hle/service/service.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace Service | ||
| 12 | |||
| 13 | namespace Service { | ||
| 14 | |||
| 15 | Manager* g_manager = NULL; ///< Service manager | ||
| 16 | |||
| 17 | Manager::Manager() { | ||
| 18 | } | ||
| 19 | |||
| 20 | Manager::~Manager() { | ||
| 21 | for(Interface* service : m_services) { | ||
| 22 | DeleteService(service->GetPortName()); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | /// Add a service to the manager (does not create it though) | ||
| 27 | void Manager::AddService(Interface* service) { | ||
| 28 | int index = m_services.size(); | ||
| 29 | u32 new_uid = GetUIDFromIndex(index); | ||
| 30 | |||
| 31 | m_services.push_back(service); | ||
| 32 | |||
| 33 | m_port_map[service->GetPortName()] = new_uid; | ||
| 34 | service->m_uid = new_uid; | ||
| 35 | } | ||
| 36 | |||
| 37 | /// Removes a service from the manager, also frees memory | ||
| 38 | void Manager::DeleteService(std::string port_name) { | ||
| 39 | auto service = FetchFromPortName(port_name); | ||
| 40 | |||
| 41 | m_services.erase(m_services.begin() + GetIndexFromUID(service->m_uid)); | ||
| 42 | m_port_map.erase(port_name); | ||
| 43 | |||
| 44 | delete service; | ||
| 45 | } | ||
| 46 | |||
| 47 | /// Get a Service Interface from its UID | ||
| 48 | Interface* Manager::FetchFromUID(u32 uid) { | ||
| 49 | int index = GetIndexFromUID(uid); | ||
| 50 | if (index < (int)m_services.size()) { | ||
| 51 | return m_services[index]; | ||
| 52 | } | ||
| 53 | return NULL; | ||
| 54 | } | ||
| 55 | |||
| 56 | /// Get a Service Interface from its port | ||
| 57 | Interface* Manager::FetchFromPortName(std::string port_name) { | ||
| 58 | auto itr = m_port_map.find(port_name); | ||
| 59 | if (itr == m_port_map.end()) { | ||
| 60 | return NULL; | ||
| 61 | } | ||
| 62 | return FetchFromUID(itr->second); | ||
| 63 | } | ||
| 64 | |||
| 65 | class Interface_SRV : public Interface { | ||
| 66 | public: | ||
| 67 | |||
| 68 | Interface_SRV() { | ||
| 69 | } | ||
| 70 | |||
| 71 | ~Interface_SRV() { | ||
| 72 | } | ||
| 73 | |||
| 74 | /** | ||
| 75 | * Gets the string name used by CTROS for a service | ||
| 76 | * @return String name of service | ||
| 77 | */ | ||
| 78 | std::string GetName() { | ||
| 79 | return "ServiceManager"; | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * Gets the string name used by CTROS for a service | ||
| 84 | * @return Port name of service | ||
| 85 | */ | ||
| 86 | std::string GetPortName() { | ||
| 87 | return "srv:"; | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 92 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 93 | */ | ||
| 94 | Syscall::Result Sync() { | ||
| 95 | ERROR_LOG(HLE, "Unimplemented function ServiceManager::Sync"); | ||
| 96 | return -1; | ||
| 97 | } | ||
| 98 | |||
| 99 | }; | ||
| 100 | |||
| 101 | /// Initialize ServiceManager | ||
| 102 | void Init() { | ||
| 103 | g_manager = new Manager; | ||
| 104 | g_manager->AddService(new Interface_SRV); | ||
| 105 | NOTICE_LOG(HLE, "ServiceManager initialized OK"); | ||
| 106 | } | ||
| 107 | |||
| 108 | /// Shutdown ServiceManager | ||
| 109 | void Shutdown() { | ||
| 110 | delete g_manager; | ||
| 111 | NOTICE_LOG(HLE, "ServiceManager shutdown OK"); | ||
| 112 | } | ||
| 113 | |||
| 114 | |||
| 115 | } | ||
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index f15099982..3fd855dee 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <vector> | ||
| 8 | #include <map> | ||
| 7 | #include <string> | 9 | #include <string> |
| 8 | 10 | ||
| 9 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| @@ -14,10 +16,13 @@ | |||
| 14 | 16 | ||
| 15 | namespace Service { | 17 | namespace Service { |
| 16 | 18 | ||
| 17 | typedef s32 NativeUID; | 19 | typedef s32 NativeUID; ///< Native handle for a service |
| 20 | |||
| 21 | class Manager; | ||
| 18 | 22 | ||
| 19 | /// Interface to a CTROS service | 23 | /// Interface to a CTROS service |
| 20 | class Interface { | 24 | class Interface { |
| 25 | friend class Manager; | ||
| 21 | public: | 26 | public: |
| 22 | 27 | ||
| 23 | virtual ~Interface() { | 28 | virtual ~Interface() { |
| @@ -43,7 +48,7 @@ public: | |||
| 43 | * Gets the string name used by CTROS for a service | 48 | * Gets the string name used by CTROS for a service |
| 44 | * @return Port name of service | 49 | * @return Port name of service |
| 45 | */ | 50 | */ |
| 46 | virtual std::string GetPort() { | 51 | virtual std::string GetPortName() { |
| 47 | return "[UNKNOWN SERVICE PORT]"; | 52 | return "[UNKNOWN SERVICE PORT]"; |
| 48 | } | 53 | } |
| 49 | 54 | ||
| @@ -57,4 +62,52 @@ private: | |||
| 57 | u32 m_uid; | 62 | u32 m_uid; |
| 58 | }; | 63 | }; |
| 59 | 64 | ||
| 65 | /// Simple class to manage accessing services from ports and UID handles | ||
| 66 | class Manager { | ||
| 67 | |||
| 68 | public: | ||
| 69 | Manager(); | ||
| 70 | |||
| 71 | ~Manager(); | ||
| 72 | |||
| 73 | /// Add a service to the manager (does not create it though) | ||
| 74 | void AddService(Interface* service); | ||
| 75 | |||
| 76 | /// Removes a service from the manager (does not delete it though) | ||
| 77 | void DeleteService(std::string port_name); | ||
| 78 | |||
| 79 | /// Get a Service Interface from its UID | ||
| 80 | Interface* FetchFromUID(u32 uid); | ||
| 81 | |||
| 82 | /// Get a Service Interface from its port | ||
| 83 | Interface* FetchFromPortName(std::string port_name); | ||
| 84 | |||
| 85 | private: | ||
| 86 | |||
| 87 | /// Convert an index into m_services vector into a UID | ||
| 88 | static u32 GetUIDFromIndex(const int index) { | ||
| 89 | return index | 0x10000000; | ||
| 90 | } | ||
| 91 | |||
| 92 | /// Convert a UID into an index into m_services | ||
| 93 | static int GetIndexFromUID(const u32 uid) { | ||
| 94 | return uid & 0x0FFFFFFF; | ||
| 95 | } | ||
| 96 | |||
| 97 | std::vector<Interface*> m_services; | ||
| 98 | std::map<std::string, u32> m_port_map; | ||
| 99 | |||
| 100 | DISALLOW_COPY_AND_ASSIGN(Manager); | ||
| 101 | }; | ||
| 102 | |||
| 103 | /// Initialize ServiceManager | ||
| 104 | void Init(); | ||
| 105 | |||
| 106 | /// Shutdown ServiceManager | ||
| 107 | void Shutdown(); | ||
| 108 | |||
| 109 | |||
| 110 | extern Manager* g_manager; ///< Service manager | ||
| 111 | |||
| 112 | |||
| 60 | } // namespace | 113 | } // namespace |
diff --git a/src/core/hle/syscall.cpp b/src/core/hle/syscall.cpp index 98155dc8e..8225f168b 100644 --- a/src/core/hle/syscall.cpp +++ b/src/core/hle/syscall.cpp | |||
| @@ -6,144 +6,154 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/function_wrappers.h" | 7 | #include "core/hle/function_wrappers.h" |
| 8 | #include "core/hle/syscall.h" | 8 | #include "core/hle/syscall.h" |
| 9 | #include "core/hle/service/service.h" | ||
| 9 | 10 | ||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | // Namespace Syscall | 12 | // Namespace Syscall |
| 12 | 13 | ||
| 13 | namespace Syscall { | 14 | namespace Syscall { |
| 14 | 15 | ||
| 15 | Result SVC_ConnectToPort(void* out, const char* port_name) { | 16 | /// Connect to an OS service given the port name, returns the handle to the port to out |
| 16 | NOTICE_LOG(OSHLE, "svcConnectToPort called, port_name: %s", port_name); | 17 | Result ConnectToPort(void* out, const char* port_name) { |
| 18 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | ||
| 19 | Core::g_app_core->SetReg(1, service->GetUID()); | ||
| 20 | return 0; | ||
| 21 | } | ||
| 22 | |||
| 23 | /// Synchronize to an OS service | ||
| 24 | Result SendSyncRequest(Handle session) { | ||
| 25 | Service::Interface* service = Service::g_manager->FetchFromUID(session); | ||
| 26 | service->Sync(); | ||
| 17 | return 0; | 27 | return 0; |
| 18 | } | 28 | } |
| 19 | 29 | ||
| 20 | const HLE::FunctionDef Syscall_Table[] = { | 30 | const HLE::FunctionDef Syscall_Table[] = { |
| 21 | {0x00, NULL, "Unknown"}, | 31 | {0x00, NULL, "Unknown"}, |
| 22 | {0x01, NULL, "svcControlMemory"}, | 32 | {0x01, NULL, "ControlMemory"}, |
| 23 | {0x02, NULL, "svcQueryMemory"}, | 33 | {0x02, NULL, "QueryMemory"}, |
| 24 | {0x03, NULL, "svcExitProcess"}, | 34 | {0x03, NULL, "ExitProcess"}, |
| 25 | {0x04, NULL, "svcGetProcessAffinityMask"}, | 35 | {0x04, NULL, "GetProcessAffinityMask"}, |
| 26 | {0x05, NULL, "svcSetProcessAffinityMask"}, | 36 | {0x05, NULL, "SetProcessAffinityMask"}, |
| 27 | {0x06, NULL, "svcGetProcessIdealProcessor"}, | 37 | {0x06, NULL, "GetProcessIdealProcessor"}, |
| 28 | {0x07, NULL, "svcSetProcessIdealProcessor"}, | 38 | {0x07, NULL, "SetProcessIdealProcessor"}, |
| 29 | {0x08, NULL, "svcCreateThread"}, | 39 | {0x08, NULL, "CreateThread"}, |
| 30 | {0x09, NULL, "svcExitThread"}, | 40 | {0x09, NULL, "ExitThread"}, |
| 31 | {0x0A, NULL, "svcSleepThread"}, | 41 | {0x0A, NULL, "SleepThread"}, |
| 32 | {0x0B, NULL, "svcGetThreadPriority"}, | 42 | {0x0B, NULL, "GetThreadPriority"}, |
| 33 | {0x0C, NULL, "svcSetThreadPriority"}, | 43 | {0x0C, NULL, "SetThreadPriority"}, |
| 34 | {0x0D, NULL, "svcGetThreadAffinityMask"}, | 44 | {0x0D, NULL, "GetThreadAffinityMask"}, |
| 35 | {0x0E, NULL, "svcSetThreadAffinityMask"}, | 45 | {0x0E, NULL, "SetThreadAffinityMask"}, |
| 36 | {0x0F, NULL, "svcGetThreadIdealProcessor"}, | 46 | {0x0F, NULL, "GetThreadIdealProcessor"}, |
| 37 | {0x10, NULL, "svcSetThreadIdealProcessor"}, | 47 | {0x10, NULL, "SetThreadIdealProcessor"}, |
| 38 | {0x11, NULL, "svcGetCurrentProcessorNumber"}, | 48 | {0x11, NULL, "GetCurrentProcessorNumber"}, |
| 39 | {0x12, NULL, "svcRun"}, | 49 | {0x12, NULL, "Run"}, |
| 40 | {0x13, NULL, "svcCreateMutex"}, | 50 | {0x13, NULL, "CreateMutex"}, |
| 41 | {0x14, NULL, "svcReleaseMutex"}, | 51 | {0x14, NULL, "ReleaseMutex"}, |
| 42 | {0x15, NULL, "svcCreateSemaphore"}, | 52 | {0x15, NULL, "CreateSemaphore"}, |
| 43 | {0x16, NULL, "svcReleaseSemaphore"}, | 53 | {0x16, NULL, "ReleaseSemaphore"}, |
| 44 | {0x17, NULL, "svcCreateEvent"}, | 54 | {0x17, NULL, "CreateEvent"}, |
| 45 | {0x18, NULL, "svcSignalEvent"}, | 55 | {0x18, NULL, "SignalEvent"}, |
| 46 | {0x19, NULL, "svcClearEvent"}, | 56 | {0x19, NULL, "ClearEvent"}, |
| 47 | {0x1A, NULL, "svcCreateTimer"}, | 57 | {0x1A, NULL, "CreateTimer"}, |
| 48 | {0x1B, NULL, "svcSetTimer"}, | 58 | {0x1B, NULL, "SetTimer"}, |
| 49 | {0x1C, NULL, "svcCancelTimer"}, | 59 | {0x1C, NULL, "CancelTimer"}, |
| 50 | {0x1D, NULL, "svcClearTimer"}, | 60 | {0x1D, NULL, "ClearTimer"}, |
| 51 | {0x1E, NULL, "svcCreateMemoryBlock"}, | 61 | {0x1E, NULL, "CreateMemoryBlock"}, |
| 52 | {0x1F, NULL, "svcMapMemoryBlock"}, | 62 | {0x1F, NULL, "MapMemoryBlock"}, |
| 53 | {0x20, NULL, "svcUnmapMemoryBlock"}, | 63 | {0x20, NULL, "UnmapMemoryBlock"}, |
| 54 | {0x21, NULL, "svcCreateAddressArbiter"}, | 64 | {0x21, NULL, "CreateAddressArbiter"}, |
| 55 | {0x22, NULL, "svcArbitrateAddress"}, | 65 | {0x22, NULL, "ArbitrateAddress"}, |
| 56 | {0x23, NULL, "svcCloseHandle"}, | 66 | {0x23, NULL, "CloseHandle"}, |
| 57 | {0x24, NULL, "svcWaitSynchronization1"}, | 67 | {0x24, NULL, "WaitSynchronization1"}, |
| 58 | {0x25, NULL, "svcWaitSynchronizationN"}, | 68 | {0x25, NULL, "WaitSynchronizationN"}, |
| 59 | {0x26, NULL, "svcSignalAndWait"}, | 69 | {0x26, NULL, "SignalAndWait"}, |
| 60 | {0x27, NULL, "svcDuplicateHandle"}, | 70 | {0x27, NULL, "DuplicateHandle"}, |
| 61 | {0x28, NULL, "svcGetSystemTick"}, | 71 | {0x28, NULL, "GetSystemTick"}, |
| 62 | {0x29, NULL, "svcGetHandleInfo"}, | 72 | {0x29, NULL, "GetHandleInfo"}, |
| 63 | {0x2A, NULL, "svcGetSystemInfo"}, | 73 | {0x2A, NULL, "GetSystemInfo"}, |
| 64 | {0x2B, NULL, "svcGetProcessInfo"}, | 74 | {0x2B, NULL, "GetProcessInfo"}, |
| 65 | {0x2C, NULL, "svcGetThreadInfo"}, | 75 | {0x2C, NULL, "GetThreadInfo"}, |
| 66 | {0x2D, WrapI_VC<SVC_ConnectToPort>, "svcConnectToPort"}, | 76 | {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"}, |
| 67 | {0x2E, NULL, "svcSendSyncRequest1"}, | 77 | {0x2E, NULL, "SendSyncRequest1"}, |
| 68 | {0x2F, NULL, "svcSendSyncRequest2"}, | 78 | {0x2F, NULL, "SendSyncRequest2"}, |
| 69 | {0x30, NULL, "svcSendSyncRequest3"}, | 79 | {0x30, NULL, "SendSyncRequest3"}, |
| 70 | {0x31, NULL, "svcSendSyncRequest4"}, | 80 | {0x31, NULL, "SendSyncRequest4"}, |
| 71 | {0x32, NULL, "svcSendSyncRequest"}, | 81 | {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"}, |
| 72 | {0x33, NULL, "svcOpenProcess"}, | 82 | {0x33, NULL, "OpenProcess"}, |
| 73 | {0x34, NULL, "svcOpenThread"}, | 83 | {0x34, NULL, "OpenThread"}, |
| 74 | {0x35, NULL, "svcGetProcessId"}, | 84 | {0x35, NULL, "GetProcessId"}, |
| 75 | {0x36, NULL, "svcGetProcessIdOfThread"}, | 85 | {0x36, NULL, "GetProcessIdOfThread"}, |
| 76 | {0x37, NULL, "svcGetThreadId"}, | 86 | {0x37, NULL, "GetThreadId"}, |
| 77 | {0x38, NULL, "svcGetResourceLimit"}, | 87 | {0x38, NULL, "GetResourceLimit"}, |
| 78 | {0x39, NULL, "svcGetResourceLimitLimitValues"}, | 88 | {0x39, NULL, "GetResourceLimitLimitValues"}, |
| 79 | {0x3A, NULL, "svcGetResourceLimitCurrentValues"}, | 89 | {0x3A, NULL, "GetResourceLimitCurrentValues"}, |
| 80 | {0x3B, NULL, "svcGetThreadContext"}, | 90 | {0x3B, NULL, "GetThreadContext"}, |
| 81 | {0x3C, NULL, "svcBreak"}, | 91 | {0x3C, NULL, "Break"}, |
| 82 | {0x3D, NULL, "svcOutputDebugString"}, | 92 | {0x3D, NULL, "OutputDebugString"}, |
| 83 | {0x3E, NULL, "svcControlPerformanceCounter"}, | 93 | {0x3E, NULL, "ControlPerformanceCounter"}, |
| 84 | {0x3F, NULL, "Unknown"}, | 94 | {0x3F, NULL, "Unknown"}, |
| 85 | {0x40, NULL, "Unknown"}, | 95 | {0x40, NULL, "Unknown"}, |
| 86 | {0x41, NULL, "Unknown"}, | 96 | {0x41, NULL, "Unknown"}, |
| 87 | {0x42, NULL, "Unknown"}, | 97 | {0x42, NULL, "Unknown"}, |
| 88 | {0x43, NULL, "Unknown"}, | 98 | {0x43, NULL, "Unknown"}, |
| 89 | {0x44, NULL, "Unknown"}, | 99 | {0x44, NULL, "Unknown"}, |
| 90 | {0x45, NULL, "Unknown"}, | 100 | {0x45, NULL, "Unknown"}, |
| 91 | {0x46, NULL, "Unknown"}, | 101 | {0x46, NULL, "Unknown"}, |
| 92 | {0x47, NULL, "svcCreatePort"}, | 102 | {0x47, NULL, "CreatePort"}, |
| 93 | {0x48, NULL, "svcCreateSessionToPort"}, | 103 | {0x48, NULL, "CreateSessionToPort"}, |
| 94 | {0x49, NULL, "svcCreateSession"}, | 104 | {0x49, NULL, "CreateSession"}, |
| 95 | {0x4A, NULL, "svcAcceptSession"}, | 105 | {0x4A, NULL, "AcceptSession"}, |
| 96 | {0x4B, NULL, "svcReplyAndReceive1"}, | 106 | {0x4B, NULL, "ReplyAndReceive1"}, |
| 97 | {0x4C, NULL, "svcReplyAndReceive2"}, | 107 | {0x4C, NULL, "ReplyAndReceive2"}, |
| 98 | {0x4D, NULL, "svcReplyAndReceive3"}, | 108 | {0x4D, NULL, "ReplyAndReceive3"}, |
| 99 | {0x4E, NULL, "svcReplyAndReceive4"}, | 109 | {0x4E, NULL, "ReplyAndReceive4"}, |
| 100 | {0x4F, NULL, "svcReplyAndReceive"}, | 110 | {0x4F, NULL, "ReplyAndReceive"}, |
| 101 | {0x50, NULL, "svcBindInterrupt"}, | 111 | {0x50, NULL, "BindInterrupt"}, |
| 102 | {0x51, NULL, "svcUnbindInterrupt"}, | 112 | {0x51, NULL, "UnbindInterrupt"}, |
| 103 | {0x52, NULL, "svcInvalidateProcessDataCache"}, | 113 | {0x52, NULL, "InvalidateProcessDataCache"}, |
| 104 | {0x53, NULL, "svcStoreProcessDataCache"}, | 114 | {0x53, NULL, "StoreProcessDataCache"}, |
| 105 | {0x54, NULL, "svcFlushProcessDataCache"}, | 115 | {0x54, NULL, "FlushProcessDataCache"}, |
| 106 | {0x55, NULL, "svcStartInterProcessDma"}, | 116 | {0x55, NULL, "StartInterProcessDma"}, |
| 107 | {0x56, NULL, "svcStopDma"}, | 117 | {0x56, NULL, "StopDma"}, |
| 108 | {0x57, NULL, "svcGetDmaState"}, | 118 | {0x57, NULL, "GetDmaState"}, |
| 109 | {0x58, NULL, "svcRestartDma"}, | 119 | {0x58, NULL, "RestartDma"}, |
| 110 | {0x59, NULL, "Unknown"}, | 120 | {0x59, NULL, "Unknown"}, |
| 111 | {0x5A, NULL, "Unknown"}, | 121 | {0x5A, NULL, "Unknown"}, |
| 112 | {0x5B, NULL, "Unknown"}, | 122 | {0x5B, NULL, "Unknown"}, |
| 113 | {0x5C, NULL, "Unknown"}, | 123 | {0x5C, NULL, "Unknown"}, |
| 114 | {0x5D, NULL, "Unknown"}, | 124 | {0x5D, NULL, "Unknown"}, |
| 115 | {0x5E, NULL, "Unknown"}, | 125 | {0x5E, NULL, "Unknown"}, |
| 116 | {0x5F, NULL, "Unknown"}, | 126 | {0x5F, NULL, "Unknown"}, |
| 117 | {0x60, NULL, "svcDebugActiveProcess"}, | 127 | {0x60, NULL, "DebugActiveProcess"}, |
| 118 | {0x61, NULL, "svcBreakDebugProcess"}, | 128 | {0x61, NULL, "BreakDebugProcess"}, |
| 119 | {0x62, NULL, "svcTerminateDebugProcess"}, | 129 | {0x62, NULL, "TerminateDebugProcess"}, |
| 120 | {0x63, NULL, "svcGetProcessDebugEvent"}, | 130 | {0x63, NULL, "GetProcessDebugEvent"}, |
| 121 | {0x64, NULL, "svcContinueDebugEvent"}, | 131 | {0x64, NULL, "ContinueDebugEvent"}, |
| 122 | {0x65, NULL, "svcGetProcessList"}, | 132 | {0x65, NULL, "GetProcessList"}, |
| 123 | {0x66, NULL, "svcGetThreadList"}, | 133 | {0x66, NULL, "GetThreadList"}, |
| 124 | {0x67, NULL, "svcGetDebugThreadContext"}, | 134 | {0x67, NULL, "GetDebugThreadContext"}, |
| 125 | {0x68, NULL, "svcSetDebugThreadContext"}, | 135 | {0x68, NULL, "SetDebugThreadContext"}, |
| 126 | {0x69, NULL, "svcQueryDebugProcessMemory"}, | 136 | {0x69, NULL, "QueryDebugProcessMemory"}, |
| 127 | {0x6A, NULL, "svcReadProcessMemory"}, | 137 | {0x6A, NULL, "ReadProcessMemory"}, |
| 128 | {0x6B, NULL, "svcWriteProcessMemory"}, | 138 | {0x6B, NULL, "WriteProcessMemory"}, |
| 129 | {0x6C, NULL, "svcSetHardwareBreakPoint"}, | 139 | {0x6C, NULL, "SetHardwareBreakPoint"}, |
| 130 | {0x6D, NULL, "svcGetDebugThreadParam"}, | 140 | {0x6D, NULL, "GetDebugThreadParam"}, |
| 131 | {0x6E, NULL, "Unknown"}, | 141 | {0x6E, NULL, "Unknown"}, |
| 132 | {0x6F, NULL, "Unknown"}, | 142 | {0x6F, NULL, "Unknown"}, |
| 133 | {0x70, NULL, "svcControlProcessMemory"}, | 143 | {0x70, NULL, "ControlProcessMemory"}, |
| 134 | {0x71, NULL, "svcMapProcessMemory"}, | 144 | {0x71, NULL, "MapProcessMemory"}, |
| 135 | {0x72, NULL, "svcUnmapProcessMemory"}, | 145 | {0x72, NULL, "UnmapProcessMemory"}, |
| 136 | {0x73, NULL, "Unknown"}, | 146 | {0x73, NULL, "Unknown"}, |
| 137 | {0x74, NULL, "Unknown"}, | 147 | {0x74, NULL, "Unknown"}, |
| 138 | {0x75, NULL, "Unknown"}, | 148 | {0x75, NULL, "Unknown"}, |
| 139 | {0x76, NULL, "svcTerminateProcess"}, | 149 | {0x76, NULL, "TerminateProcess"}, |
| 140 | {0x77, NULL, "Unknown"}, | 150 | {0x77, NULL, "Unknown"}, |
| 141 | {0x78, NULL, "svcCreateResourceLimit"}, | 151 | {0x78, NULL, "CreateResourceLimit"}, |
| 142 | {0x79, NULL, "Unknown"}, | 152 | {0x79, NULL, "Unknown"}, |
| 143 | {0x7A, NULL, "Unknown"}, | 153 | {0x7A, NULL, "Unknown"}, |
| 144 | {0x7B, NULL, "Unknown"}, | 154 | {0x7B, NULL, "Unknown"}, |
| 145 | {0x7C, NULL, "svcKernelSetState"}, | 155 | {0x7C, NULL, "KernelSetState"}, |
| 146 | {0x7D, NULL, "svcQueryProcessMemory"}, | 156 | {0x7D, NULL, "QueryProcessMemory"}, |
| 147 | }; | 157 | }; |
| 148 | 158 | ||
| 149 | void Register() { | 159 | void Register() { |
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index a5865d785..5b5c57fca 100644 --- a/src/core/mem_map.cpp +++ b/src/core/mem_map.cpp | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | 1 | // Copyright 2014 Citra Emulator Project |
| 2 | // Licensed under GPLv2 | 2 | // Licensed under GPLv2 |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| @@ -12,7 +12,6 @@ | |||
| 12 | 12 | ||
| 13 | namespace Memory { | 13 | namespace Memory { |
| 14 | 14 | ||
| 15 | |||
| 16 | u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena. | 15 | u8* g_base = NULL; ///< The base pointer to the auto-mirrored arena. |
| 17 | 16 | ||
| 18 | MemArena g_arena; ///< The MemArena class | 17 | MemArena g_arena; ///< The MemArena class |
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index 29f2dce86..2596ba925 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -33,8 +33,9 @@ enum { | |||
| 33 | MEM_VRAM_VADDR = 0x1F000000, | 33 | MEM_VRAM_VADDR = 0x1F000000, |
| 34 | MEM_SCRATCHPAD_VADDR = (0x10000000 - MEM_SCRATCHPAD_SIZE), ///< Scratchpad virtual address | 34 | MEM_SCRATCHPAD_VADDR = (0x10000000 - MEM_SCRATCHPAD_SIZE), ///< Scratchpad virtual address |
| 35 | 35 | ||
| 36 | MEM_OSHLE_VADDR = 0xC0000000, ///< Memory for use by OSHLE accessible by appcore CPU | ||
| 37 | MEM_OSHLE_SIZE = 0x08000000, ///< ...Same size as FCRAM for now | 36 | MEM_OSHLE_SIZE = 0x08000000, ///< ...Same size as FCRAM for now |
| 37 | MEM_OSHLE_VADDR = 0xA0000000, ///< Memory for use by OSHLE accessible by appcore CPU | ||
| 38 | MEM_OSHLE_VADDR_END = (MEM_OSHLE_VADDR + MEM_OSHLE_SIZE), | ||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 41 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 00719445f..f35e25caf 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/mem_map.h" | 7 | #include "core/mem_map.h" |
| 8 | #include "core/hw/hw.h" | 8 | #include "core/hw/hw.h" |
| 9 | #include "hle/hle.h" | ||
| 9 | 10 | ||
| 10 | namespace Memory { | 11 | namespace Memory { |
| 11 | 12 | ||
| @@ -15,9 +16,16 @@ inline void _Read(T &var, const u32 addr) { | |||
| 15 | // TODO: Make sure this represents the mirrors in a correct way. | 16 | // TODO: Make sure this represents the mirrors in a correct way. |
| 16 | // Could just do a base-relative read, too.... TODO | 17 | // Could just do a base-relative read, too.... TODO |
| 17 | 18 | ||
| 19 | |||
| 20 | // Memory allocated for HLE use that can be addressed from the emulated application | ||
| 21 | // The primary use of this is sharing a commandbuffer between the HLE OS (syscore) and the LLE | ||
| 22 | // core running the user application (appcore) | ||
| 23 | if (addr >= MEM_OSHLE_VADDR && addr < MEM_OSHLE_VADDR_END) { | ||
| 24 | NOTICE_LOG(MEMMAP, "OSHLE read @ 0x%08X", addr); | ||
| 25 | |||
| 18 | // Hardware I/O register reads | 26 | // Hardware I/O register reads |
| 19 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space | 27 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space |
| 20 | if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { | 28 | } else if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { |
| 21 | HW::Read<T>(var, addr); | 29 | HW::Read<T>(var, addr); |
| 22 | 30 | ||
| 23 | // FCRAM virtual address reads | 31 | // FCRAM virtual address reads |
| @@ -47,9 +55,15 @@ inline void _Read(T &var, const u32 addr) { | |||
| 47 | template <typename T> | 55 | template <typename T> |
| 48 | inline void _Write(u32 addr, const T data) { | 56 | inline void _Write(u32 addr, const T data) { |
| 49 | 57 | ||
| 58 | // Memory allocated for HLE use that can be addressed from the emulated application | ||
| 59 | // The primary use of this is sharing a commandbuffer between the HLE OS (syscore) and the LLE | ||
| 60 | // core running the user application (appcore) | ||
| 61 | if (addr >= MEM_OSHLE_VADDR && addr < MEM_OSHLE_VADDR_END) { | ||
| 62 | NOTICE_LOG(MEMMAP, "OSHLE write @ 0x%08X", addr); | ||
| 63 | |||
| 50 | // Hardware I/O register writes | 64 | // Hardware I/O register writes |
| 51 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space | 65 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space |
| 52 | if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { | 66 | } else if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { |
| 53 | HW::Write<const T>(addr, data); | 67 | HW::Write<const T>(addr, data); |
| 54 | 68 | ||
| 55 | // ExeFS:/.code is loaded here: | 69 | // ExeFS:/.code is loaded here: |