diff options
| author | 2014-04-27 21:25:16 -0400 | |
|---|---|---|
| committer | 2014-04-27 21:25:16 -0400 | |
| commit | 438dba40c1def91e9de252ef05f8650464e5c0c2 (patch) | |
| tree | 8f323d6095dfefe9d00f34cc4d7229be58a9f409 /src/core/hle | |
| parent | Merge pull request #4 from cpp3ds/master (diff) | |
| parent | removed DISALLOW_COPY_AND_ASSIGN in favor of NonCopyable class (diff) | |
| download | yuzu-438dba40c1def91e9de252ef05f8650464e5c0c2.tar.gz yuzu-438dba40c1def91e9de252ef05f8650464e5c0c2.tar.xz yuzu-438dba40c1def91e9de252ef05f8650464e5c0c2.zip | |
Merge branch 'hle-interface-updates'
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/hle.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/hle.h | 2 | ||||
| -rw-r--r-- | src/core/hle/mrc.cpp | 64 | ||||
| -rw-r--r-- | src/core/hle/mrc.h | 20 | ||||
| -rw-r--r-- | src/core/hle/service/apt.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/apt.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/gsp.cpp | 113 | ||||
| -rw-r--r-- | src/core/hle/service/gsp.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/hid.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 40 | ||||
| -rw-r--r-- | src/core/hle/service/srv.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/service/srv.h | 3 | ||||
| -rw-r--r-- | src/core/hle/syscall.cpp | 42 |
14 files changed, 241 insertions, 75 deletions
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp index 5672a659f..aae9a3943 100644 --- a/src/core/hle/hle.cpp +++ b/src/core/hle/hle.cpp | |||
| @@ -80,14 +80,6 @@ void CallSyscall(u32 opcode) { | |||
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | 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) { | 83 | void RegisterModule(std::string name, int num_functions, const FunctionDef* func_table) { |
| 92 | ModuleDef module = {name, num_functions, func_table}; | 84 | ModuleDef module = {name, num_functions, func_table}; |
| 93 | g_module_db.push_back(module); | 85 | g_module_db.push_back(module); |
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h index 628a1da89..907e2d741 100644 --- a/src/core/hle/hle.h +++ b/src/core/hle/hle.h | |||
| @@ -57,8 +57,6 @@ void RegisterModule(std::string name, int num_functions, const FunctionDef *func | |||
| 57 | 57 | ||
| 58 | void CallSyscall(u32 opcode); | 58 | void CallSyscall(u32 opcode); |
| 59 | 59 | ||
| 60 | Addr CallGetThreadCommandBuffer(); | ||
| 61 | |||
| 62 | void Init(); | 60 | void Init(); |
| 63 | 61 | ||
| 64 | void Shutdown(); | 62 | void Shutdown(); |
diff --git a/src/core/hle/mrc.cpp b/src/core/hle/mrc.cpp new file mode 100644 index 000000000..5223be7c9 --- /dev/null +++ b/src/core/hle/mrc.cpp | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/mrc.h" | ||
| 6 | #include "core/hle/hle.h" | ||
| 7 | #include "core/mem_map.h" | ||
| 8 | #include "core/core.h" | ||
| 9 | |||
| 10 | namespace HLE { | ||
| 11 | |||
| 12 | enum { | ||
| 13 | CMD_GX_REQUEST_DMA = 0x00000000, | ||
| 14 | }; | ||
| 15 | |||
| 16 | /// Data synchronization barrier | ||
| 17 | u32 DataSynchronizationBarrier(u32* command_buffer) { | ||
| 18 | u32 command = command_buffer[0]; | ||
| 19 | |||
| 20 | switch (command) { | ||
| 21 | |||
| 22 | case CMD_GX_REQUEST_DMA: | ||
| 23 | { | ||
| 24 | u32* src = (u32*)Memory::GetPointer(command_buffer[1]); | ||
| 25 | u32* dst = (u32*)Memory::GetPointer(command_buffer[2]); | ||
| 26 | u32 size = command_buffer[3]; | ||
| 27 | memcpy(dst, src, size); | ||
| 28 | } | ||
| 29 | break; | ||
| 30 | |||
| 31 | default: | ||
| 32 | ERROR_LOG(OSHLE, "MRC::DataSynchronizationBarrier unknown command 0x%08X", command); | ||
| 33 | return -1; | ||
| 34 | } | ||
| 35 | |||
| 36 | return 0; | ||
| 37 | } | ||
| 38 | |||
| 39 | /// Returns the coprocessor (in this case, syscore) command buffer pointer | ||
| 40 | Addr GetThreadCommandBuffer() { | ||
| 41 | // Called on insruction: mrc p15, 0, r0, c13, c0, 3 | ||
| 42 | // Returns an address in OSHLE memory for the CPU to read/write to | ||
| 43 | RETURN(CMD_BUFFER_ADDR); | ||
| 44 | return CMD_BUFFER_ADDR; | ||
| 45 | } | ||
| 46 | |||
| 47 | /// Call an MRC operation in HLE | ||
| 48 | u32 CallMRC(ARM11_MRC_OPERATION operation) { | ||
| 49 | switch (operation) { | ||
| 50 | |||
| 51 | case DATA_SYNCHRONIZATION_BARRIER: | ||
| 52 | return DataSynchronizationBarrier((u32*)Memory::GetPointer(PARAM(0))); | ||
| 53 | |||
| 54 | case CALL_GET_THREAD_COMMAND_BUFFER: | ||
| 55 | return GetThreadCommandBuffer(); | ||
| 56 | |||
| 57 | default: | ||
| 58 | ERROR_LOG(OSHLE, "unimplemented MRC operation 0x%02X", operation); | ||
| 59 | break; | ||
| 60 | } | ||
| 61 | return -1; | ||
| 62 | } | ||
| 63 | |||
| 64 | } // namespace | ||
diff --git a/src/core/hle/mrc.h b/src/core/hle/mrc.h new file mode 100644 index 000000000..d6b9f162f --- /dev/null +++ b/src/core/hle/mrc.h | |||
| @@ -0,0 +1,20 @@ | |||
| 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 HLE { | ||
| 10 | |||
| 11 | /// MRC operations (ARM register from coprocessor), decoded as instr[20:27] | ||
| 12 | enum ARM11_MRC_OPERATION { | ||
| 13 | DATA_SYNCHRONIZATION_BARRIER = 0xE0, | ||
| 14 | CALL_GET_THREAD_COMMAND_BUFFER = 0xE1, | ||
| 15 | }; | ||
| 16 | |||
| 17 | /// Call an MRC operation in HLE | ||
| 18 | u32 CallMRC(ARM11_MRC_OPERATION operation); | ||
| 19 | |||
| 20 | } // namespace | ||
diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp index 4f8d7248d..4a1e8c992 100644 --- a/src/core/hle/service/apt.cpp +++ b/src/core/hle/service/apt.cpp | |||
| @@ -13,16 +13,16 @@ | |||
| 13 | 13 | ||
| 14 | namespace APT_U { | 14 | namespace APT_U { |
| 15 | 15 | ||
| 16 | void Initialize() { | 16 | void Initialize(Service::Interface* self) { |
| 17 | NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); | 17 | NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | void GetLockHandle() { | 20 | void GetLockHandle(Service::Interface* self) { |
| 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | 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 | 22 | cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | const HLE::FunctionDef FunctionTable[] = { | 25 | const Interface::FunctionInfo FunctionTable[] = { |
| 26 | {0x00010040, GetLockHandle, "GetLockHandle"}, | 26 | {0x00010040, GetLockHandle, "GetLockHandle"}, |
| 27 | {0x00020080, Initialize, "Initialize"}, | 27 | {0x00020080, Initialize, "Initialize"}, |
| 28 | {0x00030040, NULL, "Enable"}, | 28 | {0x00030040, NULL, "Enable"}, |
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h index e74baac0c..4c7dd07e7 100644 --- a/src/core/hle/service/apt.h +++ b/src/core/hle/service/apt.h | |||
| @@ -32,10 +32,6 @@ public: | |||
| 32 | std::string GetPortName() const { | 32 | std::string GetPortName() const { |
| 33 | return "APT:U"; | 33 | return "APT:U"; |
| 34 | } | 34 | } |
| 35 | |||
| 36 | private: | ||
| 37 | |||
| 38 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 39 | }; | 35 | }; |
| 40 | 36 | ||
| 41 | } // namespace | 37 | } // namespace |
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index 7c80ab8b5..88c1f1a0f 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp | |||
| @@ -5,45 +5,96 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/log.h" | 6 | #include "common/log.h" |
| 7 | 7 | ||
| 8 | #include "core/mem_map.h" | ||
| 8 | #include "core/hle/hle.h" | 9 | #include "core/hle/hle.h" |
| 9 | #include "core/hle/service/gsp.h" | 10 | #include "core/hle/service/gsp.h" |
| 10 | 11 | ||
| 12 | #include "core/hw/lcd.h" | ||
| 13 | |||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 12 | // Namespace GSP_GPU | 15 | // Namespace GSP_GPU |
| 13 | 16 | ||
| 14 | namespace GSP_GPU { | 17 | namespace GSP_GPU { |
| 15 | 18 | ||
| 16 | const HLE::FunctionDef FunctionTable[] = { | 19 | enum { |
| 17 | {0x00010082, NULL, "WriteHWRegs"}, | 20 | REG_FRAMEBUFFER_1 = 0x00400468, |
| 18 | {0x00020084, NULL, "WriteHWRegsWithMask"}, | 21 | REG_FRAMEBUFFER_2 = 0x00400494, |
| 19 | {0x00030082, NULL, "WriteHWRegRepeat"}, | 22 | }; |
| 20 | {0x00040080, NULL, "ReadHWRegs"}, | 23 | |
| 21 | {0x00050200, NULL, "SetBufferSwap"}, | 24 | /// Read a GSP GPU hardware register |
| 22 | {0x00060082, NULL, "SetCommandList"}, | 25 | void ReadHWRegs(Service::Interface* self) { |
| 23 | {0x000700C2, NULL, "RequestDma"}, | 26 | static const u32 framebuffer_1[] = {LCD::PADDR_VRAM_TOP_LEFT_FRAME1, LCD::PADDR_VRAM_TOP_RIGHT_FRAME1}; |
| 24 | {0x00080082, NULL, "FlushDataCache"}, | 27 | static const u32 framebuffer_2[] = {LCD::PADDR_VRAM_TOP_LEFT_FRAME2, LCD::PADDR_VRAM_TOP_RIGHT_FRAME2}; |
| 25 | {0x00090082, NULL, "InvalidateDataCache"}, | 28 | |
| 26 | {0x000A0044, NULL, "RegisterInterruptEvents"}, | 29 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); |
| 27 | {0x000B0040, NULL, "SetLcdForceBlack"}, | 30 | u32 reg_addr = cmd_buff[1]; |
| 28 | {0x000C0000, NULL, "TriggerCmdReqQueue"}, | 31 | u32 size = cmd_buff[2]; |
| 29 | {0x000D0140, NULL, "SetDisplayTransfer"}, | 32 | u32* dst = (u32*)Memory::GetPointer(cmd_buff[0x41]); |
| 30 | {0x000E0180, NULL, "SetTextureCopy"}, | 33 | |
| 31 | {0x000F0200, NULL, "SetMemoryFill"}, | 34 | switch (reg_addr) { |
| 32 | {0x00100040, NULL, "SetAxiConfigQoSMode"}, | 35 | |
| 33 | {0x00110040, NULL, "SetPerfLogMode"}, | 36 | // NOTE: Calling SetFramebufferLocation here is a hack... Not sure the correct way yet to set |
| 34 | {0x00120000, NULL, "GetPerfLog"}, | 37 | // whether the framebuffers should be in VRAM or GSP heap, but from what I understand, if the |
| 35 | {0x00130042, NULL, "RegisterInterruptRelayQueue"}, | 38 | // user application is reading from either of these registers, then its going to be in VRAM. |
| 36 | {0x00140000, NULL, "UnregisterInterruptRelayQueue"}, | 39 | |
| 37 | {0x00150002, NULL, "TryAcquireRight"}, | 40 | // Top framebuffer 1 addresses |
| 38 | {0x00160042, NULL, "AcquireRight"}, | 41 | case REG_FRAMEBUFFER_1: |
| 39 | {0x00170000, NULL, "ReleaseRight"}, | 42 | LCD::SetFramebufferLocation(LCD::FRAMEBUFFER_LOCATION_VRAM); |
| 40 | {0x00180000, NULL, "ImportDisplayCaptureInfo"}, | 43 | memcpy(dst, framebuffer_1, size); |
| 41 | {0x00190000, NULL, "SaveVramSysArea"}, | 44 | break; |
| 42 | {0x001A0000, NULL, "RestoreVramSysArea"}, | 45 | |
| 43 | {0x001B0000, NULL, "ResetGpuCore"}, | 46 | // Top framebuffer 2 addresses |
| 44 | {0x001C0040, NULL, "SetLedForceOff"}, | 47 | case REG_FRAMEBUFFER_2: |
| 45 | {0x001D0040, NULL, "SetTestCommand"}, | 48 | LCD::SetFramebufferLocation(LCD::FRAMEBUFFER_LOCATION_VRAM); |
| 46 | {0x001E0080, NULL, "SetInternalPriorities"}, | 49 | memcpy(dst, framebuffer_2, size); |
| 50 | break; | ||
| 51 | |||
| 52 | default: | ||
| 53 | ERROR_LOG(OSHLE, "GSP_GPU::ReadHWRegs unknown register read at address %08X", reg_addr); | ||
| 54 | } | ||
| 55 | |||
| 56 | } | ||
| 57 | |||
| 58 | void RegisterInterruptRelayQueue(Service::Interface* self) { | ||
| 59 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | ||
| 60 | u32 flags = cmd_buff[1]; | ||
| 61 | u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling | ||
| 62 | cmd_buff[4] = self->NewHandle(); | ||
| 63 | |||
| 64 | return; | ||
| 65 | } | ||
| 66 | |||
| 67 | const Interface::FunctionInfo FunctionTable[] = { | ||
| 68 | {0x00010082, NULL, "WriteHWRegs"}, | ||
| 69 | {0x00020084, NULL, "WriteHWRegsWithMask"}, | ||
| 70 | {0x00030082, NULL, "WriteHWRegRepeat"}, | ||
| 71 | {0x00040080, ReadHWRegs, "ReadHWRegs"}, | ||
| 72 | {0x00050200, NULL, "SetBufferSwap"}, | ||
| 73 | {0x00060082, NULL, "SetCommandList"}, | ||
| 74 | {0x000700C2, NULL, "RequestDma"}, | ||
| 75 | {0x00080082, NULL, "FlushDataCache"}, | ||
| 76 | {0x00090082, NULL, "InvalidateDataCache"}, | ||
| 77 | {0x000A0044, NULL, "RegisterInterruptEvents"}, | ||
| 78 | {0x000B0040, NULL, "SetLcdForceBlack"}, | ||
| 79 | {0x000C0000, NULL, "TriggerCmdReqQueue"}, | ||
| 80 | {0x000D0140, NULL, "SetDisplayTransfer"}, | ||
| 81 | {0x000E0180, NULL, "SetTextureCopy"}, | ||
| 82 | {0x000F0200, NULL, "SetMemoryFill"}, | ||
| 83 | {0x00100040, NULL, "SetAxiConfigQoSMode"}, | ||
| 84 | {0x00110040, NULL, "SetPerfLogMode"}, | ||
| 85 | {0x00120000, NULL, "GetPerfLog"}, | ||
| 86 | {0x00130042, RegisterInterruptRelayQueue, "RegisterInterruptRelayQueue"}, | ||
| 87 | {0x00140000, NULL, "UnregisterInterruptRelayQueue"}, | ||
| 88 | {0x00150002, NULL, "TryAcquireRight"}, | ||
| 89 | {0x00160042, NULL, "AcquireRight"}, | ||
| 90 | {0x00170000, NULL, "ReleaseRight"}, | ||
| 91 | {0x00180000, NULL, "ImportDisplayCaptureInfo"}, | ||
| 92 | {0x00190000, NULL, "SaveVramSysArea"}, | ||
| 93 | {0x001A0000, NULL, "RestoreVramSysArea"}, | ||
| 94 | {0x001B0000, NULL, "ResetGpuCore"}, | ||
| 95 | {0x001C0040, NULL, "SetLedForceOff"}, | ||
| 96 | {0x001D0040, NULL, "SetTestCommand"}, | ||
| 97 | {0x001E0080, NULL, "SetInternalPriorities"}, | ||
| 47 | }; | 98 | }; |
| 48 | 99 | ||
| 49 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 100 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h index 3b1846082..5ba09ab70 100644 --- a/src/core/hle/service/gsp.h +++ b/src/core/hle/service/gsp.h | |||
| @@ -27,9 +27,6 @@ public: | |||
| 27 | return "gsp::Gpu"; | 27 | return "gsp::Gpu"; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | private: | ||
| 31 | |||
| 32 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 33 | }; | 30 | }; |
| 34 | 31 | ||
| 35 | } // namespace | 32 | } // namespace |
diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp index 2d823dd16..5542e5bf2 100644 --- a/src/core/hle/service/hid.cpp +++ b/src/core/hle/service/hid.cpp | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace HID_User { | 13 | namespace HID_User { |
| 14 | 14 | ||
| 15 | const HLE::FunctionDef FunctionTable[] = { | 15 | const Interface::FunctionInfo FunctionTable[] = { |
| 16 | {0x000A0000, NULL, "GetIPCHandles"}, | 16 | {0x000A0000, NULL, "GetIPCHandles"}, |
| 17 | {0x00110000, NULL, "EnableAccelerometer"}, | 17 | {0x00110000, NULL, "EnableAccelerometer"}, |
| 18 | {0x00130000, NULL, "EnableGyroscopeLow"}, | 18 | {0x00130000, NULL, "EnableGyroscopeLow"}, |
diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h index 746c1b1fc..b17fcfa86 100644 --- a/src/core/hle/service/hid.h +++ b/src/core/hle/service/hid.h | |||
| @@ -29,9 +29,6 @@ public: | |||
| 29 | return "hid:USER"; | 29 | return "hid:USER"; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | private: | ||
| 33 | |||
| 34 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 35 | }; | 32 | }; |
| 36 | 33 | ||
| 37 | } // namespace | 34 | } // namespace |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 9cbf8b6fa..b79dc9458 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -25,7 +25,7 @@ static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer | |||
| 25 | class Manager; | 25 | class Manager; |
| 26 | 26 | ||
| 27 | /// Interface to a CTROS service | 27 | /// Interface to a CTROS service |
| 28 | class Interface { | 28 | class Interface : NonCopyable { |
| 29 | friend class Manager; | 29 | friend class Manager; |
| 30 | public: | 30 | public: |
| 31 | 31 | ||
| @@ -35,6 +35,14 @@ public: | |||
| 35 | virtual ~Interface() { | 35 | virtual ~Interface() { |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | typedef void (*Function)(Interface*); | ||
| 39 | |||
| 40 | struct FunctionInfo { | ||
| 41 | u32 id; | ||
| 42 | Function func; | ||
| 43 | std::string name; | ||
| 44 | }; | ||
| 45 | |||
| 38 | /** | 46 | /** |
| 39 | * Gets the UID for the serice | 47 | * Gets the UID for the serice |
| 40 | * @return UID of service in native format | 48 | * @return UID of service in native format |
| @@ -51,6 +59,23 @@ public: | |||
| 51 | return "[UNKNOWN SERVICE PORT]"; | 59 | return "[UNKNOWN SERVICE PORT]"; |
| 52 | } | 60 | } |
| 53 | 61 | ||
| 62 | /// Allocates a new handle for the service | ||
| 63 | Syscall::Handle NewHandle() { | ||
| 64 | Syscall::Handle handle = (m_handles.size() << 16) | m_uid; | ||
| 65 | m_handles.push_back(handle); | ||
| 66 | return handle; | ||
| 67 | } | ||
| 68 | |||
| 69 | /// Frees a handle from the service | ||
| 70 | void DeleteHandle(Syscall::Handle handle) { | ||
| 71 | for(auto iter = m_handles.begin(); iter != m_handles.end(); ++iter) { | ||
| 72 | if(*iter == handle) { | ||
| 73 | m_handles.erase(iter); | ||
| 74 | break; | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 54 | /** | 79 | /** |
| 55 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand | 80 | * Called when svcSendSyncRequest is called, loads command buffer and executes comand |
| 56 | * @return Return result of svcSendSyncRequest passed back to user app | 81 | * @return Return result of svcSendSyncRequest passed back to user app |
| @@ -70,16 +95,17 @@ public: | |||
| 70 | return -1; | 95 | return -1; |
| 71 | } | 96 | } |
| 72 | 97 | ||
| 73 | itr->second.func(); | 98 | itr->second.func(this); |
| 74 | 99 | ||
| 75 | return 0; // TODO: Implement return from actual function | 100 | return 0; // TODO: Implement return from actual function |
| 76 | } | 101 | } |
| 77 | 102 | ||
| 78 | protected: | 103 | protected: |
| 104 | |||
| 79 | /** | 105 | /** |
| 80 | * Registers the functions in the service | 106 | * Registers the functions in the service |
| 81 | */ | 107 | */ |
| 82 | void Register(const HLE::FunctionDef* functions, int len) { | 108 | void Register(const FunctionInfo* functions, int len) { |
| 83 | for (int i = 0; i < len; i++) { | 109 | for (int i = 0; i < len; i++) { |
| 84 | m_functions[functions[i].id] = functions[i]; | 110 | m_functions[functions[i].id] = functions[i]; |
| 85 | } | 111 | } |
| @@ -87,9 +113,9 @@ protected: | |||
| 87 | 113 | ||
| 88 | private: | 114 | private: |
| 89 | u32 m_uid; | 115 | u32 m_uid; |
| 90 | std::map<u32, HLE::FunctionDef> m_functions; | 116 | |
| 91 | 117 | std::vector<Syscall::Handle> m_handles; | |
| 92 | DISALLOW_COPY_AND_ASSIGN(Interface); | 118 | std::map<u32, FunctionInfo> m_functions; |
| 93 | }; | 119 | }; |
| 94 | 120 | ||
| 95 | /// Simple class to manage accessing services from ports and UID handles | 121 | /// Simple class to manage accessing services from ports and UID handles |
| @@ -126,8 +152,6 @@ private: | |||
| 126 | 152 | ||
| 127 | std::vector<Interface*> m_services; | 153 | std::vector<Interface*> m_services; |
| 128 | std::map<std::string, u32> m_port_map; | 154 | std::map<std::string, u32> m_port_map; |
| 129 | |||
| 130 | DISALLOW_COPY_AND_ASSIGN(Manager); | ||
| 131 | }; | 155 | }; |
| 132 | 156 | ||
| 133 | /// Initialize ServiceManager | 157 | /// Initialize ServiceManager |
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index 579ea4a34..9437868c5 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp | |||
| @@ -12,11 +12,11 @@ | |||
| 12 | 12 | ||
| 13 | namespace SRV { | 13 | namespace SRV { |
| 14 | 14 | ||
| 15 | void Initialize() { | 15 | void Initialize(Service::Interface* self) { |
| 16 | NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); | 16 | NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | void GetServiceHandle() { | 19 | void GetServiceHandle(Service::Interface* self) { |
| 20 | Syscall::Result res = 0; | 20 | Syscall::Result res = 0; |
| 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); | 21 | u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); |
| 22 | 22 | ||
| @@ -37,7 +37,7 @@ void GetServiceHandle() { | |||
| 37 | //return res; | 37 | //return res; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | const HLE::FunctionDef FunctionTable[] = { | 40 | const Interface::FunctionInfo FunctionTable[] = { |
| 41 | {0x00010002, Initialize, "Initialize"}, | 41 | {0x00010002, Initialize, "Initialize"}, |
| 42 | {0x00020000, NULL, "GetProcSemaphore"}, | 42 | {0x00020000, NULL, "GetProcSemaphore"}, |
| 43 | {0x00030100, NULL, "RegisterService"}, | 43 | {0x00030100, NULL, "RegisterService"}, |
diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h index d9ac8fc88..760c976b4 100644 --- a/src/core/hle/service/srv.h +++ b/src/core/hle/service/srv.h | |||
| @@ -32,9 +32,6 @@ public: | |||
| 32 | */ | 32 | */ |
| 33 | Syscall::Result Sync(); | 33 | Syscall::Result Sync(); |
| 34 | 34 | ||
| 35 | private: | ||
| 36 | |||
| 37 | DISALLOW_COPY_AND_ASSIGN(Interface); | ||
| 38 | }; | 35 | }; |
| 39 | 36 | ||
| 40 | } // namespace | 37 | } // namespace |
diff --git a/src/core/hle/syscall.cpp b/src/core/hle/syscall.cpp index e5533a741..df6412743 100644 --- a/src/core/hle/syscall.cpp +++ b/src/core/hle/syscall.cpp | |||
| @@ -15,14 +15,29 @@ | |||
| 15 | 15 | ||
| 16 | namespace Syscall { | 16 | namespace Syscall { |
| 17 | 17 | ||
| 18 | enum ControlMemoryOperation { | ||
| 19 | MEMORY_OPERATION_HEAP = 0x00000003, | ||
| 20 | MEMORY_OPERATION_GSP_HEAP = 0x00010003, | ||
| 21 | }; | ||
| 22 | |||
| 23 | enum MapMemoryPermission { | ||
| 24 | MEMORY_PERMISSION_UNMAP = 0x00000000, | ||
| 25 | MEMORY_PERMISSION_NORMAL = 0x00000001, | ||
| 26 | }; | ||
| 27 | |||
| 18 | /// Map application or GSP heap memory | 28 | /// Map application or GSP heap memory |
| 19 | Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operation, u32 permissions) { | 29 | Result ControlMemory(u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { |
| 20 | u32 virtual_address = 0x00000000; | 30 | u32 virtual_address = 0x00000000; |
| 21 | 31 | ||
| 22 | switch (operation) { | 32 | switch (operation) { |
| 23 | 33 | ||
| 24 | // Map GSP heap memory? | 34 | // Map normal heap memory |
| 25 | case 0x00010003: | 35 | case MEMORY_OPERATION_HEAP: |
| 36 | virtual_address = Memory::MapBlock_Heap(size, operation, permissions); | ||
| 37 | break; | ||
| 38 | |||
| 39 | // Map GSP heap memory | ||
| 40 | case MEMORY_OPERATION_GSP_HEAP: | ||
| 26 | virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); | 41 | virtual_address = Memory::MapBlock_HeapGSP(size, operation, permissions); |
| 27 | break; | 42 | break; |
| 28 | 43 | ||
| @@ -31,7 +46,22 @@ Result ControlMemory(void* outaddr, u32 addr0, u32 addr1, u32 size, u32 operatio | |||
| 31 | ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation); | 46 | ERROR_LOG(OSHLE, "Unknown ControlMemory operation %08X", operation); |
| 32 | } | 47 | } |
| 33 | 48 | ||
| 34 | Core::g_app_core->SetReg(1, Memory::MapBlock_HeapGSP(size, operation, permissions)); | 49 | Core::g_app_core->SetReg(1, virtual_address); |
| 50 | return 0; | ||
| 51 | } | ||
| 52 | |||
| 53 | /// Maps a memory block to specified address | ||
| 54 | Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) { | ||
| 55 | int x = 0; | ||
| 56 | switch (mypermissions) { | ||
| 57 | case MEMORY_PERMISSION_NORMAL: | ||
| 58 | case MEMORY_PERMISSION_NORMAL + 1: | ||
| 59 | case MEMORY_PERMISSION_NORMAL + 2: | ||
| 60 | Memory::MapBlock_Shared(memblock, addr, mypermissions); | ||
| 61 | break; | ||
| 62 | default: | ||
| 63 | ERROR_LOG(OSHLE, "Unknown MapMemoryBlock permissions %08X", mypermissions); | ||
| 64 | } | ||
| 35 | return 0; | 65 | return 0; |
| 36 | } | 66 | } |
| 37 | 67 | ||
| @@ -63,7 +93,7 @@ Result WaitSynchronization1(Handle handle, s64 nanoseconds) { | |||
| 63 | 93 | ||
| 64 | const HLE::FunctionDef Syscall_Table[] = { | 94 | const HLE::FunctionDef Syscall_Table[] = { |
| 65 | {0x00, NULL, "Unknown"}, | 95 | {0x00, NULL, "Unknown"}, |
| 66 | {0x01, WrapI_VUUUUU<ControlMemory>, "ControlMemory"}, | 96 | {0x01, WrapI_UUUUU<ControlMemory>, "ControlMemory"}, |
| 67 | {0x02, NULL, "QueryMemory"}, | 97 | {0x02, NULL, "QueryMemory"}, |
| 68 | {0x03, NULL, "ExitProcess"}, | 98 | {0x03, NULL, "ExitProcess"}, |
| 69 | {0x04, NULL, "GetProcessAffinityMask"}, | 99 | {0x04, NULL, "GetProcessAffinityMask"}, |
| @@ -93,7 +123,7 @@ const HLE::FunctionDef Syscall_Table[] = { | |||
| 93 | {0x1C, NULL, "CancelTimer"}, | 123 | {0x1C, NULL, "CancelTimer"}, |
| 94 | {0x1D, NULL, "ClearTimer"}, | 124 | {0x1D, NULL, "ClearTimer"}, |
| 95 | {0x1E, NULL, "CreateMemoryBlock"}, | 125 | {0x1E, NULL, "CreateMemoryBlock"}, |
| 96 | {0x1F, NULL, "MapMemoryBlock"}, | 126 | {0x1F, WrapI_UUUU<MapMemoryBlock>, "MapMemoryBlock"}, |
| 97 | {0x20, NULL, "UnmapMemoryBlock"}, | 127 | {0x20, NULL, "UnmapMemoryBlock"}, |
| 98 | {0x21, NULL, "CreateAddressArbiter"}, | 128 | {0x21, NULL, "CreateAddressArbiter"}, |
| 99 | {0x22, NULL, "ArbitrateAddress"}, | 129 | {0x22, NULL, "ArbitrateAddress"}, |