diff options
Diffstat (limited to 'src/core/hle/service/gsp.cpp')
| -rw-r--r-- | src/core/hle/service/gsp.cpp | 113 |
1 files changed, 82 insertions, 31 deletions
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 | //////////////////////////////////////////////////////////////////////////////////////////////////// |