int loadmodulemem(char *buf,int len,int lenarg,char *arg) { unsigned iopmem=0; int ret=0; SifInitIopHeap(); iopmem=(unsigned int)SifAllocIopHeap(len+15); printf("iopmem=%d\n", iopmem); if(iopmem==0) { return -1; } if(iop_heap_dma_upload(buf, iopmem,len+15)<0) { SifFreeIopHeap((void*)iopmem); return -1; } if(SifLoadModuleBuffer((void *)iopmem, lenarg, arg) < 0) { SifFreeIopHeap((void*)iopmem); return -1; } return ret; }
int sndLoadSample(void *buf, u32 spuaddr, int size) { void *iopbuf; int id, iopfree; SifDmaTransfer_t sifdma; iopfree = sndQueryMaxFreeMemSize()/2; if (size>iopfree) { return(-1); } iopbuf = SifAllocIopHeap(size); if (iopbuf==0) return(-1); FlushCache(0); sifdma.src = buf; sifdma.dest = iopbuf; sifdma.size = size; sifdma.attr = 0; id = SifSetDma(&sifdma, 1); while(SifDmaStat(id) >= 0);; FlushCache(0); SdVoiceTrans(0, SD_TRANS_WRITE, iopbuf, (void*)spuaddr, size); SdVoiceTransStatus(0, 1); SifFreeIopHeap(iopbuf); return(size); }
int audsrv_load_adpcm(audsrv_adpcm_t *adpcm, void *buffer, int size) { void* iop_addr; SifDmaTransfer_t sifdma; int id, ret; iop_addr = SifAllocIopHeap(size); if (iop_addr == 0) { return -AUDSRV_ERR_OUT_OF_MEMORY; } sifdma.src = buffer; sifdma.dest = iop_addr; sifdma.size = size; sifdma.attr = 0; /* send by dma */ while((id = SifSetDma(&sifdma, 1)) == 0); while(SifDmaStat(id) >= 0); WaitSema(completion_sema); sbuff[0] = (int)iop_addr; sbuff[1] = size; sbuff[2] = (int)adpcm; /* use as id */ SifCallRpc(&cd0, AUDSRV_LOAD_ADPCM, 0, sbuff, 12, sbuff, 16, NULL, NULL); if(sbuff[0] != 0) { adpcm->buffer = 0; ret = sbuff[0]; } else { adpcm->buffer = buffer; adpcm->size = size; adpcm->pitch = sbuff[1]; adpcm->loop = sbuff[2]; adpcm->channels = sbuff[3]; ret = AUDSRV_ERR_NOERROR; } SignalSema(completion_sema); SifFreeIopHeap(iop_addr); return ret; }