Skip to content

Commit

Permalink
The SPU thread example is now fully functional.
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkman committed Jan 10, 2011
1 parent b5a322c commit 5c88330
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 0 additions & 5 deletions samples/spudma/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ int main(int argc, const char* argv[])
printf("Waiting for SPU to return...\n");
while (ret == 0);



printf("Terminating SPU thread group... ");
printf("%08x\n", lv2SpuThreadGroupTerminate(group_id, 42));

printf("Joining SPU thread group... ");
printf("%08x\n", lv2SpuThreadGroupJoin(group_id, &cause, &status));
printf("cause=%d status=%d\n", cause, status);
Expand Down
6 changes: 6 additions & 0 deletions samples/spudma/spu/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#define TAG 1

extern void spu_thread_exit(uint32_t);

/* wait for dma transfer to be finished */
static void wait_for_completion(void) {
mfc_write_tag_mask(1<<TAG);
Expand All @@ -23,6 +25,8 @@ int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4)

/* 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 */
Expand All @@ -34,5 +38,7 @@ int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4)
mfc_put(&ok, outptr, 4, TAG, 0, 0);
wait_for_completion();

/* properly exit the thread */
spu_thread_exit(0);
return 0;
}
7 changes: 7 additions & 0 deletions samples/spudma/spu/source/spu_thread_exit.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.globl spu_thread_exit

spu_thread_exit:
wrch $ch28,$3
stop 0x102
bi $0
lnop

0 comments on commit 5c88330

Please sign in to comment.