void db_dumpiojunk( const IORegistryPlane * plane ) { IORegistryEntry * next; IORegistryIterator * iter; OSOrderedSet * all; char format[] = "%xxxs"; IOService * service; iter = IORegistryIterator::iterateOver( plane ); all = iter->iterateAll(); if( all) { dbugprintf("Count %d\n", all->getCount() ); all->release(); } else dbugprintf("Empty\n"); iter->reset(); while( (next = iter->getNextObjectRecursive())) { snprintf(format + 1, sizeof(format) - 1, "%ds", 2 * next->getDepth( plane )); dbugprintf( format, ""); dbugprintf( "%s", next->getName( plane )); if( (next->getLocation( plane ))) dbugprintf("@%s", next->getLocation( plane )); dbugprintf(" <class %s", next->getMetaClass()->getClassName()); if( (service = OSDynamicCast(IOService, next))) dbugprintf(", busy %ld", service->getBusyState()); dbugprintf( ">\n"); } iter->release(); }
uint8_t CheckBumpers(void) { ES_Event thisEvent; uint8_t returnVal = FALSE; uint16_t currentState = 0; uint16_t result = 0; static uint16_t lastState = 0; currentState = Sensors_CheckBumperStatus(BUMPER_ALL); result = lastState ^ currentState; if ((currentState & 0xFF) != 0xF8) { if (result) { thisEvent.EventType = BUMPED; thisEvent.EventParam = result; PostToplevelHSM(thisEvent); PostReturnCenterFSM(thisEvent); PostSearchCastleFSM(thisEvent); PostRotateFSM(thisEvent); dbugprintf("BUMPED = 0x%X\n", result); lastState = currentState; returnVal = TRUE; } } return returnVal; }
uint8_t CheckTapes(void) { ES_Event thisEvent; uint8_t returnVal = FALSE; static uint8_t currentState = 0, lastState = TAPE_RIGHT2 | TAPE_LEFT2; uint16_t result = TAPE_RIGHT2 | TAPE_LEFT2; currentState = Sensors_CheckTapeStatus(TAPE_RIGHT2 | TAPE_LEFT2); result = lastState ^ currentState; if (result) { thisEvent.EventType = TAPE; thisEvent.EventParam = result; PostToplevelHSM(thisEvent); PostReturnCenterFSM(thisEvent); PostSearchCastleFSM(thisEvent); lastState = currentState; dbugprintf("TAPE = 0x%X\n", result); returnVal = TRUE; } return returnVal; }
uint8_t NORTH_WALL_InitSubHSM(void) { ES_Event returnEvent; ES_Event PostEvent; currentState = INIT_NORTH_WALL_STATE; returnEvent = NORTH_WALL_RunSubHSM(INIT_EVENT); dbugprintf("NORTH_WALL_INITFUNCTION, currentState = %d\n", currentState); return returnEvent.EventType == ES_NO_EVENT; }
void db_piokjunk(void) { dbugprintf("\nDT plane:\n"); db_dumpiojunk( gIODTPlane ); dbugprintf("\n\nService plane:\n"); db_dumpiojunk( gIOServicePlane ); dbugprintf("\n\n" "ivar kalloc() 0x%08x\n" "malloc() 0x%08x\n" "containers kalloc() 0x%08x\n" "IOMalloc() 0x%08x\n" "----------------------------------------\n", debug_ivars_size, debug_malloc_size, debug_container_malloc_size, debug_iomalloc_size ); }
uint8_t FIND_RULING_InitSubHSM(void) { ES_Event returnEvent; currentState = INIT_FIND_RULING_STATE; returnEvent = FIND_RULING_RunSubHSM(INIT_EVENT); dbugprintf("FIND_RULING_INITFUNCTION, currentState = %d\n", currentState); return returnEvent.EventType == ES_NO_EVENT; }
ES_Event NORTH_WALL_RunSubHSM(ES_Event ThisEvent) { uint8_t makeTransition = FALSE; SubNorthWall_t nextState; uint8_t temp1, temp2; static uint8_t once = 0; ES_Event PostEvent; switch(currentState) { case INIT_NORTH_WALL_STATE: if(ThisEvent.EventType == ES_INIT) { currentState = NORTH_WALL_ALIGN; ThisEvent.EventType = ES_NO_EVENT; dbugprintf("INIT_NORTH_WALL = %d\n", currentState); //makeTransition = TRUE; } break; case NORTH_WALL_ALIGN: if (ThisEvent.EventType != ES_NO_EVENT) { switch(ThisEvent.EventType) { case ES_ENTRY: PostEvent.EventType = START_ALIGN; PostEvent.EventParam = 0; PostAlignFSM(PostEvent); dbugprintf("NORTH_WALL_ALIGN\n"); break; case COMPLETE: nextState = NORTH_WALL_CCW90; makeTransition = TRUE; ThisEvent.EventType = ES_NO_EVENT; break; default: break; } } break; case NORTH_WALL_CCW90: if (ThisEvent.EventType != ES_NO_EVENT) { switch(ThisEvent.EventType) { case ES_ENTRY: dbugprintf("NORTH_WALL_CCW180\n"); Motor_RightSpeed(ccw_R); Motor_LeftSpeed(ccw_L); HSM_LEDSubIndicate(0x0B); ES_Timer_InitTimer(HSM_TIMER, ccw90_Time); break; case ES_TIMEOUT: nextState = NORTH_WALL_FORWARD; makeTransition = TRUE; ThisEvent.EventType = ES_NO_EVENT; break; default: break; } } break; case NORTH_WALL_FORWARD: if (ThisEvent.EventType != ES_NO_EVENT) { switch(ThisEvent.EventType) { case ES_ENTRY: Motor_RightSpeed(forward_R); Motor_LeftSpeed(forward_L); HSM_LEDSubIndicate(0x08); break; case BUMPED: ThisEvent.EventType = COMPLETE; break; default: break; } } break; default: break; } if (makeTransition) { NORTH_WALL_RunSubHSM(EXIT_EVENT); currentState = nextState; NORTH_WALL_RunSubHSM(ENTRY_EVENT); } return ThisEvent; }
ES_Event FIND_RULING_RunSubHSM(ES_Event ThisEvent) { uint8_t makeTransition = FALSE; SubFindRuling_t nextState; static uint8_t tape = 0; static uint8_t lock = 0; switch(currentState) { case INIT_FIND_RULING_STATE: if(ThisEvent.EventType == ES_INIT) { SEARCH_CASTLE_SE_InitSubHSM(); SEARCH_CASTLE_SW_InitSubHSM(); SEARCH_CASTLE_NW_InitSubHSM(); currentState = FIND_RULING_CHOOSE; ThisEvent.EventType = ES_NO_EVENT; dbugprintf("INIT_FIND_RULING = %d\n", currentState); //makeTransition = TRUE; } break; case FIND_RULING_CHOOSE: if (ThisEvent.EventType == ES_ENTRY) { #ifdef CHEAT_SEARCH_SE if (beacon || testing) { nextState = FIND_RULING_SEARCH_CASTLE_NW; } else { nextState = FIND_RULING_SEARCH_CASTLE_SE; } #endif #ifdef CHEAT_SEARCH_NW if (beacon || testing) { nextState = FIND_RULING_SEARCH_CASTLE_SE; } else { nextState = FIND_RULING_SEARCH_CASTLE_NW; } #endif makeTransition = TRUE; } break; case FIND_RULING_SEARCH_CASTLE_SE: ThisEvent = SEARCH_CASTLE_SE_RunSubHSM(ThisEvent); if (ThisEvent.EventType != ES_NO_EVENT) { switch(ThisEvent.EventType) { case FOUND_RULING: ThisEvent.EventType = COMPLETE; //dbugstop(); break; case NOT_FOUND_RULING: nextState = FIND_RULING_SEARCH_CASTLE_SW; makeTransition = TRUE; ThisEvent.EventType = ES_NO_EVENT; default: break; } } break; case FIND_RULING_SEARCH_CASTLE_SW: ThisEvent = SEARCH_CASTLE_SW_RunSubHSM(ThisEvent); if (ThisEvent.EventType != ES_NO_EVENT) { switch(ThisEvent.EventType) { case FOUND_RULING: ThisEvent.EventType = COMPLETE; //dbugstop(); break; case NOT_FOUND_RULING: nextState = FIND_RULING_SEARCH_CASTLE_SW; makeTransition = TRUE; ThisEvent.EventType = ES_NO_EVENT; default: break; } } break; case FIND_RULING_SEARCH_CASTLE_NW: ThisEvent = SEARCH_CASTLE_NW_RunSubHSM(ThisEvent); if (ThisEvent.EventType != ES_NO_EVENT) { switch(ThisEvent.EventType) { case FOUND_RULING: ThisEvent.EventType = COMPLETE; //dbugstop(); break; default: break; } } break; default: break; } if (makeTransition) { FIND_RULING_RunSubHSM(EXIT_EVENT); currentState = nextState; FIND_RULING_RunSubHSM(ENTRY_EVENT); } return ThisEvent; }