int spu_init(alt_u32 dev_pcm) // 初期化 { int i; if (dev_pcm == 0) { IOWR(g_dev_spu, spu_reg_status, spu_mute_enable); IOWR(g_dev_spu, spu_reg_setup, 0); if (p_g_wavbuff != NULL) alt_uncached_free(p_g_wavbuff); g_dev_spu = 0; return 0; } p_g_wavbuff = (alt_u16 *)alt_uncached_malloc(nd_WAVBUFF_SIZE); if (p_g_wavbuff == NULL) return -1; g_dev_spu = dev_pcm; // IOWR(dev_pcm, spu_reg_status, spu_mute_enable); IOWR(dev_pcm, spu_reg_setup, 0); for(i=1 ; i<=spudef_slotmax ; i++) { IOWR(dev_pcm, spu_reg_slotstatus(i), spu_keyoff); IOWR(dev_pcm, spu_reg_volume_l(i), 0); IOWR(dev_pcm, spu_reg_volume_r(i), 0); } IOWR(dev_pcm, spu_reg_setup, spudef_slotmax); IOWR(dev_pcm, spu_reg_status, 0); IOWR(dev_pcm, spu_reg_aclink, 0x04000); IOWR(dev_pcm, spu_reg_aclink, 0x14000); IOWR(dev_pcm, spu_reg_sync, 1); while( (IORD(dev_pcm, spu_reg_sync) & spu_syncbusy_bitmask) ) {} return 0; }
int main(void) { alt_u16 *pFrameBuffer; // システム初期化 IOWR(LED_7SEG_BASE, 0, ~0x71733d77); // FPGAと表示する IOWR(BLCON_BASE, 0, (0<<8)); // バックライトOFF systeminit(); // ファイルシステム初期化 mmcfs_setup(); // VGA初期化 nd_GsVgaInit(); pFrameBuffer = (alt_u16 *)alt_uncached_malloc(na_VRAM_size); if (pFrameBuffer == NULL) { printf("[!] Framebuffer assignment failed.\n"); return -1; } nd_GsVgaSetBuffer((nd_u32)pFrameBuffer); nd_GsEglPage((nd_u32)pFrameBuffer,(nd_u32)pFrameBuffer,0); nd_color(nd_COLORGRAY, 0, 256); nd_boxfill(0, 0, window_xmax, window_ymax); nd_color(nd_COLORWHITE, 0, 256); nd_line(0,0, 0,window_ymax); nd_color(nd_COLORRED, 0, 256); nd_line(window_xmax,0, window_xmax,window_ymax); nd_color(nd_COLORLIGHTGREEN, 0, 256); nd_line(0,0, window_xmax,0); nd_color(nd_COLORBLUE, 0, 256); nd_line(0,window_ymax, window_xmax,window_ymax); nd_GsVgaScanOn(); IOWR(BLCON_BASE, 0, (1<<8)|0); // バックライトON、輝度最大 // 画像を展開 loadbmp("mmcfs:/de0/test.bmp",pFrameBuffer); printf("done.\n"); while(1) {} // 終了処理 nd_GsVgaScanOff(); alt_uncached_free(pFrameBuffer); return 0; }
static int MemDMATest(unsigned int memory_base, unsigned int nBytes) { int rc; int ret_code = 0; int pattern, offset; alt_dma_txchan txchan; alt_dma_rxchan rxchan; void* data_written; void* data_read; /* Get a couple buffers for the test */ data_written = (void*)alt_uncached_malloc(0x1000); data_read = (void*)alt_uncached_malloc(0x1000); /* Fill write buffer with known values */ for (pattern = 1, offset = 0; offset < sizeof(data_written); pattern++, offset+=4) { IOWR_32DIRECT((int)data_written, offset, pattern); } /* Create the transmit channel */ if ((txchan = alt_dma_txchan_open("/dev/dma")) == NULL) { printf ("Failed to open transmit channel\n"); exit (1); } /* Create the receive channel */ if ((rxchan = alt_dma_rxchan_open("/dev/dma")) == NULL) { printf ("Failed to open receive channel\n"); exit (1); } for(offset = memory_base; offset < (memory_base + nBytes); offset += 0x1000) { /* Use DMA to transfer from write buffer to memory under test */ /* Post the transmit request */ if ((rc = alt_dma_txchan_send (txchan, data_written, 0x1000, NULL, NULL)) < 0) { printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); } /* Post the receive request */ if ((rc = alt_dma_rxchan_prepare (rxchan, (void*)offset, 0x1000, dma_done, NULL)) < 0) { printf ("Failed to post read request, reason = %i\n", rc); exit (1); } /* Wait for transfer to complete */ while (!rx_done); rx_done = 0; /* Clear the read buffer before we fill it */ memset(data_read, 0, 0x1000); /* Use DMA to read data back into read buffer from memory under test */ /* Post the transmit request */ if ((rc = alt_dma_txchan_send (txchan, (void*)offset, 0x1000, NULL, NULL)) < 0) { printf ("Failed to post transmit request, reason = %i\n", rc); exit (1); } /* Post the receive request */ if ((rc = alt_dma_rxchan_prepare (rxchan, data_read, 0x1000, dma_done, NULL)) < 0) { printf ("Failed to post read request, reason = %i\n", rc); exit (1); } /* Wait for transfer to complete */ while (!rx_done); rx_done = 0; if (memcmp(data_written, data_read, 0x1000)) { ret_code = offset; break; } } alt_uncached_free(data_written); alt_uncached_free(data_read); return ret_code; }
//------------------------------------------------------------------------------ void openmac_uncachedFree(UINT8* pMem_p) { alt_uncached_free(pMem_p); }
//------------------------------------------------------------------------------ void openmac_uncachedFree(void* pMem_p) { alt_uncached_free(pMem_p); }