9 #define GSP_EVENT_STACK_SIZE 0x1000
18 static vu8* gspEventData;
20 static void gspEventThreadMain(
u32 arg);
44 for (j = 0; j < i; j ++)
52 gspEventData = _gspSharedMem + gspThreadId*0x40;
81 void gspEventThreadMain(
u32 arg)
88 int count = gspEventData[1];
89 int cur = gspEventData[0];
90 int last = cur + count;
91 while (last >= 0x34) last -= 0x34;
93 for (i = 0; i < count; i ++)
95 int curEvt = gspEventData[0xC + cur];
97 if (cur >= 0x34) cur -= 0x34;
102 gspEventData[0] = last;
103 gspEventData[1] -= count;
113 if(size>0x80 || !data)
return -1;
116 cmdbuf[0]=0x00010082;
119 cmdbuf[3]=(size<<14)|2;
132 if(datasize>0x80 || !data)
return -1;
135 cmdbuf[0]=0x00020084;
138 cmdbuf[3]=(datasize<<14)|2;
140 cmdbuf[5]=(masksize<<14)|0x402;
141 cmdbuf[6]=(
u32)maskdata;
153 if(size>0x80 || !data)
return -1;
156 cmdbuf[0]=0x00040080;
159 cmdbuf[0x40]=(size<<14)|2;
160 cmdbuf[0x40+1]=(
u32)data;
175 cmdbuf[0] = 0x00050200;
176 cmdbuf[1] = screenid;
189 cmdbuf[0]=0x00080082;
193 cmdbuf[4]=0xffff8001;
208 cmdbuf[0] = 0x00090082;
209 cmdbuf[1] = (
u32)adr;
212 cmdbuf[4] = 0xFFFF8001;
224 cmdbuf[0]=0x000B0040;
238 cmdbuf[0]=0x000C0000;
251 cmdbuf[0]=0x00130042;
254 cmdbuf[3]=eventHandle;
259 if(threadID)*threadID=cmdbuf[2];
260 if(outMemHandle)*outMemHandle=cmdbuf[4];
270 cmdbuf[0]=0x00140000;
286 cmdbuf[3]=0xffff8001;
312 cmdbuf[0]=0x00180000;
321 memcpy(captureinfo, &cmdbuf[2], 0x20);
332 cmdbuf[0]=0x00190000;
345 cmdbuf[0]=0x001A0000;
358 if(!sharedGspCmdBuf || !gxCommand)
return -1;
361 __asm__ __volatile__ (
"ldrex %[result], [%[adr]]" : [result]
"=r" (cmdBufHeader) : [adr]
"r" (sharedGspCmdBuf));
363 u8 commandIndex=cmdBufHeader&0xFF;
364 u8 totalCommands=(cmdBufHeader>>8)&0xFF;
366 if(totalCommands>=15)
return -2;
368 u8 nextCmd=(commandIndex+totalCommands)%15;
369 u32* dst=&sharedGspCmdBuf[8*(1+nextCmd)];
370 memcpy(dst, gxCommand, 0x20);
373 __asm__ __volatile__ (
"mcr p15, 0, %[val], c7, c10, 4" :: [val]
"r" (mcrVal));
375 cmdBufHeader=((cmdBufHeader)&0xFFFF00FF)|(((
u32)totalCommands)<<8);
380 __asm__ __volatile__ (
"strex %[result], %[val], [%[adr]]" : [result]
"=&r" (strexResult) : [adr]
"r" (sharedGspCmdBuf), [val]
"r" (cmdBufHeader));
381 if(!strexResult)
break;
383 __asm__ __volatile__ (
"ldrex %[result], [%[adr]]" : [result]
"=r" (cmdBufHeader) : [adr]
"r" (sharedGspCmdBuf));
384 totalCommands=((cmdBufHeader&0xFF00)>>8)+1;
385 cmdBufHeader=((cmdBufHeader)&0xFFFF00FF)|((totalCommands<<8)&0xFF00);
s32 svcClearEvent(Handle handle)
Result GSPGPU_ImportDisplayCaptureInfo(Handle *handle, GSP_CaptureInfo *captureinfo)
s32 svcCloseHandle(Handle handle)
s32 svcWaitSynchronization(Handle handle, s64 nanoseconds)
s32 svcCreateThread(Handle *thread, ThreadFunc entrypoint, u32 arg, u32 *stack_top, s32 thread_priority, s32 processor_id)
Result srvGetServiceHandle(Handle *out, const char *name)
Result GSPGPU_ReleaseRight(Handle *handle)
Result GSPGPU_SubmitGxCommand(u32 *sharedGspCmdBuf, u32 gxCommand[0x8], Handle *handle)
Result GSPGPU_WriteHWRegs(Handle *handle, u32 regAddr, u32 *data, u8 size)
Result gspInitEventHandler(Handle _gspEvent, vu8 *_gspSharedMem, u8 gspThreadId)
Result GSPGPU_RestoreVramSysArea(Handle *handle)
Result GSPGPU_WriteHWRegsWithMask(Handle *handle, u32 regAddr, u32 *data, u8 datasize, u32 *maskdata, u8 masksize)
u32 * getThreadCommandBuffer(void)
Result GSPGPU_FlushDataCache(Handle *handle, u8 *adr, u32 size)
volatile bool gspRunEvents
Result GSPGPU_SaveVramSysArea(Handle *handle)
Result GSPGPU_TriggerCmdReqQueue(Handle *handle)
void gspWaitForEvent(GSP_Event id, bool nextEvent)
Result GSPGPU_ReadHWRegs(Handle *handle, u32 regAddr, u32 *data, u8 size)
Result GSPGPU_SetLcdForceBlack(Handle *handle, u8 flags)
s32 svcCreateEvent(Handle *event, u8 reset_type)
Result GSPGPU_SetBufferSwap(Handle *handle, u32 screenid, GSP_FramebufferInfo *framebufinfo)
Handle gspEvents[GSPEVENT_MAX]
s32 svcSendSyncRequest(Handle session)
Result GSPGPU_InvalidateDataCache(Handle *handle, u8 *adr, u32 size)
Result GSPGPU_UnregisterInterruptRelayQueue(Handle *handle)
Result GSPGPU_AcquireRight(Handle *handle, u8 flags)
s32 svcSignalEvent(Handle handle)
#define GSP_EVENT_STACK_SIZE
u64 gspEventStack[GSP_EVENT_STACK_SIZE/sizeof(u64)]
Result GSPGPU_RegisterInterruptRelayQueue(Handle *handle, Handle eventHandle, u32 flags, Handle *outMemHandle, u8 *threadID)
void gspExitEventHandler()