///////////////////////////////////////////////////////////////////////[0E] void SifInitRpc(int mode){ u32 x; _dprintf("%s\n", __FUNCTION__); SifInitCmd(); CpuSuspendIntr(&x); if (sifInitRpc){ CpuResumeIntr(x); }else{ sifInitRpc=1; rpc_common.paddr=(RPC_PACKET*)bufx; rpc_common.size=32; rpc_common.paddr2=0; rpc_common.size2=0; rpc_common.next=(RPC_PACKET*)bufy; rpc_common.count=32; rpc_common.base=0; rpc_common.pid=1; SifAddCmdHandler(0x80000008, (cmdh_func)cmd80000008_END, &rpc_common); SifAddCmdHandler(0x80000009, (cmdh_func)cmd80000009_BIND, &rpc_common); SifAddCmdHandler(0x8000000A, (cmdh_func)cmd8000000A_CALL, &rpc_common); SifAddCmdHandler(0x8000000C, (cmdh_func)cmd8000000C_RDATA, &rpc_common); CpuResumeIntr(x); ((SifCmdSRData*)bufx)->rno =0; ((SifCmdSRData*)bufx)->value=1; SifSendCmd(0x80000001, (void*)bufx, sizeof(SifCmdSRData), 0, 0, 0); } WaitEventFlag(GetSystemStatusFlag(), 0x800, 0, 0); }
/** Initializes audsrv library @returns error code */ int audsrv_init() { int ret; if (initialized) { /* already done */ return 0; } memset(&cd0, '\0', sizeof(cd0)); while (1) { if (SifBindRpc(&cd0, AUDSRV_IRX, 0) < 0) { set_error(AUDSRV_ERR_RPC_FAILED); return -1; } if (cd0.server != 0) { break; } nopdelay(); } ee_sema_t compSema; compSema.init_count = 1; compSema.max_count = 1; compSema.option = 0; completion_sema = CreateSema(&compSema); if (completion_sema < 0) { set_error(AUDSRV_ERR_FAILED_TO_CREATE_SEMA); return -1; } SifCallRpc(&cd0, AUDSRV_INIT, 0, sbuff, 64, sbuff, 64, NULL, NULL); ret = sbuff[0]; if (ret != 0) { set_error(ret); return ret; } /* register a callback handler */ DI(); SifAddCmdHandler(AUDSRV_CDDA_CALLBACK, cdda_stopped, NULL); SifAddCmdHandler(AUDSRV_FILLBUF_CALLBACK, fillbuf_requested, NULL); EI(); /* initialize IOP heap (for adpcm samples) */ SifInitIopHeap(); set_error(AUDSRV_ERR_NOERROR); return AUDSRV_ERR_NOERROR; }
int poweroffInit() { int res; static int _init_count = -1; if(_init_count == _iop_reboot_count) return 0; _init_count = _iop_reboot_count; while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) >= 0) && (cd0.server == NULL)) nopdelay(); ee_thread_t thread; ee_thread_status_t thisThread; ee_sema_t sema; // Terminate and delete any previously created threads if (powerOffThreadId >= 0) { TerminateThread(powerOffThreadId); DeleteThread(powerOffThreadId); powerOffThreadId = -1; } // Delete any previously created semaphores if (PowerOffSema >= 0) { DeleteSema(PowerOffSema); PowerOffSema = -1; } sema.init_count = 0; sema.max_count = 1; sema.option = 0; PowerOffSema = CreateSema(&sema); ReferThreadStatus(GetThreadId(), &thisThread); if (thisThread.current_priority == 0) { ChangeThreadPriority(GetThreadId(), 51); thread.initial_priority = 50; } else thread.initial_priority = thisThread.current_priority - 1; thread.stack_size = 512 * 16; thread.gp_reg = &_gp; thread.func = PowerOffThread; thread.stack = (void *)poffThreadStack; powerOffThreadId = CreateThread(&thread); StartThread(powerOffThreadId, NULL); DIntr(); SifAddCmdHandler(POFF_SIF_CMD, _poff_intr_callback, NULL); EIntr(); int autoShutdown = 0; SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, &autoShutdown, sizeof(autoShutdown), 0, 0); return res; }
int SjPCM_InitEx(int sync, int num_blocks) { int i; while(1){ if (SifBindRpc( &cd0, SJPCM_IRX, 0) < 0) return -1; // bind error if (cd0.server != 0) break; i = 0x10000; while(i--); } sbuff[0] = num_blocks; SifCallRpc(&cd0,SJPCM_SETNUMBLOCKS,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,0,0); sbuff[0] = sync; SifCallRpc(&cd0,SJPCM_INIT,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,0,0); FlushCache(0); pcmbufl = sbuff[1]; pcmbufr = sbuff[2]; bufpos = sbuff[3]; DIntr(); SifAddCmdHandler(SJPCM_CALLBACK, _sjpcm_callback, NULL); EIntr(); sjpcm_inited = 1; return 0; }
void SifInitRpc(int mode) { u32 *cmdp; static int _rb_count = 0; if(_rb_count != _iop_reboot_count) { _rb_count = _iop_reboot_count; SifExitCmd(); init = 0; } if (init) return; init = 1; SifInitCmd(); DI(); _sif_rpc_data.pkt_table = UNCACHED_SEG(_sif_rpc_data.pkt_table); _sif_rpc_data.rdata_table = UNCACHED_SEG(_sif_rpc_data.rdata_table); _sif_rpc_data.client_table = UNCACHED_SEG(_sif_rpc_data.client_table); SifAddCmdHandler(0x80000008, (void *)_request_end, &_sif_rpc_data); SifAddCmdHandler(0x80000009, (void *)_request_bind, &_sif_rpc_data); SifAddCmdHandler(0x8000000a, (void *)_request_call, &_sif_rpc_data); SifAddCmdHandler(0x8000000c, (void *)_request_rdata, &_sif_rpc_data); EI(); if (SifGetReg(0x80000002)) return; cmdp = (u32 *)&pkt_table[64]; cmdp[3] = 1; SifSendCmd(0x80000002, cmdp, 16, NULL, NULL, 0); while (!SifGetSreg(0)) ; SifSetReg(0x80000002, 1); }
int poweroffInit(void) { ee_thread_t thread; ee_sema_t sema; int res; static int _init_count = -1; if(_init_count == _iop_reboot_count) return 0; _init_count = _iop_reboot_count; while(((res = SifBindRpc(&cd0, PWROFF_IRX, 0)) >= 0) && (cd0.server == NULL)) nopdelay(); // Terminate and delete any previously created threads if (powerOffThreadId >= 0) { TerminateThread(powerOffThreadId); DeleteThread(powerOffThreadId); powerOffThreadId = -1; } // Delete any previously created semaphores if (PowerOffSema >= 0) { DeleteSema(PowerOffSema); PowerOffSema = -1; } sema.init_count = 0; sema.max_count = 1; sema.option = 0; PowerOffSema = CreateSema(&sema); thread.initial_priority = POWEROFF_THREAD_PRIORITY; thread.stack_size = sizeof(poffThreadStack); thread.gp_reg = &_gp; thread.func = PowerOffThread; thread.stack = (void *)poffThreadStack; powerOffThreadId = CreateThread(&thread); StartThread(powerOffThreadId, NULL); DI(); SifAddCmdHandler(POFF_SIF_CMD, _poff_intr_callback, NULL); EI(); int autoShutdown = 0; SifCallRpc(&cd0, PWROFF_ENABLE_AUTO_SHUTOFF, 0, NULL, 0, &autoShutdown, sizeof(autoShutdown), NULL, NULL); return res; }
void SifInitRpc(void) { u32 status; core_save_disable(&status); if (init) { core_restore(status); return; } init = 1; SifInitCmd(); _sif_rpc_data.pkt_table = UNCACHED_SEG(_sif_rpc_data.pkt_table); _sif_rpc_data.rdata_table = UNCACHED_SEG(_sif_rpc_data.rdata_table); _sif_rpc_data.client_table = UNCACHED_SEG(_sif_rpc_data.client_table); SifAddCmdHandler(0x80000008, (void *)_request_end, &_sif_rpc_data); SifAddCmdHandler(0x80000009, (void *)_request_bind, &_sif_rpc_data); SifAddCmdHandler(0x8000000a, (void *)_request_call, &_sif_rpc_data); SifAddCmdHandler(0x8000000c, (void *)_request_rdata, &_sif_rpc_data); #if 0 /* XXX: IOP is already initialized, we can't do this. */ if (SifGetReg(0x80000002)) return; cmdp = (u32 *)&pkt_table[64]; cmdp[3] = 1; SifSendCmd(0x80000002, cmdp, 16, NULL, NULL, 0); while (!SifGetSreg(0)) ; #endif SifSetReg(0x80000002, 1); core_restore(status); }
int SjPCM_Init(int sync) { int i; /* do { if (sif_bind_rpc(&cd0, SJPCM_IRX, 0) < 0) { return -1; } nopdelay(); } while(!cd0.server); */ while(1){ if (SifBindRpc( &cd0, SJPCM_IRX, 0) < 0) return -1; // bind error if (cd0.server != 0) break; i = 0x10000; while(i--); } sbuff[0] = sync; SifCallRpc(&cd0,SJPCM_INIT,0,(void*)(&sbuff[0]),64,(void*)(&sbuff[0]),64,0,0); FlushCache(0); pcmbufl = sbuff[1]; pcmbufr = sbuff[2]; bufpos = sbuff[3]; DIntr(); SifAddCmdHandler(SJPCM_CALLBACK, _sjpcm_callback, NULL); EIntr(); sjpcm_inited = 1; return 0; }
void addEEDebugHandler(void) { /* Register eedebug handler. */ SifAddCmdHandler(0x00000010, print_iop_data, NULL); }
int sbcall_sifaddcmdhandler(tge_sbcall_sifaddcmdhandler_arg_t *arg) { SifAddCmdHandler(arg->fid, arg->handler, arg->harg); return 0; }