diff options
Diffstat (limited to '')
40 files changed, 2373 insertions, 221 deletions
diff --git a/src/common/log.h b/src/common/log.h index 432a307f0..02db8bd55 100644 --- a/src/common/log.h +++ b/src/common/log.h | |||
| @@ -55,8 +55,8 @@ enum LOG_TYPE { | |||
| 55 | WII_IPC_HID, | 55 | WII_IPC_HID, |
| 56 | WII_IPC_HLE, | 56 | WII_IPC_HLE, |
| 57 | WII_IPC_NET, | 57 | WII_IPC_NET, |
| 58 | WII_IPC_WC24, | 58 | NDMA, |
| 59 | WII_IPC_SSL, | 59 | HLE, |
| 60 | RENDER, | 60 | RENDER, |
| 61 | LCD, | 61 | LCD, |
| 62 | HW, | 62 | HW, |
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp index 245760d0d..8e56deb8f 100644 --- a/src/common/log_manager.cpp +++ b/src/common/log_manager.cpp | |||
| @@ -67,9 +67,9 @@ LogManager::LogManager() | |||
| 67 | m_Log[LogTypes::RENDER] = new LogContainer("RENDER", "RENDER"); | 67 | m_Log[LogTypes::RENDER] = new LogContainer("RENDER", "RENDER"); |
| 68 | m_Log[LogTypes::LCD] = new LogContainer("LCD", "LCD"); | 68 | m_Log[LogTypes::LCD] = new LogContainer("LCD", "LCD"); |
| 69 | m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET"); | 69 | m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET"); |
| 70 | m_Log[LogTypes::WII_IPC_WC24] = new LogContainer("WII_IPC_WC24", "WII IPC WC24"); | 70 | m_Log[LogTypes::NDMA] = new LogContainer("NDMA", "NDMA"); |
| 71 | m_Log[LogTypes::WII_IPC_SSL] = new LogContainer("WII_IPC_SSL", "WII IPC SSL"); | 71 | m_Log[LogTypes::HLE] = new LogContainer("HLE", "High Level Emulation"); |
| 72 | m_Log[LogTypes::HW] = new LogContainer("HARDWARE", "HARDWARE"); | 72 | m_Log[LogTypes::HW] = new LogContainer("HW", "Hardware"); |
| 73 | m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); | 73 | m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay"); |
| 74 | m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); | 74 | m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); |
| 75 | m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); | 75 | m_Log[LogTypes::NETPLAY] = new LogContainer("NETPLAY", "Netplay"); |
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index a99644f11..e5a9ba322 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -17,6 +17,22 @@ | |||
| 17 | #include <errno.h> | 17 | #include <errno.h> |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | /// Make a string lowercase | ||
| 21 | void LowerStr(char* str) { | ||
| 22 | for (int i = 0; str[i]; i++) { | ||
| 23 | str[i] = tolower(str[ i ]); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | /// Make a string uppercase | ||
| 28 | void UpperStr(char* str) { | ||
| 29 | for (int i=0; i < strlen(str); i++) { | ||
| 30 | if(str[i] >= 'a' && str[i] <= 'z') { | ||
| 31 | str[i] &= 0xDF; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 20 | // faster than sscanf | 36 | // faster than sscanf |
| 21 | bool AsciiToHex(const char* _szValue, u32& result) | 37 | bool AsciiToHex(const char* _szValue, u32& result) |
| 22 | { | 38 | { |
diff --git a/src/common/string_util.h b/src/common/string_util.h index 6b7e84797..b3c99a807 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -14,6 +14,12 @@ | |||
| 14 | 14 | ||
| 15 | #include "common/common.h" | 15 | #include "common/common.h" |
| 16 | 16 | ||
| 17 | /// Make a string lowercase | ||
| 18 | void LowerStr(char* str); | ||
| 19 | |||
| 20 | /// Make a string uppercase | ||
| 21 | void UpperStr(char* str); | ||
| 22 | |||
| 17 | std::string StringFromFormat(const char* format, ...); | 23 | std::string StringFromFormat(const char* format, ...); |
| 18 | // Cheap! | 24 | // Cheap! |
| 19 | bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); | 25 | bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args); |
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index dafde8368..eee4726db 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h | |||
| @@ -43,6 +43,13 @@ public: | |||
| 43 | virtual u32 GetReg(int index) const = 0; | 43 | virtual u32 GetReg(int index) const = 0; |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * Set an ARM register | ||
| 47 | * @param index Register index (0-15) | ||
| 48 | * @param value Value to set register to | ||
| 49 | */ | ||
| 50 | virtual void SetReg(int index, u32 value) = 0; | ||
| 51 | |||
| 52 | /** | ||
| 46 | * Get the current CPSR register | 53 | * Get the current CPSR register |
| 47 | * @return Returns the value of the CPSR register | 54 | * @return Returns the value of the CPSR register |
| 48 | */ | 55 | */ |
| @@ -59,11 +66,13 @@ public: | |||
| 59 | return m_num_instructions; | 66 | return m_num_instructions; |
| 60 | } | 67 | } |
| 61 | 68 | ||
| 62 | private: | 69 | protected: |
| 63 | 70 | ||
| 64 | /// Execture next instruction | 71 | /// Execture next instruction |
| 65 | virtual void ExecuteInstruction() = 0; | 72 | virtual void ExecuteInstruction() = 0; |
| 66 | 73 | ||
| 74 | private: | ||
| 75 | |||
| 67 | u64 m_num_instructions; ///< Number of instructions executed | 76 | u64 m_num_instructions; ///< Number of instructions executed |
| 68 | 77 | ||
| 69 | DISALLOW_COPY_AND_ASSIGN(ARM_Interface); | 78 | DISALLOW_COPY_AND_ASSIGN(ARM_Interface); |
diff --git a/src/core/arm/interpreter/arm_interpreter.cpp b/src/core/arm/interpreter/arm_interpreter.cpp index 81f38f016..4045779d7 100644 --- a/src/core/arm/interpreter/arm_interpreter.cpp +++ b/src/core/arm/interpreter/arm_interpreter.cpp | |||
| @@ -31,30 +31,61 @@ ARM_Interpreter::ARM_Interpreter() { | |||
| 31 | m_state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack | 31 | m_state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | ARM_Interpreter::~ARM_Interpreter() { | ||
| 35 | delete m_state; | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Set the Program Counter to an address | ||
| 40 | * @param addr Address to set PC to | ||
| 41 | */ | ||
| 34 | void ARM_Interpreter::SetPC(u32 pc) { | 42 | void ARM_Interpreter::SetPC(u32 pc) { |
| 35 | m_state->pc = m_state->Reg[15] = pc; | 43 | m_state->pc = m_state->Reg[15] = pc; |
| 36 | } | 44 | } |
| 37 | 45 | ||
| 46 | /* | ||
| 47 | * Get the current Program Counter | ||
| 48 | * @return Returns current PC | ||
| 49 | */ | ||
| 38 | u32 ARM_Interpreter::GetPC() const { | 50 | u32 ARM_Interpreter::GetPC() const { |
| 39 | return m_state->pc; | 51 | return m_state->pc; |
| 40 | } | 52 | } |
| 41 | 53 | ||
| 54 | /** | ||
| 55 | * Get an ARM register | ||
| 56 | * @param index Register index (0-15) | ||
| 57 | * @return Returns the value in the register | ||
| 58 | */ | ||
| 42 | u32 ARM_Interpreter::GetReg(int index) const { | 59 | u32 ARM_Interpreter::GetReg(int index) const { |
| 43 | return m_state->Reg[index]; | 60 | return m_state->Reg[index]; |
| 44 | } | 61 | } |
| 45 | 62 | ||
| 63 | /** | ||
| 64 | * Set an ARM register | ||
| 65 | * @param index Register index (0-15) | ||
| 66 | * @param value Value to set register to | ||
| 67 | */ | ||
| 68 | void ARM_Interpreter::SetReg(int index, u32 value) { | ||
| 69 | m_state->Reg[index] = value; | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Get the current CPSR register | ||
| 74 | * @return Returns the value of the CPSR register | ||
| 75 | */ | ||
| 46 | u32 ARM_Interpreter::GetCPSR() const { | 76 | u32 ARM_Interpreter::GetCPSR() const { |
| 47 | return m_state->Cpsr; | 77 | return m_state->Cpsr; |
| 48 | } | 78 | } |
| 49 | 79 | ||
| 80 | /** | ||
| 81 | * Returns the number of clock ticks since the last reset | ||
| 82 | * @return Returns number of clock ticks | ||
| 83 | */ | ||
| 50 | u64 ARM_Interpreter::GetTicks() const { | 84 | u64 ARM_Interpreter::GetTicks() const { |
| 51 | return ARMul_Time(m_state); | 85 | return ARMul_Time(m_state); |
| 52 | } | 86 | } |
| 53 | 87 | ||
| 54 | ARM_Interpreter::~ARM_Interpreter() { | 88 | /// Execture next instruction |
| 55 | delete m_state; | ||
| 56 | } | ||
| 57 | |||
| 58 | void ARM_Interpreter::ExecuteInstruction() { | 89 | void ARM_Interpreter::ExecuteInstruction() { |
| 59 | m_state->step++; | 90 | m_state->step++; |
| 60 | m_state->cycle++; | 91 | m_state->cycle++; |
diff --git a/src/core/arm/interpreter/arm_interpreter.h b/src/core/arm/interpreter/arm_interpreter.h index 932046d9a..f3c86f8dd 100644 --- a/src/core/arm/interpreter/arm_interpreter.h +++ b/src/core/arm/interpreter/arm_interpreter.h | |||
| @@ -12,22 +12,55 @@ | |||
| 12 | 12 | ||
| 13 | class ARM_Interpreter : virtual public ARM_Interface { | 13 | class ARM_Interpreter : virtual public ARM_Interface { |
| 14 | public: | 14 | public: |
| 15 | |||
| 15 | ARM_Interpreter(); | 16 | ARM_Interpreter(); |
| 16 | ~ARM_Interpreter(); | 17 | ~ARM_Interpreter(); |
| 17 | 18 | ||
| 18 | void ExecuteInstruction(); | 19 | /** |
| 19 | 20 | * Set the Program Counter to an address | |
| 21 | * @param addr Address to set PC to | ||
| 22 | */ | ||
| 20 | void SetPC(u32 pc); | 23 | void SetPC(u32 pc); |
| 21 | 24 | ||
| 25 | /* | ||
| 26 | * Get the current Program Counter | ||
| 27 | * @return Returns current PC | ||
| 28 | */ | ||
| 22 | u32 GetPC() const; | 29 | u32 GetPC() const; |
| 23 | 30 | ||
| 31 | /** | ||
| 32 | * Get an ARM register | ||
| 33 | * @param index Register index (0-15) | ||
| 34 | * @return Returns the value in the register | ||
| 35 | */ | ||
| 24 | u32 GetReg(int index) const; | 36 | u32 GetReg(int index) const; |
| 25 | 37 | ||
| 38 | /** | ||
| 39 | * Set an ARM register | ||
| 40 | * @param index Register index (0-15) | ||
| 41 | * @param value Value to set register to | ||
| 42 | */ | ||
| 43 | void SetReg(int index, u32 value); | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Get the current CPSR register | ||
| 47 | * @return Returns the value of the CPSR register | ||
| 48 | */ | ||
| 26 | u32 GetCPSR() const; | 49 | u32 GetCPSR() const; |
| 27 | 50 | ||
| 51 | /** | ||
| 52 | * Returns the number of clock ticks since the last reset | ||
| 53 | * @return Returns number of clock ticks | ||
| 54 | */ | ||
| 28 | u64 GetTicks() const; | 55 | u64 GetTicks() const; |
| 29 | 56 | ||
| 57 | protected: | ||
| 58 | |||
| 59 | /// Execture next instruction | ||
| 60 | void ExecuteInstruction(); | ||
| 61 | |||
| 30 | private: | 62 | private: |
| 63 | |||
| 31 | ARMul_State* m_state; | 64 | ARMul_State* m_state; |
| 32 | 65 | ||
| 33 | DISALLOW_COPY_AND_ASSIGN(ARM_Interpreter); | 66 | DISALLOW_COPY_AND_ASSIGN(ARM_Interpreter); |
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/arm/interpreter/armemu.h b/src/core/arm/interpreter/armemu.h index 7391dea7f..7c118948a 100644 --- a/src/core/arm/interpreter/armemu.h +++ b/src/core/arm/interpreter/armemu.h | |||
| @@ -229,6 +229,17 @@ extern ARMword isize; | |||
| 229 | } \ | 229 | } \ |
| 230 | while (0) | 230 | while (0) |
| 231 | 231 | ||
| 232 | #define SETABORT_SKIPBRANCH(i, m, d) \ | ||
| 233 | do \ | ||
| 234 | { \ | ||
| 235 | int SETABORT_mode = (m); \ | ||
| 236 | \ | ||
| 237 | ARMul_SetSPSR (state, SETABORT_mode, ARMul_GetCPSR (state)); \ | ||
| 238 | ARMul_SetCPSR (state, ((ARMul_GetCPSR (state) & ~(EMODE | TBIT)) \ | ||
| 239 | | (i) | SETABORT_mode)); \ | ||
| 240 | } \ | ||
| 241 | while (0) | ||
| 242 | |||
| 232 | //#ifndef MODE32 | 243 | //#ifndef MODE32 |
| 233 | #define VECTORS 0x20 | 244 | #define VECTORS 0x20 |
| 234 | #define LEGALADDR 0x03ffffff | 245 | #define LEGALADDR 0x03ffffff |
diff --git a/src/core/arm/interpreter/arminit.cpp b/src/core/arm/interpreter/arminit.cpp index cdbd02f3c..a8aeecdea 100644 --- a/src/core/arm/interpreter/arminit.cpp +++ b/src/core/arm/interpreter/arminit.cpp | |||
| @@ -530,9 +530,13 @@ ARMul_Abort (ARMul_State * state, ARMword vector) | |||
| 530 | isize); | 530 | isize); |
| 531 | break; | 531 | break; |
| 532 | case ARMul_SWIV: /* Software Interrupt */ | 532 | case ARMul_SWIV: /* Software Interrupt */ |
| 533 | SETABORT (IBIT, state->prog32Sig ? SVC32MODE : SVC26MODE, | 533 | // Modified SETABORT that doesn't branch to a SVC vector as we are implementing this in HLE |
| 534 | // Instead of doing normal routine, backup R15 by one instruction (this is what PC will get | ||
| 535 | // set to, making it the next instruction after the SVC call), and skip setting the LR. | ||
| 536 | SETABORT_SKIPBRANCH (IBIT, state->prog32Sig ? SVC32MODE : SVC26MODE, | ||
| 534 | isize); | 537 | isize); |
| 535 | break; | 538 | state->Reg[15] -= 4; |
| 539 | return; | ||
| 536 | case ARMul_PrefetchAbortV: /* Prefetch Abort */ | 540 | case ARMul_PrefetchAbortV: /* Prefetch Abort */ |
| 537 | state->AbortAddr = 1; | 541 | state->AbortAddr = 1; |
| 538 | SETABORT (IBIT, state->prog32Sig ? ABORT32MODE : SVC26MODE, | 542 | SETABORT (IBIT, state->prog32Sig ? ABORT32MODE : SVC26MODE, |
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.cpp b/src/core/core.cpp index 28f6b6c58..859a62c78 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -40,7 +40,7 @@ void Stop() { | |||
| 40 | 40 | ||
| 41 | /// Initialize the core | 41 | /// Initialize the core |
| 42 | int Init() { | 42 | int Init() { |
| 43 | NOTICE_LOG(MASTER_LOG, "Core initialized OK"); | 43 | NOTICE_LOG(MASTER_LOG, "initialized OK"); |
| 44 | 44 | ||
| 45 | g_disasm = new ARM_Disasm(); | 45 | g_disasm = new ARM_Disasm(); |
| 46 | g_app_core = new ARM_Interpreter(); | 46 | g_app_core = new ARM_Interpreter(); |
| @@ -54,7 +54,7 @@ void Shutdown() { | |||
| 54 | delete g_app_core; | 54 | delete g_app_core; |
| 55 | delete g_sys_core; | 55 | delete g_sys_core; |
| 56 | 56 | ||
| 57 | NOTICE_LOG(MASTER_LOG, "Core shutdown OK"); | 57 | NOTICE_LOG(MASTER_LOG, "shutdown OK"); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | } // namespace | 60 | } // namespace |
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index 1800b5512..b6fc604c6 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj | |||
| @@ -152,8 +152,16 @@ | |||
| 152 | <ClCompile Include="elf\elf_reader.cpp" /> | 152 | <ClCompile Include="elf\elf_reader.cpp" /> |
| 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" /> | ||
| 156 | <ClCompile Include="hle\service\apt.cpp" /> | ||
| 157 | <ClCompile Include="hle\service\gsp.cpp" /> | ||
| 158 | <ClCompile Include="hle\service\hid.cpp" /> | ||
| 159 | <ClCompile Include="hle\service\service.cpp" /> | ||
| 160 | <ClCompile Include="hle\service\srv.cpp" /> | ||
| 161 | <ClCompile Include="hle\syscall.cpp" /> | ||
| 155 | <ClCompile Include="hw\hw.cpp" /> | 162 | <ClCompile Include="hw\hw.cpp" /> |
| 156 | <ClCompile Include="hw\hw_lcd.cpp" /> | 163 | <ClCompile Include="hw\lcd.cpp" /> |
| 164 | <ClCompile Include="hw\ndma.cpp" /> | ||
| 157 | <ClCompile Include="loader.cpp" /> | 165 | <ClCompile Include="loader.cpp" /> |
| 158 | <ClCompile Include="mem_map.cpp" /> | 166 | <ClCompile Include="mem_map.cpp" /> |
| 159 | <ClCompile Include="mem_map_funcs.cpp" /> | 167 | <ClCompile Include="mem_map_funcs.cpp" /> |
| @@ -182,8 +190,17 @@ | |||
| 182 | <ClInclude Include="file_sys\directory_file_system.h" /> | 190 | <ClInclude Include="file_sys\directory_file_system.h" /> |
| 183 | <ClInclude Include="file_sys\file_sys.h" /> | 191 | <ClInclude Include="file_sys\file_sys.h" /> |
| 184 | <ClInclude Include="file_sys\meta_file_system.h" /> | 192 | <ClInclude Include="file_sys\meta_file_system.h" /> |
| 193 | <ClInclude Include="hle\function_wrappers.h" /> | ||
| 194 | <ClInclude Include="hle\hle.h" /> | ||
| 195 | <ClInclude Include="hle\service\apt.h" /> | ||
| 196 | <ClInclude Include="hle\service\gsp.h" /> | ||
| 197 | <ClInclude Include="hle\service\hid.h" /> | ||
| 198 | <ClInclude Include="hle\service\service.h" /> | ||
| 199 | <ClInclude Include="hle\service\srv.h" /> | ||
| 200 | <ClInclude Include="hle\syscall.h" /> | ||
| 185 | <ClInclude Include="hw\hw.h" /> | 201 | <ClInclude Include="hw\hw.h" /> |
| 186 | <ClInclude Include="hw\hw_lcd.h" /> | 202 | <ClInclude Include="hw\lcd.h" /> |
| 203 | <ClInclude Include="hw\ndma.h" /> | ||
| 187 | <ClInclude Include="loader.h" /> | 204 | <ClInclude Include="loader.h" /> |
| 188 | <ClInclude Include="mem_map.h" /> | 205 | <ClInclude Include="mem_map.h" /> |
| 189 | <ClInclude Include="system.h" /> | 206 | <ClInclude Include="system.h" /> |
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index 2efac8127..ff7877feb 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters | |||
| @@ -22,6 +22,12 @@ | |||
| 22 | <Filter Include="elf"> | 22 | <Filter Include="elf"> |
| 23 | <UniqueIdentifier>{7ae34319-6d72-4d12-bc62-9b438ba9241f}</UniqueIdentifier> | 23 | <UniqueIdentifier>{7ae34319-6d72-4d12-bc62-9b438ba9241f}</UniqueIdentifier> |
| 24 | </Filter> | 24 | </Filter> |
| 25 | <Filter Include="hle"> | ||
| 26 | <UniqueIdentifier>{8b62769e-3e2a-4a57-a7bc-b3b2933c2bc7}</UniqueIdentifier> | ||
| 27 | </Filter> | ||
| 28 | <Filter Include="hle\service"> | ||
| 29 | <UniqueIdentifier>{812c5189-ca49-4704-b842-3ffad09092d3}</UniqueIdentifier> | ||
| 30 | </Filter> | ||
| 25 | </ItemGroup> | 31 | </ItemGroup> |
| 26 | <ItemGroup> | 32 | <ItemGroup> |
| 27 | <ClCompile Include="arm\disassembler\arm_disasm.cpp"> | 33 | <ClCompile Include="arm\disassembler\arm_disasm.cpp"> |
| @@ -63,9 +69,6 @@ | |||
| 63 | <ClCompile Include="hw\hw.cpp"> | 69 | <ClCompile Include="hw\hw.cpp"> |
| 64 | <Filter>hw</Filter> | 70 | <Filter>hw</Filter> |
| 65 | </ClCompile> | 71 | </ClCompile> |
| 66 | <ClCompile Include="hw\hw_lcd.cpp"> | ||
| 67 | <Filter>hw</Filter> | ||
| 68 | </ClCompile> | ||
| 69 | <ClCompile Include="elf\elf_reader.cpp"> | 72 | <ClCompile Include="elf\elf_reader.cpp"> |
| 70 | <Filter>elf</Filter> | 73 | <Filter>elf</Filter> |
| 71 | </ClCompile> | 74 | </ClCompile> |
| @@ -75,6 +78,33 @@ | |||
| 75 | <ClCompile Include="mem_map_funcs.cpp" /> | 78 | <ClCompile Include="mem_map_funcs.cpp" /> |
| 76 | <ClCompile Include="system.cpp" /> | 79 | <ClCompile Include="system.cpp" /> |
| 77 | <ClCompile Include="core_timing.cpp" /> | 80 | <ClCompile Include="core_timing.cpp" /> |
| 81 | <ClCompile Include="hle\hle.cpp"> | ||
| 82 | <Filter>hle</Filter> | ||
| 83 | </ClCompile> | ||
| 84 | <ClCompile Include="hle\syscall.cpp"> | ||
| 85 | <Filter>hle</Filter> | ||
| 86 | </ClCompile> | ||
| 87 | <ClCompile Include="hle\service\service.cpp"> | ||
| 88 | <Filter>hle\service</Filter> | ||
| 89 | </ClCompile> | ||
| 90 | <ClCompile Include="hle\service\apt.cpp"> | ||
| 91 | <Filter>hle\service</Filter> | ||
| 92 | </ClCompile> | ||
| 93 | <ClCompile Include="hle\service\srv.cpp"> | ||
| 94 | <Filter>hle\service</Filter> | ||
| 95 | </ClCompile> | ||
| 96 | <ClCompile Include="hle\service\gsp.cpp"> | ||
| 97 | <Filter>hle\service</Filter> | ||
| 98 | </ClCompile> | ||
| 99 | <ClCompile Include="hle\service\hid.cpp"> | ||
| 100 | <Filter>hle\service</Filter> | ||
| 101 | </ClCompile> | ||
| 102 | <ClCompile Include="hw\ndma.cpp"> | ||
| 103 | <Filter>hw</Filter> | ||
| 104 | </ClCompile> | ||
| 105 | <ClCompile Include="hw\lcd.cpp"> | ||
| 106 | <Filter>hw</Filter> | ||
| 107 | </ClCompile> | ||
| 78 | </ItemGroup> | 108 | </ItemGroup> |
| 79 | <ItemGroup> | 109 | <ItemGroup> |
| 80 | <ClInclude Include="arm\disassembler\arm_disasm.h"> | 110 | <ClInclude Include="arm\disassembler\arm_disasm.h"> |
| @@ -131,9 +161,6 @@ | |||
| 131 | <ClInclude Include="hw\hw.h"> | 161 | <ClInclude Include="hw\hw.h"> |
| 132 | <Filter>hw</Filter> | 162 | <Filter>hw</Filter> |
| 133 | </ClInclude> | 163 | </ClInclude> |
| 134 | <ClInclude Include="hw\hw_lcd.h"> | ||
| 135 | <Filter>hw</Filter> | ||
| 136 | </ClInclude> | ||
| 137 | <ClInclude Include="elf\elf_reader.h"> | 164 | <ClInclude Include="elf\elf_reader.h"> |
| 138 | <Filter>elf</Filter> | 165 | <Filter>elf</Filter> |
| 139 | </ClInclude> | 166 | </ClInclude> |
| @@ -148,6 +175,36 @@ | |||
| 148 | <ClInclude Include="loader.h" /> | 175 | <ClInclude Include="loader.h" /> |
| 149 | <ClInclude Include="mem_map.h" /> | 176 | <ClInclude Include="mem_map.h" /> |
| 150 | <ClInclude Include="system.h" /> | 177 | <ClInclude Include="system.h" /> |
| 178 | <ClInclude Include="hle\hle.h"> | ||
| 179 | <Filter>hle</Filter> | ||
| 180 | </ClInclude> | ||
| 181 | <ClInclude Include="hle\function_wrappers.h"> | ||
| 182 | <Filter>hle</Filter> | ||
| 183 | </ClInclude> | ||
| 184 | <ClInclude Include="hle\service\service.h"> | ||
| 185 | <Filter>hle\service</Filter> | ||
| 186 | </ClInclude> | ||
| 187 | <ClInclude Include="hle\syscall.h"> | ||
| 188 | <Filter>hle</Filter> | ||
| 189 | </ClInclude> | ||
| 190 | <ClInclude Include="hle\service\apt.h"> | ||
| 191 | <Filter>hle\service</Filter> | ||
| 192 | </ClInclude> | ||
| 193 | <ClInclude Include="hle\service\srv.h"> | ||
| 194 | <Filter>hle\service</Filter> | ||
| 195 | </ClInclude> | ||
| 196 | <ClInclude Include="hle\service\gsp.h"> | ||
| 197 | <Filter>hle\service</Filter> | ||
| 198 | </ClInclude> | ||
| 199 | <ClInclude Include="hle\service\hid.h"> | ||
| 200 | <Filter>hle\service</Filter> | ||
| 201 | </ClInclude> | ||
| 202 | <ClInclude Include="hw\ndma.h"> | ||
| 203 | <Filter>hw</Filter> | ||
| 204 | </ClInclude> | ||
| 205 | <ClInclude Include="hw\lcd.h"> | ||
| 206 | <Filter>hw</Filter> | ||
| 207 | </ClInclude> | ||
| 151 | </ItemGroup> | 208 | </ItemGroup> |
| 152 | <ItemGroup> | 209 | <ItemGroup> |
| 153 | <Text Include="CMakeLists.txt" /> | 210 | <Text Include="CMakeLists.txt" /> |
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h new file mode 100644 index 000000000..4897d3f28 --- /dev/null +++ b/src/core/hle/function_wrappers.h | |||
| @@ -0,0 +1,736 @@ | |||
| 1 | // Copyright (c) 2012- PPSSPP Project. | ||
| 2 | |||
| 3 | // This program is free software: you can redistribute it and/or modify | ||
| 4 | // it under the terms of the GNU General Public License as published by | ||
| 5 | // the Free Software Foundation, version 2.0 or later versions. | ||
| 6 | |||
| 7 | // This program is distributed in the hope that it will be useful, | ||
| 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 10 | // GNU General Public License 2.0 for more details. | ||
| 11 | |||
| 12 | // A copy of the GPL 2.0 should have been included with the program. | ||
| 13 | // If not, see http://www.gnu.org/licenses/ | ||
| 14 | |||
| 15 | // Official git repository and contact information can be found at | ||
| 16 | // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include "common/common_types.h" | ||
| 21 | #include "core/mem_map.h" | ||
| 22 | #include "core/hle/hle.h" | ||
| 23 | |||
| 24 | // For easy parameter parsing and return value processing. | ||
| 25 | |||
| 26 | //32bit wrappers | ||
| 27 | template<void func()> void WrapV_V() { | ||
| 28 | func(); | ||
| 29 | } | ||
| 30 | |||
| 31 | template<u32 func()> void WrapU_V() { | ||
| 32 | RETURN(func()); | ||
| 33 | } | ||
| 34 | |||
| 35 | template<int func(void *, const char *)> void WrapI_VC() { | ||
| 36 | u32 retval = func(Memory::GetPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1))); | ||
| 37 | RETURN(retval); | ||
| 38 | } | ||
| 39 | |||
| 40 | template<u32 func(int, void *, int)> void WrapU_IVI() { | ||
| 41 | u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), PARAM(2)); | ||
| 42 | RETURN(retval); | ||
| 43 | } | ||
| 44 | |||
| 45 | template<int func(const char *, int, int, u32)> void WrapI_CIIU() { | ||
| 46 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 47 | RETURN(retval); | ||
| 48 | } | ||
| 49 | |||
| 50 | template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() { | ||
| 51 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); | ||
| 52 | RETURN(retval); | ||
| 53 | } | ||
| 54 | |||
| 55 | // Hm, do so many params get passed in registers? | ||
| 56 | template<int func(const char *, int, const char *, int, int, int, int, int)> void WrapI_CICIIIII() { | ||
| 57 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), Memory::GetCharPointer(PARAM(2)), | ||
| 58 | PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7)); | ||
| 59 | RETURN(retval); | ||
| 60 | } | ||
| 61 | |||
| 62 | // Hm, do so many params get passed in registers? | ||
| 63 | template<int func(const char *, int, int, int, int, int, int)> void WrapI_CIIIIII() { | ||
| 64 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 65 | PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 66 | RETURN(retval); | ||
| 67 | } | ||
| 68 | |||
| 69 | // Hm, do so many params get passed in registers? | ||
| 70 | template<int func(int, int, int, int, int, int, u32)> void WrapI_IIIIIIU() { | ||
| 71 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 72 | RETURN(retval); | ||
| 73 | } | ||
| 74 | |||
| 75 | // Hm, do so many params get passed in registers? | ||
| 76 | template<int func(int, int, int, int, int, int, int, int, u32)> void WrapI_IIIIIIIIU() { | ||
| 77 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6), PARAM(7), PARAM(8)); | ||
| 78 | RETURN(retval); | ||
| 79 | } | ||
| 80 | |||
| 81 | template<u32 func(int, void *)> void WrapU_IV() { | ||
| 82 | u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1))); | ||
| 83 | RETURN(retval); | ||
| 84 | } | ||
| 85 | |||
| 86 | template<float func()> void WrapF_V() { | ||
| 87 | RETURNF(func()); | ||
| 88 | } | ||
| 89 | |||
| 90 | // TODO: Not sure about the floating point parameter passing | ||
| 91 | template<float func(int, float, u32)> void WrapF_IFU() { | ||
| 92 | RETURNF(func(PARAM(0), PARAMF(0), PARAM(1))); | ||
| 93 | } | ||
| 94 | |||
| 95 | template<u32 func(u32)> void WrapU_U() { | ||
| 96 | u32 retval = func(PARAM(0)); | ||
| 97 | RETURN(retval); | ||
| 98 | } | ||
| 99 | |||
| 100 | template<u32 func(u32, int)> void WrapU_UI() { | ||
| 101 | u32 retval = func(PARAM(0), PARAM(1)); | ||
| 102 | RETURN(retval); | ||
| 103 | } | ||
| 104 | |||
| 105 | template<int func(u32)> void WrapI_U() { | ||
| 106 | int retval = func(PARAM(0)); | ||
| 107 | RETURN(retval); | ||
| 108 | } | ||
| 109 | |||
| 110 | template<int func(u32, int)> void WrapI_UI() { | ||
| 111 | int retval = func(PARAM(0), PARAM(1)); | ||
| 112 | RETURN(retval); | ||
| 113 | } | ||
| 114 | |||
| 115 | template<int func(u32, int, int, u32)> void WrapI_UIIU() { | ||
| 116 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 117 | RETURN(retval); | ||
| 118 | } | ||
| 119 | |||
| 120 | template<u32 func(int, u32, int)> void WrapU_IUI() { | ||
| 121 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 122 | RETURN(retval); | ||
| 123 | } | ||
| 124 | |||
| 125 | template<int func(u32, u32)> void WrapI_UU() { | ||
| 126 | int retval = func(PARAM(0), PARAM(1)); | ||
| 127 | RETURN(retval); | ||
| 128 | } | ||
| 129 | |||
| 130 | template<int func(u32, float, float)> void WrapI_UFF() { | ||
| 131 | // Not sure about the float arguments. | ||
| 132 | int retval = func(PARAM(0), PARAMF(0), PARAMF(1)); | ||
| 133 | RETURN(retval); | ||
| 134 | } | ||
| 135 | |||
| 136 | template<int func(u32, u32, u32)> void WrapI_UUU() { | ||
| 137 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 138 | RETURN(retval); | ||
| 139 | } | ||
| 140 | |||
| 141 | template<int func(u32, u32, u32, int)> void WrapI_UUUI() { | ||
| 142 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 143 | RETURN(retval); | ||
| 144 | } | ||
| 145 | |||
| 146 | template<int func(u32, u32, u32, int, int, int,int )> void WrapI_UUUIIII() { | ||
| 147 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 148 | RETURN(retval); | ||
| 149 | } | ||
| 150 | |||
| 151 | template<int func(u32, u32, u32, u32)> void WrapI_UUUU() { | ||
| 152 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 153 | RETURN(retval); | ||
| 154 | } | ||
| 155 | |||
| 156 | template<int func(u32, u32, u32, u32, u32)> void WrapI_UUUUU() { | ||
| 157 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 158 | RETURN(retval); | ||
| 159 | } | ||
| 160 | |||
| 161 | template<int func()> void WrapI_V() { | ||
| 162 | int retval = func(); | ||
| 163 | RETURN(retval); | ||
| 164 | } | ||
| 165 | |||
| 166 | template<u32 func(int)> void WrapU_I() { | ||
| 167 | u32 retval = func(PARAM(0)); | ||
| 168 | RETURN(retval); | ||
| 169 | } | ||
| 170 | |||
| 171 | template<u32 func(int, int, u32)> void WrapU_IIU() { | ||
| 172 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 173 | RETURN(retval); | ||
| 174 | } | ||
| 175 | |||
| 176 | template<int func(int)> void WrapI_I() { | ||
| 177 | int retval = func(PARAM(0)); | ||
| 178 | RETURN(retval); | ||
| 179 | } | ||
| 180 | |||
| 181 | template<void func(u32)> void WrapV_U() { | ||
| 182 | func(PARAM(0)); | ||
| 183 | } | ||
| 184 | |||
| 185 | template<void func(int)> void WrapV_I() { | ||
| 186 | func(PARAM(0)); | ||
| 187 | } | ||
| 188 | |||
| 189 | template<void func(u32, u32)> void WrapV_UU() { | ||
| 190 | func(PARAM(0), PARAM(1)); | ||
| 191 | } | ||
| 192 | |||
| 193 | template<void func(int, int)> void WrapV_II() { | ||
| 194 | func(PARAM(0), PARAM(1)); | ||
| 195 | } | ||
| 196 | |||
| 197 | template<void func(u32, const char *)> void WrapV_UC() { | ||
| 198 | func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 199 | } | ||
| 200 | |||
| 201 | template<int func(u32, const char *)> void WrapI_UC() { | ||
| 202 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 203 | RETURN(retval); | ||
| 204 | } | ||
| 205 | |||
| 206 | template<int func(u32, const char *, int)> void WrapI_UCI() { | ||
| 207 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2)); | ||
| 208 | RETURN(retval); | ||
| 209 | } | ||
| 210 | |||
| 211 | template<u32 func(u32, int , int , int, int, int)> void WrapU_UIIIII() { | ||
| 212 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 213 | RETURN(retval); | ||
| 214 | } | ||
| 215 | |||
| 216 | template<u32 func(u32, int , int , int, u32)> void WrapU_UIIIU() { | ||
| 217 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 218 | RETURN(retval); | ||
| 219 | } | ||
| 220 | |||
| 221 | template<u32 func(u32, int , int , int, int, int, int)> void WrapU_UIIIIII() { | ||
| 222 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 223 | RETURN(retval); | ||
| 224 | } | ||
| 225 | |||
| 226 | template<u32 func(u32, u32)> void WrapU_UU() { | ||
| 227 | u32 retval = func(PARAM(0), PARAM(1)); | ||
| 228 | RETURN(retval); | ||
| 229 | } | ||
| 230 | |||
| 231 | template<u32 func(u32, u32, int)> void WrapU_UUI() { | ||
| 232 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 233 | RETURN(retval); | ||
| 234 | } | ||
| 235 | |||
| 236 | template<u32 func(u32, u32, int, int)> void WrapU_UUII() { | ||
| 237 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 238 | RETURN(retval); | ||
| 239 | } | ||
| 240 | |||
| 241 | template<u32 func(const char *, u32, u32, u32)> void WrapU_CUUU() { | ||
| 242 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 243 | RETURN(retval); | ||
| 244 | } | ||
| 245 | |||
| 246 | template<void func(u32, int, u32, int, int)> void WrapV_UIUII() { | ||
| 247 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 248 | } | ||
| 249 | |||
| 250 | template<u32 func(u32, int, u32, int, int)> void WrapU_UIUII() { | ||
| 251 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 252 | RETURN(retval); | ||
| 253 | } | ||
| 254 | |||
| 255 | template<int func(u32, int, u32, int, int)> void WrapI_UIUII() { | ||
| 256 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 257 | RETURN(retval); | ||
| 258 | } | ||
| 259 | |||
| 260 | template<u32 func(u32, int, u32, int)> void WrapU_UIUI() { | ||
| 261 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 262 | RETURN(retval); | ||
| 263 | } | ||
| 264 | |||
| 265 | template<int func(u32, int, u32, int)> void WrapI_UIUI() { | ||
| 266 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 267 | RETURN(retval); | ||
| 268 | } | ||
| 269 | |||
| 270 | template<u32 func(u32, int, u32)> void WrapU_UIU() { | ||
| 271 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 272 | RETURN(retval); | ||
| 273 | } | ||
| 274 | |||
| 275 | template<u32 func(u32, int, u32, u32)> void WrapU_UIUU() { | ||
| 276 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 277 | RETURN(retval); | ||
| 278 | } | ||
| 279 | |||
| 280 | template<u32 func(u32, int, int)> void WrapU_UII() { | ||
| 281 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 282 | RETURN(retval); | ||
| 283 | } | ||
| 284 | |||
| 285 | template<u32 func(u32, int, int, u32)> void WrapU_UIIU() { | ||
| 286 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 287 | RETURN(retval); | ||
| 288 | } | ||
| 289 | |||
| 290 | template<int func(u32, int, int, u32, u32)> void WrapI_UIIUU() { | ||
| 291 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 292 | RETURN(retval); | ||
| 293 | } | ||
| 294 | |||
| 295 | template<int func(u32, u32, int, int)> void WrapI_UUII() { | ||
| 296 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 297 | RETURN(retval); | ||
| 298 | } | ||
| 299 | |||
| 300 | template<int func(u32, u32, int, int, int)> void WrapI_UUIII() { | ||
| 301 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 302 | RETURN(retval); | ||
| 303 | } | ||
| 304 | |||
| 305 | template<void func(u32, int, int, int)> void WrapV_UIII() { | ||
| 306 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 307 | } | ||
| 308 | |||
| 309 | template<void func(u32, int, int, int, int, int)> void WrapV_UIIIII() { | ||
| 310 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 311 | } | ||
| 312 | |||
| 313 | template<void func(u32, int, int)> void WrapV_UII() { | ||
| 314 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 315 | } | ||
| 316 | |||
| 317 | template<u32 func(int, u32)> void WrapU_IU() { | ||
| 318 | int retval = func(PARAM(0), PARAM(1)); | ||
| 319 | RETURN(retval); | ||
| 320 | } | ||
| 321 | |||
| 322 | template<int func(int, u32)> void WrapI_IU() { | ||
| 323 | int retval = func(PARAM(0), PARAM(1)); | ||
| 324 | RETURN(retval); | ||
| 325 | } | ||
| 326 | |||
| 327 | template<int func(u32, u32, int)> void WrapI_UUI() { | ||
| 328 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 329 | RETURN(retval); | ||
| 330 | } | ||
| 331 | |||
| 332 | template<int func(u32, u32, int, u32)> void WrapI_UUIU() { | ||
| 333 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 334 | RETURN(retval); | ||
| 335 | } | ||
| 336 | |||
| 337 | template<int func(int, int)> void WrapI_II() { | ||
| 338 | int retval = func(PARAM(0), PARAM(1)); | ||
| 339 | RETURN(retval); | ||
| 340 | } | ||
| 341 | |||
| 342 | template<int func(int, int, int)> void WrapI_III() { | ||
| 343 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 344 | RETURN(retval); | ||
| 345 | } | ||
| 346 | |||
| 347 | template<int func(int, u32, int)> void WrapI_IUI() { | ||
| 348 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 349 | RETURN(retval); | ||
| 350 | } | ||
| 351 | |||
| 352 | template<int func(int, int, int, int)> void WrapI_IIII() { | ||
| 353 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 354 | RETURN(retval); | ||
| 355 | } | ||
| 356 | |||
| 357 | template<int func(u32, int, int, int)> void WrapI_UIII() { | ||
| 358 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 359 | RETURN(retval); | ||
| 360 | } | ||
| 361 | |||
| 362 | template<int func(int, int, int, u32, int)> void WrapI_IIIUI() { | ||
| 363 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 364 | RETURN(retval); | ||
| 365 | } | ||
| 366 | |||
| 367 | template<int func(int, u32, u32, int, int)> void WrapI_IUUII() { | ||
| 368 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 369 | RETURN(retval); | ||
| 370 | } | ||
| 371 | |||
| 372 | template<int func(int, const char *, int, u32, u32)> void WrapI_ICIUU() { | ||
| 373 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), PARAM(4)); | ||
| 374 | RETURN(retval); | ||
| 375 | } | ||
| 376 | |||
| 377 | template<int func(int, int, u32)> void WrapI_IIU() { | ||
| 378 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 379 | RETURN(retval); | ||
| 380 | } | ||
| 381 | |||
| 382 | template<void func(int, u32)> void WrapV_IU() { | ||
| 383 | func(PARAM(0), PARAM(1)); | ||
| 384 | } | ||
| 385 | |||
| 386 | template<void func(u32, int)> void WrapV_UI() { | ||
| 387 | func(PARAM(0), PARAM(1)); | ||
| 388 | } | ||
| 389 | |||
| 390 | template<u32 func(const char *)> void WrapU_C() { | ||
| 391 | u32 retval = func(Memory::GetCharPointer(PARAM(0))); | ||
| 392 | RETURN(retval); | ||
| 393 | } | ||
| 394 | |||
| 395 | template<u32 func(const char *, const char *, const char *, u32)> void WrapU_CCCU() { | ||
| 396 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), | ||
| 397 | Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), | ||
| 398 | PARAM(3)); | ||
| 399 | RETURN(retval); | ||
| 400 | } | ||
| 401 | |||
| 402 | template<int func(const char *)> void WrapI_C() { | ||
| 403 | int retval = func(Memory::GetCharPointer(PARAM(0))); | ||
| 404 | RETURN(retval); | ||
| 405 | } | ||
| 406 | |||
| 407 | template<int func(const char *, u32)> void WrapI_CU() { | ||
| 408 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 409 | RETURN(retval); | ||
| 410 | } | ||
| 411 | |||
| 412 | template<int func(const char *, u32, int)> void WrapI_CUI() { | ||
| 413 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 414 | RETURN(retval); | ||
| 415 | } | ||
| 416 | |||
| 417 | template<int func(int, const char *, int, u32)> void WrapI_ICIU() { | ||
| 418 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); | ||
| 419 | RETURN(retval); | ||
| 420 | } | ||
| 421 | |||
| 422 | template<int func(const char *, int, u32)> void WrapI_CIU() { | ||
| 423 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 424 | RETURN(retval); | ||
| 425 | } | ||
| 426 | |||
| 427 | template<int func(const char *, u32, u32)> void WrapI_CUU() { | ||
| 428 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 429 | RETURN(retval); | ||
| 430 | } | ||
| 431 | |||
| 432 | template<int func(const char *, u32, u32, u32)> void WrapI_CUUU() { | ||
| 433 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 434 | PARAM(3)); | ||
| 435 | RETURN(retval); | ||
| 436 | } | ||
| 437 | |||
| 438 | template<int func(const char *, const char*, int, int)> void WrapI_CCII() { | ||
| 439 | int retval = func(Memory::GetCharPointer(PARAM(0)), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); | ||
| 440 | RETURN(retval); | ||
| 441 | } | ||
| 442 | |||
| 443 | template<int func(const char *, u32, u32, int, u32, u32)> void WrapI_CUUIUU() { | ||
| 444 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 445 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 446 | RETURN(retval); | ||
| 447 | } | ||
| 448 | |||
| 449 | template<int func(const char *, int, int, u32, int, int)> void WrapI_CIIUII() { | ||
| 450 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 451 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 452 | RETURN(retval); | ||
| 453 | } | ||
| 454 | |||
| 455 | template<int func(const char *, int, u32, u32, u32)> void WrapI_CIUUU() { | ||
| 456 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 457 | PARAM(3), PARAM(4)); | ||
| 458 | RETURN(retval); | ||
| 459 | } | ||
| 460 | |||
| 461 | template<int func(const char *, u32, u32, u32, u32, u32)> void WrapI_CUUUUU() { | ||
| 462 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 463 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 464 | RETURN(retval); | ||
| 465 | } | ||
| 466 | |||
| 467 | template<u32 func(const char *, u32)> void WrapU_CU() { | ||
| 468 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 469 | RETURN((u32) retval); | ||
| 470 | } | ||
| 471 | |||
| 472 | template<u32 func(u32, const char *)> void WrapU_UC() { | ||
| 473 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 474 | RETURN(retval); | ||
| 475 | } | ||
| 476 | |||
| 477 | template<u32 func(const char *, u32, u32)> void WrapU_CUU() { | ||
| 478 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 479 | RETURN((u32) retval); | ||
| 480 | } | ||
| 481 | |||
| 482 | template<u32 func(int, int, int)> void WrapU_III() { | ||
| 483 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 484 | RETURN(retval); | ||
| 485 | } | ||
| 486 | |||
| 487 | template<u32 func(int, int)> void WrapU_II() { | ||
| 488 | u32 retval = func(PARAM(0), PARAM(1)); | ||
| 489 | RETURN(retval); | ||
| 490 | } | ||
| 491 | |||
| 492 | template<u32 func(int, int, int, int)> void WrapU_IIII() { | ||
| 493 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 494 | RETURN(retval); | ||
| 495 | } | ||
| 496 | |||
| 497 | template<u32 func(int, u32, u32)> void WrapU_IUU() { | ||
| 498 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 499 | RETURN(retval); | ||
| 500 | } | ||
| 501 | |||
| 502 | template<u32 func(int, u32, u32, u32)> void WrapU_IUUU() { | ||
| 503 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 504 | RETURN(retval); | ||
| 505 | } | ||
| 506 | |||
| 507 | template<u32 func(int, u32, u32, u32, u32)> void WrapU_IUUUU() { | ||
| 508 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 509 | RETURN(retval); | ||
| 510 | } | ||
| 511 | |||
| 512 | template<u32 func(u32, u32, u32)> void WrapU_UUU() { | ||
| 513 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 514 | RETURN(retval); | ||
| 515 | } | ||
| 516 | |||
| 517 | template<void func(int, u32, u32)> void WrapV_IUU() { | ||
| 518 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 519 | } | ||
| 520 | |||
| 521 | template<void func(int, int, u32)> void WrapV_IIU() { | ||
| 522 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 523 | } | ||
| 524 | |||
| 525 | template<void func(u32, int, u32)> void WrapV_UIU() { | ||
| 526 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 527 | } | ||
| 528 | |||
| 529 | template<int func(u32, int, u32)> void WrapI_UIU() { | ||
| 530 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 531 | RETURN(retval); | ||
| 532 | } | ||
| 533 | |||
| 534 | template<void func(int, u32, u32, u32, u32)> void WrapV_IUUUU() { | ||
| 535 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 536 | } | ||
| 537 | |||
| 538 | template<void func(u32, u32, u32)> void WrapV_UUU() { | ||
| 539 | func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 540 | } | ||
| 541 | |||
| 542 | template<void func(u32, u32, u32, u32)> void WrapV_UUUU() { | ||
| 543 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 544 | } | ||
| 545 | |||
| 546 | template<void func(const char *, u32, int, u32)> void WrapV_CUIU() { | ||
| 547 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 548 | } | ||
| 549 | |||
| 550 | template<int func(const char *, u32, int, u32)> void WrapI_CUIU() { | ||
| 551 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3)); | ||
| 552 | RETURN(retval); | ||
| 553 | } | ||
| 554 | |||
| 555 | template<void func(u32, const char *, u32, int, u32)> void WrapV_UCUIU() { | ||
| 556 | func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3), | ||
| 557 | PARAM(4)); | ||
| 558 | } | ||
| 559 | |||
| 560 | template<int func(u32, const char *, u32, int, u32)> void WrapI_UCUIU() { | ||
| 561 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), | ||
| 562 | PARAM(3), PARAM(4)); | ||
| 563 | RETURN(retval); | ||
| 564 | } | ||
| 565 | |||
| 566 | template<void func(const char *, u32, int, int, u32)> void WrapV_CUIIU() { | ||
| 567 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), | ||
| 568 | PARAM(4)); | ||
| 569 | } | ||
| 570 | |||
| 571 | template<int func(const char *, u32, int, int, u32)> void WrapI_CUIIU() { | ||
| 572 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 573 | PARAM(3), PARAM(4)); | ||
| 574 | RETURN(retval); | ||
| 575 | } | ||
| 576 | |||
| 577 | template<u32 func(u32, u32, u32, u32)> void WrapU_UUUU() { | ||
| 578 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 579 | RETURN(retval); | ||
| 580 | } | ||
| 581 | |||
| 582 | template<u32 func(u32, const char *, u32, u32)> void WrapU_UCUU() { | ||
| 583 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), PARAM(3)); | ||
| 584 | RETURN(retval); | ||
| 585 | } | ||
| 586 | |||
| 587 | template<u32 func(u32, u32, u32, int)> void WrapU_UUUI() { | ||
| 588 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 589 | RETURN(retval); | ||
| 590 | } | ||
| 591 | |||
| 592 | template<u32 func(u32, u32, u32, int, u32)> void WrapU_UUUIU() { | ||
| 593 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 594 | RETURN(retval); | ||
| 595 | } | ||
| 596 | |||
| 597 | template<u32 func(u32, u32, u32, int, u32, int)> void WrapU_UUUIUI() { | ||
| 598 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 599 | RETURN(retval); | ||
| 600 | } | ||
| 601 | |||
| 602 | template<u32 func(u32, u32, int, u32)> void WrapU_UUIU() { | ||
| 603 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 604 | RETURN(retval); | ||
| 605 | } | ||
| 606 | |||
| 607 | template<u32 func(u32, int, int, int)> void WrapU_UIII() { | ||
| 608 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 609 | RETURN(retval); | ||
| 610 | } | ||
| 611 | |||
| 612 | template<int func(int, u32, u32, u32, u32)> void WrapI_IUUUU() { | ||
| 613 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 614 | RETURN(retval); | ||
| 615 | } | ||
| 616 | |||
| 617 | template<int func(int, u32, u32, u32, u32, u32)> void WrapI_IUUUUU() { | ||
| 618 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 619 | RETURN(retval); | ||
| 620 | } | ||
| 621 | |||
| 622 | template<int func(int, u32, int, int)> void WrapI_IUII() { | ||
| 623 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 624 | RETURN(retval); | ||
| 625 | } | ||
| 626 | template<u32 func(u32, u32, u32, u32, u32)> void WrapU_UUUUU() { | ||
| 627 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 628 | RETURN(retval); | ||
| 629 | } | ||
| 630 | |||
| 631 | template<void func(u32, u32, u32, u32, u32)> void WrapV_UUUUU() { | ||
| 632 | func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)); | ||
| 633 | } | ||
| 634 | |||
| 635 | template<u32 func(const char *, const char *)> void WrapU_CC() { | ||
| 636 | int retval = func(Memory::GetCharPointer(PARAM(0)), | ||
| 637 | Memory::GetCharPointer(PARAM(1))); | ||
| 638 | RETURN(retval); | ||
| 639 | } | ||
| 640 | |||
| 641 | template<void func(const char *, int)> void WrapV_CI() { | ||
| 642 | func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 643 | } | ||
| 644 | |||
| 645 | template<u32 func(const char *, int)> void WrapU_CI() { | ||
| 646 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1)); | ||
| 647 | RETURN(retval); | ||
| 648 | } | ||
| 649 | |||
| 650 | template<u32 func(const char *, int, int)> void WrapU_CII() { | ||
| 651 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 652 | RETURN(retval); | ||
| 653 | } | ||
| 654 | |||
| 655 | template<int func(const char *, int, u32, int, u32)> void WrapU_CIUIU() { | ||
| 656 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 657 | PARAM(3), PARAM(4)); | ||
| 658 | RETURN(retval); | ||
| 659 | } | ||
| 660 | |||
| 661 | template<u32 func(const char *, int, u32, int, u32, int)> void WrapU_CIUIUI() { | ||
| 662 | u32 retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2), | ||
| 663 | PARAM(3), PARAM(4), PARAM(5)); | ||
| 664 | RETURN(retval); | ||
| 665 | } | ||
| 666 | |||
| 667 | template<u32 func(u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUU() { | ||
| 668 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), | ||
| 669 | PARAM(5)); | ||
| 670 | RETURN(retval); | ||
| 671 | } | ||
| 672 | |||
| 673 | template<int func(int, u32, u32, u32)> void WrapI_IUUU() { | ||
| 674 | int retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 675 | RETURN(retval); | ||
| 676 | } | ||
| 677 | |||
| 678 | template<int func(int, u32, u32)> void WrapI_IUU() { | ||
| 679 | int retval = func(PARAM(0), PARAM(1), PARAM(2)); | ||
| 680 | RETURN(retval); | ||
| 681 | } | ||
| 682 | |||
| 683 | template<u32 func(u32, u32, u32, u32, u32, u32, u32)> void WrapU_UUUUUUU() { | ||
| 684 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5), PARAM(6)); | ||
| 685 | RETURN(retval); | ||
| 686 | } | ||
| 687 | |||
| 688 | template<int func(u32, int, u32, u32)> void WrapI_UIUU() { | ||
| 689 | u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)); | ||
| 690 | RETURN(retval); | ||
| 691 | } | ||
| 692 | |||
| 693 | template<int func(int, const char *)> void WrapI_IC() { | ||
| 694 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1))); | ||
| 695 | RETURN(retval); | ||
| 696 | } | ||
| 697 | |||
| 698 | template <int func(int, const char *, const char *, u32, int)> void WrapI_ICCUI() { | ||
| 699 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), PARAM(3), PARAM(4)); | ||
| 700 | RETURN(retval); | ||
| 701 | } | ||
| 702 | |||
| 703 | template <int func(int, const char *, const char *, int)> void WrapI_ICCI() { | ||
| 704 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), Memory::GetCharPointer(PARAM(2)), PARAM(3)); | ||
| 705 | RETURN(retval); | ||
| 706 | } | ||
| 707 | |||
| 708 | template <int func(const char *, int, int)> void WrapI_CII() { | ||
| 709 | int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2)); | ||
| 710 | RETURN(retval); | ||
| 711 | } | ||
| 712 | |||
| 713 | template <int func(int, const char *, int)> void WrapI_ICI() { | ||
| 714 | int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2)); | ||
| 715 | RETURN(retval); | ||
| 716 | } | ||
| 717 | |||
| 718 | template<int func(int, void *, void *, void *, void *, u32, int)> void WrapI_IVVVVUI(){ | ||
| 719 | u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)), Memory::GetPointer(PARAM(2)), Memory::GetPointer(PARAM(3)), Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) ); | ||
| 720 | RETURN(retval); | ||
| 721 | } | ||
| 722 | |||
| 723 | template<int func(int, const char *, u32, void *, int, int, int)> void WrapI_ICUVIII(){ | ||
| 724 | u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)), PARAM(4), PARAM(5), PARAM(6)); | ||
| 725 | RETURN(retval); | ||
| 726 | } | ||
| 727 | |||
| 728 | template<int func(void *, u32, u32, u32, u32, u32)> void WrapI_VUUUUU(){ | ||
| 729 | u32 retval = func(Memory::GetPointer(PARAM(0)), PARAM(1), PARAM(2), PARAM(3), PARAM(4), PARAM(5)); | ||
| 730 | RETURN(retval); | ||
| 731 | } | ||
| 732 | |||
| 733 | template<int func(u32, s64)> void WrapI_US64() { | ||
| 734 | int retval = func(PARAM(0), PARAM64(2)); | ||
| 735 | RETURN(retval); | ||
| 736 | } | ||
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp new file mode 100644 index 000000000..5672a659f --- /dev/null +++ b/src/core/hle/hle.cpp | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | #include "core/mem_map.h" | ||
| 8 | #include "core/hle/hle.h" | ||
| 9 | #include "core/hle/syscall.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 13 | |||
| 14 | namespace HLE { | ||
| 15 | |||
| 16 | static std::vector<ModuleDef> g_module_db; | ||
| 17 | |||
| 18 | u8* g_command_buffer = NULL; ///< Command buffer used for sharing between appcore and syscore | ||
| 19 | |||
| 20 | // Read from memory used by CTROS HLE functions | ||
| 21 | template <typename T> | ||
| 22 | inline 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 | ||
| 31 | template <typename T> | ||
| 32 | inline 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 | u8 *GetPointer(const u32 addr) { | ||
| 41 | if (addr >= HLE::CMD_BUFFER_ADDR && addr < HLE::CMD_BUFFER_ADDR_END) { | ||
| 42 | return g_command_buffer + (addr & CMD_BUFFER_MASK); | ||
| 43 | } else { | ||
| 44 | ERROR_LOG(HLE, "unknown pointer from address %08X", addr); | ||
| 45 | return 0; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 50 | |||
| 51 | template void Read<u64>(u64 &var, const u32 addr); | ||
| 52 | template void Read<u32>(u32 &var, const u32 addr); | ||
| 53 | template void Read<u16>(u16 &var, const u32 addr); | ||
| 54 | template void Read<u8>(u8 &var, const u32 addr); | ||
| 55 | |||
| 56 | template void Write<u64>(u32 addr, const u64 data); | ||
| 57 | template void Write<u32>(u32 addr, const u32 data); | ||
| 58 | template void Write<u16>(u32 addr, const u16 data); | ||
| 59 | template void Write<u8>(u32 addr, const u8 data); | ||
| 60 | |||
| 61 | const FunctionDef* GetSyscallInfo(u32 opcode) { | ||
| 62 | u32 func_num = opcode & 0xFFFFFF; // 8 bits | ||
| 63 | if (func_num > 0xFF) { | ||
| 64 | ERROR_LOG(HLE,"Unknown syscall: 0x%02X", func_num); | ||
| 65 | return NULL; | ||
| 66 | } | ||
| 67 | return &g_module_db[0].func_table[func_num]; | ||
| 68 | } | ||
| 69 | |||
| 70 | void CallSyscall(u32 opcode) { | ||
| 71 | const FunctionDef *info = GetSyscallInfo(opcode); | ||
| 72 | |||
| 73 | if (!info) { | ||
| 74 | return; | ||
| 75 | } | ||
| 76 | if (info->func) { | ||
| 77 | info->func(); | ||
| 78 | } else { | ||
| 79 | ERROR_LOG(HLE, "Unimplemented SysCall function %s(..)", info->name.c_str()); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | /// Returns the coprocessor (in this case, syscore) command buffer pointer | ||
| 84 | Addr CallGetThreadCommandBuffer() { | ||
| 85 | // Called on insruction: mrc p15, 0, r0, c13, c0, 3 | ||
| 86 | // Returns an address in OSHLE memory for the CPU to read/write to | ||
| 87 | RETURN(CMD_BUFFER_ADDR); | ||
| 88 | return CMD_BUFFER_ADDR; | ||
| 89 | } | ||
| 90 | |||
| 91 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { | ||
| 92 | ModuleDef module = {name, num_functions, func_table}; | ||
| 93 | g_module_db.push_back(module); | ||
| 94 | } | ||
| 95 | |||
| 96 | void RegisterAllModules() { | ||
| 97 | Syscall::Register(); | ||
| 98 | } | ||
| 99 | |||
| 100 | void Init() { | ||
| 101 | Service::Init(); | ||
| 102 | |||
| 103 | g_command_buffer = new u8[CMD_BUFFER_SIZE]; | ||
| 104 | |||
| 105 | RegisterAllModules(); | ||
| 106 | |||
| 107 | NOTICE_LOG(HLE, "initialized OK"); | ||
| 108 | } | ||
| 109 | |||
| 110 | void Shutdown() { | ||
| 111 | Service::Shutdown(); | ||
| 112 | |||
| 113 | delete g_command_buffer; | ||
| 114 | |||
| 115 | g_module_db.clear(); | ||
| 116 | |||
| 117 | NOTICE_LOG(HLE, "shutdown OK"); | ||
| 118 | } | ||
| 119 | |||
| 120 | } // namespace | ||
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h new file mode 100644 index 000000000..628a1da89 --- /dev/null +++ b/src/core/hle/hle.h | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/core.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | |||
| 12 | #define PARAM(n) Core::g_app_core->GetReg(n) | ||
| 13 | #define PARAM64(n) (Core::g_app_core->GetReg(n) | ((u64)Core::g_app_core->GetReg(n + 1) << 32)) | ||
| 14 | #define RETURN(n) Core::g_app_core->SetReg(0, n) | ||
| 15 | |||
| 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 17 | |||
| 18 | namespace HLE { | ||
| 19 | |||
| 20 | enum { | ||
| 21 | CMD_BUFFER_ADDR = 0xA0010000, ///< Totally arbitrary unused address space | ||
| 22 | CMD_BUFFER_SIZE = 0x10000, | ||
| 23 | CMD_BUFFER_MASK = (CMD_BUFFER_SIZE - 1), | ||
| 24 | CMD_BUFFER_ADDR_END = (CMD_BUFFER_ADDR + CMD_BUFFER_SIZE), | ||
| 25 | }; | ||
| 26 | |||
| 27 | typedef u32 Addr; | ||
| 28 | typedef void (*Func)(); | ||
| 29 | |||
| 30 | struct FunctionDef { | ||
| 31 | u32 id; | ||
| 32 | Func func; | ||
| 33 | std::string name; | ||
| 34 | }; | ||
| 35 | |||
| 36 | struct ModuleDef { | ||
| 37 | std::string name; | ||
| 38 | int num_funcs; | ||
| 39 | const FunctionDef* func_table; | ||
| 40 | }; | ||
| 41 | |||
| 42 | // Read from memory used by CTROS HLE functions | ||
| 43 | template <typename T> | ||
| 44 | inline void Read(T &var, const u32 addr); | ||
| 45 | |||
| 46 | // Write to memory used by CTROS HLE functions | ||
| 47 | template <typename T> | ||
| 48 | inline void Write(u32 addr, const T data); | ||
| 49 | |||
| 50 | u8* GetPointer(const u32 Address); | ||
| 51 | |||
| 52 | inline const char* GetCharPointer(const u32 address) { | ||
| 53 | return (const char *)GetPointer(address); | ||
| 54 | } | ||
| 55 | |||
| 56 | void RegisterModule(std::string name, int num_functions, const FunctionDef *func_table); | ||
| 57 | |||
| 58 | void CallSyscall(u32 opcode); | ||
| 59 | |||
| 60 | Addr CallGetThreadCommandBuffer(); | ||
| 61 | |||
| 62 | void Init(); | ||
| 63 | |||
| 64 | void Shutdown(); | ||
| 65 | |||
| 66 | } // namespace | ||
diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp new file mode 100644 index 000000000..4f8d7248d --- /dev/null +++ b/src/core/hle/service/apt.cpp | |||
| @@ -0,0 +1,116 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | |||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hle/hle.h" | ||
| 9 | #include "core/hle/service/apt.h" | ||
| 10 | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | // Namespace APT_U | ||
| 13 | |||
| 14 | namespace APT_U { | ||
| 15 | |||
| 16 | void Initialize() { | ||
| 17 | NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); | ||
| 18 | } | ||
| 19 | |||
| 20 | void GetLockHandle() { | ||
| 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | ||
| 22 | cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle | ||
| 23 | } | ||
| 24 | |||
| 25 | const HLE::FunctionDef FunctionTable[] = { | ||
| 26 | {0x00010040, GetLockHandle, "GetLockHandle"}, | ||
| 27 | {0x00020080, Initialize, "Initialize"}, | ||
| 28 | {0x00030040, NULL, "Enable"}, | ||
| 29 | {0x00040040, NULL, "Finalize"}, | ||
| 30 | {0x00050040, NULL, "GetAppletManInfo"}, | ||
| 31 | {0x00060040, NULL, "GetAppletInfo"}, | ||
| 32 | {0x00070000, NULL, "GetLastSignaledAppletId"}, | ||
| 33 | {0x00080000, NULL, "CountRegisteredApplet"}, | ||
| 34 | {0x00090040, NULL, "IsRegistered"}, | ||
| 35 | {0x000A0040, NULL, "GetAttribute"}, | ||
| 36 | {0x000B0040, NULL, "InquireNotification"}, | ||
| 37 | {0x000C0104, NULL, "SendParameter"}, | ||
| 38 | {0x000D0080, NULL, "ReceiveParameter"}, | ||
| 39 | {0x000E0080, NULL, "GlanceParameter"}, | ||
| 40 | {0x000F0100, NULL, "CancelParameter"}, | ||
| 41 | {0x001000C2, NULL, "DebugFunc"}, | ||
| 42 | {0x001100C0, NULL, "MapProgramIdForDebug"}, | ||
| 43 | {0x00120040, NULL, "SetHomeMenuAppletIdForDebug"}, | ||
| 44 | {0x00130000, NULL, "GetPreparationState"}, | ||
| 45 | {0x00140040, NULL, "SetPreparationState"}, | ||
| 46 | {0x00150140, NULL, "PrepareToStartApplication"}, | ||
| 47 | {0x00160040, NULL, "PreloadLibraryApplet"}, | ||
| 48 | {0x00170040, NULL, "FinishPreloadingLibraryApplet"}, | ||
| 49 | {0x00180040, NULL, "PrepareToStartLibraryApplet"}, | ||
| 50 | {0x00190040, NULL, "PrepareToStartSystemApplet"}, | ||
| 51 | {0x001A0000, NULL, "PrepareToStartNewestHomeMenu"}, | ||
| 52 | {0x001B00C4, NULL, "StartApplication"}, | ||
| 53 | {0x001C0000, NULL, "WakeupApplication"}, | ||
| 54 | {0x001D0000, NULL, "CancelApplication"}, | ||
| 55 | {0x001E0084, NULL, "StartLibraryApplet"}, | ||
| 56 | {0x001F0084, NULL, "StartSystemApplet"}, | ||
| 57 | {0x00200044, NULL, "StartNewestHomeMenu"}, | ||
| 58 | {0x00210000, NULL, "OrderToCloseApplication"}, | ||
| 59 | {0x00220040, NULL, "PrepareToCloseApplication"}, | ||
| 60 | {0x00230040, NULL, "PrepareToJumpToApplication"}, | ||
| 61 | {0x00240044, NULL, "JumpToApplication"}, | ||
| 62 | {0x002500C0, NULL, "PrepareToCloseLibraryApplet"}, | ||
| 63 | {0x00260000, NULL, "PrepareToCloseSystemApplet"}, | ||
| 64 | {0x00270044, NULL, "CloseApplication"}, | ||
| 65 | {0x00280044, NULL, "CloseLibraryApplet"}, | ||
| 66 | {0x00290044, NULL, "CloseSystemApplet"}, | ||
| 67 | {0x002A0000, NULL, "OrderToCloseSystemApplet"}, | ||
| 68 | {0x002B0000, NULL, "PrepareToJumpToHomeMenu"}, | ||
| 69 | {0x002C0044, NULL, "JumpToHomeMenu"}, | ||
| 70 | {0x002D0000, NULL, "PrepareToLeaveHomeMenu"}, | ||
| 71 | {0x002E0044, NULL, "LeaveHomeMenu"}, | ||
| 72 | {0x002F0040, NULL, "PrepareToLeaveResidentApplet"}, | ||
| 73 | {0x00300044, NULL, "LeaveResidentApplet"}, | ||
| 74 | {0x00310100, NULL, "PrepareToDoApplicationJump"}, | ||
| 75 | {0x00320084, NULL, "DoApplicationJump"}, | ||
| 76 | {0x00330000, NULL, "GetProgramIdOnApplicationJump"}, | ||
| 77 | {0x00340084, NULL, "SendDeliverArg"}, | ||
| 78 | {0x00350080, NULL, "ReceiveDeliverArg"}, | ||
| 79 | {0x00360040, NULL, "LoadSysMenuArg"}, | ||
| 80 | {0x00370042, NULL, "StoreSysMenuArg"}, | ||
| 81 | {0x00380040, NULL, "PreloadResidentApplet"}, | ||
| 82 | {0x00390040, NULL, "PrepareToStartResidentApplet"}, | ||
| 83 | {0x003A0044, NULL, "StartResidentApplet"}, | ||
| 84 | {0x003B0040, NULL, "CancelLibraryApplet"}, | ||
| 85 | {0x003C0042, NULL, "SendDspSleep"}, | ||
| 86 | {0x003D0042, NULL, "SendDspWakeUp"}, | ||
| 87 | {0x003E0080, NULL, "ReplySleepQuery"}, | ||
| 88 | {0x003F0040, NULL, "ReplySleepNotificationComplete"}, | ||
| 89 | {0x00400042, NULL, "SendCaptureBufferInfo"}, | ||
| 90 | {0x00410040, NULL, "ReceiveCaptureBufferInfo"}, | ||
| 91 | {0x00420080, NULL, "SleepSystem"}, | ||
| 92 | {0x00430040, NULL, "NotifyToWait"}, | ||
| 93 | {0x00440000, NULL, "GetSharedFont"}, | ||
| 94 | {0x00450040, NULL, "GetWirelessRebootInfo"}, | ||
| 95 | {0x00460104, NULL, "Wrap"}, | ||
| 96 | {0x00470104, NULL, "Unwrap"}, | ||
| 97 | {0x00480100, NULL, "GetProgramInfo"}, | ||
| 98 | {0x00490180, NULL, "Reboot"}, | ||
| 99 | {0x004A0040, NULL, "GetCaptureInfo"}, | ||
| 100 | {0x004B00C2, NULL, "AppletUtility"}, | ||
| 101 | {0x004C0000, NULL, "SetFatalErrDispMode"}, | ||
| 102 | {0x004D0080, NULL, "GetAppletProgramInfo"}, | ||
| 103 | {0x004E0000, NULL, "HardwareResetAsync"}, | ||
| 104 | }; | ||
| 105 | |||
| 106 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 107 | // Interface class | ||
| 108 | |||
| 109 | Interface::Interface() { | ||
| 110 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 111 | } | ||
| 112 | |||
| 113 | Interface::~Interface() { | ||
| 114 | } | ||
| 115 | |||
| 116 | } // namespace | ||
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h new file mode 100644 index 000000000..e74baac0c --- /dev/null +++ b/src/core/hle/service/apt.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace APT_U | ||
| 11 | |||
| 12 | namespace APT_U { | ||
| 13 | |||
| 14 | // Application and title launching service. These services handle signaling for home/power button as | ||
| 15 | // well. Only one session for either APT service can be open at a time, normally processes close the | ||
| 16 | // service handle immediately once finished using the service. The commands for APT:U and APT:S are | ||
| 17 | // exactly the same, however certain commands are only accessible with APT:S(NS module will call | ||
| 18 | // svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services. | ||
| 19 | |||
| 20 | /// Interface to "APT:U" service | ||
| 21 | class Interface : public Service::Interface { | ||
| 22 | public: | ||
| 23 | |||
| 24 | Interface(); | ||
| 25 | |||
| 26 | ~Interface(); | ||
| 27 | |||
| 28 | /** | ||
| 29 | * Gets the string port name used by CTROS for the service | ||
| 30 | * @return Port name of service | ||
| 31 | */ | ||
| 32 | std::string GetPortName() const { | ||
| 33 | return "APT:U"; | ||
| 34 | } | ||
| 35 | |||
| 36 | private: | ||
| 37 | |||
| 38 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 39 | }; | ||
| 40 | |||
| 41 | } // namespace | ||
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp new file mode 100644 index 000000000..7c80ab8b5 --- /dev/null +++ b/src/core/hle/service/gsp.cpp | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | |||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hle/hle.h" | ||
| 9 | #include "core/hle/service/gsp.h" | ||
| 10 | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 12 | // Namespace GSP_GPU | ||
| 13 | |||
| 14 | namespace GSP_GPU { | ||
| 15 | |||
| 16 | const HLE::FunctionDef FunctionTable[] = { | ||
| 17 | {0x00010082, NULL, "WriteHWRegs"}, | ||
| 18 | {0x00020084, NULL, "WriteHWRegsWithMask"}, | ||
| 19 | {0x00030082, NULL, "WriteHWRegRepeat"}, | ||
| 20 | {0x00040080, NULL, "ReadHWRegs"}, | ||
| 21 | {0x00050200, NULL, "SetBufferSwap"}, | ||
| 22 | {0x00060082, NULL, "SetCommandList"}, | ||
| 23 | {0x000700C2, NULL, "RequestDma"}, | ||
| 24 | {0x00080082, NULL, "FlushDataCache"}, | ||
| 25 | {0x00090082, NULL, "InvalidateDataCache"}, | ||
| 26 | {0x000A0044, NULL, "RegisterInterruptEvents"}, | ||
| 27 | {0x000B0040, NULL, "SetLcdForceBlack"}, | ||
| 28 | {0x000C0000, NULL, "TriggerCmdReqQueue"}, | ||
| 29 | {0x000D0140, NULL, "SetDisplayTransfer"}, | ||
| 30 | {0x000E0180, NULL, "SetTextureCopy"}, | ||
| 31 | {0x000F0200, NULL, "SetMemoryFill"}, | ||
| 32 | {0x00100040, NULL, "SetAxiConfigQoSMode"}, | ||
| 33 | {0x00110040, NULL, "SetPerfLogMode"}, | ||
| 34 | {0x00120000, NULL, "GetPerfLog"}, | ||
| 35 | {0x00130042, NULL, "RegisterInterruptRelayQueue"}, | ||
| 36 | {0x00140000, NULL, "UnregisterInterruptRelayQueue"}, | ||
| 37 | {0x00150002, NULL, "TryAcquireRight"}, | ||
| 38 | {0x00160042, NULL, "AcquireRight"}, | ||
| 39 | {0x00170000, NULL, "ReleaseRight"}, | ||
| 40 | {0x00180000, NULL, "ImportDisplayCaptureInfo"}, | ||
| 41 | {0x00190000, NULL, "SaveVramSysArea"}, | ||
| 42 | {0x001A0000, NULL, "RestoreVramSysArea"}, | ||
| 43 | {0x001B0000, NULL, "ResetGpuCore"}, | ||
| 44 | {0x001C0040, NULL, "SetLedForceOff"}, | ||
| 45 | {0x001D0040, NULL, "SetTestCommand"}, | ||
| 46 | {0x001E0080, NULL, "SetInternalPriorities"}, | ||
| 47 | }; | ||
| 48 | |||
| 49 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 50 | // Interface class | ||
| 51 | |||
| 52 | Interface::Interface() { | ||
| 53 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 54 | } | ||
| 55 | |||
| 56 | Interface::~Interface() { | ||
| 57 | } | ||
| 58 | |||
| 59 | } // namespace | ||
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h new file mode 100644 index 000000000..3b1846082 --- /dev/null +++ b/src/core/hle/service/gsp.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace GSP_GPU | ||
| 11 | |||
| 12 | namespace GSP_GPU { | ||
| 13 | |||
| 14 | /// Interface to "srv:" service | ||
| 15 | class Interface : public Service::Interface { | ||
| 16 | public: | ||
| 17 | |||
| 18 | Interface(); | ||
| 19 | |||
| 20 | ~Interface(); | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Gets the string port name used by CTROS for the service | ||
| 24 | * @return Port name of service | ||
| 25 | */ | ||
| 26 | std::string GetPortName() const { | ||
| 27 | return "gsp::Gpu"; | ||
| 28 | } | ||
| 29 | |||
| 30 | private: | ||
| 31 | |||
| 32 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 33 | }; | ||
| 34 | |||
| 35 | } // namespace | ||
diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp new file mode 100644 index 000000000..2d823dd16 --- /dev/null +++ b/src/core/hle/service/hid.cpp | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/log.h" | ||
| 6 | |||
| 7 | #include "core/hle/hle.h" | ||
| 8 | #include "core/hle/service/hid.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace HID_User | ||
| 12 | |||
| 13 | namespace HID_User { | ||
| 14 | |||
| 15 | const HLE::FunctionDef FunctionTable[] = { | ||
| 16 | {0x000A0000, NULL, "GetIPCHandles"}, | ||
| 17 | {0x00110000, NULL, "EnableAccelerometer"}, | ||
| 18 | {0x00130000, NULL, "EnableGyroscopeLow"}, | ||
| 19 | {0x00150000, NULL, "GetGyroscopeLowRawToDpsCoefficient"}, | ||
| 20 | {0x00160000, NULL, "GetGyroscopeLowCalibrateParam"}, | ||
| 21 | }; | ||
| 22 | |||
| 23 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 24 | // Interface class | ||
| 25 | |||
| 26 | Interface::Interface() { | ||
| 27 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 28 | } | ||
| 29 | |||
| 30 | Interface::~Interface() { | ||
| 31 | } | ||
| 32 | |||
| 33 | } // namespace | ||
diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h new file mode 100644 index 000000000..746c1b1fc --- /dev/null +++ b/src/core/hle/service/hid.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace HID_User | ||
| 11 | |||
| 12 | // This service is used for interfacing to physical user controls... perhaps "Human Interface | ||
| 13 | // Devices"? Uses include game pad controls, accelerometers, gyroscopes, etc. | ||
| 14 | |||
| 15 | namespace HID_User { | ||
| 16 | |||
| 17 | class Interface : public Service::Interface { | ||
| 18 | public: | ||
| 19 | |||
| 20 | Interface(); | ||
| 21 | |||
| 22 | ~Interface(); | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Gets the string port name used by CTROS for the service | ||
| 26 | * @return Port name of service | ||
| 27 | */ | ||
| 28 | std::string GetPortName() const { | ||
| 29 | return "hid:USER"; | ||
| 30 | } | ||
| 31 | |||
| 32 | private: | ||
| 33 | |||
| 34 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 35 | }; | ||
| 36 | |||
| 37 | } // namespace | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp new file mode 100644 index 000000000..e6605a398 --- /dev/null +++ b/src/core/hle/service/service.cpp | |||
| @@ -0,0 +1,94 @@ | |||
| 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 | #include "common/string_util.h" | ||
| 8 | |||
| 9 | #include "core/hle/hle.h" | ||
| 10 | #include "core/hle/service/service.h" | ||
| 11 | #include "core/hle/service/apt.h" | ||
| 12 | #include "core/hle/service/gsp.h" | ||
| 13 | #include "core/hle/service/hid.h" | ||
| 14 | #include "core/hle/service/srv.h" | ||
| 15 | |||
| 16 | namespace Service { | ||
| 17 | |||
| 18 | Manager* g_manager = NULL; ///< Service manager | ||
| 19 | |||
| 20 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 21 | // Service Manager class | ||
| 22 | |||
| 23 | Manager::Manager() { | ||
| 24 | } | ||
| 25 | |||
| 26 | Manager::~Manager() { | ||
| 27 | for(Interface* service : m_services) { | ||
| 28 | DeleteService(service->GetPortName()); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | /// Add a service to the manager (does not create it though) | ||
| 33 | void Manager::AddService(Interface* service) { | ||
| 34 | int index = m_services.size(); | ||
| 35 | u32 new_uid = GetUIDFromIndex(index); | ||
| 36 | |||
| 37 | m_services.push_back(service); | ||
| 38 | |||
| 39 | m_port_map[service->GetPortName()] = new_uid; | ||
| 40 | service->m_uid = new_uid; | ||
| 41 | } | ||
| 42 | |||
| 43 | /// Removes a service from the manager, also frees memory | ||
| 44 | void Manager::DeleteService(std::string port_name) { | ||
| 45 | auto service = FetchFromPortName(port_name); | ||
| 46 | |||
| 47 | m_services.erase(m_services.begin() + GetIndexFromUID(service->m_uid)); | ||
| 48 | m_port_map.erase(port_name); | ||
| 49 | |||
| 50 | delete service; | ||
| 51 | } | ||
| 52 | |||
| 53 | /// Get a Service Interface from its UID | ||
| 54 | Interface* Manager::FetchFromUID(u32 uid) { | ||
| 55 | int index = GetIndexFromUID(uid); | ||
| 56 | if (index < (int)m_services.size()) { | ||
| 57 | return m_services[index]; | ||
| 58 | } | ||
| 59 | return NULL; | ||
| 60 | } | ||
| 61 | |||
| 62 | /// Get a Service Interface from its port | ||
| 63 | Interface* Manager::FetchFromPortName(std::string port_name) { | ||
| 64 | auto itr = m_port_map.find(port_name); | ||
| 65 | if (itr == m_port_map.end()) { | ||
| 66 | return NULL; | ||
| 67 | } | ||
| 68 | return FetchFromUID(itr->second); | ||
| 69 | } | ||
| 70 | |||
| 71 | |||
| 72 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 73 | // Module interface | ||
| 74 | |||
| 75 | /// Initialize ServiceManager | ||
| 76 | void Init() { | ||
| 77 | g_manager = new Manager; | ||
| 78 | |||
| 79 | g_manager->AddService(new SRV::Interface); | ||
| 80 | g_manager->AddService(new APT_U::Interface); | ||
| 81 | g_manager->AddService(new GSP_GPU::Interface); | ||
| 82 | g_manager->AddService(new HID_User::Interface); | ||
| 83 | |||
| 84 | NOTICE_LOG(HLE, "Services initialized OK"); | ||
| 85 | } | ||
| 86 | |||
| 87 | /// Shutdown ServiceManager | ||
| 88 | void Shutdown() { | ||
| 89 | delete g_manager; | ||
| 90 | NOTICE_LOG(HLE, "Services shutdown OK"); | ||
| 91 | } | ||
| 92 | |||
| 93 | |||
| 94 | } | ||
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h new file mode 100644 index 000000000..9cbf8b6fa --- /dev/null +++ b/src/core/hle/service/service.h | |||
| @@ -0,0 +1,143 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <vector> | ||
| 8 | #include <map> | ||
| 9 | #include <string> | ||
| 10 | |||
| 11 | #include "common/common.h" | ||
| 12 | #include "common/common_types.h" | ||
| 13 | #include "core/hle/syscall.h" | ||
| 14 | |||
| 15 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 16 | // Namespace Service | ||
| 17 | |||
| 18 | namespace Service { | ||
| 19 | |||
| 20 | typedef s32 NativeUID; ///< Native handle for a service | ||
| 21 | |||
| 22 | static const int kMaxPortSize = 0x08; ///< Maximum size of a port name (8 characters) | ||
| 23 | static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header | ||
| 24 | |||
| 25 | class Manager; | ||
| 26 | |||
| 27 | /// Interface to a CTROS service | ||
| 28 | class Interface { | ||
| 29 | friend class Manager; | ||
| 30 | public: | ||
| 31 | |||
| 32 | Interface() { | ||
| 33 | } | ||
| 34 | |||
| 35 | virtual ~Interface() { | ||
| 36 | } | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Gets the UID for the serice | ||
| 40 | * @return UID of service in native format | ||
| 41 | */ | ||
| 42 | NativeUID GetUID() const { | ||
| 43 | return (NativeUID)m_uid; | ||
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Gets the string name used by CTROS for a service | ||
| 48 | * @return Port name of service | ||
| 49 | */ | ||
| 50 | virtual std::string GetPortName() const { | ||
| 51 | return "[UNKNOWN SERVICE PORT]"; | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 56 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 57 | */ | ||
| 58 | Syscall::Result Sync() { | ||
| 59 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + kCommandHeaderOffset); | ||
| 60 | auto itr = m_functions.find(cmd_buff[0]); | ||
| 61 | |||
| 62 | if (itr == m_functions.end()) { | ||
| 63 | ERROR_LOG(OSHLE, "Unknown/unimplemented function: port = %s, command = 0x%08X!", | ||
| 64 | GetPortName().c_str(), cmd_buff[0]); | ||
| 65 | return -1; | ||
| 66 | } | ||
| 67 | if (itr->second.func == NULL) { | ||
| 68 | ERROR_LOG(OSHLE, "Unimplemented function: port = %s, name = %s!", | ||
| 69 | GetPortName().c_str(), itr->second.name.c_str()); | ||
| 70 | return -1; | ||
| 71 | } | ||
| 72 | |||
| 73 | itr->second.func(); | ||
| 74 | |||
| 75 | return 0; // TODO: Implement return from actual function | ||
| 76 | } | ||
| 77 | |||
| 78 | protected: | ||
| 79 | /** | ||
| 80 | * Registers the functions in the service | ||
| 81 | */ | ||
| 82 | void Register(const HLE::FunctionDef* functions, int len) { | ||
| 83 | for (int i = 0; i < len; i++) { | ||
| 84 | m_functions[functions[i].id] = functions[i]; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | private: | ||
| 89 | u32 m_uid; | ||
| 90 | std::map<u32, HLE::FunctionDef> m_functions; | ||
| 91 | |||
| 92 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 93 | }; | ||
| 94 | |||
| 95 | /// Simple class to manage accessing services from ports and UID handles | ||
| 96 | class Manager { | ||
| 97 | |||
| 98 | public: | ||
| 99 | Manager(); | ||
| 100 | |||
| 101 | ~Manager(); | ||
| 102 | |||
| 103 | /// Add a service to the manager (does not create it though) | ||
| 104 | void AddService(Interface* service); | ||
| 105 | |||
| 106 | /// Removes a service from the manager (does not delete it though) | ||
| 107 | void DeleteService(std::string port_name); | ||
| 108 | |||
| 109 | /// Get a Service Interface from its UID | ||
| 110 | Interface* FetchFromUID(u32 uid); | ||
| 111 | |||
| 112 | /// Get a Service Interface from its port | ||
| 113 | Interface* FetchFromPortName(std::string port_name); | ||
| 114 | |||
| 115 | private: | ||
| 116 | |||
| 117 | /// Convert an index into m_services vector into a UID | ||
| 118 | static u32 GetUIDFromIndex(const int index) { | ||
| 119 | return index | 0x10000000; | ||
| 120 | } | ||
| 121 | |||
| 122 | /// Convert a UID into an index into m_services | ||
| 123 | static int GetIndexFromUID(const u32 uid) { | ||
| 124 | return uid & 0x0FFFFFFF; | ||
| 125 | } | ||
| 126 | |||
| 127 | std::vector<Interface*> m_services; | ||
| 128 | std::map<std::string, u32> m_port_map; | ||
| 129 | |||
| 130 | DISALLOW_COPY_AND_ASSIGN(Manager); | ||
| 131 | }; | ||
| 132 | |||
| 133 | /// Initialize ServiceManager | ||
| 134 | void Init(); | ||
| 135 | |||
| 136 | /// Shutdown ServiceManager | ||
| 137 | void Shutdown(); | ||
| 138 | |||
| 139 | |||
| 140 | extern Manager* g_manager; ///< Service manager | ||
| 141 | |||
| 142 | |||
| 143 | } // namespace | ||
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp new file mode 100644 index 000000000..579ea4a34 --- /dev/null +++ b/src/core/hle/service/srv.cpp | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/hle.h" | ||
| 6 | #include "core/hle/service/srv.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // Namespace SRV | ||
| 12 | |||
| 13 | namespace SRV { | ||
| 14 | |||
| 15 | void Initialize() { | ||
| 16 | NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); | ||
| 17 | } | ||
| 18 | |||
| 19 | void GetServiceHandle() { | ||
| 20 | Syscall::Result res = 0; | ||
| 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | ||
| 22 | |||
| 23 | std::string port_name = std::string((const char*)&cmd_buff[1], 0, Service::kMaxPortSize); | ||
| 24 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | ||
| 25 | |||
| 26 | NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name.c_str(), | ||
| 27 | service->GetUID()); | ||
| 28 | |||
| 29 | if (NULL != service) { | ||
| 30 | cmd_buff[3] = service->GetUID(); | ||
| 31 | } else { | ||
| 32 | ERROR_LOG(OSHLE, "Service %s does not exist", port_name.c_str()); | ||
| 33 | res = -1; | ||
| 34 | } | ||
| 35 | cmd_buff[1] = res; | ||
| 36 | |||
| 37 | //return res; | ||
| 38 | } | ||
| 39 | |||
| 40 | const HLE::FunctionDef FunctionTable[] = { | ||
| 41 | {0x00010002, Initialize, "Initialize"}, | ||
| 42 | {0x00020000, NULL, "GetProcSemaphore"}, | ||
| 43 | {0x00030100, NULL, "RegisterService"}, | ||
| 44 | {0x000400C0, NULL, "UnregisterService"}, | ||
| 45 | {0x00050100, GetServiceHandle, "GetServiceHandle"}, | ||
| 46 | }; | ||
| 47 | |||
| 48 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 49 | // Interface class | ||
| 50 | |||
| 51 | Interface::Interface() { | ||
| 52 | Register(FunctionTable, ARRAY_SIZE(FunctionTable)); | ||
| 53 | } | ||
| 54 | |||
| 55 | Interface::~Interface() { | ||
| 56 | } | ||
| 57 | |||
| 58 | } // namespace | ||
diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h new file mode 100644 index 000000000..d9ac8fc88 --- /dev/null +++ b/src/core/hle/service/srv.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/service/service.h" | ||
| 6 | |||
| 7 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 8 | // Namespace SRV | ||
| 9 | |||
| 10 | namespace SRV { | ||
| 11 | |||
| 12 | /// Interface to "srv:" service | ||
| 13 | class Interface : public Service::Interface { | ||
| 14 | |||
| 15 | public: | ||
| 16 | |||
| 17 | Interface(); | ||
| 18 | |||
| 19 | ~Interface(); | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Gets the string name used by CTROS for the service | ||
| 23 | * @return Port name of service | ||
| 24 | */ | ||
| 25 | std::string GetPortName() const { | ||
| 26 | return "srv:"; | ||
| 27 | } | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | ||
| 31 | * @return Return result of svcSendSyncRequest passed back to user app | ||
| 32 | */ | ||
| 33 | Syscall::Result Sync(); | ||
| 34 | |||
| 35 | private: | ||
| 36 | |||
| 37 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 38 | }; | ||
| 39 | |||
| 40 | } // namespace | ||
diff --git a/src/core/hle/syscall.cpp b/src/core/hle/syscall.cpp new file mode 100644 index 000000000..e5533a741 --- /dev/null +++ b/src/core/hle/syscall.cpp | |||
| @@ -0,0 +1,197 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <map> | ||
| 6 | |||
| 7 | #include "core/mem_map.h" | ||
| 8 | |||
| 9 | #include "core/hle/function_wrappers.h" | ||
| 10 | #include "core/hle/syscall.h" | ||
| 11 | #include "core/hle/service/service.h" | ||
| 12 | |||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 14 | // Namespace Syscall | ||
| 15 | |||
| 16 | namespace Syscall { | ||
| 17 | |||
| 18 | /// Map application or GSP heap memory | ||
| 19 | Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions) { | ||
| 20 | u32 virtual_address = 0x00000000; | ||
| 21 | |||
| 22 | switch (operation) { | ||
| 23 | |||
| 24 | // Map GSP heap memory? | ||
| 25 | case 0x00010003: | ||
| 26 | virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); | ||
| 27 | break; | ||
| 28 | |||
| 29 | // Unknown ControlMemory operation | ||
| 30 | default: | ||
| 31 | ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation); | ||
| 32 | } | ||
| 33 | |||
| 34 | Core::g_app_core->SetReg(1, Memory::MapBlock_HeapGSP(size, operation, permissions)); | ||
| 35 | return 0; | ||
| 36 | } | ||
| 37 | |||
| 38 | /// Connect to an OS service given the port name, returns the handle to the port to out | ||
| 39 | Result ConnectToPort(void* out, const char* port_name) { | ||
| 40 | Service::Interface* service = Service::g_manager->FetchFromPortName(port_name); | ||
| 41 | Core::g_app_core->SetReg(1, service->GetUID()); | ||
| 42 | return 0; | ||
| 43 | } | ||
| 44 | |||
| 45 | /// Synchronize to an OS service | ||
| 46 | Result SendSyncRequest(Handle session) { | ||
| 47 | Service::Interface* service = Service::g_manager->FetchFromUID(session); | ||
| 48 | service->Sync(); | ||
| 49 | return 0; | ||
| 50 | } | ||
| 51 | |||
| 52 | /// Close a handle | ||
| 53 | Result CloseHandle(Handle handle) { | ||
| 54 | // ImplementMe | ||
| 55 | return 0; | ||
| 56 | } | ||
| 57 | |||
| 58 | /// Wait for a handle to synchronize, timeout after the specified nanoseconds | ||
| 59 | Result WaitSynchronization1(Handle handle, s64 nanoseconds) { | ||
| 60 | // ImplementMe | ||
| 61 | return 0; | ||
| 62 | } | ||
| 63 | |||
| 64 | const HLE::FunctionDef Syscall_Table[] = { | ||
| 65 | {0x00, NULL, "Unknown"}, | ||
| 66 | {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, | ||
| 67 | {0x02, NULL, "QueryMemory"}, | ||
| 68 | {0x03, NULL, "ExitProcess"}, | ||
| 69 | {0x04, NULL, "GetProcessAffinityMask"}, | ||
| 70 | {0x05, NULL, "SetProcessAffinityMask"}, | ||
| 71 | {0x06, NULL, "GetProcessIdealProcessor"}, | ||
| 72 | {0x07, NULL, "SetProcessIdealProcessor"}, | ||
| 73 | {0x08, NULL, "CreateThread"}, | ||
| 74 | {0x09, NULL, "ExitThread"}, | ||
| 75 | {0x0A, NULL, "SleepThread"}, | ||
| 76 | {0x0B, NULL, "GetThreadPriority"}, | ||
| 77 | {0x0C, NULL, "SetThreadPriority"}, | ||
| 78 | {0x0D, NULL, "GetThreadAffinityMask"}, | ||
| 79 | {0x0E, NULL, "SetThreadAffinityMask"}, | ||
| 80 | {0x0F, NULL, "GetThreadIdealProcessor"}, | ||
| 81 | {0x10, NULL, "SetThreadIdealProcessor"}, | ||
| 82 | {0x11, NULL, "GetCurrentProcessorNumber"}, | ||
| 83 | {0x12, NULL, "Run"}, | ||
| 84 | {0x13, NULL, "CreateMutex"}, | ||
| 85 | {0x14, NULL, "ReleaseMutex"}, | ||
| 86 | {0x15, NULL, "CreateSemaphore"}, | ||
| 87 | {0x16, NULL, "ReleaseSemaphore"}, | ||
| 88 | {0x17, NULL, "CreateEvent"}, | ||
| 89 | {0x18, NULL, "SignalEvent"}, | ||
| 90 | {0x19, NULL, "ClearEvent"}, | ||
| 91 | {0x1A, NULL, "CreateTimer"}, | ||
| 92 | {0x1B, NULL, "SetTimer"}, | ||
| 93 | {0x1C, NULL, "CancelTimer"}, | ||
| 94 | {0x1D, NULL, "ClearTimer"}, | ||
| 95 | {0x1E, NULL, "CreateMemoryBlock"}, | ||
| 96 | {0x1F, NULL, "MapMemoryBlock"}, | ||
| 97 | {0x20, NULL, "UnmapMemoryBlock"}, | ||
| 98 | {0x21, NULL, "CreateAddressArbiter"}, | ||
| 99 | {0x22, NULL, "ArbitrateAddress"}, | ||
| 100 | {0x23, WrapI_U<CloseHandle>, "CloseHandle"}, | ||
| 101 | {0x24, WrapI_US64<WaitSynchronization1>, "WaitSynchronization1"}, | ||
| 102 | {0x25, NULL, "WaitSynchronizationN"}, | ||
| 103 | {0x26, NULL, "SignalAndWait"}, | ||
| 104 | {0x27, NULL, "DuplicateHandle"}, | ||
| 105 | {0x28, NULL, "GetSystemTick"}, | ||
| 106 | {0x29, NULL, "GetHandleInfo"}, | ||
| 107 | {0x2A, NULL, "GetSystemInfo"}, | ||
| 108 | {0x2B, NULL, "GetProcessInfo"}, | ||
| 109 | {0x2C, NULL, "GetThreadInfo"}, | ||
| 110 | {0x2D, WrapI_VC<ConnectToPort>, "ConnectToPort"}, | ||
| 111 | {0x2E, NULL, "SendSyncRequest1"}, | ||
| 112 | {0x2F, NULL, "SendSyncRequest2"}, | ||
| 113 | {0x30, NULL, "SendSyncRequest3"}, | ||
| 114 | {0x31, NULL, "SendSyncRequest4"}, | ||
| 115 | {0x32, WrapI_U<SendSyncRequest>, "SendSyncRequest"}, | ||
| 116 | {0x33, NULL, "OpenProcess"}, | ||
| 117 | {0x34, NULL, "OpenThread"}, | ||
| 118 | {0x35, NULL, "GetProcessId"}, | ||
| 119 | {0x36, NULL, "GetProcessIdOfThread"}, | ||
| 120 | {0x37, NULL, "GetThreadId"}, | ||
| 121 | {0x38, NULL, "GetResourceLimit"}, | ||
| 122 | {0x39, NULL, "GetResourceLimitLimitValues"}, | ||
| 123 | {0x3A, NULL, "GetResourceLimitCurrentValues"}, | ||
| 124 | {0x3B, NULL, "GetThreadContext"}, | ||
| 125 | {0x3C, NULL, "Break"}, | ||
| 126 | {0x3D, NULL, "OutputDebugString"}, | ||
| 127 | {0x3E, NULL, "ControlPerformanceCounter"}, | ||
| 128 | {0x3F, NULL, "Unknown"}, | ||
| 129 | {0x40, NULL, "Unknown"}, | ||
| 130 | {0x41, NULL, "Unknown"}, | ||
| 131 | {0x42, NULL, "Unknown"}, | ||
| 132 | {0x43, NULL, "Unknown"}, | ||
| 133 | {0x44, NULL, "Unknown"}, | ||
| 134 | {0x45, NULL, "Unknown"}, | ||
| 135 | {0x46, NULL, "Unknown"}, | ||
| 136 | {0x47, NULL, "CreatePort"}, | ||
| 137 | {0x48, NULL, "CreateSessionToPort"}, | ||
| 138 | {0x49, NULL, "CreateSession"}, | ||
| 139 | {0x4A, NULL, "AcceptSession"}, | ||
| 140 | {0x4B, NULL, "ReplyAndReceive1"}, | ||
| 141 | {0x4C, NULL, "ReplyAndReceive2"}, | ||
| 142 | {0x4D, NULL, "ReplyAndReceive3"}, | ||
| 143 | {0x4E, NULL, "ReplyAndReceive4"}, | ||
| 144 | {0x4F, NULL, "ReplyAndReceive"}, | ||
| 145 | {0x50, NULL, "BindInterrupt"}, | ||
| 146 | {0x51, NULL, "UnbindInterrupt"}, | ||
| 147 | {0x52, NULL, "InvalidateProcessDataCache"}, | ||
| 148 | {0x53, NULL, "StoreProcessDataCache"}, | ||
| 149 | {0x54, NULL, "FlushProcessDataCache"}, | ||
| 150 | {0x55, NULL, "StartInterProcessDma"}, | ||
| 151 | {0x56, NULL, "StopDma"}, | ||
| 152 | {0x57, NULL, "GetDmaState"}, | ||
| 153 | {0x58, NULL, "RestartDma"}, | ||
| 154 | {0x59, NULL, "Unknown"}, | ||
| 155 | {0x5A, NULL, "Unknown"}, | ||
| 156 | {0x5B, NULL, "Unknown"}, | ||
| 157 | {0x5C, NULL, "Unknown"}, | ||
| 158 | {0x5D, NULL, "Unknown"}, | ||
| 159 | {0x5E, NULL, "Unknown"}, | ||
| 160 | {0x5F, NULL, "Unknown"}, | ||
| 161 | {0x60, NULL, "DebugActiveProcess"}, | ||
| 162 | {0x61, NULL, "BreakDebugProcess"}, | ||
| 163 | {0x62, NULL, "TerminateDebugProcess"}, | ||
| 164 | {0x63, NULL, "GetProcessDebugEvent"}, | ||
| 165 | {0x64, NULL, "ContinueDebugEvent"}, | ||
| 166 | {0x65, NULL, "GetProcessList"}, | ||
| 167 | {0x66, NULL, "GetThreadList"}, | ||
| 168 | {0x67, NULL, "GetDebugThreadContext"}, | ||
| 169 | {0x68, NULL, "SetDebugThreadContext"}, | ||
| 170 | {0x69, NULL, "QueryDebugProcessMemory"}, | ||
| 171 | {0x6A, NULL, "ReadProcessMemory"}, | ||
| 172 | {0x6B, NULL, "WriteProcessMemory"}, | ||
| 173 | {0x6C, NULL, "SetHardwareBreakPoint"}, | ||
| 174 | {0x6D, NULL, "GetDebugThreadParam"}, | ||
| 175 | {0x6E, NULL, "Unknown"}, | ||
| 176 | {0x6F, NULL, "Unknown"}, | ||
| 177 | {0x70, NULL, "ControlProcessMemory"}, | ||
| 178 | {0x71, NULL, "MapProcessMemory"}, | ||
| 179 | {0x72, NULL, "UnmapProcessMemory"}, | ||
| 180 | {0x73, NULL, "Unknown"}, | ||
| 181 | {0x74, NULL, "Unknown"}, | ||
| 182 | {0x75, NULL, "Unknown"}, | ||
| 183 | {0x76, NULL, "TerminateProcess"}, | ||
| 184 | {0x77, NULL, "Unknown"}, | ||
| 185 | {0x78, NULL, "CreateResourceLimit"}, | ||
| 186 | {0x79, NULL, "Unknown"}, | ||
| 187 | {0x7A, NULL, "Unknown"}, | ||
| 188 | {0x7B, NULL, "Unknown"}, | ||
| 189 | {0x7C, NULL, "KernelSetState"}, | ||
| 190 | {0x7D, NULL, "QueryProcessMemory"}, | ||
| 191 | }; | ||
| 192 | |||
| 193 | void Register() { | ||
| 194 | HLE::RegisterModule("SyscallTable", ARRAY_SIZE(Syscall_Table), Syscall_Table); | ||
| 195 | } | ||
| 196 | |||
| 197 | } // namespace | ||
diff --git a/src/core/hle/syscall.h b/src/core/hle/syscall.h new file mode 100644 index 000000000..7a94e0136 --- /dev/null +++ b/src/core/hle/syscall.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 10 | // Namespace Syscall | ||
| 11 | |||
| 12 | namespace Syscall { | ||
| 13 | |||
| 14 | typedef u32 Handle; | ||
| 15 | typedef s32 Result; | ||
| 16 | |||
| 17 | void Register(); | ||
| 18 | |||
| 19 | } // namespace | ||
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp index 44625e3af..16bd70125 100644 --- a/src/core/hw/hw.cpp +++ b/src/core/hw/hw.cpp | |||
| @@ -6,18 +6,73 @@ | |||
| 6 | #include "common/log.h" | 6 | #include "common/log.h" |
| 7 | 7 | ||
| 8 | #include "core/hw/hw.h" | 8 | #include "core/hw/hw.h" |
| 9 | #include "core/hw/hw_lcd.h" | 9 | #include "core/hw/lcd.h" |
| 10 | #include "core/hw/ndma.h" | ||
| 10 | 11 | ||
| 11 | namespace HW { | 12 | namespace HW { |
| 12 | 13 | ||
| 14 | enum { | ||
| 15 | ADDRESS_CONFIG = 0x10000000, | ||
| 16 | ADDRESS_IRQ = 0x10001000, | ||
| 17 | ADDRESS_NDMA = 0x10002000, | ||
| 18 | ADDRESS_TIMER = 0x10003000, | ||
| 19 | ADDRESS_CTRCARD = 0x10004000, | ||
| 20 | ADDRESS_CTRCARD_2 = 0x10005000, | ||
| 21 | ADDRESS_SDMC_NAND = 0x10006000, | ||
| 22 | ADDRESS_SDMC_NAND_2 = 0x10007000, // Apparently not used on retail | ||
| 23 | ADDRESS_PXI = 0x10008000, | ||
| 24 | ADDRESS_AES = 0x10009000, | ||
| 25 | ADDRESS_SHA = 0x1000A000, | ||
| 26 | ADDRESS_RSA = 0x1000B000, | ||
| 27 | ADDRESS_XDMA = 0x1000C000, | ||
| 28 | ADDRESS_SPICARD = 0x1000D800, | ||
| 29 | ADDRESS_CONFIG_2 = 0x10010000, | ||
| 30 | ADDRESS_HASH = 0x10101000, | ||
| 31 | ADDRESS_CSND = 0x10103000, | ||
| 32 | ADDRESS_DSP = 0x10140000, | ||
| 33 | ADDRESS_PDN = 0x10141000, | ||
| 34 | ADDRESS_CODEC = 0x10141000, | ||
| 35 | ADDRESS_SPI = 0x10142000, | ||
| 36 | ADDRESS_SPI_2 = 0x10143000, | ||
| 37 | ADDRESS_I2C = 0x10144000, | ||
| 38 | ADDRESS_CODEC_2 = 0x10145000, | ||
| 39 | ADDRESS_HID = 0x10146000, | ||
| 40 | ADDRESS_PAD = 0x10146000, | ||
| 41 | ADDRESS_PTM = 0x10146000, | ||
| 42 | ADDRESS_I2C_2 = 0x10148000, | ||
| 43 | ADDRESS_SPI_3 = 0x10160000, | ||
| 44 | ADDRESS_I2C_3 = 0x10161000, | ||
| 45 | ADDRESS_MIC = 0x10162000, | ||
| 46 | ADDRESS_PXI_2 = 0x10163000, | ||
| 47 | ADDRESS_NTRCARD = 0x10164000, | ||
| 48 | ADDRESS_DSP_2 = 0x10203000, | ||
| 49 | ADDRESS_HASH_2 = 0x10301000, | ||
| 50 | }; | ||
| 51 | |||
| 13 | template <typename T> | 52 | template <typename T> |
| 14 | inline void Read(T &var, const u32 addr) { | 53 | inline void Read(T &var, const u32 addr) { |
| 15 | NOTICE_LOG(HW, "Hardware read from address %08X", addr); | 54 | switch (addr & 0xFFFFF000) { |
| 55 | |||
| 56 | case ADDRESS_NDMA: | ||
| 57 | NDMA::Read(var, addr); | ||
| 58 | break; | ||
| 59 | |||
| 60 | default: | ||
| 61 | ERROR_LOG(HW, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); | ||
| 62 | } | ||
| 16 | } | 63 | } |
| 17 | 64 | ||
| 18 | template <typename T> | 65 | template <typename T> |
| 19 | inline void Write(u32 addr, const T data) { | 66 | inline void Write(u32 addr, const T data) { |
| 20 | NOTICE_LOG(HW, "Hardware write to address %08X", addr); | 67 | switch (addr & 0xFFFFF000) { |
| 68 | |||
| 69 | case ADDRESS_NDMA: | ||
| 70 | NDMA::Write(addr, data); | ||
| 71 | break; | ||
| 72 | |||
| 73 | default: | ||
| 74 | ERROR_LOG(HW, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); | ||
| 75 | } | ||
| 21 | } | 76 | } |
| 22 | 77 | ||
| 23 | // Explicitly instantiate template functions because we aren't defining this in the header: | 78 | // Explicitly instantiate template functions because we aren't defining this in the header: |
| @@ -27,25 +82,27 @@ template void Read<u32>(u32 &var, const u32 addr); | |||
| 27 | template void Read<u16>(u16 &var, const u32 addr); | 82 | template void Read<u16>(u16 &var, const u32 addr); |
| 28 | template void Read<u8>(u8 &var, const u32 addr); | 83 | template void Read<u8>(u8 &var, const u32 addr); |
| 29 | 84 | ||
| 30 | template void Write<const u64>(u32 addr, const u64 data); | 85 | template void Write<u64>(u32 addr, const u64 data); |
| 31 | template void Write<const u32>(u32 addr, const u32 data); | 86 | template void Write<u32>(u32 addr, const u32 data); |
| 32 | template void Write<const u16>(u32 addr, const u16 data); | 87 | template void Write<u16>(u32 addr, const u16 data); |
| 33 | template void Write<const u8>(u32 addr, const u8 data); | 88 | template void Write<u8>(u32 addr, const u8 data); |
| 34 | 89 | ||
| 35 | /// Update hardware | 90 | /// Update hardware |
| 36 | void Update() { | 91 | void Update() { |
| 37 | LCD::Update(); | 92 | LCD::Update(); |
| 93 | NDMA::Update(); | ||
| 38 | } | 94 | } |
| 39 | 95 | ||
| 40 | /// Initialize hardware | 96 | /// Initialize hardware |
| 41 | void Init() { | 97 | void Init() { |
| 42 | LCD::Init(); | 98 | LCD::Init(); |
| 43 | NOTICE_LOG(HW, "Hardware initialized OK"); | 99 | NDMA::Init(); |
| 100 | NOTICE_LOG(HW, "initialized OK"); | ||
| 44 | } | 101 | } |
| 45 | 102 | ||
| 46 | /// Shutdown hardware | 103 | /// Shutdown hardware |
| 47 | void Shutdown() { | 104 | void Shutdown() { |
| 48 | NOTICE_LOG(HW, "Hardware shutdown OK"); | 105 | NOTICE_LOG(HW, "shutdown OK"); |
| 49 | } | 106 | } |
| 50 | 107 | ||
| 51 | } \ No newline at end of file | 108 | } \ No newline at end of file |
diff --git a/src/core/hw/hw_lcd.cpp b/src/core/hw/lcd.cpp index fd783a84a..3013673f8 100644 --- a/src/core/hw/hw_lcd.cpp +++ b/src/core/hw/lcd.cpp | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "common/log.h" | 6 | #include "common/log.h" |
| 7 | 7 | ||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hw/hw_lcd.h" | 9 | #include "core/hw/lcd.h" |
| 10 | 10 | ||
| 11 | #include "video_core/video_core.h" | 11 | #include "video_core/video_core.h" |
| 12 | 12 | ||
| @@ -37,12 +37,12 @@ void Update() { | |||
| 37 | /// Initialize hardware | 37 | /// Initialize hardware |
| 38 | void Init() { | 38 | void Init() { |
| 39 | g_last_ticks = Core::g_app_core->GetTicks(); | 39 | g_last_ticks = Core::g_app_core->GetTicks(); |
| 40 | NOTICE_LOG(LCD, "LCD initialized OK"); | 40 | NOTICE_LOG(LCD, "initialized OK"); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | /// Shutdown hardware | 43 | /// Shutdown hardware |
| 44 | void Shutdown() { | 44 | void Shutdown() { |
| 45 | NOTICE_LOG(LCD, "LCD shutdown OK"); | 45 | NOTICE_LOG(LCD, "shutdown OK"); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | } // namespace | 48 | } // namespace |
diff --git a/src/core/hw/hw_lcd.h b/src/core/hw/lcd.h index 386ed6004..386ed6004 100644 --- a/src/core/hw/hw_lcd.h +++ b/src/core/hw/lcd.h | |||
diff --git a/src/core/hw/ndma.cpp b/src/core/hw/ndma.cpp new file mode 100644 index 000000000..52e459ebd --- /dev/null +++ b/src/core/hw/ndma.cpp | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "common/log.h" | ||
| 7 | |||
| 8 | #include "core/hw/ndma.h" | ||
| 9 | |||
| 10 | namespace NDMA { | ||
| 11 | |||
| 12 | template <typename T> | ||
| 13 | inline void Read(T &var, const u32 addr) { | ||
| 14 | ERROR_LOG(NDMA, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); | ||
| 15 | } | ||
| 16 | |||
| 17 | template <typename T> | ||
| 18 | inline void Write(u32 addr, const T data) { | ||
| 19 | ERROR_LOG(NDMA, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); | ||
| 20 | } | ||
| 21 | |||
| 22 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 23 | |||
| 24 | template void Read<u64>(u64 &var, const u32 addr); | ||
| 25 | template void Read<u32>(u32 &var, const u32 addr); | ||
| 26 | template void Read<u16>(u16 &var, const u32 addr); | ||
| 27 | template void Read<u8>(u8 &var, const u32 addr); | ||
| 28 | |||
| 29 | template void Write<u64>(u32 addr, const u64 data); | ||
| 30 | template void Write<u32>(u32 addr, const u32 data); | ||
| 31 | template void Write<u16>(u32 addr, const u16 data); | ||
| 32 | template void Write<u8>(u32 addr, const u8 data); | ||
| 33 | |||
| 34 | /// Update hardware | ||
| 35 | void Update() { | ||
| 36 | } | ||
| 37 | |||
| 38 | /// Initialize hardware | ||
| 39 | void Init() { | ||
| 40 | NOTICE_LOG(LCD, "initialized OK"); | ||
| 41 | } | ||
| 42 | |||
| 43 | /// Shutdown hardware | ||
| 44 | void Shutdown() { | ||
| 45 | NOTICE_LOG(LCD, "shutdown OK"); | ||
| 46 | } | ||
| 47 | |||
| 48 | } // namespace | ||
diff --git a/src/core/hw/ndma.h b/src/core/hw/ndma.h new file mode 100644 index 000000000..d8fa3d40b --- /dev/null +++ b/src/core/hw/ndma.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace NDMA { | ||
| 10 | |||
| 11 | template <typename T> | ||
| 12 | inline void Read(T &var, const u32 addr); | ||
| 13 | |||
| 14 | template <typename T> | ||
| 15 | inline void Write(u32 addr, const T data); | ||
| 16 | |||
| 17 | /// Update hardware | ||
| 18 | void Update(); | ||
| 19 | |||
| 20 | /// Initialize hardware | ||
| 21 | void Init(); | ||
| 22 | |||
| 23 | /// Shutdown hardware | ||
| 24 | void Shutdown(); | ||
| 25 | |||
| 26 | } // namespace | ||
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp index 96f8d0440..180829239 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,27 +12,27 @@ | |||
| 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 |
| 19 | 18 | ||
| 20 | u8* g_bootrom = NULL; ///< Bootrom physical memory | 19 | u8* g_heap_gsp = NULL; ///< GSP heap (main memory) |
| 21 | u8* g_fcram = NULL; ///< Main memory (FCRAM) pointer | 20 | u8* g_heap = NULL; ///< Application heap (main memory) |
| 22 | u8* g_vram = NULL; ///< Video memory (VRAM) pointer | 21 | u8* g_vram = NULL; ///< Video memory (VRAM) pointer |
| 23 | u8* g_scratchpad = NULL; ///< Scratchpad memory - Used for main thread stack | ||
| 24 | 22 | ||
| 25 | u8* g_physical_bootrom = NULL; ///< Bootrom physical memory | 23 | u8* g_physical_bootrom = NULL; ///< Bootrom physical memory |
| 26 | u8* g_uncached_bootrom = NULL; | 24 | u8* g_uncached_bootrom = NULL; |
| 27 | 25 | ||
| 28 | u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) | 26 | u8* g_physical_fcram = NULL; ///< Main physical memory (FCRAM) |
| 27 | u8* g_physical_heap_gsp = NULL; | ||
| 29 | u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) | 28 | u8* g_physical_vram = NULL; ///< Video physical memory (VRAM) |
| 30 | u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack | 29 | u8* g_physical_scratchpad = NULL; ///< Scratchpad memory used for main thread stack |
| 31 | 30 | ||
| 32 | // We don't declare the IO region in here since its handled by other means. | 31 | // We don't declare the IO region in here since its handled by other means. |
| 33 | static MemoryView g_views[] = { | 32 | static MemoryView g_views[] = { |
| 34 | { &g_vram, &g_physical_vram, MEM_VRAM_VADDR, MEM_VRAM_SIZE, 0 }, | 33 | {&g_vram, &g_physical_vram, VRAM_VADDR, VRAM_SIZE, 0}, |
| 35 | { &g_fcram, &g_physical_fcram, MEM_FCRAM_VADDR, MEM_FCRAM_SIZE, MV_IS_PRIMARY_RAM }, | 34 | {&g_heap_gsp, &g_physical_heap_gsp, HEAP_GSP_VADDR, HEAP_GSP_SIZE, 0}, |
| 35 | {&g_heap, &g_physical_fcram, HEAP_VADDR, HEAP_SIZE, MV_IS_PRIMARY_RAM}, | ||
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | /*static MemoryView views[] = | 38 | /*static MemoryView views[] = |
| @@ -56,14 +56,12 @@ void Init() { | |||
| 56 | 56 | ||
| 57 | for (size_t i = 0; i < ARRAY_SIZE(g_views); i++) { | 57 | for (size_t i = 0; i < ARRAY_SIZE(g_views); i++) { |
| 58 | if (g_views[i].flags & MV_IS_PRIMARY_RAM) | 58 | if (g_views[i].flags & MV_IS_PRIMARY_RAM) |
| 59 | g_views[i].size = MEM_FCRAM_SIZE; | 59 | g_views[i].size = FCRAM_SIZE; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &g_arena); | 62 | g_base = MemoryMap_Setup(g_views, kNumMemViews, flags, &g_arena); |
| 63 | 63 | ||
| 64 | g_scratchpad = new u8[MEM_SCRATCHPAD_SIZE]; | 64 | NOTICE_LOG(MEMMAP, "initialized OK, RAM at %p (mirror at 0 @ %p)", g_heap, |
| 65 | |||
| 66 | NOTICE_LOG(MEMMAP, "Memory system initialized. RAM at %p (mirror at 0 @ %p)", g_fcram, | ||
| 67 | g_physical_fcram); | 65 | g_physical_fcram); |
| 68 | } | 66 | } |
| 69 | 67 | ||
| @@ -72,12 +70,9 @@ void Shutdown() { | |||
| 72 | MemoryMap_Shutdown(g_views, kNumMemViews, flags, &g_arena); | 70 | MemoryMap_Shutdown(g_views, kNumMemViews, flags, &g_arena); |
| 73 | 71 | ||
| 74 | g_arena.ReleaseSpace(); | 72 | g_arena.ReleaseSpace(); |
| 75 | delete[] g_scratchpad; | 73 | g_base = NULL; |
| 76 | |||
| 77 | g_base = NULL; | ||
| 78 | g_scratchpad = NULL; | ||
| 79 | 74 | ||
| 80 | NOTICE_LOG(MEMMAP, "Memory system shut down."); | 75 | NOTICE_LOG(MEMMAP, "shutdown OK"); |
| 81 | } | 76 | } |
| 82 | 77 | ||
| 83 | } // namespace | 78 | } // namespace |
diff --git a/src/core/mem_map.h b/src/core/mem_map.h index 1a3bd7234..ab1eb2606 100644 --- a/src/core/mem_map.h +++ b/src/core/mem_map.h | |||
| @@ -4,39 +4,67 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 8 | |||
| 9 | #include "common/common.h" | 7 | #include "common/common.h" |
| 10 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 11 | 9 | ||
| 10 | namespace Memory { | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 13 | 13 | ||
| 14 | enum { | 14 | enum { |
| 15 | MEM_BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size | 15 | BOOTROM_SIZE = 0x00010000, ///< Bootrom (super secret code/data @ 0x8000) size |
| 16 | MEM_MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size | 16 | MPCORE_PRIV_SIZE = 0x00002000, ///< MPCore private memory region size |
| 17 | MEM_VRAM_SIZE = 0x00600000, ///< VRAM size | 17 | VRAM_SIZE = 0x00600000, ///< VRAM size |
| 18 | MEM_DSP_SIZE = 0x00080000, ///< DSP memory size | 18 | DSP_SIZE = 0x00080000, ///< DSP memory size |
| 19 | MEM_AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size | 19 | AXI_WRAM_SIZE = 0x00080000, ///< AXI WRAM size |
| 20 | MEM_FCRAM_SIZE = 0x08000000, ///< FCRAM size... Really 0x07E00000, but power of 2 | 20 | FCRAM_SIZE = 0x08000000, ///< FCRAM size |
| 21 | // works much better | 21 | SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader |
| 22 | MEM_SCRATCHPAD_SIZE = 0x00004000, ///< Typical stack size - TODO: Read from exheader | 22 | HEAP_GSP_SIZE = 0x02000000, ///< GSP heap size... TODO: Define correctly? |
| 23 | 23 | HEAP_SIZE = FCRAM_SIZE, ///< Application heap size | |
| 24 | MEM_VRAM_MASK = 0x007FFFFF, | 24 | |
| 25 | MEM_FCRAM_MASK = (MEM_FCRAM_SIZE - 1), ///< FCRAM mask | 25 | HEAP_PADDR = HEAP_GSP_SIZE, |
| 26 | MEM_SCRATCHPAD_MASK = (MEM_SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask | 26 | HEAP_PADDR_END = (HEAP_PADDR + HEAP_SIZE), |
| 27 | 27 | HEAP_VADDR = 0x08000000, | |
| 28 | MEM_FCRAM_PADDR = 0x20000000, ///< FCRAM physical address | 28 | HEAP_VADDR_END = (HEAP_VADDR + HEAP_SIZE), |
| 29 | MEM_FCRAM_PADDR_END = (MEM_FCRAM_PADDR + MEM_FCRAM_SIZE), ///< FCRAM end of physical space | 29 | HEAP_GSP_VADDR = 0x14000000, |
| 30 | MEM_FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address | 30 | HEAP_GSP_VADDR_END = (HEAP_GSP_VADDR + HEAP_GSP_SIZE), |
| 31 | MEM_FCRAM_VADDR_END = (MEM_FCRAM_VADDR + MEM_FCRAM_SIZE), ///< FCRAM end of virtual space | 31 | HEAP_GSP_PADDR = 0x00000000, |
| 32 | 32 | HEAP_GSP_PADDR_END = (HEAP_GSP_PADDR + HEAP_GSP_SIZE), | |
| 33 | MEM_VRAM_VADDR = 0x1F000000, | 33 | |
| 34 | MEM_SCRATCHPAD_VADDR = (0x10000000 - MEM_SCRATCHPAD_SIZE), ///< Scratchpad virtual address | 34 | VRAM_MASK = 0x007FFFFF, |
| 35 | FCRAM_MASK = (FCRAM_SIZE - 1), ///< FCRAM mask | ||
| 36 | SCRATCHPAD_MASK = (SCRATCHPAD_SIZE - 1), ///< Scratchpad memory mask | ||
| 37 | HEAP_GSP_MASK = (HEAP_GSP_SIZE - 1), | ||
| 38 | HEAP_MASK = (HEAP_SIZE - 1), | ||
| 39 | |||
| 40 | FCRAM_PADDR = 0x20000000, ///< FCRAM physical address | ||
| 41 | FCRAM_PADDR_END = (FCRAM_PADDR + FCRAM_SIZE), ///< FCRAM end of physical space | ||
| 42 | FCRAM_VADDR = 0x08000000, ///< FCRAM virtual address | ||
| 43 | FCRAM_VADDR_END = (FCRAM_VADDR + FCRAM_SIZE), ///< FCRAM end of virtual space | ||
| 44 | |||
| 45 | VRAM_VADDR = 0x1F000000, | ||
| 46 | SCRATCHPAD_VADDR_END = 0x10000000, | ||
| 47 | SCRATCHPAD_VADDR = (SCRATCHPAD_VADDR_END - SCRATCHPAD_SIZE), ///< Stack space | ||
| 35 | }; | 48 | }; |
| 36 | 49 | ||
| 37 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 50 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 | 51 | ||
| 39 | namespace Memory { | 52 | /// Represents a block of heap memory mapped by ControlMemory |
| 53 | struct HeapBlock { | ||
| 54 | HeapBlock() : base_address(0), address(0), size(0), operation(0), permissions(0) { | ||
| 55 | } | ||
| 56 | u32 base_address; | ||
| 57 | u32 address; | ||
| 58 | u32 size; | ||
| 59 | u32 operation; | ||
| 60 | u32 permissions; | ||
| 61 | |||
| 62 | const u32 GetVirtualAddress() const{ | ||
| 63 | return base_address + address; | ||
| 64 | } | ||
| 65 | }; | ||
| 66 | |||
| 67 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 40 | 68 | ||
| 41 | // Base is a pointer to the base of the memory map. Yes, some MMU tricks | 69 | // Base is a pointer to the base of the memory map. Yes, some MMU tricks |
| 42 | // are used to set up a full GC or Wii memory map in process memory. on | 70 | // are used to set up a full GC or Wii memory map in process memory. on |
| @@ -50,9 +78,9 @@ extern u8 *g_base; | |||
| 50 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). | 78 | // These are guaranteed to point to "low memory" addresses (sub-32-bit). |
| 51 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror | 79 | // 64-bit: Pointers to low-mem (sub-0x10000000) mirror |
| 52 | // 32-bit: Same as the corresponding physical/virtual pointers. | 80 | // 32-bit: Same as the corresponding physical/virtual pointers. |
| 53 | extern u8* g_fcram; ///< Main memory | 81 | extern u8* g_heap_gsp; ///< GSP heap (main memory) |
| 54 | extern u8* g_vram; ///< Video memory (VRAM) | 82 | extern u8* g_heap; ///< Application heap (main memory) |
| 55 | extern u8* g_scratchpad; ///< Stack memory | 83 | extern u8* g_vram; ///< Video memory (VRAM) |
| 56 | 84 | ||
| 57 | void Init(); | 85 | void Init(); |
| 58 | void Shutdown(); | 86 | void Shutdown(); |
| @@ -70,4 +98,16 @@ void Write32(const u32 addr, const u32 data); | |||
| 70 | 98 | ||
| 71 | u8* GetPointer(const u32 Address); | 99 | u8* GetPointer(const u32 Address); |
| 72 | 100 | ||
| 101 | /** | ||
| 102 | * Maps a block of memory on the GSP heap | ||
| 103 | * @param size Size of block in bytes | ||
| 104 | * @param operation Control memory operation | ||
| 105 | * @param permissions Control memory permissions | ||
| 106 | */ | ||
| 107 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions); | ||
| 108 | |||
| 109 | inline const char* GetCharPointer(const u32 address) { | ||
| 110 | return (const char *)GetPointer(address); | ||
| 111 | } | ||
| 112 | |||
| 73 | } // namespace | 113 | } // namespace |
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 4c0e08b3f..af4cfacbd 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp | |||
| @@ -2,149 +2,144 @@ | |||
| 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 | ||
| 5 | #include <map> | ||
| 6 | |||
| 5 | #include "common/common.h" | 7 | #include "common/common.h" |
| 6 | 8 | ||
| 7 | #include "core/mem_map.h" | 9 | #include "core/mem_map.h" |
| 8 | #include "core/hw/hw.h" | 10 | #include "core/hw/hw.h" |
| 11 | #include "hle/hle.h" | ||
| 9 | 12 | ||
| 10 | namespace Memory { | 13 | namespace Memory { |
| 11 | 14 | ||
| 15 | std::map<u32, HeapBlock> g_heap_gsp_map; | ||
| 16 | |||
| 17 | /// Convert a physical address to virtual address | ||
| 18 | u32 _AddressPhysicalToVirtual(const u32 addr) { | ||
| 19 | // Our memory interface read/write functions assume virtual addresses. Put any physical address | ||
| 20 | // to virtual address translations here. This is obviously quite hacky... But we're not doing | ||
| 21 | // any MMU emulation yet or anything | ||
| 22 | if ((addr >= FCRAM_PADDR) && (addr < (FCRAM_PADDR_END))) { | ||
| 23 | return (addr & FCRAM_MASK) | FCRAM_VADDR; | ||
| 24 | } | ||
| 25 | return addr; | ||
| 26 | } | ||
| 27 | |||
| 12 | template <typename T> | 28 | template <typename T> |
| 13 | inline void _Read(T &var, const u32 addr) { | 29 | inline void _Read(T &var, const u32 addr) { |
| 14 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). | 30 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). |
| 15 | // TODO: Make sure this represents the mirrors in a correct way. | 31 | // TODO: Make sure this represents the mirrors in a correct way. |
| 16 | // Could just do a base-relative read, too.... TODO | 32 | // Could just do a base-relative read, too.... TODO |
| 17 | 33 | ||
| 34 | const u32 vaddr = _AddressPhysicalToVirtual(addr); | ||
| 35 | |||
| 36 | // Memory allocated for HLE use that can be addressed from the emulated application | ||
| 37 | // The primary use of this is sharing a commandbuffer between the HLE OS (syscore) and the LLE | ||
| 38 | // core running the user application (appcore) | ||
| 39 | if (vaddr >= HLE::CMD_BUFFER_ADDR && vaddr < HLE::CMD_BUFFER_ADDR_END) { | ||
| 40 | HLE::Read<T>(var, vaddr); | ||
| 41 | |||
| 18 | // Hardware I/O register reads | 42 | // Hardware I/O register reads |
| 19 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space | 43 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space |
| 20 | if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { | 44 | } else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) { |
| 21 | HW::Read<T>(var, addr); | 45 | HW::Read<T>(var, vaddr); |
| 22 | 46 | ||
| 23 | // FCRAM virtual address reads | 47 | // FCRAM - GSP heap |
| 24 | } else if ((addr & 0x3E000000) == 0x08000000) { | 48 | } else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) { |
| 25 | var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); | 49 | var = *((const T*)&g_heap_gsp[vaddr & HEAP_GSP_MASK]); |
| 26 | 50 | ||
| 27 | // Scratchpad memory | 51 | // FCRAM - application heap |
| 28 | } else if (addr > MEM_SCRATCHPAD_VADDR && addr <= (MEM_SCRATCHPAD_VADDR + MEM_SCRATCHPAD_SIZE)) { | 52 | } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { |
| 29 | var = *((const T*)&g_scratchpad[addr & MEM_SCRATCHPAD_MASK]); | 53 | var = *((const T*)&g_heap[vaddr & HEAP_MASK]); |
| 30 | 54 | ||
| 31 | /*else if ((addr & 0x3F800000) == 0x04000000) { | 55 | /*else if ((vaddr & 0x3F800000) == 0x04000000) { |
| 32 | var = *((const T*)&m_pVRAM[addr & VRAM_MASK]); | 56 | var = *((const T*)&m_pVRAM[vaddr & VRAM_MASK]);*/ |
| 33 | }*/ | ||
| 34 | |||
| 35 | // HACK(bunnei): There is no layer yet to translate virtual addresses to physical addresses. | ||
| 36 | // Until we progress far enough along, we'll accept all physical address reads here. I think | ||
| 37 | // that this is typically a corner-case from usermode software unless they are trying to do | ||
| 38 | // bare-metal things (e.g. early 3DS homebrew writes directly to the FB @ 0x20184E60, etc. | ||
| 39 | } else if (((addr & 0xF0000000) == MEM_FCRAM_PADDR) && (addr < (MEM_FCRAM_PADDR_END))) { | ||
| 40 | var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); | ||
| 41 | 57 | ||
| 42 | } else { | 58 | } else { |
| 43 | _assert_msg_(MEMMAP, false, "unknown memory read"); | 59 | //_assert_msg_(MEMMAP, false, "unknown Read%d @ 0x%08X", sizeof(var) * 8, vaddr); |
| 44 | } | 60 | } |
| 45 | } | 61 | } |
| 46 | 62 | ||
| 47 | template <typename T> | 63 | template <typename T> |
| 48 | inline void _Write(u32 addr, const T data) { | 64 | inline void _Write(u32 addr, const T data) { |
| 65 | u32 vaddr = _AddressPhysicalToVirtual(addr); | ||
| 49 | 66 | ||
| 67 | // Memory allocated for HLE use that can be addressed from the emulated application | ||
| 68 | // The primary use of this is sharing a commandbuffer between the HLE OS (syscore) and the LLE | ||
| 69 | // core running the user application (appcore) | ||
| 70 | if (vaddr >= HLE::CMD_BUFFER_ADDR && vaddr < HLE::CMD_BUFFER_ADDR_END) { | ||
| 71 | HLE::Write<T>(vaddr, data); | ||
| 72 | |||
| 50 | // Hardware I/O register writes | 73 | // Hardware I/O register writes |
| 51 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space | 74 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space |
| 52 | if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { | 75 | } else if ((vaddr & 0xFF000000) == 0x10000000 || (vaddr & 0xFF000000) == 0x1E000000) { |
| 53 | HW::Write<const T>(addr, data); | 76 | HW::Write<T>(vaddr, data); |
| 54 | 77 | ||
| 55 | // ExeFS:/.code is loaded here: | 78 | // FCRAM - GSP heap |
| 56 | } else if ((addr & 0xFFF00000) == 0x00100000) { | 79 | } else if ((vaddr > HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) { |
| 57 | // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: | 80 | *(T*)&g_heap_gsp[vaddr & HEAP_GSP_MASK] = data; |
| 58 | // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions | 81 | |
| 59 | // The ExeFS:/.code is loaded here, executables must be loaded to the 0x00100000 region when | 82 | // FCRAM - application heap |
| 60 | // the exheader "special memory" flag is clear. The 0x03F00000-byte size restriction only | 83 | } else if ((vaddr > HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { |
| 61 | // applies when this flag is clear. Executables are usually loaded to 0x14000000 when the | 84 | *(T*)&g_heap[vaddr & HEAP_MASK] = data; |
| 62 | // exheader "special memory" flag is set, however this address can be arbitrary. | 85 | |
| 63 | *(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data; | 86 | } else if ((vaddr & 0xFF000000) == 0x14000000) { |
| 64 | |||
| 65 | // Scratchpad memory | ||
| 66 | } else if (addr > MEM_SCRATCHPAD_VADDR && addr <= (MEM_SCRATCHPAD_VADDR + MEM_SCRATCHPAD_SIZE)) { | ||
| 67 | *(T*)&g_scratchpad[addr & MEM_SCRATCHPAD_MASK] = data; | ||
| 68 | |||
| 69 | // Heap mapped by ControlMemory: | ||
| 70 | } else if ((addr & 0x3E000000) == 0x08000000) { | ||
| 71 | // TODO(ShizZy): Writes to this virtual address should be put in physical memory at FCRAM + GSP | ||
| 72 | // heap size... the following is writing to FCRAM + 0, which is actually supposed to be the | ||
| 73 | // application's GSP heap | ||
| 74 | *(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data; | ||
| 75 | |||
| 76 | } else if ((addr & 0xFF000000) == 0x14000000) { | ||
| 77 | _assert_msg_(MEMMAP, false, "umimplemented write to GSP heap"); | 87 | _assert_msg_(MEMMAP, false, "umimplemented write to GSP heap"); |
| 78 | } else if ((addr & 0xFFF00000) == 0x1EC00000) { | 88 | } else if ((vaddr & 0xFFF00000) == 0x1EC00000) { |
| 79 | _assert_msg_(MEMMAP, false, "umimplemented write to IO registers"); | 89 | _assert_msg_(MEMMAP, false, "umimplemented write to IO registers"); |
| 80 | } else if ((addr & 0xFF000000) == 0x1F000000) { | 90 | } else if ((vaddr & 0xFF000000) == 0x1F000000) { |
| 81 | _assert_msg_(MEMMAP, false, "umimplemented write to VRAM"); | 91 | _assert_msg_(MEMMAP, false, "umimplemented write to VRAM"); |
| 82 | } else if ((addr & 0xFFF00000) == 0x1FF00000) { | 92 | } else if ((vaddr & 0xFFF00000) == 0x1FF00000) { |
| 83 | _assert_msg_(MEMMAP, false, "umimplemented write to DSP memory"); | 93 | _assert_msg_(MEMMAP, false, "umimplemented write to DSP memory"); |
| 84 | } else if ((addr & 0xFFFF0000) == 0x1FF80000) { | 94 | } else if ((vaddr & 0xFFFF0000) == 0x1FF80000) { |
| 85 | _assert_msg_(MEMMAP, false, "umimplemented write to Configuration Memory"); | 95 | _assert_msg_(MEMMAP, false, "umimplemented write to Configuration Memory"); |
| 86 | } else if ((addr & 0xFFFFF000) == 0x1FF81000) { | 96 | } else if ((vaddr & 0xFFFFF000) == 0x1FF81000) { |
| 87 | _assert_msg_(MEMMAP, false, "umimplemented write to shared page"); | 97 | _assert_msg_(MEMMAP, false, "umimplemented write to shared page"); |
| 88 | 98 | ||
| 89 | // HACK(bunnei): There is no layer yet to translate virtual addresses to physical addresses. | ||
| 90 | // Until we progress far enough along, we'll accept all physical address writes here. I think | ||
| 91 | // that this is typically a corner-case from usermode software unless they are trying to do | ||
| 92 | // bare-metal things (e.g. early 3DS homebrew writes directly to the FB @ 0x20184E60, etc. | ||
| 93 | } else if (((addr & 0xF0000000) == MEM_FCRAM_PADDR) && (addr < (MEM_FCRAM_PADDR_END))) { | ||
| 94 | *(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data; | ||
| 95 | |||
| 96 | // Error out... | 99 | // Error out... |
| 97 | } else { | 100 | } else { |
| 98 | _assert_msg_(MEMMAP, false, "unknown memory write"); | 101 | _assert_msg_(MEMMAP, false, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, |
| 102 | data, vaddr); | ||
| 99 | } | 103 | } |
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | bool IsValidAddress(const u32 addr) { | 106 | u8 *GetPointer(const u32 addr) { |
| 103 | if ((addr & 0x3E000000) == 0x08000000) { | 107 | const u32 vaddr = _AddressPhysicalToVirtual(addr); |
| 104 | return true; | 108 | |
| 105 | } else if ((addr & 0x3F800000) == 0x04000000) { | 109 | // FCRAM - GSP heap |
| 106 | return true; | 110 | if ((vaddr >= HEAP_GSP_VADDR) && (vaddr < HEAP_GSP_VADDR_END)) { |
| 107 | } else if ((addr & 0xBFFF0000) == 0x00010000) { | 111 | return g_heap_gsp + (vaddr & HEAP_GSP_MASK); |
| 108 | return true; | 112 | |
| 109 | } else if ((addr & 0x3F000000) >= 0x08000000 && (addr & 0x3F000000) < 0x08000000 + MEM_FCRAM_MASK) { | 113 | // FCRAM - application heap |
| 110 | return true; | 114 | } else if ((vaddr >= HEAP_VADDR) && (vaddr < HEAP_VADDR_END)) { |
| 115 | return g_heap + (vaddr & HEAP_MASK); | ||
| 116 | |||
| 111 | } else { | 117 | } else { |
| 112 | return false; | 118 | ERROR_LOG(MEMMAP, "Unknown GetPointer @ 0x%08x", vaddr); |
| 119 | return 0; | ||
| 113 | } | 120 | } |
| 114 | } | 121 | } |
| 115 | 122 | ||
| 116 | u8 *GetPointer(const u32 addr) { | 123 | /** |
| 117 | // TODO(bunnei): Just a stub for now... ImplementMe! | 124 | * Maps a block of memory on the GSP heap |
| 118 | if ((addr & 0x3E000000) == 0x08000000) { | 125 | * @param size Size of block in bytes |
| 119 | return g_fcram + (addr & MEM_FCRAM_MASK); | 126 | * @param flags Memory allocation flags |
| 120 | 127 | */ | |
| 121 | // HACK(bunnei): There is no layer yet to translate virtual addresses to physical addresses. | 128 | u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) { |
| 122 | // Until we progress far enough along, we'll accept all physical address reads here. I think | 129 | HeapBlock block; |
| 123 | // that this is typically a corner-case from usermode software unless they are trying to do | 130 | |
| 124 | // bare-metal things (e.g. early 3DS homebrew writes directly to the FB @ 0x20184E60, etc. | 131 | block.base_address = HEAP_GSP_VADDR; |
| 125 | } else if (((addr & 0xF0000000) == MEM_FCRAM_PADDR) && (addr < (MEM_FCRAM_PADDR_END))) { | 132 | block.size = size; |
| 126 | return g_fcram + (addr & MEM_FCRAM_MASK); | 133 | block.operation = operation; |
| 127 | 134 | block.permissions = permissions; | |
| 128 | //else if ((addr & 0x3F800000) == 0x04000000) { | 135 | |
| 129 | // return g_vram + (addr & MEM_VRAM_MASK); | 136 | if (g_heap_gsp_map.size() > 0) { |
| 130 | //} | 137 | const HeapBlock last_block = g_heap_gsp_map.rbegin()->second; |
| 131 | //else if ((addr & 0x3F000000) >= 0x08000000 && (addr & 0x3F000000) < 0x08000000 + g_MemorySize) { | 138 | block.address = last_block.address + last_block.size; |
| 132 | // return m_pRAM + (addr & g_MemoryMask); | ||
| 133 | //} | ||
| 134 | } else { | ||
| 135 | //ERROR_LOG(MEMMAP, "Unknown GetPointer %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]); | ||
| 136 | ERROR_LOG(MEMMAP, "Unknown GetPointer %08x", addr); | ||
| 137 | static bool reported = false; | ||
| 138 | //if (!reported) { | ||
| 139 | // Reporting::ReportMessage("Unknown GetPointer %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]); | ||
| 140 | // reported = true; | ||
| 141 | //} | ||
| 142 | //if (!g_Config.bIgnoreBadMemAccess) { | ||
| 143 | // Core_EnableStepping(true); | ||
| 144 | // host->SetDebugMode(true); | ||
| 145 | //} | ||
| 146 | return 0; | ||
| 147 | } | 139 | } |
| 140 | g_heap_gsp_map[block.GetVirtualAddress()] = block; | ||
| 141 | |||
| 142 | return block.GetVirtualAddress(); | ||
| 148 | } | 143 | } |
| 149 | 144 | ||
| 150 | u8 Read8(const u32 addr) { | 145 | u8 Read8(const u32 addr) { |
diff --git a/src/core/system.cpp b/src/core/system.cpp index edb07fef5..c77092327 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "core/mem_map.h" | 7 | #include "core/mem_map.h" |
| 8 | #include "core/system.h" | 8 | #include "core/system.h" |
| 9 | #include "core/hw/hw.h" | 9 | #include "core/hw/hw.h" |
| 10 | #include "core/hle/hle.h" | ||
| 10 | 11 | ||
| 11 | #include "video_core/video_core.h" | 12 | #include "video_core/video_core.h" |
| 12 | 13 | ||
| @@ -19,15 +20,16 @@ void UpdateState(State state) { | |||
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | void Init(EmuWindow* emu_window) { | 22 | void Init(EmuWindow* emu_window) { |
| 22 | Core::Init(); | 23 | Core::Init(); |
| 23 | Memory::Init(); | 24 | Memory::Init(); |
| 24 | HW::Init(); | 25 | HW::Init(); |
| 25 | CoreTiming::Init(); | 26 | HLE::Init(); |
| 27 | CoreTiming::Init(); | ||
| 26 | VideoCore::Init(emu_window); | 28 | VideoCore::Init(emu_window); |
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | void RunLoopFor(int cycles) { | 31 | void RunLoopFor(int cycles) { |
| 30 | RunLoopUntil(CoreTiming::GetTicks() + cycles); | 32 | RunLoopUntil(CoreTiming::GetTicks() + cycles); |
| 31 | } | 33 | } |
| 32 | 34 | ||
| 33 | void RunLoopUntil(u64 global_cycles) { | 35 | void RunLoopUntil(u64 global_cycles) { |
| @@ -35,9 +37,12 @@ void RunLoopUntil(u64 global_cycles) { | |||
| 35 | 37 | ||
| 36 | void Shutdown() { | 38 | void Shutdown() { |
| 37 | Core::Shutdown(); | 39 | Core::Shutdown(); |
| 40 | Memory::Shutdown(); | ||
| 38 | HW::Shutdown(); | 41 | HW::Shutdown(); |
| 42 | HLE::Shutdown(); | ||
| 43 | CoreTiming::Shutdown(); | ||
| 39 | VideoCore::Shutdown(); | 44 | VideoCore::Shutdown(); |
| 40 | g_ctr_file_system.Shutdown(); | 45 | g_ctr_file_system.Shutdown(); |
| 41 | } | 46 | } |
| 42 | 47 | ||
| 43 | } // namespace | 48 | } // namespace |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 97f84c248..35804aee1 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 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 | ||
| 5 | #include "core/hw/lcd.h" | ||
| 6 | |||
| 5 | #include "video_core/video_core.h" | 7 | #include "video_core/video_core.h" |
| 6 | #include "video_core/renderer_opengl/renderer_opengl.h" | 8 | #include "video_core/renderer_opengl/renderer_opengl.h" |
| 7 | 9 | ||
| @@ -75,8 +77,8 @@ void RendererOpenGL::FlipFramebuffer(u32 addr, u8* out) { | |||
| 75 | */ | 77 | */ |
| 76 | void RendererOpenGL::RenderXFB(const Rect& src_rect, const Rect& dst_rect) { | 78 | void RendererOpenGL::RenderXFB(const Rect& src_rect, const Rect& dst_rect) { |
| 77 | 79 | ||
| 78 | FlipFramebuffer(0x20282160, m_xfb_top_flipped); | 80 | FlipFramebuffer(LCD::TOP_RIGHT_FRAME1, m_xfb_top_flipped); |
| 79 | FlipFramebuffer(0x202118E0, m_xfb_bottom_flipped); | 81 | FlipFramebuffer(LCD::SUB_FRAME1, m_xfb_bottom_flipped); |
| 80 | 82 | ||
| 81 | // Blit the top framebuffer | 83 | // Blit the top framebuffer |
| 82 | // ------------------------ | 84 | // ------------------------ |
| @@ -84,7 +86,7 @@ void RendererOpenGL::RenderXFB(const Rect& src_rect, const Rect& dst_rect) { | |||
| 84 | // Update textures with contents of XFB in RAM - top | 86 | // Update textures with contents of XFB in RAM - top |
| 85 | glBindTexture(GL_TEXTURE_2D, m_xfb_texture_top); | 87 | glBindTexture(GL_TEXTURE_2D, m_xfb_texture_top); |
| 86 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight, | 88 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight, |
| 87 | GL_RGB, GL_UNSIGNED_BYTE, m_xfb_top_flipped); | 89 | GL_BGR, GL_UNSIGNED_BYTE, m_xfb_top_flipped); |
| 88 | glBindTexture(GL_TEXTURE_2D, 0); | 90 | glBindTexture(GL_TEXTURE_2D, 0); |
| 89 | 91 | ||
| 90 | // Render target is destination framebuffer | 92 | // Render target is destination framebuffer |
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index e227b6795..f2e17f9f9 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp | |||
| @@ -38,12 +38,13 @@ void Init(EmuWindow* emu_window) { | |||
| 38 | 38 | ||
| 39 | g_current_frame = 0; | 39 | g_current_frame = 0; |
| 40 | 40 | ||
| 41 | NOTICE_LOG(VIDEO, "initialized ok"); | 41 | NOTICE_LOG(VIDEO, "initialized OK"); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /// Shutdown the video core | 44 | /// Shutdown the video core |
| 45 | void Shutdown() { | 45 | void Shutdown() { |
| 46 | delete g_renderer; | 46 | delete g_renderer; |
| 47 | NOTICE_LOG(VIDEO, "shutdown OK"); | ||
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | } // namespace | 50 | } // namespace |