int snd_init_firmware(const char *filename) { file_t f; size_t sz; uint8 *buff; f = fs_open(filename, O_RDONLY); if(f < 0) { ds_printf("DS_ERROR: Can't open firmware %s\n", filename); return -1; } sz = fs_total(f); ds_printf("DS_PROCESS: Loading firmware %s (%d bytes) into SPU RAM\n", filename, sz); buff = (uint8*)malloc(sz); fs_read(f, buff, sz); fs_close(f); spu_disable(); spu_memset(0, 0, AICA_RAM_START); spu_memload(0, buff, sz); /* Enable the AICA and give it a few ms to start up */ spu_enable(); timer_spin_sleep(10); /* Initialize the RAM allocator */ snd_mem_init(AICA_RAM_START); return 0; }
/* Shutdown the player */ void sndmp3_shutdown() { sndmp3_status = STATUS_QUIT; sem_signal(sndmp3_halt_sem); while (sndmp3_status != STATUS_ZOMBIE) thd_pass(); spu_disable(); }
/* Initialize driver; note that this replaces the AICA program so that if you had anything else going on, it's gone now! */ int snd_init() { int amt; /* Finish loading the stream driver */ if (!initted) { spu_disable(); spu_memset(0, 0, AICA_RAM_START); amt = snd_stream_drv_end - snd_stream_drv; if (amt % 4) amt = (amt + 4) & ~3; printf("snd_init(): loading %d bytes into SPU RAM\n", amt); spu_memload(0, snd_stream_drv, amt); /* Enable the AICA and give it a few ms to start up */ spu_enable(); timer_spin_sleep(10); /* Initialize the RAM allocator */ snd_mem_init(AICA_RAM_START); /* Setup semaphores */ sem_qram = sem_create(1); } initted = 1; return 0; }
/* Shut everything down and free mem */ void snd_shutdown() { if (initted) { spu_disable(); sem_destroy(sem_qram); snd_mem_shutdown(); initted = 0; } }
static int snd_aicapcm_pcm_close(struct snd_pcm_substream *substream) { struct snd_card_aica *dreamcastcard = substream->pcm->private_data; flush_work(&(dreamcastcard->spu_dma_work)); if (dreamcastcard->timer.data) del_timer(&dreamcastcard->timer); kfree(dreamcastcard->channel); spu_disable(); return 0; }
/* * Halt the sound processor, clear the memory, * load some default ARM7 code, and then restart ARM7 */ static void spu_reset(void) { unsigned long flags; spu_disable(); spu_memset(0, 0, 0x200000 / 4); /* Put ARM7 in endless loop */ local_irq_save(flags); __raw_writel(0xea000002, SPU_MEMORY_BASE); local_irq_restore(flags); spu_enable(); }
static int load_aica_firmware(void) { int err; const struct firmware *fw_entry; spu_reset(); err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev); if (unlikely(err)) return err; /* write firmware into memory */ spu_disable(); spu_memload(0, fw_entry->data, fw_entry->size); spu_enable(); release_firmware(fw_entry); return err; }
void copy_s3m(char *song, int len) { spu_disable(); spu_memload(0x10000, song, len); spu_memload(0, s3mplay, sizeof(s3mplay)); /* Switch channels to mono if uncommented */ /* snd_dbg[1] = 1; */ printf("Load OK, starting ARM\n"); spu_enable(); while(*snd_dbg != 3) ; while(*snd_dbg == 3) ; }
/* Called to shut down non-gracefully; assume the system is in peril and don't try to call the dtors */ void arch_abort() { /* Turn off UBC breakpoints, if any */ // ubc_disable_all(); dbglog(DBG_CRITICAL, "arch: aborting the system\n"); #if 0 /* PVR disable-by-fire */ PVR_SET(PVR_RESET, PVR_RESET_ALL); PVR_SET(PVR_RESET, PVR_RESET_NONE); /* Maple disable-by-fire */ maple_dma_stop(); /* Sound disable (nothing weird done in here) */ spu_disable(); /* Turn off any IRQs */ irq_disable(); #endif arch_real_exit(); }