static void ieee1394_callback(int reason, unsigned long int offset, unsigned long int size){ #if 0 iLinkBufferOffset=offset; iLinkTransferSize=size; if(reason==iLink_CB_WRITE_REQUEST){ u32 statusFIFO_result; // XPRINTF("Write request: Offset: 0x%08lx; size: 0x%08lx.\n", iLinkBufferOffset, iLinkTransferSize); if(iLinkBufferOffset==(u32)statusFIFO){ /* Check to be sure that we don't signal ieee1394_Sync() too early; Some transactions are transactions involving multiple ORBs. */ statusFIFO_result=((struct sbp2_status *)statusFIFO)->status; if(RESP_SRC(statusFIFO_result)!=0) SetEventFlag(sbp2_event_flag, WRITE_REQ_INCOMING); /* Signal ieee1394_Sync() only after the last ORB was read. */ } } else #endif if(reason==iLink_CB_BUS_RESET){ SetEventFlag(sbp2_event_flag, BUS_RESET_COMPLETE); } #if 0 else{ //XPRINTF("Read request: Offset: 0x%08lx; size: 0x%08lx;\n", iLinkBufferOffset, iLinkTransferSize); } #endif }
/* 48 */ void sio2_mtap_transfer_init() { SetEventFlag(event_flag, EF_MTAP_TRANSFER_INIT); WaitEventFlag(event_flag, EF_MTAP_TRANSFER_READY, 0, NULL); ClearEventFlag(event_flag, ~EF_MTAP_TRANSFER_READY); }
void SIO2_TransferInit1 ( void ) { SetEventFlag ( s_EventFlag, 0x00000004 ); WaitEventFlag ( s_EventFlag, 0x00000008, 0, NULL ); ClearEventFlag ( s_EventFlag, ~0x00000008 ); } /* end SIO2_TransferInit1 */
static void *rpc_end_func(int fid, void *buf, int bufsize) { SetEventFlag(eng_args.evflg, EF_ATA_DONE); ReleaseWaitThread(cur_thid); return NULL; }
void SIO2_TransferInit3 ( void ) { SetEventFlag ( s_EventFlag, 0x00000040 ); WaitEventFlag ( s_EventFlag, 0x00000080, 0, NULL ); ClearEventFlag ( s_EventFlag, ~0x00000080 ); } /* end SIO2_TransferInit3 */
void SIO2_TransferInit0 ( void ) { SetEventFlag ( s_EventFlag, 0x00000001 ); WaitEventFlag ( s_EventFlag, 0x00000002, 0, NULL ); ClearEventFlag ( s_EventFlag, ~0x00000002 ); } /* end SIO2_TransferInit0 */
s32 padEnd(void) { if(padman_init != 0) { int port,slot; for(port = 0; port < 2; port++) for(slot=0; slot < 4; slot++) { if((openSlots[port] >> slot) & 0x1) padPortClose(port, slot, 1); } SetEventFlag(vblankData.eventflag, EF_EXIT_THREAD); vblankData.padEnd = 1; WaitEventFlag(vblankData.eventflag, EF_VB_WAIT_THREAD_EXIT, 0x11, 0); DeleteThreadsEventFlag( &vblankData ); while(ReleaseVblankHandler(0, (void*)VblankStart) != 0) M_PRINTF("Release VB_START failed.\n"); while(ReleaseVblankHandler(1, VblankEnd) != 0) M_PRINTF("Release VB_END failed.\n"); padman_init = 0; }
void SIO2_TransferInit4 ( void ) { SetEventFlag ( s_EventFlag, 0x00000100 ); WaitEventFlag ( s_EventFlag, 0x00000200, 0, NULL ); ClearEventFlag ( s_EventFlag, ~0x00000200 ); } /* end SIO2_TransferInit4 */
void TransferThread(void *arg) { while(1) { WaitClearEvent(vblankData.eventflag, EF_VB_TRANSFER, 0x10, 0); pdTransfer(); SetEventFlag(vblankData.eventflag, EF_VB_TRANSFER_DONE); } }
/* 25 */ int sio2_transfer(sio2_transfer_data_t *td) { transfer_data = td; SetEventFlag(event_flag, EF_TRANSFER_START); WaitEventFlag(event_flag, EF_TRANSFER_FINISH, 0, NULL); ClearEventFlag(event_flag, ~EF_TRANSFER_FINISH); return 1; }
static void TransferThread(void *arg) { while(1) { WaitClearEvent(vblankData.eventflag, EF_VB_TRANSFER, WEF_AND|WEF_CLEAR, NULL); pdTransfer(); SetEventFlag(vblankData.eventflag, EF_VB_TRANSFER_DONE); } }
int SIO2_Transfer ( SIO2_TransferData* apData ) { s_pTransferData = apData; SetEventFlag ( s_EventFlag, 0x00000400 ); WaitEventFlag ( s_EventFlag, 0x00000800, 0, NULL ); ClearEventFlag ( s_EventFlag, ~0x00000800 ); return 1; } /* end SIO2_Transfer */
void NetManToggleNetIFLinkState(int NetIFID, unsigned char state){ struct NetManNetIF *pNetIF; WaitSema(NetManIOSemaID); if((NetIFID&0xFF)<NETMAN_MAX_NETIF_COUNT && NetIFID==NetIFs[NetIFID&0xFF].id && (NetIFs[NetIFID&0xFF].flags&NETMAN_NETIF_IN_USE)){ pNetIF = &NetIFs[NetIFID&0xFF]; ClearEventFlag(pNetIF->EventFlagID, ~(NETMAN_NETIF_EVF_UP|NETMAN_NETIF_EVF_DOWN)); if(state){ pNetIF->flags|=NETMAN_NETIF_LINK_UP; SetEventFlag(pNetIF->EventFlagID, NETMAN_NETIF_EVF_UP); } else{ pNetIF->flags&=~NETMAN_NETIF_LINK_UP; SetEventFlag(pNetIF->EventFlagID, NETMAN_NETIF_EVF_DOWN); } UpdateNetIFStatus(); } SignalSema(NetManIOSemaID); }
void signalCallbackThreadFunc(IoRequest *req) { int intrStat; CpuSuspendIntr(&intrStat); req->prev = cbListEnd; req->next = NULL; if (cbListEnd) cbListEnd->next = req; else cbListStart = req; cbListEnd = req; CpuResumeIntr(intrStat); SetEventFlag(callbackEvent, 1); }
void update_slot_numbers_thread() { while(1) { u32 resbits, port; s32 slots; WaitEventFlag(event_flag, EF_UPDATE_SLOTS | EF_EXIT_THREAD, 0x11, &resbits); if((resbits & EF_EXIT_THREAD) == 1) { SetEventFlag(event_flag, 0x4); ExitThread(); } for(port=0; port < 4; port++) { if(state_open[port] == 1) { if(state_getcon[port] == 0) slots = get_slot_number(port, 10); else slots = get_slot_number(port, 0); if(slots < 0) { state_slots[port] = 1; state_getcon[port] = 0; } else { state_slots[port] = slots; state_getcon[port] = 1; } } } } }
//----------------------------------------------------------------------------- // // void CEventControl::upData( ccTime dt ) { for( int i = 0; ; i++ ) { if( 0 == GetEventPointFlag( i + 1 ) ) { CBaseDataEvent* pBaseDataEvent = g_pClientLoader->GetEventDataFromId( i + 1 ); if( NULL == pBaseDataEvent ) { break; } m_TempEventPoint = pBaseDataEvent->m_EventPointInfo; //task point unlock if( CheckCurrentEventPointLimit() ) { //…Ë÷√∆ϱ͌™1(Ω‚À¯◊¥Ã¨) m_iEventState = EVENT_STATE_NEW; AddTaskData( pBaseDataEvent ); SetEventPointFlag( i + 1, 1 ); } } } for( int i = 0; i < MAX_TASK_EVNET; i++ ) { CBaseDataEvent* pBaseDataEvent = g_pClientLoader->GetEventDataFromId( m_TaskData[i].EventId ); if( NULL != pBaseDataEvent ) { if( 0 == GetEventFlag( m_TaskData[i].EventId ) && CheckSubEvent( m_TaskData[i].EventId )) { SetEventFlag( m_TaskData[i].EventId , 1 ); for( int iRunCount = 0; iRunCount < pBaseDataEvent->m_SubEvent.m_wEventRunCount; iRunCount++ ) { HandleExecRunFunc( pBaseDataEvent->m_SubEvent.m_iFunctionRun[iRunCount] ); } for( int iRunCount = 0; iRunCount < pBaseDataEvent->m_EventPointInfo.m_iPointRunCount; iRunCount++ ) { HandleExecRunFunc( pBaseDataEvent->m_EventPointInfo.m_iPointRunArray[iRunCount] ); } //CNd91Mng::NdUnLockAchievement( pBaseDataEvent->m_EventPointInfo.m_w91Id ); CTaskFinishGui *pGui = new CTaskFinishGui( m_TaskData[i].EventId ); pGui->init(); pGui->autorelease(); CCSize s = CCDirector::sharedDirector()->getWinSize(); pGui->setContentSize( s ); CCDirector::sharedDirector()->getRunningScene()->addChild( pGui,TASK_EVNET_DIALOG_TAG, TASK_EVNET_DIALOG_TAG ); pGui->FadeOut(); } } } if( 0 == GetCurTaskCount() ) { m_iEventState = EVENT_STATE_NONE; } }
static void MainThread(void *arg) { while(1) { u32 port, slot; mainThreadCount++; if( mainThreadCount % 30 == 0 ) sio2_mtap_update_slots(); for(port=0; port < 2; port++) { for(slot=0; slot < 4; slot++) { if( ((openSlots[port] >> slot) & 0x1) == 1) { pdSetActive(port, slot, 0); padState[port][slot].stat70bit = pdGetStat70bit(port, slot); if(padState[port][slot].runTask != TASK_NONE) { if(padState[port][slot].runTask == TASK_PORT_CLOSE) { padState[port][slot].currentTask = padState[port][slot].runTask; padState[port][slot].runTask = TASK_NONE; padState[port][slot].reqState = PAD_RSTAT_BUSY; SetEventFlag(padState[port][slot].eventflag, EF_EXIT_THREAD); } else { if(padState[port][slot].currentTask == TASK_UPDATE_PAD) { // Start Task StartThread(padState[port][slot].taskTid, NULL); padState[port][slot].currentTask = padState[port][slot].runTask; padState[port][slot].runTask = TASK_NONE; padState[port][slot].reqState = PAD_RSTAT_BUSY; } else { padState[port][slot].runTask = TASK_NONE; padState[port][slot].reqState = PAD_RSTAT_FAILED; } } } } switch(padState[port][slot].currentTask) { case TASK_UPDATE_PAD: { SetEventFlag(padState[port][slot].eventflag, EF_UPDATE_PAD); WaitEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_START, 0x10, 0); pdSetActive(port, slot, 1); } break; case TASK_QUERY_PAD: { padState[port][slot].buttonDataReady = 0; SetEventFlag(padState[port][slot].eventflag, EF_QUERY_PAD); WaitEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_START, 0x10, 0); pdSetActive(port, slot, 1); } break; case TASK_PORT_CLOSE: { if(GetThreadsStatus( &padState[port][slot] ) == 1) { padState[port][slot].currentTask = TASK_NONE; padState[port][slot].reqState = PAD_RSTAT_COMPLETE; openSlots[port] ^= (1 << slot); DeleteThreads( &padState[port][slot] ); SetEventFlag(padState[port][slot].eventflag, EF_PORT_CLOSE); } } break; case TASK_SET_MAIN_MODE: { padState[port][slot].buttonDataReady = 0; SetEventFlag(padState[port][slot].eventflag, EF_SET_MAIN_MODE); WaitEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_START, 0x10, 0); pdSetActive(port, slot, 1); } break; case TASK_SET_ACT_ALIGN: { padState[port][slot].buttonDataReady = 0; SetEventFlag(padState[port][slot].eventflag, EF_SET_ACT_ALIGN); WaitEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_START, 0x10, 0); pdSetActive(port, slot, 1); } break; case TASK_SET_BUTTON_INFO: { padState[port][slot].buttonDataReady = 0; SetEventFlag(padState[port][slot].eventflag, EF_SET_SET_BUTTON_INFO); WaitEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_START, 0x10, 0); pdSetActive(port, slot, 1); } break; case TASK_SET_VREF_PARAM: { padState[port][slot].buttonDataReady = 0; SetEventFlag(padState[port][slot].eventflag, EF_SET_VREF_PARAM); WaitEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_START, 0x10, 0); pdSetActive(port, slot, 1); } break; } } } // Transfer is started in VblankStart vblankData.stopTransfer = 0; WaitClearEvent(vblankData.eventflag, EF_VB_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL); if( (openSlots[0] != 0) || (openSlots[1] != 0)) { for(port=0; port < 2; port++) { for(slot=0; slot < 4; slot++) { if(pdIsActive(port, slot) == 1) { /* Signal transfer done and wait to task (reading sio2 data) to be done. */ SetEventFlag(padState[port][slot].eventflag, EF_PAD_TRANSFER_DONE); WaitEventFlag(padState[port][slot].eventflag, EF_TASK_DONE, 0x10, 0); } } } } // Send pad data to EE DmaSendEE(); mainThreadCount2++; // s7 // Check for disconnected controllers if(mainThreadCount2 >= 8) { if(mainThreadCount % 30 != 0) { if( pdIsActive(pad_port, pad_slot) == 1) { if( padState[pad_port][pad_slot].state == PAD_STATE_DISCONN) pad_portdata[pad_port] &= ~(1 << pad_slot); // clear slot else pad_portdata[pad_port] |= (1 << pad_slot); // set slot } else { if( pdCheckConnection(pad_port, pad_slot) == 1) pad_portdata[pad_port] |= (1 << pad_slot); // set slot else pad_portdata[pad_port] &= ~(1 << pad_slot); // clear slot } //Move onto the next slot pad_slot++; if(pad_slot >= 4) { //Move onto the next port pad_slot = 0; pad_port++; if(pad_port >= 2) pad_port = 0; } mainThreadCount2 = 0; } } } }
void main_thread(void *unused) { u32 resbits[4]; while (1) { #ifndef XSIO2MAN log_flush(0); #endif WaitEventFlag(event_flag, EF_PAD_TRANSFER_INIT | EF_MC_TRANSFER_INIT | EF_MTAP_TRANSFER_INIT, 1, resbits); if (resbits[0] & EF_PAD_TRANSFER_INIT) { ClearEventFlag(event_flag, ~EF_PAD_TRANSFER_INIT); SetEventFlag(event_flag, EF_PAD_TRANSFER_READY); #ifndef XSIO2MAN log_default(LOG_PAD_READY); #endif } else if (resbits[0] & EF_MC_TRANSFER_INIT) { ClearEventFlag(event_flag, ~EF_MC_TRANSFER_INIT); SetEventFlag(event_flag, EF_MC_TRANSFER_READY); #ifndef XSIO2MAN log_default(LOG_MC_READY); #endif } else if (resbits[0] & EF_MTAP_TRANSFER_INIT) { ClearEventFlag(event_flag, ~EF_MTAP_TRANSFER_INIT); SetEventFlag(event_flag, EF_MTAP_TRANSFER_READY); #ifndef XSIO2MAN log_default(LOG_MTAP_READY); #endif } else { EPRINTF("Unknown event %08lx. Exiting.\n", resbits[0]); return; } transfer_loop: WaitEventFlag(event_flag, EF_TRANSFER_START | EF_TRANSFER_RESET, 1, resbits); if (resbits[0] & EF_TRANSFER_RESET) { ClearEventFlag(event_flag, ~EF_TRANSFER_RESET); #ifndef XSIO2MAN log_default(LOG_RESET); #endif continue; } ClearEventFlag(event_flag, ~EF_TRANSFER_START); sio2_ctrl_set(sio2_ctrl_get() | 0xc); send_td(transfer_data); sio2_ctrl_set(sio2_ctrl_get() | 1); WaitEventFlag(event_flag, EF_SIO2_INTR_COMPLETE, 0, NULL); ClearEventFlag(event_flag, ~EF_SIO2_INTR_COMPLETE); recv_td(transfer_data); SetEventFlag(event_flag, EF_TRANSFER_FINISH); /* Bah... this is needed to get the initial dump from XMCMAN, but it will kill the IOP when XPADMAN is spamming... TODO I guess the correct solution is to do all logging in a dedicated thread. */ // log_flush(1); goto transfer_loop; } }
void SIO2_TransferReset ( void ) { SetEventFlag ( s_EventFlag, 0x00001000 ); } /* end SIO2_TransferReset */
/* 26 */ void sio2_transfer_reset() { SetEventFlag(event_flag, EF_TRANSFER_RESET); }
void update_slot_numbers() { SetEventFlag(event_flag, EF_UPDATE_SLOTS); }
static void _MainThread ( void* apParam ) { u32 lBits[ 4 ]; u32 lEventFlag; while ( 1 ) { WaitEventFlag ( s_EventFlag, 0x00000155, 1, lBits ); if ( lBits[ 0 ] & 0x00000001 ) { /* SIO2_TransferInit0 */ ClearEventFlag ( s_EventFlag, ~0x00000001 ); lEventFlag = 0x00000002; } else if ( lBits[ 0 ] & 0x00000004 ) { /* SIO2_TransferInit1 */ ClearEventFlag ( s_EventFlag, ~0x00000004 ); lEventFlag = 0x00000008; } else if ( lBits[ 0 ] & 0x00000010 ) { /* SIO2_TransferInit2 */ ClearEventFlag ( s_EventFlag, ~0x00000010 ); lEventFlag = 0x00000020; } else if ( lBits[ 0 ] & 0x00000040 ) { /* SIO2_TransferInit3 */ ClearEventFlag ( s_EventFlag, ~0x00000040 ); lEventFlag = 0x00000080; } else if ( lBits[ 0 ] & 0x00000100 ) { /* SIO2_TransferInit4 */ ClearEventFlag ( s_EventFlag, ~0x00000100 ); lEventFlag = 0x00000200; } else break; loop: SetEventFlag ( s_EventFlag, lEventFlag ); WaitEventFlag ( s_EventFlag, 0x00001400, 1, lBits ); /* SIO2_Transfer or SIO2_TransferReset */ if ( lBits[ 0 ] & 0x00001000 ) { /* SIO2_TransferReset */ ClearEventFlag ( s_EventFlag, ~0x00001000 ); continue; } /* end if */ ClearEventFlag ( s_EventFlag, ~0x00000400 ); /* SIO2_Transfer */ SIO2_SwitchCtrlC (); _Send ( s_pTransferData ); SIO2_SwitchCtrl1 (); WaitEventFlag ( s_EventFlag, 0x00002000, 0, NULL ); ClearEventFlag ( s_EventFlag, ~0x00002000 ); _Recv ( s_pTransferData ); lEventFlag = 0x00000800; goto loop; } /* end while */ } /* end _MainThread */