Permalink
Browse files

Cleanup in spudma sample prog.

  • Loading branch information...
1 parent 8925210 commit 1b4d9f5511d31a7b930835fe1ddbb40abe1f7a3b @zerkman zerkman committed Jan 10, 2011
Showing with 14 additions and 28 deletions.
  1. +0 −5 samples/spudma/source/main.c
  2. +14 −23 samples/spudma/spu/source/main.c
@@ -43,11 +43,6 @@ int main(int argc, const char* argv[])
printf("Loading ELF image... ");
printf("%08x\n", sysSpuImageImport(&image, spu_bin, 0));
- /* Make up attributes */
- /* attr.nameAddress = "mythread";
- attr.nameSize = 8+1;
- attr.attribute = LV2_SPU_THREAD_ATTRIBUTE_NONE; */
-
printf("Creating thread group... ");
printf("%08x\n", lv2SpuThreadGroupCreate(&group_id, 1, 100, &grpattr));
@@ -3,46 +3,37 @@
int main(uint64_t ea, uint64_t outptr, uint64_t arg3, uint64_t arg4)
{
-#if 0
- /* memory-aligned buffer */
- volatile vec_uchar16 tmp;
- char *buf = (char *)&tmp;
+ /* memory-aligned buffer (vectors always are properly aligned) */
+ volatile vec_uchar16 v;
/* fetch the 16 bytes using dma */
- //mfc_get(buf, ea, 16, 0, 0, 0);
+ mfc_get(&v, ea, 16, 0, 0, 0);
/* wait for dma transfer to be finished */
- //mfc_write_tag_mask(1);
- //spu_mfcstat(MFC_TAG_UPDATE_ALL);
+ mfc_write_tag_mask(1);
+ spu_mfcstat(MFC_TAG_UPDATE_ALL);
- /* fetch all 16 bytes into a character vector */
- vec_uchar16 v = tmp;
-
- /* compare all characters with the small 'a' caracter code */
- vec_uchar16 cmp = spu_cmpgt(v, spu_splats((unsigned char)'a'));
+ /* 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;
v = v - sub;
- /* write the updated vector to memory */
- *((vec_uchar16 *)buf) = v;
-
/* send the updated vector to ppe */
- //mfc_put(buf, ea, 16, 0, 0, 0);
+ mfc_put(&v, ea, 16, 0, 0, 0);
/* wait for dma transfer to be finished */
- //mfc_write_tag_mask(1);
- //spu_mfcstat(MFC_TAG_UPDATE_ALL);
+ mfc_write_tag_mask(1);
+ spu_mfcstat(MFC_TAG_UPDATE_ALL);
/* send a message to inform the ppe program that the work is done */
- //uint32_t ok = 1;
- //mfc_put(&ok, outptr, 4, 0, 0, 0);
+ uint32_t ok = 1;
+ mfc_put(&ok, outptr, 4, 0, 0, 0);
/* wait for dma transfer to be finished */
- //mfc_write_tag_mask(1);
- //spu_mfcstat(MFC_TAG_UPDATE_ALL);
-#endif
+ mfc_write_tag_mask(1);
+ spu_mfcstat(MFC_TAG_UPDATE_ALL);
return 0;
}

0 comments on commit 1b4d9f5

Please sign in to comment.