diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 8 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom_run.h | 41 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom_thumb.cpp | 2 | ||||
-rw-r--r-- | src/core/arm/dyncom/arm_dyncom_thumb.h | 4 | ||||
-rw-r--r-- | src/core/arm/skyeye_common/skyeye_defs.h | 25 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir.cpp | 48 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir.h | 30 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir_rst.cpp | 24 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir_rst.h (renamed from src/core/hle/service/ir_rst.h) | 13 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir_u.cpp (renamed from src/core/hle/service/ir_u.cpp) | 17 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir_u.h (renamed from src/core/hle/service/ir_u.h) | 13 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir_user.cpp | 34 | ||||
-rw-r--r-- | src/core/hle/service/ir/ir_user.h | 22 | ||||
-rw-r--r-- | src/core/hle/service/ir_rst.cpp | 27 | ||||
-rw-r--r-- | src/core/hle/service/service.cpp | 7 |
16 files changed, 218 insertions, 109 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index bdf4b6212..0528175ba 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -61,8 +61,10 @@ set(SRCS hle/service/hid/hid_spvr.cpp hle/service/gsp_lcd.cpp hle/service/http_c.cpp - hle/service/ir_rst.cpp - hle/service/ir_u.cpp + hle/service/ir/ir.cpp + hle/service/ir/ir_rst.cpp + hle/service/ir/ir_u.cpp + hle/service/ir/ir_user.cpp hle/service/ldr_ro.cpp hle/service/mic_u.cpp hle/service/ndm_u.cpp @@ -170,8 +172,10 @@ set(HEADERS hle/service/hid/hid_user.h hle/service/gsp_lcd.h hle/service/http_c.h - hle/service/ir_rst.h - hle/service/ir_u.h + hle/service/ir/ir.h + hle/service/ir/ir_rst.h + hle/service/ir/ir_u.h + hle/service/ir/ir_user.h hle/service/ldr_ro.h hle/service/mic_u.h hle/service/ndm_u.h diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index 65fe8a055..fde11e4ff 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp @@ -3557,7 +3557,7 @@ enum { FETCH_FAILURE }; -static tdstate decode_thumb_instr(ARMul_State* cpu, uint32_t inst, addr_t addr, uint32_t* arm_inst, uint32_t* inst_size, ARM_INST_PTR* ptr_inst_base){ +static tdstate decode_thumb_instr(ARMul_State* cpu, u32 inst, u32 addr, u32* arm_inst, u32* inst_size, ARM_INST_PTR* ptr_inst_base) { // Check if in Thumb mode tdstate ret = thumb_translate (addr, inst, arm_inst, inst_size); if(ret == t_branch){ @@ -3620,7 +3620,7 @@ typedef struct instruction_set_encoding_item ISEITEM; extern const ISEITEM arm_instruction[]; -static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, addr_t addr) { +static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, u32 addr) { Common::Profiling::ScopeTimer timer_decode(profile_decode); // Decode instruction, get index @@ -3638,8 +3638,8 @@ static int InterpreterTranslate(ARMul_State* cpu, int& bb_start, addr_t addr) { if (cpu->TFlag) thumb = THUMB; - addr_t phys_addr = addr; - addr_t pc_start = cpu->Reg[15]; + u32 phys_addr = addr; + u32 pc_start = cpu->Reg[15]; while(ret == NON_BRANCH) { inst = Memory::Read32(phys_addr & 0xFFFFFFFC); diff --git a/src/core/arm/dyncom/arm_dyncom_run.h b/src/core/arm/dyncom/arm_dyncom_run.h index e17420497..85774c565 100644 --- a/src/core/arm/dyncom/arm_dyncom_run.h +++ b/src/core/arm/dyncom/arm_dyncom_run.h @@ -22,31 +22,36 @@ void switch_mode(ARMul_State* core, uint32_t mode); -/* FIXME, we temporarily think thumb instruction is always 16 bit */ +// Note that for the 3DS, a Thumb instruction will only ever be +// two bytes in size. Thus we don't need to worry about ThumbEE +// or Thumb-2 where instructions can be 4 bytes in length. static inline u32 GET_INST_SIZE(ARMul_State* core) { return core->TFlag? 2 : 4; } /** -* @brief Read R15 and forced R15 to wold align, used address calculation -* -* @param core -* @param Rn -* -* @return -*/ -static inline addr_t CHECK_READ_REG15_WA(ARMul_State* core, int Rn) { - return (Rn == 15)? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; + * Checks if the PC is being read, and if so, word-aligns it. + * Used with address calculations. + * + * @param core The ARM CPU state instance. + * @param Rn The register being read. + * + * @return If the PC is being read, then the word-aligned PC value is returned. + * If the PC is not being read, then the value stored in the register is returned. + */ +static inline u32 CHECK_READ_REG15_WA(ARMul_State* core, int Rn) { + return (Rn == 15) ? ((core->Reg[15] & ~0x3) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; } /** -* @brief Read R15, used to data processing with pc -* -* @param core -* @param Rn -* -* @return -*/ + * Reads the PC. Used for data processing operations that use the PC. + * + * @param core The ARM CPU state instance. + * @param Rn The register being read. + * + * @return If the PC is being read, then the incremented PC value is returned. + * If the PC is not being read, then the values stored in the register is returned. + */ static inline u32 CHECK_READ_REG15(ARMul_State* core, int Rn) { - return (Rn == 15)? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; + return (Rn == 15) ? ((core->Reg[15] & ~0x1) + GET_INST_SIZE(core) * 2) : core->Reg[Rn]; } diff --git a/src/core/arm/dyncom/arm_dyncom_thumb.cpp b/src/core/arm/dyncom/arm_dyncom_thumb.cpp index e30d515fb..bfb45f104 100644 --- a/src/core/arm/dyncom/arm_dyncom_thumb.cpp +++ b/src/core/arm/dyncom/arm_dyncom_thumb.cpp @@ -13,7 +13,7 @@ // with the following Thumb instruction held in the high 16-bits. Passing in two Thumb instructions // allows easier simulation of the special dual BL instruction. -tdstate thumb_translate(addr_t addr, uint32_t instr, uint32_t* ainstr, uint32_t* inst_size) { +tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size) { tdstate valid = t_uninitialized; ARMword tinstr = instr; diff --git a/src/core/arm/dyncom/arm_dyncom_thumb.h b/src/core/arm/dyncom/arm_dyncom_thumb.h index a1785abb8..8394ff156 100644 --- a/src/core/arm/dyncom/arm_dyncom_thumb.h +++ b/src/core/arm/dyncom/arm_dyncom_thumb.h @@ -35,9 +35,9 @@ enum tdstate { t_uninitialized, }; -tdstate thumb_translate(addr_t addr, u32 instr, u32* ainstr, u32* inst_size); +tdstate thumb_translate(u32 addr, u32 instr, u32* ainstr, u32* inst_size); -static inline u32 get_thumb_instr(u32 instr, addr_t pc) { +static inline u32 get_thumb_instr(u32 instr, u32 pc) { u32 tinstr; if ((pc & 0x3) != 0) tinstr = instr >> 16; diff --git a/src/core/arm/skyeye_common/skyeye_defs.h b/src/core/arm/skyeye_common/skyeye_defs.h index edf6097e0..94b02459d 100644 --- a/src/core/arm/skyeye_common/skyeye_defs.h +++ b/src/core/arm/skyeye_common/skyeye_defs.h @@ -11,28 +11,3 @@ struct cpu_config_t u32 cpu_mask; // cpu_val's mask. u32 cachetype; // CPU cache type }; - -enum { - // No exception - No_exp = 0, - // Memory allocation exception - Malloc_exp, - // File open exception - File_open_exp, - // DLL open exception - Dll_open_exp, - // Invalid argument exception - Invarg_exp, - // Invalid module exception - Invmod_exp, - // wrong format exception for config file parsing - Conf_format_exp, - // some reference excess the predefiend range. Such as the index out of array range - Excess_range_exp, - // Can not find the desirable result - Not_found_exp, - // Unknown exception - Unknown_exp -}; - -typedef u32 addr_t; diff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cpp new file mode 100644 index 000000000..58dfd8e1a --- /dev/null +++ b/src/core/hle/service/ir/ir.cpp @@ -0,0 +1,48 @@ +// Copyright 2015 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/service/service.h" +#include "core/hle/service/ir/ir.h" +#include "core/hle/service/ir/ir_rst.h" +#include "core/hle/service/ir/ir_u.h" +#include "core/hle/service/ir/ir_user.h" + +#include "core/hle/hle.h" +#include "core/hle/kernel/event.h" +#include "core/hle/kernel/shared_memory.h" + +namespace Service { +namespace IR { + +static Kernel::SharedPtr<Kernel::Event> handle_event = nullptr; +static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr; + +void GetHandles(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[2] = 0x4000000; + cmd_buff[3] = Kernel::g_handle_table.Create(Service::IR::shared_memory).MoveFrom(); + cmd_buff[4] = Kernel::g_handle_table.Create(Service::IR::handle_event).MoveFrom(); +} + +void Init() { + using namespace Kernel; + + AddService(new IR_RST_Interface); + AddService(new IR_U_Interface); + AddService(new IR_User_Interface); + + shared_memory = SharedMemory::Create("IR:SharedMemory"); + + // Create event handle(s) + handle_event = Event::Create(RESETTYPE_ONESHOT, "IR:HandleEvent"); +} + +void Shutdown() { +} + +} // namespace IR + +} // namespace Service diff --git a/src/core/hle/service/ir/ir.h b/src/core/hle/service/ir/ir.h new file mode 100644 index 000000000..c16d963e7 --- /dev/null +++ b/src/core/hle/service/ir/ir.h @@ -0,0 +1,30 @@ +// Copyright 2015 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/kernel/kernel.h" +#include "core/hle/service/service.h" + +namespace Service { +namespace IR { + +/** + * IR::GetHandles service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + * 2 : Translate header, used by the ARM11-kernel + * 3 : Shared memory handle + * 4 : Event handle + */ +void GetHandles(Interface* self); + +/// Initialize IR service +void Init(); + +/// Shutdown IR service +void Shutdown(); + +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir/ir_rst.cpp b/src/core/hle/service/ir/ir_rst.cpp new file mode 100644 index 000000000..96ae63420 --- /dev/null +++ b/src/core/hle/service/ir/ir_rst.cpp @@ -0,0 +1,24 @@ +// Copyright 2015 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/hle.h" +#include "core/hle/service/ir/ir.h" +#include "core/hle/service/ir/ir_rst.h" + +namespace Service { +namespace IR { + +const Interface::FunctionInfo FunctionTable[] = { + {0x00010000, GetHandles, "GetHandles"}, + {0x00020080, nullptr, "Initialize"}, + {0x00030000, nullptr, "Shutdown"}, + {0x00090000, nullptr, "WriteToTwoFields"}, +}; + +IR_RST_Interface::IR_RST_Interface() { + Register(FunctionTable); +} + +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir_rst.h b/src/core/hle/service/ir/ir_rst.h index deef701c5..a492e15c9 100644 --- a/src/core/hle/service/ir_rst.h +++ b/src/core/hle/service/ir/ir_rst.h @@ -6,18 +6,17 @@ #include "core/hle/service/service.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace IR_RST +namespace Service { +namespace IR { -namespace IR_RST { - -class Interface : public Service::Interface { +class IR_RST_Interface : public Service::Interface { public: - Interface(); + IR_RST_Interface(); std::string GetPortName() const override { return "ir:rst"; } }; -} // namespace +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir_u.cpp b/src/core/hle/service/ir/ir_u.cpp index 608ed3c06..1b1e3078b 100644 --- a/src/core/hle/service/ir_u.cpp +++ b/src/core/hle/service/ir/ir_u.cpp @@ -3,12 +3,11 @@ // Refer to the license.txt file included. #include "core/hle/hle.h" -#include "core/hle/service/ir_u.h" +#include "core/hle/service/ir/ir.h" +#include "core/hle/service/ir/ir_u.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace IR_U - -namespace IR_U { +namespace Service { +namespace IR { const Interface::FunctionInfo FunctionTable[] = { {0x00010000, nullptr, "Initialize"}, @@ -31,11 +30,9 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00120040, nullptr, "SetSleepModeState"}, }; -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Interface class - -Interface::Interface() { +IR_U_Interface::IR_U_Interface() { Register(FunctionTable); } -} // namespace +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir_u.h b/src/core/hle/service/ir/ir_u.h index ec47a1524..056d2ce1a 100644 --- a/src/core/hle/service/ir_u.h +++ b/src/core/hle/service/ir/ir_u.h @@ -6,18 +6,17 @@ #include "core/hle/service/service.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace IR_U +namespace Service { +namespace IR { -namespace IR_U { - -class Interface : public Service::Interface { +class IR_U_Interface : public Service::Interface { public: - Interface(); + IR_U_Interface(); std::string GetPortName() const override { return "ir:u"; } }; -} // namespace +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp new file mode 100644 index 000000000..8e3ff140f --- /dev/null +++ b/src/core/hle/service/ir/ir_user.cpp @@ -0,0 +1,34 @@ +// Copyright 2015 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/hle.h" +#include "core/hle/service/ir/ir.h" +#include "core/hle/service/ir/ir_user.h" + +namespace Service { +namespace IR { + +const Interface::FunctionInfo FunctionTable[] = { + {0x00010182, nullptr, "InitializeIrNop"}, + {0x00020000, nullptr, "FinalizeIrNop"}, + {0x00030000, nullptr, "ClearReceiveBuffer"}, + {0x00040000, nullptr, "ClearSendBuffer"}, + {0x00060040, nullptr, "RequireConnection"}, + {0x00090000, nullptr, "Disconnect"}, + {0x000A0000, nullptr, "GetReceiveEvent"}, + {0x000B0000, nullptr, "GetSendEvent"}, + {0x000C0000, nullptr, "GetConnectionStatusEvent"}, + {0x000D0042, nullptr, "SendIrNop"}, + {0x000E0042, nullptr, "SendIrNopLarge"}, + {0x00180182, nullptr, "InitializeIrNopShared"}, + {0x00190040, nullptr, "ReleaseReceivedData"}, + {0x001A0040, nullptr, "SetOwnMachineId"}, +}; + +IR_User_Interface::IR_User_Interface() { + Register(FunctionTable); +} + +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir/ir_user.h b/src/core/hle/service/ir/ir_user.h new file mode 100644 index 000000000..71c932ffa --- /dev/null +++ b/src/core/hle/service/ir/ir_user.h @@ -0,0 +1,22 @@ +// Copyright 2015 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/service/service.h" + +namespace Service { +namespace IR { + +class IR_User_Interface : public Service::Interface { +public: + IR_User_Interface(); + + std::string GetPortName() const override { + return "ir:USER"; + } +}; + +} // namespace IR +} // namespace Service diff --git a/src/core/hle/service/ir_rst.cpp b/src/core/hle/service/ir_rst.cpp deleted file mode 100644 index 4c26c2f03..000000000 --- a/src/core/hle/service/ir_rst.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/hle.h" -#include "core/hle/service/ir_rst.h" - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace IR_RST - -namespace IR_RST { - -const Interface::FunctionInfo FunctionTable[] = { - {0x00010000, nullptr, "GetHandles"}, - {0x00020080, nullptr, "Initialize"}, - {0x00030000, nullptr, "Shutdown"}, - {0x00090000, nullptr, "WriteToTwoFields"}, -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Interface class - -Interface::Interface() { - Register(FunctionTable); -} - -} // namespace diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index eeb404659..134ff1740 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -24,8 +24,6 @@ #include "core/hle/service/gsp_gpu.h" #include "core/hle/service/gsp_lcd.h" #include "core/hle/service/http_c.h" -#include "core/hle/service/ir_rst.h" -#include "core/hle/service/ir_u.h" #include "core/hle/service/ldr_ro.h" #include "core/hle/service/mic_u.h" #include "core/hle/service/ndm_u.h" @@ -45,6 +43,7 @@ #include "core/hle/service/fs/archive.h" #include "core/hle/service/cfg/cfg.h" #include "core/hle/service/hid/hid.h" +#include "core/hle/service/ir/ir.h" #include "core/hle/service/ptm/ptm.h" namespace Service { @@ -73,6 +72,7 @@ void Init() { Service::APT::Init(); Service::PTM::Init(); Service::HID::Init(); + Service::IR::Init(); AddService(new AC_U::Interface); AddService(new ACT_U::Interface); @@ -91,8 +91,6 @@ void Init() { AddService(new GSP_GPU::Interface); AddService(new GSP_LCD::Interface); AddService(new HTTP_C::Interface); - AddService(new IR_RST::Interface); - AddService(new IR_U::Interface); AddService(new LDR_RO::Interface); AddService(new MIC_U::Interface); AddService(new NDM_U::Interface); @@ -112,6 +110,7 @@ void Init() { /// Shutdown ServiceManager void Shutdown() { + Service::IR::Shutdown(); Service::HID::Shutdown(); Service::PTM::Shutdown(); Service::APT::Shutdown(); |