int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4) { /* memory-aligned buffer (vectors always are properly aligned) */ volatile vec_uchar16 v; /* fetch the 16 bytes using dma */ mfc_get(&v, ea, 16, TAG, 0, 0); wait_for_completion(); /* compare all characters with the small 'a' character code */ vec_uchar16 cmp = spu_cmpgt(v, spu_splats((unsigned char)('a'-1))); /* for all small characters, we remove 0x20 to get the corresponding capital*/ vec_uchar16 sub = spu_splats((unsigned char)0x20) & cmp; /* convert all small characters to capitals */ v = v - sub; /* send the updated vector to ppe */ mfc_put(&v, ea, 16, TAG, 0, 0); wait_for_completion(); /* send a message to inform the ppe program that the work is done */ uint32_t ok __attribute__((aligned(16))) = 1; mfc_put(&ok, outptr, 4, TAG, 0, 0); wait_for_completion(); /* properly exit the thread */ spu_thread_exit(0); return 0; }
int main(uint64_t sync_ea, uint64_t response_ea, uint64_t arg3, uint64_t arg4) { /* get input value from ppu via signal notification register 1 (blocking read) */ uint32_t x = spu_read_signal1(); /* return the value multiplied by 3 to response variable with sync via dma */ send_response(sync_ea, response_ea, x*3); wait_for_completion(); /* properly exit the thread */ spu_thread_exit(0); return 0; }
int main(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { /* get data structure */ spu_ea = arg1; mfc_get(&spu, spu_ea, sizeof(spustr_t), TAG, 0, 0); wait_for_completion(TAG); /* main loop: wait for screen address or 0 to end */ uint32_t buffer_ea; while ((buffer_ea = spu_read_signal1()) != 0) { mfc_get(&spu, spu_ea, sizeof(spustr_t), TAG, 0, 0); wait_for_completion(TAG); draw_frame(buffer_ea); send_response(1); wait_for_completion(TAG); } /* properly exit the thread */ spu_thread_exit(0); return 0; }