00001 #include <string.h>
00002
00003 #include <moc.h>
00004 #include <ppu/moc_dma_ppu.h>
00005 #include <internal/ppu/imoc_macros_ppu.h>
00006 #include <internal/ppu/imoc_core_ppu.h>
00007 #include <internal/ppu/imoc_dma_ppu.h>
00008
00009 int IMOC_put_data(void* source, uint64_t target, uint32_t size, int dest)
00010 {
00011 uint32_t remainder_16b;
00012 uint32_t remainder_16kb;
00013 uint32_t offset;
00014 int err;
00015 uint32_t dmastatus;
00016
00017
00018 remainder_16b = size % 16;
00019
00020
00021 size -= remainder_16b;
00022 offset = 0;
00023
00024
00025 if (size <= MAX_DMA_CALL_SIZE)
00026 {
00027 err = spe_mfcio_get(
00028 moc_spu_thread_list[dest - moc_ppu_thread_count].speid, target,
00029 source, size, 15, 0, 0);
00030 if (err)
00031 return MOC_ERR_INTERN;
00032 }
00033
00034 else
00035 {
00036 remainder_16kb = size % MAX_DMA_CALL_SIZE;
00037 while (offset + MAX_DMA_CALL_SIZE <= size)
00038 {
00039 err = spe_mfcio_get(
00040 moc_spu_thread_list[dest - moc_ppu_thread_count].speid,
00041 target + offset, source + offset, MAX_DMA_CALL_SIZE, 15, 0,
00042 0);
00043 if (err)
00044 return MOC_ERR_INTERN;
00045
00046 offset += MAX_DMA_CALL_SIZE;
00047 }
00048 if (remainder_16kb > 0)
00049 {
00050 err = spe_mfcio_get(
00051 moc_spu_thread_list[dest - moc_ppu_thread_count].speid,
00052 target + offset, source + offset, remainder_16kb, 15, 0, 0);
00053 if (err)
00054 return MOC_ERR_INTERN;
00055 }
00056 }
00057
00058 if (remainder_16b > 0)
00059 {
00060
00061 err = spe_mfcio_get(
00062 moc_spu_thread_list[dest - moc_ppu_thread_count].speid, target
00063 + size, source + size, 16, 15, 0, 0);
00064 if (err)
00065 return MOC_ERR_INTERN;
00066
00067 }
00068
00069
00070 err = spe_mfcio_tag_status_read(moc_spu_thread_list[dest
00071 - moc_ppu_thread_count].speid, 0, SPE_TAG_ALL, &dmastatus);
00072 if (err)
00073 return MOC_ERR_INTERN;
00074
00075 return MOC_SUCCESS;
00076 }
00077