summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Tony Wasserka2014-05-17 22:26:45 +0200
committerGravatar bunnei2014-06-12 06:10:48 -0400
commit82d32603593cbec12499c5f0bfcbe61d2cac5629 (patch)
tree1e7ae95f30841f4a424ed4cfe8d20d84be4392cd /src/core
parentPica: Add command list registers. (diff)
downloadyuzu-82d32603593cbec12499c5f0bfcbe61d2cac5629.tar.gz
yuzu-82d32603593cbec12499c5f0bfcbe61d2cac5629.tar.xz
yuzu-82d32603593cbec12499c5f0bfcbe61d2cac5629.zip
GSP: Define more GX commands.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/gsp.cpp51
-rw-r--r--src/core/hle/service/gsp.h17
2 files changed, 54 insertions, 14 deletions
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp
index 50cee2c41..3dda4c934 100644
--- a/src/core/hle/service/gsp.cpp
+++ b/src/core/hle/service/gsp.cpp
@@ -12,23 +12,24 @@
12 12
13#include "core/hw/lcd.h" 13#include "core/hw/lcd.h"
14 14
15#include "video_core/gpu_debugger.h"
16
15//////////////////////////////////////////////////////////////////////////////////////////////////// 17////////////////////////////////////////////////////////////////////////////////////////////////////
16 18
17/// GSP shared memory GX command buffer header 19/// GSP shared memory GX command buffer header
18union GX_CmdBufferHeader { 20union GX_CmdBufferHeader {
19 u32 hex; 21 u32 hex;
20 22
21 // Current command index. This index is updated by GSP module after loading the command data, 23 // Current command index. This index is updated by GSP module after loading the command data,
22 // right before the command is processed. When this index is updated by GSP module, the total 24 // right before the command is processed. When this index is updated by GSP module, the total
23 // commands field is decreased by one as well. 25 // commands field is decreased by one as well.
24 BitField<0,8,u32> index; 26 BitField<0,8,u32> index;
25 27
26 // Total commands to process, must not be value 0 when GSP module handles commands. This must be 28 // Total commands to process, must not be value 0 when GSP module handles commands. This must be
27 // <=15 when writing a command to shared memory. This is incremented by the application when 29 // <=15 when writing a command to shared memory. This is incremented by the application when
28 // writing a command to shared memory, after increasing this value TriggerCmdReqQueue is only 30 // writing a command to shared memory, after increasing this value TriggerCmdReqQueue is only
29 // used if this field is value 1. 31 // used if this field is value 1.
30 BitField<8,8,u32> number_commands; 32 BitField<8,8,u32> number_commands;
31
32}; 33};
33 34
34/// Gets the address of the start (header) of a command buffer in GSP shared memory 35/// Gets the address of the start (header) of a command buffer in GSP shared memory
@@ -45,6 +46,7 @@ static inline u8* GX_GetCmdBufferPointer(u32 thread_id, u32 offset=0) {
45void GX_FinishCommand(u32 thread_id) { 46void GX_FinishCommand(u32 thread_id) {
46 GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id); 47 GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id);
47 header->number_commands = header->number_commands - 1; 48 header->number_commands = header->number_commands - 1;
49 // TODO: Increment header->index?
48} 50}
49 51
50//////////////////////////////////////////////////////////////////////////////////////////////////// 52////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -55,10 +57,6 @@ namespace GSP_GPU {
55u32 g_thread_id = 0; 57u32 g_thread_id = 0;
56 58
57enum { 59enum {
58 CMD_GX_REQUEST_DMA = 0x00000000,
59};
60
61enum {
62 REG_FRAMEBUFFER_1 = 0x00400468, 60 REG_FRAMEBUFFER_1 = 0x00400468,
63 REG_FRAMEBUFFER_2 = 0x00400494, 61 REG_FRAMEBUFFER_2 = 0x00400494,
64}; 62};
@@ -72,7 +70,7 @@ void ReadHWRegs(Service::Interface* self) {
72 u32 reg_addr = cmd_buff[1]; 70 u32 reg_addr = cmd_buff[1];
73 u32 size = cmd_buff[2]; 71 u32 size = cmd_buff[2];
74 u32* dst = (u32*)Memory::GetPointer(cmd_buff[0x41]); 72 u32* dst = (u32*)Memory::GetPointer(cmd_buff[0x41]);
75 73
76 switch (reg_addr) { 74 switch (reg_addr) {
77 75
78 // NOTE: Calling SetFramebufferLocation here is a hack... Not sure the correct way yet to set 76 // NOTE: Calling SetFramebufferLocation here is a hack... Not sure the correct way yet to set
@@ -101,25 +99,50 @@ void RegisterInterruptRelayQueue(Service::Interface* self) {
101 u32* cmd_buff = Service::GetCommandBuffer(); 99 u32* cmd_buff = Service::GetCommandBuffer();
102 u32 flags = cmd_buff[1]; 100 u32 flags = cmd_buff[1];
103 u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling 101 u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling
102
104 cmd_buff[2] = g_thread_id; // ThreadID 103 cmd_buff[2] = g_thread_id; // ThreadID
105} 104}
106 105
106
107/// This triggers handling of the GX command written to the command buffer in shared memory. 107/// This triggers handling of the GX command written to the command buffer in shared memory.
108void TriggerCmdReqQueue(Service::Interface* self) { 108void TriggerCmdReqQueue(Service::Interface* self) {
109 GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id); 109 GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id);
110 u32* cmd_buff = (u32*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20)); 110 u32* cmd_buff = (u32*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20));
111 111
112 switch (cmd_buff[0]) { 112 switch (static_cast<GXCommandId>(cmd_buff[0])) {
113 113
114 // GX request DMA - typically used for copying memory from GSP heap to VRAM 114 // GX request DMA - typically used for copying memory from GSP heap to VRAM
115 case CMD_GX_REQUEST_DMA: 115 case GXCommandId::REQUEST_DMA:
116 memcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]); 116 memcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]);
117 break; 117 break;
118 118
119 case GXCommandId::SET_COMMAND_LIST_LAST:
120 LCD::Write<u32>(LCD::CommandListAddress, cmd_buff[1] >> 3);
121 LCD::Write<u32>(LCD::CommandListSize, cmd_buff[2] >> 3);
122 LCD::Write<u32>(LCD::ProcessCommandList, 1); // TODO: Not sure if we are supposed to always write this
123 break;
124
125 case GXCommandId::SET_MEMORY_FILL:
126 break;
127
128 case GXCommandId::SET_DISPLAY_TRANSFER:
129 break;
130
131 case GXCommandId::SET_TEXTURE_COPY:
132 break;
133
134 case GXCommandId::SET_COMMAND_LIST_FIRST:
135 {
136 //u32* buf0_data = (u32*)Memory::GetPointer(cmd_buff[1]);
137 //u32* buf1_data = (u32*)Memory::GetPointer(cmd_buff[3]);
138 //u32* buf2_data = (u32*)Memory::GetPointer(cmd_buff[5]);
139 break;
140 }
141
119 default: 142 default:
120 ERROR_LOG(GSP, "TriggerCmdReqQueue unknown command 0x%08X", cmd_buff[0]); 143 ERROR_LOG(GSP, "TriggerCmdReqQueue unknown command 0x%08X", cmd_buff[0]);
121 } 144 }
122 145
123 GX_FinishCommand(g_thread_id); 146 GX_FinishCommand(g_thread_id);
124} 147}
125 148
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h
index eb5786cd1..214de140f 100644
--- a/src/core/hle/service/gsp.h
+++ b/src/core/hle/service/gsp.h
@@ -11,6 +11,23 @@
11 11
12namespace GSP_GPU { 12namespace GSP_GPU {
13 13
14enum class GXCommandId : u32 {
15 REQUEST_DMA = 0x00000000,
16 SET_COMMAND_LIST_LAST = 0x00000001,
17 SET_MEMORY_FILL = 0x00000002, // TODO: Confirm? (lictru uses 0x01000102)
18 SET_DISPLAY_TRANSFER = 0x00000003,
19 SET_TEXTURE_COPY = 0x00000004,
20 SET_COMMAND_LIST_FIRST = 0x00000005,
21};
22
23union GXCommand {
24 struct {
25 GXCommandId id;
26 };
27
28 u32 data[0x20];
29};
30
14/// Interface to "srv:" service 31/// Interface to "srv:" service
15class Interface : public Service::Interface { 32class Interface : public Service::Interface {
16public: 33public: