00001 #include <spu_mfcio.h>
00002 #include <string.h>
00003
00004 #include <moc.h>
00005 #include <internal/imoc_macros.h>
00006 #include <internal/spu/imoc_dma_spu.h>
00007
00008 int IMOC_put_data(void* source, uint64_t target, uint32_t size)
00009 {
00010 uint32_t remainder_16b;
00011 uint32_t remainder_16kb;
00012 uint32_t offset;
00013 uint32_t tag_id;
00014
00015 if ((tag_id = mfc_tag_reserve()) == MFC_TAG_INVALID)
00016 {
00017 return MOC_ERR_INTERN;
00018 }
00019
00020
00021 remainder_16b = size % 16;
00022
00023
00024 size -= remainder_16b;
00025 offset = 0;
00026
00027
00028 if (size <= MAX_DMA_CALL_SIZE)
00029 {
00030 mfc_put(source, target, size, tag_id, 0, 0);
00031 }
00032
00033 else
00034 {
00035 remainder_16kb = size % MAX_DMA_CALL_SIZE;
00036 while (offset + MAX_DMA_CALL_SIZE <= size)
00037 {
00038 mfc_put(source + offset, target + offset, MAX_DMA_CALL_SIZE,
00039 tag_id, 0, 0);
00040 offset += MAX_DMA_CALL_SIZE;
00041 }
00042 if (remainder_16kb > 0)
00043 {
00044 mfc_put(source + offset, target + offset, remainder_16kb, tag_id,
00045 0, 0);
00046 }
00047 }
00048
00049 if (remainder_16b > 0)
00050 {
00051
00052 mfc_put(source + size, target + size, 16, tag_id, 0, 0);
00053 }
00054
00055
00056 mfc_write_tag_mask(1 << tag_id);
00057 mfc_read_tag_status_all();
00058 mfc_tag_release(tag_id);
00059 return MOC_SUCCESS;
00060 }
00061