psl1ght
A free SDK for Sony's PS3 console
spu.h
Go to the documentation of this file.
1 
98 #ifndef __SYS_SPU_H__
99 #define __SYS_SPU_H__
100 
101 #include <ppu-asm.h>
102 #include <ppu-lv2.h>
103 #include <lv2/spu.h>
104 
105 /* MFC channel registers */
106 #define MFC_LSA 0x3004
107 #define MFC_EAH 0x3008
108 #define MFC_EAL 0x300C
109 #define MFC_Size 0x3010
110 #define MFC_Class_CMD 0x3014
111 #define MFC_CMD_Status 0x3014
112 #define MFC_QStatus 0x3104
113 #define Prxy_QueryType 0x3204
114 #define Prxy_QueryMask 0x321C
115 #define Prxy_TagStatus 0x322C
116 #define SPU_Out_MBox 0x4004
117 #define SPU_In_MBox 0x400C
118 #define SPU_MBox_Status 0x4014
119 #define SPU_RunCtrl 0x401C
120 #define SPU_Status 0x4024
121 #define SPU_NextPC 0x4034
122 #define SPU_Sig_Notify_1 0x1400C
123 #define SPU_Sig_Notify_2 0x1C00C
124 
125 #define SPU_THREAD_ATTR_NONE 0x00
127 #define SPU_THREAD_ATTR_ASYNC_INT_ENABLE 0x01
129 #define SPU_THREAD_ATTR_DEC_SYNC_TB_ENABLE 0x02
131 
133 #define SPU_THREAD_EVENT_USER 0x01
134 #define SPU_THREAD_EVENT_DMA 0x02
136 
138 #define SPU_THREAD_EVENT_USER_KEY 0xFFFFFFFF53505501ULL
139 #define SPU_THREAD_EVENT_DMA_KEY 0xFFFFFFFF53505502ULL
141 
143 #define SPU_SIGNAL1_OVERWRITE 0x00
144 #define SPU_SIGNAL1_OR 0x01
146 #define SPU_SIGNAL2_OVERWRITE 0x00
148 #define SPU_SIGNAL2_OR 0x02
150 
152 #define SPU_THREAD_BASE 0xF0000000ULL
153 #define SPU_THREAD_OFFSET 0x00100000ULL
155 #define SPU_RAW_BASE 0xE0000000ULL
157 #define SPU_RAW_OFFSET 0x00100000ULL
159 #define SPU_LOCAL_OFFSET 0x00000000ULL
161 #define SPU_PROBLEM_OFFSET 0x00040000ULL
163 
167 #define SPU_RAW_GET_BASE_OFFSET(spu) \
168  (SPU_RAW_BASE + (SPU_RAW_OFFSET*(spu)))
169 
171 #define SPU_RAW_GET_LOCAL_STORAGE(spu,reg) \
172  (SPU_RAW_GET_BASE_OFFSET(spu) + SPU_LOCAL_OFFSET + (reg))
173 
175 #define SPU_RAW_GET_PROBLEM_STORAGE(spu,reg) \
176  (SPU_RAW_GET_BASE_OFFSET(spu) + SPU_PROBLEM_OFFSET + (reg))
177 
181 #define SPU_THREAD_GET_BASE_OFFSET(spu) \
182  (SPU_THREAD_BASE + (SPU_THREAD_OFFSET*(spu)))
183 
185 #define SPU_THREAD_GET_LOCAL_STORAGE(spu,reg) \
186  (SPU_THREAD_GET_BASE_OFFSET(spu) + SPU_LOCAL_OFFSET + (reg))
187 
189 #define SPU_THREAD_GET_PROBLEM_STORAGE(spu,reg) \
190  (SPU_THREAD_GET_BASE_OFFSET(spu) + SPU_PROBLEM_OFFSET + (reg))
191 
192 #ifdef __cplusplus
193 extern "C" {
194 #endif
195 
197 typedef struct _sys_spu_thread_arg
198 {
199  u64 arg0;
200  u64 arg1;
201  u64 arg2;
202  u64 arg3;
204 
212 typedef struct _sys_spu_thread_attr
213 {
215  u32 nameSize;
216  u32 attribute;
218 
221 {
222  u32 nameSize;
224  u32 groupType;
227 
236 LV2_SYSCALL sysSpuInitialize(u32 spus,u32 rawspus)
237 {
238  lv2syscall2(169,spus,rawspus);
239  return_to_user_prog(s32);
240 }
241 
250 LV2_SYSCALL sysSpuRawCreate(sys_raw_spu_t *spu,u32 *attributes)
251 {
252  lv2syscall2(160,(u64)spu,(u64)attributes);
253  return_to_user_prog(s32);
254 }
255 
262 LV2_SYSCALL sysSpuRawDestroy(sys_raw_spu_t spu)
263 {
264  lv2syscall1(161,spu);
265  return_to_user_prog(s32);
266 }
267 
280 LV2_SYSCALL sysSpuRawCreateInterrupTag(sys_raw_spu_t spu,u32 classid,u32 hardwarethread,u32 *tag)
281 {
282  lv2syscall4(150,spu,classid,hardwarethread,(u64)tag);
283  return_to_user_prog(s32);
284 }
285 
296 LV2_SYSCALL sysSpuRawSetIntMask(sys_raw_spu_t spu,u32 classid,u64 mask)
297 {
298  lv2syscall3(151,spu,classid,mask);
299  return_to_user_prog(s32);
300 }
301 
312 LV2_SYSCALL sysSpuRawGetIntMask(sys_raw_spu_t spu,u32 classid,u64 *mask)
313 {
314  lv2syscall3(152,spu,classid,(u64)mask);
315  return_to_user_prog(s32);
316 }
317 
328 LV2_SYSCALL sysSpuRawSetIntStat(sys_raw_spu_t spu, u32 classid, u64 stat)
329 {
330  lv2syscall3(153, spu, classid, stat);
331  return_to_user_prog(s32);
332 }
333 
344 LV2_SYSCALL sysSpuRawGetIntStat(sys_raw_spu_t spu, u32 classid, u64* stat)
345 {
346  lv2syscall3(154, spu, classid, (u64)stat);
347  return_to_user_prog(s32);
348 }
349 
358 LV2_SYSCALL sysSpuRawReadPuintMb(sys_raw_spu_t spu, u32* value)
359 {
360  lv2syscall2(163, spu, (u64)value);
361  return_to_user_prog(s32);
362 }
363 
376 LV2_SYSCALL sysSpuRawSetConfiguration(sys_raw_spu_t spu, u32 value)
377 {
378  lv2syscall2(196, spu, value);
379  return_to_user_prog(s32);
380 }
381 
395 LV2_SYSCALL sysSpuRawGetConfirugation(sys_raw_spu_t spu, u32* value)
396 {
397  lv2syscall2(197, spu, (u64)value);
398  return_to_user_prog(s32);
399 }
400 
407 LV2_SYSCALL sysSpuRawRecoverPageFault(sys_raw_spu_t spu)
408 {
409  lv2syscall1(199, spu);
410  return_to_user_prog(s32);
411 }
412 
421 LV2_SYSCALL sysSpuImageOpen(sysSpuImage* image, const char* path)
422 {
423  lv2syscall2(156, (u64)image, (u64)path);
424  return_to_user_prog(s32);
425 }
426 
437 LV2_SYSCALL sysSpuImageOpenFd(sysSpuImage* image, s32 fd, u64 offset)
438 {
439  lv2syscall3(260, (u64)image, fd, offset);
440  return_to_user_prog(s32);
441 }
442 
459 LV2_SYSCALL sysSpuThreadInitialize(sys_spu_thread_t* thread, sys_spu_group_t group, u32 spu, sysSpuImage* image, sysSpuThreadAttribute* attributes, sysSpuThreadArgument* arguments)
460 {
461  lv2syscall6(172, (u64)thread, group, spu, (u64)image, (u64)attributes, (u64)arguments);
462  return_to_user_prog(s32);
463 }
464 
473 LV2_SYSCALL sysSpuThreadSetArguments(sys_spu_thread_t thread, sysSpuThreadArgument* arguments)
474 {
475  lv2syscall2(166, thread, (u64)arguments);
476  return_to_user_prog(s32);
477 }
478 
489 LV2_SYSCALL sysSpuThreadGetExitStatus(sys_spu_thread_t thread, s32* status)
490 {
491  lv2syscall2(165, thread, (u64)status);
492  return_to_user_prog(s32);
493 }
494 
510 LV2_SYSCALL sysSpuThreadConnectEvent(sys_spu_thread_t thread, sys_event_queue_t queue, u32 type, u8 spup)
511 {
512  lv2syscall4(191, thread, queue, type, spup);
513  return_to_user_prog(s32);
514 }
515 
529 LV2_SYSCALL sysSpuThreadDisconnectEvent(sys_spu_thread_t thread, u32 type, u8 spup)
530 {
531  lv2syscall3(192, thread, type, spup);
532  return_to_user_prog(s32);
533 }
534 
545 LV2_SYSCALL sysSpuThreadBindQueue(sys_spu_thread_t thread, sys_event_queue_t queue, u32 spuq_num)
546 {
547  lv2syscall3(193, thread, queue, spuq_num);
548  return_to_user_prog(s32);
549 }
550 
559 LV2_SYSCALL sysSpuThreadUnbindQueue(sys_spu_thread_t thread, u32 spuq_num)
560 {
561  lv2syscall2(194, thread, spuq_num);
562  return_to_user_prog(s32);
563 }
564 
578 LV2_SYSCALL sysSpuThreadWriteLocalStorage(sys_spu_thread_t thread, u32 address, u64 value, u32 type)
579 {
580  lv2syscall4(181, thread, address, value, type);
581  return_to_user_prog(s32);
582 }
583 
597 LV2_SYSCALL sysSpuThreadReadLocalStorage(sys_spu_thread_t thread, u32 address, u64* value, u32 type)
598 {
599  lv2syscall4(182, thread, address, (u64)value, type);
600  return_to_user_prog(s32);
601 }
602 
615 LV2_SYSCALL sysSpuThreadWriteSignal(sys_spu_thread_t thread,u32 signal,u32 value)
616 {
617  lv2syscall3(184,thread,signal,value);
618  return_to_user_prog(s32);
619 }
620 
634 LV2_SYSCALL sysSpuThreadSetConfiguration(sys_spu_thread_t thread, u64 value)
635 {
636  lv2syscall2(187, thread, value);
637  return_to_user_prog(s32);
638 }
639 
654 LV2_SYSCALL sysSpuThreadGetConfiguration(sys_spu_thread_t thread, u64* value)
655 {
656  lv2syscall2(188, thread, (u64)value);
657  return_to_user_prog(s32);
658 }
659 
669 LV2_SYSCALL sysSpuThreadWriteMb(sys_spu_thread_t thread, u32 value)
670 {
671  lv2syscall2(190, thread, value);
672  return_to_user_prog(s32);
673 }
674 
682 LV2_SYSCALL sysSpuThreadRecoverPageFault(sys_spu_thread_t thread)
683 {
684  lv2syscall1(198, thread);
685  return_to_user_prog(s32);
686 }
687 
701 LV2_SYSCALL sysSpuThreadGroupCreate(sys_spu_group_t *group,u32 num,u32 prio,sysSpuThreadGroupAttribute *attr)
702 {
703  lv2syscall4(170,(u64)group,num,prio,(u64)attr);
704  return_to_user_prog(s32);
705 }
706 
714 LV2_SYSCALL sysSpuThreadGroupDestroy(sys_spu_group_t group)
715 {
716  lv2syscall1(171,group);
717  return_to_user_prog(s32);
718 }
719 
727 LV2_SYSCALL sysSpuThreadGroupStart(sys_spu_group_t group)
728 {
729  lv2syscall1(173,group);
730  return_to_user_prog(s32);
731 }
732 
740 LV2_SYSCALL sysSpuThreadGroupSuspend(sys_spu_group_t group)
741 {
742  lv2syscall1(174,group);
743  return_to_user_prog(s32);
744 }
745 
753 LV2_SYSCALL sysSpuThreadGroupResume(sys_spu_group_t group)
754 {
755  lv2syscall1(175,group);
756  return_to_user_prog(s32);
757 }
758 
766 LV2_SYSCALL sysSpuThreadGroupYield(sys_spu_group_t group)
767 {
768  lv2syscall1(176,group);
769  return_to_user_prog(s32);
770 }
771 
779 LV2_SYSCALL sysSpuThreadGroupTerminate(sys_spu_group_t group,u32 value)
780 {
781  lv2syscall2(177,group,value);
782  return_to_user_prog(s32);
783 }
784 
796 LV2_SYSCALL sysSpuThreadGroupJoin(sys_spu_group_t group,u32 *cause,u32 *status)
797 {
798  lv2syscall3(178,group,(u64)cause,(u64)status);
799  return_to_user_prog(s32);
800 }
801 
811 LV2_SYSCALL sysSpuThreadGroupSetPriority(sys_spu_group_t group,u32 prio)
812 {
813  lv2syscall2(179,group,prio);
814  return_to_user_prog(s32);
815 }
816 
826 LV2_SYSCALL sysSpuThreadGroupGetPriority(sys_spu_group_t group,u32 *prio)
827 {
828  lv2syscall2(180,group,(u64)prio);
829  return_to_user_prog(s32);
830 }
831 
832 LV2_SYSCALL sysSpuThreadGroupConnectEvent(sys_spu_group_t group,sys_event_queue_t eventQ,u32 eventType)
833 {
834  lv2syscall3(185,group,eventQ,eventType);
835  return_to_user_prog(s32);
836 }
837 
838 LV2_SYSCALL sysSpuThreadGroupDisconnectEvent(sys_spu_group_t group,u32 eventType)
839 {
840  lv2syscall2(186,group,eventType);
841  return_to_user_prog(s32);
842 }
843 
844 LV2_SYSCALL sysSpuThreadGroupConnectEventAllThreads(sys_spu_group_t group,sys_event_queue_t eventQ,u64 req,u8 *spup)
845 {
846  lv2syscall4(251,group,eventQ,req,(u64)spup);
847  return_to_user_prog(s32);
848 }
849 
850 LV2_SYSCALL sysSpuThreadGroupDisonnectEventAllThreads(sys_spu_group_t group,u8 spup)
851 {
852  lv2syscall2(252,group,spup);
853  return_to_user_prog(s32);
854 }
855 
856 static inline void sysSpuRawWriteProblemStorage(sys_raw_spu_t spu,u32 reg,u32 value)
857 {
858  __write32(SPU_RAW_GET_PROBLEM_STORAGE(spu,reg),value);
859 }
860 
861 static inline u32 sysSpuRawReadProblemStorage(sys_raw_spu_t spu,u32 reg)
862 {
863  return __read32(SPU_RAW_GET_PROBLEM_STORAGE(spu,reg));
864 }
865 
866 static inline void sysSpuRawWriteLocalStorage(sys_raw_spu_t spu,u32 reg,u32 value)
867 {
868  __write32(SPU_RAW_GET_LOCAL_STORAGE(spu,reg),value);
869 }
870 
871 static inline u32 sysSpuRawReadLocalStorage(sys_raw_spu_t spu,u32 reg)
872 {
873  return __read32(SPU_RAW_GET_LOCAL_STORAGE(spu,reg));
874 }
875 
876 static inline void sysSpuThreadWriteProblemStorage(sys_raw_spu_t spu,u32 reg,u32 value)
877 {
878  __write32(SPU_THREAD_GET_PROBLEM_STORAGE(spu,reg),value);
879 }
880 
881 static inline u32 sysSpuThreadReadProblemStorage(sys_raw_spu_t spu,u32 reg)
882 {
883  return __read32(SPU_THREAD_GET_PROBLEM_STORAGE(spu,reg));
884 }
885 
886 #ifdef __cplusplus
887  }
888 #endif
889 
890 #endif
u32 nameAddress
Effective address of the thread group's name string.
Definition: spu.h:223
LV2_SYSCALL sysSpuRawCreateInterrupTag(sys_raw_spu_t spu, u32 classid, u32 hardwarethread, u32 *tag)
Create an interrupt tag for a raw SPU.
Definition: spu.h:280
u32 groupType
Thread group type (0 for normal thread groups).
Definition: spu.h:224
#define SPU_RAW_GET_PROBLEM_STORAGE(spu, reg)
Returns the memory-mapped address of problem storage of a raw SPU.
Definition: spu.h:175
LV2_SYSCALL sysSpuImageOpen(sysSpuImage *image, const char *path)
Create a SPU image from an ELF file.
Definition: spu.h:421
LV2_SYSCALL sysSpuThreadDisconnectEvent(sys_spu_thread_t thread, u32 type, u8 spup)
Disconnect an event queue from a SPU thread.
Definition: spu.h:529
LV2_SYSCALL sysSpuRawGetConfirugation(sys_raw_spu_t spu, u32 *value)
Get the configuration of the raw SPU's signal notification.
Definition: spu.h:395
LV2_SYSCALL sysSpuThreadRecoverPageFault(sys_spu_thread_t thread)
Recover from a SPU thread page fault.
Definition: spu.h:682
LV2_SYSCALL sysSpuThreadGroupGetPriority(sys_spu_group_t group, u32 *prio)
Get a SPU thread group's priority.
Definition: spu.h:826
LV2_SYSCALL sysSpuThreadWriteLocalStorage(sys_spu_thread_t thread, u32 address, u64 value, u32 type)
Write a value to a SPU thread's local store memory.
Definition: spu.h:578
u64 arg0
First argument.
Definition: spu.h:199
LV2_SYSCALL sysSpuRawDestroy(sys_raw_spu_t spu)
De-allocate a raw SPU.
Definition: spu.h:262
LV2_SYSCALL sysSpuThreadGroupResume(sys_spu_group_t group)
Resume a SPU thread group.
Definition: spu.h:753
LV2_SYSCALL sysSpuRawSetConfiguration(sys_raw_spu_t spu, u32 value)
Configure the raw SPU's signal notification.
Definition: spu.h:376
LV2_SYSCALL sysSpuThreadSetConfiguration(sys_spu_thread_t thread, u64 value)
Configure the SPU thread's signal notification.
Definition: spu.h:634
A structure containing the arguments passed to the SPU main function.
Definition: spu.h:197
LV2_SYSCALL sysSpuThreadGroupYield(sys_spu_group_t group)
Yield a SPU thread group.
Definition: spu.h:766
LV2_SYSCALL sysSpuThreadGroupStart(sys_spu_group_t group)
Start a SPU thread group.
Definition: spu.h:727
LV2_SYSCALL sysSpuThreadReadLocalStorage(sys_spu_thread_t thread, u32 address, u64 *value, u32 type)
Read a value From the SPU thread's local store memory.
Definition: spu.h:597
LV2_SYSCALL sysSpuImageOpenFd(sysSpuImage *image, s32 fd, u64 offset)
Create a SPU image from an open binary file.
Definition: spu.h:437
u32 memContainer
Memory container id (0 for normal thread groups).
Definition: spu.h:225
struct _sys_spu_thread_arg sysSpuThreadArgument
A structure containing the arguments passed to the SPU main function.
u64 arg1
Second argument.
Definition: spu.h:200
#define SPU_THREAD_GET_PROBLEM_STORAGE(spu, reg)
Returns the memory-mapped address of problem storage of a SPU thread.
Definition: spu.h:189
LV2_SYSCALL sysSpuThreadGroupTerminate(sys_spu_group_t group, u32 value)
Terminate a SPU thread group.
Definition: spu.h:779
LV2_SYSCALL sysSpuInitialize(u32 spus, u32 rawspus)
Initialize the SPU management.
Definition: spu.h:236
LV2_SYSCALL sysSpuThreadConnectEvent(sys_spu_thread_t thread, sys_event_queue_t queue, u32 type, u8 spup)
Connect an event queue to a SPU thread.
Definition: spu.h:510
LV2_SYSCALL sysSpuRawCreate(sys_raw_spu_t *spu, u32 *attributes)
Allocate a raw SPU.
Definition: spu.h:250
LV2_SYSCALL sysSpuThreadGroupSetPriority(sys_spu_group_t group, u32 prio)
Set a SPU thread group's priority.
Definition: spu.h:811
LV2_SYSCALL sysSpuThreadGroupDestroy(sys_spu_group_t group)
Destroy a SPU thread group.
Definition: spu.h:714
struct _sys_spu_thread_group_attr sysSpuThreadGroupAttribute
A structure containing SPU thread group attributes.
LV2_SYSCALL sysSpuThreadWriteSignal(sys_spu_thread_t thread, u32 signal, u32 value)
Write to the SPU thread's signal notification register.
Definition: spu.h:615
A structure containing SPU thread attributes.
Definition: spu.h:212
LV2_SYSCALL sysSpuRawRecoverPageFault(sys_raw_spu_t spu)
Recover a raw SPU from a page fault.
Definition: spu.h:407
LV2_SYSCALL sysSpuThreadGetConfiguration(sys_spu_thread_t thread, u64 *value)
Get the configuration of the SPU thread's signal notification.
Definition: spu.h:654
LV2_SYSCALL sysSpuThreadWriteMb(sys_spu_thread_t thread, u32 value)
Write to the SPU thread's inbound mailbox register.
Definition: spu.h:669
LV2_SYSCALL sysSpuThreadUnbindQueue(sys_spu_thread_t thread, u32 spuq_num)
Unbind an event queue from a SPU thread.
Definition: spu.h:559
u32 nameSize
Size of the name string in bytes (including terminating null byte).
Definition: spu.h:222
LV2_SYSCALL sysSpuRawGetIntMask(sys_raw_spu_t spu, u32 classid, u64 *mask)
Get the value of the interrupt mask register for a raw SPU.
Definition: spu.h:312
#define SPU_RAW_GET_LOCAL_STORAGE(spu, reg)
Returns the memory-mapped address of local storage of a raw SPU.
Definition: spu.h:171
u64 arg2
Third argument.
Definition: spu.h:201
LV2_SYSCALL sysSpuThreadBindQueue(sys_spu_thread_t thread, sys_event_queue_t queue, u32 spuq_num)
Bind an event queue to a SPU thread.
Definition: spu.h:545
LV2_SYSCALL sysSpuThreadSetArguments(sys_spu_thread_t thread, sysSpuThreadArgument *arguments)
Set the SPU thread arguments.
Definition: spu.h:473
SPU management library.
SPU image data structure.
Definition: spu.h:55
LV2_SYSCALL sysSpuRawReadPuintMb(sys_raw_spu_t spu, u32 *value)
Read from the raw SPU's outbound interrupt mailbox register.
Definition: spu.h:358
struct _sys_spu_thread_attr sysSpuThreadAttribute
A structure containing SPU thread attributes.
LV2_SYSCALL sysSpuThreadGroupSuspend(sys_spu_group_t group)
Suspend a SPU thread group.
Definition: spu.h:740
A structure containing SPU thread group attributes.
Definition: spu.h:220
LV2_SYSCALL sysSpuThreadGetExitStatus(sys_spu_thread_t thread, s32 *status)
Get the exit status of a thread.
Definition: spu.h:489
LV2_SYSCALL sysSpuRawSetIntStat(sys_raw_spu_t spu, u32 classid, u64 stat)
Set the value of the interrupt status register for a raw SPU.
Definition: spu.h:328
LV2_SYSCALL sysSpuRawGetIntStat(sys_raw_spu_t spu, u32 classid, u64 *stat)
Get the value of the interrupt status register for a raw SPU.
Definition: spu.h:344
LV2_SYSCALL sysSpuThreadInitialize(sys_spu_thread_t *thread, sys_spu_group_t group, u32 spu, sysSpuImage *image, sysSpuThreadAttribute *attributes, sysSpuThreadArgument *arguments)
Initialize a SPU thread.
Definition: spu.h:459
u32 nameAddress
Effective address of the thread's name string.
Definition: spu.h:214
LV2_SYSCALL sysSpuThreadGroupJoin(sys_spu_group_t group, u32 *cause, u32 *status)
Wait for a SPU thread group to finish its execution.
Definition: spu.h:796
u64 arg3
Fourth argument.
Definition: spu.h:202
LV2_SYSCALL sysSpuRawSetIntMask(sys_raw_spu_t spu, u32 classid, u64 mask)
Set the value of the interrupt mask register for a raw SPU.
Definition: spu.h:296
u32 nameSize
Size of the name string in bytes (including terminating null byte).
Definition: spu.h:215
u32 attribute
OR'ed list of SPU thread attribute flags (or SPU_THREAD_ATTR_NONE)
Definition: spu.h:216
LV2_SYSCALL sysSpuThreadGroupCreate(sys_spu_group_t *group, u32 num, u32 prio, sysSpuThreadGroupAttribute *attr)
Create a SPU thread group.
Definition: spu.h:701