The ease of implementing a DMA transfer using intrinsics versus assembly-language instructions is illustrated in the example-implementation of the dma_transfer subroutine that is provided in this section.
extern void dma_transfer(volatile void *lsa, // local store address unsigned int eah, // high 32-bit effective address unsigned int eal, // low 32-bit effective address unsigned int size, // transfer size in bytes unsigned int tag_id, // tag identifier (0-31) unsigned int cmd); // DMA command
.text .global dma_transfer dma_transfer: wrch $MFC_LSA, $3 wrch $MFC_EAH, $4 wrch $MFC_EAL, $5 wrch $MFC_Size, $6 wrch $MFC_TagID, $7 wrch $MFC_Cmd, $8 bi $0
#include <spu_intrinsics.h> void dma_transfer(volatile void *lsa, unsigned int eah, unsigned int eal, unsigned int size, unsigned int tag_id, unsigned int cmd) { spu_writech(MFC_LSA, (unsigned int)lsa); spu_writech(MFC_EAH, eah); spu_writech(MFC_EAL, eal); spu_writech(MFC_Size, size); spu_writech(MFC_TagID, tag_id); spu_writech(MFC_Cmd, cmd); }
#include <spu_intrinsics.h> void dma_transfer(volatile void *lsa, unsigned int eah, unsigned int eal, unsigned int size, unsigned int tag_id, unsigned int cmd) { spu_mfcdma64(lsa, eah, eal, size, tag_id, cmd); }