Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_SPU_SAMPLE_TASK_PROCESS_H
00017 #define BT_SPU_SAMPLE_TASK_PROCESS_H
00018
00019 #include <assert.h>
00020
00021
00022 #include "PlatformDefinitions.h"
00023
00024 #include <stdlib.h>
00025
00026 #include "LinearMath/btAlignedObjectArray.h"
00027
00028
00029 #include "SpuSampleTask/SpuSampleTask.h"
00030
00031
00032
00033 #define CMD_SAMPLE_TASK_COMMAND 10
00034
00035
00036
00040 class SpuSampleTaskProcess
00041 {
00042
00043 btAlignedObjectArray<bool> m_taskBusy;
00044 btAlignedObjectArray<SpuSampleTaskDesc>m_spuSampleTaskDesc;
00045
00046 int m_numBusyTasks;
00047
00048
00049 int m_currentTask;
00050
00051 bool m_initialized;
00052
00053 void postProcess(int taskId, int outputSize);
00054
00055 class btThreadSupportInterface* m_threadInterface;
00056
00057 int m_maxNumOutstandingTasks;
00058
00059
00060
00061 public:
00062 SpuSampleTaskProcess(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks);
00063
00064 ~SpuSampleTaskProcess();
00065
00067 void initialize();
00068
00069 void issueTask(void* sampleMainMemPtr,int sampleValue,int sampleCommand);
00070
00072 void flush();
00073 };
00074
00075
00076 #if defined(USE_LIBSPE2) && defined(__SPU__)
00077
00078 #include "../SpuLibspe2Support.h"
00079 #include <spu_intrinsics.h>
00080 #include <spu_mfcio.h>
00081 #include <SpuFakeDma.h>
00082
00083 void * SamplelsMemoryFunc();
00084 void SampleThreadFunc(void* userPtr,void* lsMemory);
00085
00086
00087
00088 int main(unsigned long long speid, addr64 argp, addr64 envp)
00089 {
00090 printf("SPU is up \n");
00091
00092 ATTRIBUTE_ALIGNED128(btSpuStatus status);
00093 ATTRIBUTE_ALIGNED16( SpuSampleTaskDesc taskDesc ) ;
00094 unsigned int received_message = Spu_Mailbox_Event_Nothing;
00095 bool shutdown = false;
00096
00097 cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00098 cellDmaWaitTagStatusAll(DMA_MASK(3));
00099
00100 status.m_status = Spu_Status_Free;
00101 status.m_lsMemory.p = SamplelsMemoryFunc();
00102
00103 cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00104 cellDmaWaitTagStatusAll(DMA_MASK(3));
00105
00106
00107 while (!shutdown)
00108 {
00109 received_message = spu_read_in_mbox();
00110
00111
00112
00113 switch(received_message)
00114 {
00115 case Spu_Mailbox_Event_Shutdown:
00116 shutdown = true;
00117 break;
00118 case Spu_Mailbox_Event_Task:
00119
00120 #ifdef DEBUG_LIBSPE2_MAINLOOP
00121 printf("SPU recieved Task \n");
00122 #endif //DEBUG_LIBSPE2_MAINLOOP
00123 cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00124 cellDmaWaitTagStatusAll(DMA_MASK(3));
00125
00126 btAssert(status.m_status==Spu_Status_Occupied);
00127
00128 cellDmaGet(&taskDesc, status.m_taskDesc.p, sizeof(SpuSampleTaskDesc), DMA_TAG(3), 0, 0);
00129 cellDmaWaitTagStatusAll(DMA_MASK(3));
00130
00131 SampleThreadFunc((void*)&taskDesc, reinterpret_cast<void*> (taskDesc.m_mainMemoryPtr) );
00132 break;
00133 case Spu_Mailbox_Event_Nothing:
00134 default:
00135 break;
00136 }
00137
00138
00139 status.m_status = Spu_Status_Free;
00140 cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00141 cellDmaWaitTagStatusAll(DMA_MASK(3));
00142
00143
00144 }
00145 return 0;
00146 }
00148 #endif
00149
00150
00151
00152 #endif // BT_SPU_SAMPLE_TASK_PROCESS_H
00153