int serial_init (void) { DECLARE_GLOBAL_DATA_PTR; int clock_divisor = (CONFIG_SYS_TCLK / 16)/gd->baudrate; if (whoAmI() == MASTER_CPU) { #ifdef CONFIG_SYS_INIT_CHAN1 mvUartInit(0, clock_divisor, mvUartBase(0)); #endif } #if defined(MV78XX0) if ((whoAmI() == MASTER_CPU) || (whoAmI() == SLAVE_CPU)) #endif { #ifdef CONFIG_SYS_INIT_CHAN2 mvUartInit(1, clock_divisor, mvUartBase(1)); #endif } #if 0 /* print banner */ print_mvBanner(); #endif return (0); }
/** * Creates 2 children, one running tail and one grep, connecting them with a pipe, and connects itself * with grep, so it can catch every phrase with the word you want to find in the file filename. */ void monitorWord(char *word, char *filename){ //sleep(TIME_BEFORE_LAUNCH); int pipe1[2], pipe2[2]; pipe(pipe1); __pid_t pid; if((pid=fork())==0) { //tail if(DEBUG) whoAmI(filename, "tail"); close(pipe1[READ]); dup2(pipe1[WRITE], STDOUT_FILENO); execlp("tail", "tail", "-fn 1", filename, NULL); } else { setpgid(pid, getpid()); pipe(pipe2); if((pid=fork())== 0) { //grep if(DEBUG) whoAmI(filename, "grep"); close(pipe1[WRITE]); close(pipe2[READ]); dup2(pipe1[READ], STDIN_FILENO); dup2(pipe2[WRITE], STDOUT_FILENO); execlp("grep", "grep", "--line-buffered", word, NULL); } else { //console output if(DEBUG) whoAmI(filename, "grep output to console"); setpgid(pid, getpid()); close(pipe2[WRITE]); time_t t = time(NULL); struct tm tm = *localtime(&t); char receive[MAX_SIZE]; int read_bytes= 0; while((read_bytes= read(pipe2[READ], receive, MAX_SIZE))!= -1 || read_bytes!= 0) { t= time(NULL); tm = *localtime(&t); receive[read_bytes]='\0'; //tm_mon january is 0 december is 11 printf("%4d-%02d-%02dT%02d:%02d:%02d - %s - %s", tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, filename, receive); } } } }
MV_VOID mvSocUnitMapPrint(MV_8* buf) { int i, count; count = mvOsSPrintf(buf, "CPU core %d, SoC units in use:\n", whoAmI()); for (i = 0; mv_res_table[i].cpuId != -1; i++) { if (mv_res_table[i].cpuId == whoAmI()) { count += mvOsSPrintf(buf+count, "%s ", mv_res_table[i].unitName); } } }
static void serial_initialize(void) { #if defined(CONFIG_MV78200) mv_uart.resource = &mv_uart_resources[2*whoAmI()]; mv_uart.dev.platform_data = &mv_uart_data[1*whoAmI()]; mv_uart_data[1*whoAmI()].uartclk = mvTclk; platform_device_register(&mv_uart); #else mv_uart_data[0].uartclk = mv_uart_data[1].uartclk = mvTclk; platform_device_register(&mv_uart); #endif }
void serial_putc(const char c) { #if defined(CONFIG_MV_SMP) || (defined(MV78XX0) && defined(MV78200)) if (c == '\n') mvUartPutc((whoAmI())%2, '\r'); mvUartPutc((whoAmI())%2, c); #else if (c == '\n') mvUartPutc(CONFIG_SYS_DUART_CHAN, '\r'); mvUartPutc(CONFIG_SYS_DUART_CHAN, c); #endif }
Flow* PointerAnalysis::executeFlowFunction(Flow *in, Instruction *inst, int NodeId){ PointerAnalysisFlow* inFlow = static_cast<PointerAnalysisFlow*>(in); PointerAnalysisFlow * output; errs()<<inst<<"\n"; int opType = whoAmI(inFlow,inst); switch(opType) { case X_rY: output = operation_X_rY(inFlow,inst); break; case X_Y: output = operation_X_Y(inFlow,inst); break; case pX_Y: output = operation_pX_Y(inFlow,inst); break; case X_pY: output = operation_X_pY(inFlow,inst); break; default: output = new PointerAnalysisFlow(inFlow); } return output; }
QpGenStochLinsysRootAugRedPrecond:: QpGenStochLinsysRootAugRedPrecond(QpGenStoch* factory_, QpGenStochData* prob, OoqpVector* dd_, OoqpVector* dq_, OoqpVector* nomegaInv_, OoqpVector* rhs_) : QpGenStochLinsysRootAugRed(), Pmult(NULL), Amult(NULL), tmpVec1(NULL) { //QpGenStochLinsy factory = factory_; nx = prob->nx; my = prob->my; mz = prob->mz; ixlow = prob->ixlow; ixupp = prob->ixupp; iclow = prob->iclow; icupp = prob->icupp; nxlow = prob->nxlow; nxupp = prob->nxupp; mclow = prob->mclow; mcupp = prob->mcupp; if( nxupp + nxlow > 0 ) { //dd = OoqpVectorHandle(dd_); dd= dd_; //dq = OoqpVectorHandle(dq_); dq = dq_; } //nomegaInv = OoqpVectorHandle(nomegaInv_); //rhs = OoqpVectorHandle(rhs_); nomegaInv = nomegaInv_; rhs = rhs_; useRefs=1; data = prob; stochNode = prob->stochNode; //QpGenStochLinsysRoot iAmDistrib = 0; //QpGenStochLinsyRootAug prob->getLocalSizes(locnx, locmy, locmz); UtV = NULL; //QpGenStochLinsyRootAug CtDC=NULL; redRhs = new SimpleVector(locnx+locmy+locmz); kkt = createKKT(prob); solver = createSolver(prob, kkt); //intializations related to this class me = whoAmI(); createChildren(prob); };
int serial_tstc(void) { #if defined(CONFIG_MV_SMP) || (defined(MV78XX0) && defined(MV78200)) return mvUartTstc((whoAmI())%2); #else return mvUartTstc(CONFIG_SYS_DUART_CHAN); #endif }
int board_init(void) { DECLARE_GLOBAL_DATA_PTR; if (whoAmI() != 0) return 0; #if defined(MV_INCLUDE_TWSI) MV_TWSI_ADDR slave; #endif unsigned int i; maskAllInt(); /* Init the Board environment module (device bank params init) */ mvBoardEnvInit(); #if defined(MV_INCLUDE_TWSI) slave.type = ADDR7_BIT; slave.address = 0; mvTwsiInit(0, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_TCLK, &slave, 0); #endif /* Init the Controlloer environment module (MPP init) */ mvCtrlEnvInit(); #if defined(CONFIG_DISPLAY_CPUINFO) late_print_cpuinfo(); /* display cpu info (and speed) */ #endif mvBoardDebugLed(2); mvCpuIfInit(mvCpuAddrWinMap); #ifdef MV_NOR_BOOT env_init(); #endif /* Init the GPIO sub-system */ MV_GPP_HAL_DATA gppHalData; gppHalData.ctrlRev = mvCtrlRevGet(); mvGppInit(&gppHalData); gd->bd->bi_arch_number = 528; gd->bd->bi_boot_params = 0x00000100; /* relocate the exception vectors */ /* U-Boot is running from DRAM at this stage */ for (i = 0; i < 0x100; i += 4) *(unsigned int*)(0x0 + i) = *(unsigned int*)(CONFIG_SYS_TEXT_BASE + i); mvBoardDebugLed(4); return 0; }
QpGenStochLinsysRootAugRedPrecond:: QpGenStochLinsysRootAugRedPrecond(QpGenStoch * factory_, QpGenStochData * prob) : QpGenStochLinsysRootAugRed(), Pmult(NULL), Amult(NULL), tmpVec1(NULL) { factory = factory_; kkt = NULL; solver = NULL; nx = prob->nx; my = prob->my; mz = prob->mz; ixlow = prob->ixlow; ixupp = prob->ixupp; iclow = prob->iclow; icupp = prob->icupp; nxlow = prob->nxlow; nxupp = prob->nxupp; mclow = prob->mclow; mcupp = prob->mcupp; if( nxupp + nxlow > 0 ) { dd = factory_->tree->newPrimalVector(); dq = factory_->tree->newPrimalVector(); prob->getDiagonalOfQ( *dq ); } nomegaInv = factory_->tree->newDualZVector(); rhs = factory_->tree->newRhs(); useRefs=0; data = prob; stochNode = prob->stochNode; //QpGenStochLinsysRoot iAmDistrib = 0; //QpGenStochLinsyRootAug prob->getLocalSizes(locnx, locmy, locmz); UtV = NULL; //QpGenStochLinsyRootAug CtDC=NULL; kkt = createKKT(prob); solver = createSolver(prob, kkt); //QpGenStochLinsyRootAugRed redRhs = new SimpleVector(locnx+locmy+locmz); //intializations related to this class me = whoAmI(); createChildren(prob); };
/******************************************************************************* * twsiMainIntGet - Get twsi bit from main Interrupt cause. * * DESCRIPTION: * This routine returns the twsi interrupt flag value. * * INPUT: * None. * * OUTPUT: * None. * * RETURN: * MV_TRUE is interrupt flag is set, MV_FALSE otherwise. * *******************************************************************************/ static MV_BOOL twsiMainIntGet(MV_U8 chanNum) { MV_U32 temp; /* get the int flag bit */ temp = MV_REG_READ(MV_TWSI_CPU_MAIN_INT_CAUSE(chanNum, whoAmI())); if (temp & (1<<CPU_MAIN_INT_TWSI_OFFS(chanNum))) /* (TWSI_CPU_MAIN_INT_BIT(chanNum))) */ return MV_TRUE; return MV_FALSE; }
MV_BOOL mvSemaTryLock(MV_32 num) { MV_U32 tmp; if (num > MV_MAX_SEMA) { mvOsPrintf("Invalid semaphore number\n"); return MV_FALSE; } tmp = MV_REG_BYTE_READ(MV_SEMA_REG_BASE+num); if ((tmp & 0xFF) != whoAmI()) { return MV_FALSE; } else return MV_TRUE; }
MV_BOOL mvSemaLock(MV_32 num) { MV_U32 tmp; MV_U32 cpuId; if (num > MV_MAX_SEMA) { mvOsPrintf("Invalid semaphore number\n"); return MV_FALSE; } cpuId = whoAmI(); do { tmp = MV_REG_BYTE_READ(MV_SEMA_REG_BASE+num); } while ((tmp & 0xFF) != cpuId); return MV_TRUE; }
static void __init mv_init(void) { /* init the Board environment */ mvBoardEnvInit(); /* init the controller environment */ if (mvCtrlEnvInit() ) { printk( "Controller env initialization failed.\n" ); return; } /* Init the CPU windows setting and the access protection windows. */ if (mvCpuIfInit(mv_sys_map())) { printk( "Cpu Interface initialization failed.\n" ); return; } #if defined (CONFIG_MV78XX0_Z0) mvCpuIfBridgeReorderWAInit(); #endif /* Init Tclk & SysClk */ mvTclk = mvBoardTclkGet(); mvSysclk = mvBoardSysClkGet(); support_wait_for_interrupt = 1; #ifdef CONFIG_JTAG_DEBUG support_wait_for_interrupt = 0; /* for Lauterbach */ #endif mv_vfp_init(); elf_hwcap &= ~HWCAP_JAVA; serial_initialize(); /* At this point, the CPU windows are configured according to default definitions in mvSysHwConfig.h */ /* and cpuAddrWinMap table in mvCpuIf.c. Now it's time to change defaults for each platform. */ mvCpuIfAddrDecShow(whoAmI()); print_board_info(); }
int serial_init (void) { DECLARE_GLOBAL_DATA_PTR; if (whoAmI() == MASTER_CPU) { int clock_divisor = (CONFIG_SYS_TCLK / 16)/gd->baudrate; #ifdef CONFIG_SYS_INIT_CHAN1 mvUartInit(0, clock_divisor, mvUartBase(0)); #endif #ifdef CONFIG_SYS_INIT_CHAN2 mvUartInit(1, clock_divisor, mvUartBase(1)); #endif } /* print banner */ #if !defined(DB_88AP510_PCAC) print_mvBanner(); #endif return (0); }
void __init mv_init_irq(void) { u32 gppMask,i; #if defined(CONFIG_MV78200) || defined(CONFIG_MV632X) coreId = whoAmI(); printk("IRQ initialize for core %d\n", coreId); #endif /* Disable all interrupts initially. */ if (0 == coreId) { MV_REG_WRITE(GPP_INT_MASK_REG(0), 0); MV_REG_WRITE(GPP_INT_LVL_REG(0), 0); } MV_REG_WRITE(CPU_INT_MASK_LOW_REG(coreId), 0); MV_REG_WRITE(CPU_INT_MASK_HIGH_REG(coreId), 0); /* Set Gpp interrupts as needed */ if (0 == coreId) /*GPP for core 0 only*/ { gppMask = mvBoardGpioIntMaskGet(); mvGppTypeSet(0, gppMask , (MV_GPP_IN & gppMask)); mvGppPolaritySet(0, gppMask , (MV_GPP_IN_INVERT & gppMask)); /* clear all int */ MV_REG_WRITE(GPP_INT_MASK_REG(0), 0); MV_REG_WRITE(CPU_INT_MASK_HIGH_REG(coreId), IRQ_GPP_MASK); } else MV_REG_WRITE(CPU_INT_MASK_HIGH_REG(coreId), 0); /* Do the core module ones */ for (i = 0; i < NR_IRQS; i++) { set_irq_chip(i, &mv_chip); set_irq_handler(i, handle_level_irq); set_irq_flags(i, IRQF_VALID | IRQF_PROBE); } /* TBD. Add support for error interrupts */ return; }
void mv_print_map(void) { #ifdef DB_78X60_PCAC return 0; #endif printf("\nMap: Code:\t\t\t0x%08x:0x%08x\n", (unsigned int)gd->reloc_off, (unsigned int)(gd->reloc_off + _bss_start_ofs)); printf(" BSS:\t\t\t0x%08x\n", (unsigned int)(gd->reloc_off + _bss_end_ofs)); printf(" Stack:\t\t\t0x%08x\n", (unsigned int)gd->start_addr_sp); #if defined(MV_INCLUDE_MONT_EXT) int add; if (!enaMonExt()) { add = MV_PT_BASE(whoAmI()); printf(" PageTable:\t0x%08x\n", add); } #endif printf(" Heap:\t\t\t0x%08x:0x%08x\n", (unsigned int)(gd->relocaddr - TOTAL_MALLOC_LEN), (unsigned int)gd->relocaddr); printf(" U-Boot Environment:\t0x%08x:0x%08x ", CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE); #ifdef MV_NAND_BOOT printf("(NAND)\n\n"); #elif defined(MV_SPI_BOOT) printf("(SPI)\n\n"); #endif }
void decideHunterMove(HunterView gameState) { int dracLocation; // don't call when round is 0 int myLocation; // don't call when round is 0 // get the current round number Round roundNum = giveMeTheRound(gameState); // current hunter PlayerID hunter = whoAmI(gameState); printf("My life points are: %d\n", howHealthyIs(gameState, hunter)); // health of current player //int currentHealth = howHealthyIs(gameState, hunter); srand(time(NULL)); //srand(time(NULL)); //LocationID whereIs(HunterView currentView, PlayerID player); // Mina setup at castle dracula for whole game // camp at KL/GA. if drac is at DC, then move to DC if (hunter == PLAYER_LORD_GODALMING) { if (roundNum == 0) { registerBestPlay("KL", "First round.."); } else { dracLocation = whereIs(gameState, PLAYER_DRACULA); myLocation = whereIs(gameState, hunter); printf("--- mylocation: %d, draclocation: %d\n", myLocation, dracLocation); // drac is at castle dracula. if i'm at SZ/KL then move there if (dracLocation == CASTLE_DRACULA && (myLocation == GALATZ || myLocation == KLAUSENBURG || myLocation == CASTLE_DRACULA)) { registerBestPlay("CD", "Drac is at CD! Attack!"); }else if(dracLocation == myLocation){ registerBestPlay(idToAbbrev(myLocation),"Drac is Here I'm Staying"); }else if((roundNum%RESEARCH_ROUND) == 0 && roundNum != 1){ registerBestPlay(idToAbbrev(myLocation),"Lets Just Rest Here"); } else { // drac isn't at CD, or I'm not near there. // camp at Klausenburg/Galatz or return from hospital if (myLocation == KLAUSENBURG) { registerBestPlay("GA", "Klausenburg -> Galatz"); } else if (myLocation == GALATZ) { registerBestPlay("KL", "Galatz -> Klausenburg"); } else if (myLocation == ST_JOSEPH_AND_ST_MARYS) { registerBestPlay("SZ", "I died. Heading Back To the Castle"); } else if (myLocation == SZEGED) { registerBestPlay("KL", "Heading Back To the Castle"); } else if (myLocation == CASTLE_DRACULA) { registerBestPlay("KL", "Castle Drac -> Klausenburg"); } } } // hunters other than mina harker // for round zero, spawn hunters in spanned out locations on map } else if (roundNum == 0) { switch (hunter) { case PLAYER_MINA_HARKER: registerBestPlay("MA", "I'm starting at Madrid"); break; case PLAYER_DR_SEWARD: registerBestPlay("FR", "I'm starting at Frankfurt"); break; case PLAYER_VAN_HELSING: registerBestPlay("ZA", "I'm starting at Szeged"); break; } // randomised location } else { myLocation = whereIs(gameState, hunter); LocationID goToID = goToDrac(gameState, myLocation, roundNum, hunter); char *goTo = idToAbbrev(goToID); registerBestPlay(goTo, "Never Stop Looking For Drac."); } }
LocationID goToDrac(HunterView gameState, int myLocation, Round roundNum, PlayerID hunter){ int size, *goToArr; goToArr = whereCanIgo(gameState, &size, 1, 0, 0); printf("Size is %d\n", size); LocationID dracTrail[TRAIL_SIZE]; giveMeTheTrail(gameState, PLAYER_DRACULA, dracTrail); LocationID myTrail[TRAIL_SIZE]; giveMeTheTrail(gameState, hunter, myTrail); int i = 0; LocationID trailValue = NOWHERE; while(trailValue == NOWHERE && i < TRAIL_SIZE){ if(dracTrail[i] == HIDE && dracTrail[i+1] != CITY_UNKNOWN && dracTrail[i+1] != SEA_UNKNOWN){ if((i+1) < TRAIL_SIZE) trailValue = dracTrail[i+1]; }else if(dracTrail[i] >= DOUBLE_BACK_1 && dracTrail[i] <= DOUBLE_BACK_5){ int k = dracTrail[i] - DOUBLE_BACK_1 + 1 + i; if(dracTrail[k]!= CITY_UNKNOWN && dracTrail[k] != SEA_UNKNOWN && k < TRAIL_SIZE) trailValue = dracTrail[k]; }else if(dracTrail[i] != CITY_UNKNOWN && dracTrail[i] != SEA_UNKNOWN){ trailValue = dracTrail[i]; } i++; } while(i > 0 && trailValue != NOWHERE){ if(trailValue == myTrail[i] && trailValue != dracTrail[0]) trailValue = NOWHERE; i--; } LocationID goToID = NOWHERE; if(trailValue == dracTrail[0] && trailValue == myLocation){ goToID = myLocation; printf("Drac is here, I'm staying here"); } else if(trailValue != NOWHERE && trailValue != myLocation){ printf("Looking For Drac near me, drac is near %s\n", idToAbbrev(trailValue)); treeBase *B = newTree(gameState, whoAmI(gameState),goToArr,size); goToID = searchTree(B, trailValue); freeTree(B); if(goToID != NOWHERE) printf("Heading Towards Drac. Move: %s -> %s\n", idToAbbrev(myLocation), idToAbbrev(goToID)); }else if(trailValue == NOWHERE && (roundNum+1)%RESEARCH_ROUND == 0 && hunter != PLAYER_LORD_GODALMING){ goToID = myLocation; printf("Lets do research"); } int loopCount = 0; int choice = -1; while(goToID == NOWHERE){ choice = rand() % size; goToID = goToArr[choice]; printf("-- random choice is: %d. Move: %s -> %s\n", choice, idToAbbrev(myLocation), idToAbbrev(goToID)); i = 0; while(i<TRAIL_SIZE){ if((goToID == myTrail[i] && loopCount < (size*2)) || goToID == CASTLE_DRACULA) goToID = NOWHERE; i++; } loopCount++; } free(goToArr); return goToID; }
void decideHunterMove(HunterView gameState) { int turn = giveMeTurnNum(gameState); messages = malloc(sizeof(PlayerMessage)*turn); getMessages(gameState,messages); int current_player = whoAmI(gameState); srand(time(NULL)); //initialises current_leader global variable int current_round = giveMeTheRound(gameState); int current_rank = getRank(gameState, current_player, current_round); PlayerMessage message = ""; int leader_trail[TRAIL_SIZE]; giveMeTheTrail(gameState,current_leader,leader_trail); printf("current leader is %d\n",current_leader); printf("LT->"); int j; for (j=0;j<TRAIL_SIZE;j++){ printf("%d->",leader_trail[j]); } printf("x\n"); int drac_trail[TRAIL_SIZE]; giveMeTheTrail(gameState,PLAYER_DRACULA,drac_trail); printf("DT->"); int m; for (m=0;m<TRAIL_SIZE;m++){ printf("%d->",drac_trail[m]); } printf("x\n"); int move; char *moveTo; printf("check %d %d\n",current_round,current_leader); if (current_round == 0) { if(current_player == PLAYER_LORD_GODALMING) {move = PLAYER1_START_POS;} else if(current_player == PLAYER_DR_SEWARD) {move = PLAYER2_START_POS;} else if(current_player == PLAYER_VAN_HELSING) {move = PLAYER3_START_POS;} else if(current_player == PLAYER_MINA_HARKER) {move = PLAYER4_START_POS;} else printf("I am noone..\n"); makeMessageFollower(gameState, current_player, message); } else if (current_player == current_leader) { printf("I am the leader\n"); move = makeRandomMove2(gameState,current_player); moveTo = idToAbbrev(move); registerBestPlay(moveTo,message); move = makeLeaderMove(gameState,message); } else { printf("I am a follower"); move = makeRandomMove2(gameState,current_player); moveTo = idToAbbrev(move); registerBestPlay(moveTo,message); printf(" and I am making a move\n"); move = makeFollowerMove(gameState, current_player, current_rank); makeMessageFollower(gameState, current_player, message); } printf("move is %d\n",move); moveTo = idToAbbrev(move); registerBestPlay(moveTo,message); }
int PTexist(void) { char *env; #ifdef MV_PT env = getenv("enaPT"); #ifdef CONFIG_MV_LE /* if LE page table disable is the default. ( MIPS - unstable, PPC need to change the page settings) */ if( ( (strcmp(env,"yes") == 0) || (strcmp(env,"Yes") == 0) ) ){ #else /* if BE page table enable is the default. */ if(!env || ( (strcmp(env,"yes") == 0) || (strcmp(env,"Yes") == 0) ) ){ #endif return 1; } #endif return 0; } #endif /***********************************************************************************/ /* hook function that is called after rellocating to the DRAM, Flash Init, PCI init*/ /* and malloc init are done, and before Gig port init. */ /***********************************************************************************/ void mon_extension_after_relloc(void) { #if defined(MV_INCLUDE_MONT_FFS) unsigned int status; #endif #if defined(MV_INCLUDE_MONT_MMU) if ((mvOsCpuPartGet() == CPU_PART_ARM926) || (mvOsCpuPartGet() == CPU_PART_MRVL131) || (mvOsCpuPartGet() == CPU_PART_MRVLPJ4B_UP) || (mvOsCpuPartGet() == CPU_PART_MRVLPJ4B_MP)) { /* Page Table */ if(PTexist() ) { pageTableInit(); setenv("enaPT","yes"); } else setenv("enaPT","no"); } #endif /* MV_INCLUDE_MONT_MMU */ #if defined(MV_INCLUDE_MONT_MPU) else if (mvOsCpuPartGet() == CPU_PART_ARM946) { char *env; env = getenv("enaMPU"); if ((!env)||( (strcmp(env,"yes") == 0) || (strcmp(env,"Yes") == 0) )) { setenv("enaMPU","yes"); MPU_Init(); } } #endif /* MV_INCLUDE_MONT_MPU */ #if defined(CONFIG_CMD_BSP) #if defined(MV_INCLUDE_MONT_FFS) if (whoAmI() == MASTER_CPU) { status = mvFSInit(FS_NO_CACHE); if(!(status == FS_NO_VALID_FAT_STRING || status == FS_OFFSET_OUT_OF_RANGE)) { printf("File system present and initialized on the main Flash Memory\n"); } } else { printf("No File system on the main Flash Memory\n"); } #endif /* MV_INCLUDE_MONT_FFS */ #endif return; }
MV_BOOL mvSocUnitIsMappedToThisCpu(MV_SOC_UNIT unit) { return (mvSocUnitMapGet(unit) == whoAmI()); }
void tempest::me() { whoAmI(); }
void decideHunterMove(HunterView gameState) { //printf("------------------------------------------"); int playerID = whoAmI(gameState); if(howHealthyIs(gameState,playerID)==0){ registerBestPlay("JM","Dead"); }else if(playerID == 0){ int round = giveMeTheRound(gameState); LocationID trail[TRAIL_SIZE]; giveMeTheTrail(gameState, whoAmI(gameState), trail); int dead = 0; int i; for(i=0; i<3; i++){ if(trail[i] == nameToID("JM")) dead = i; fprintf(stderr, "Dead%d\n",dead); } if(dead){ if(round%2==0){ registerBestPlay("KL","Camping 1"); }else if(round%2==1){ registerBestPlay("BC","Camping 2"); } }else{ if(dead == 0){ registerBestPlay("SZ","Recovery 1"); }else if(dead == 1){ registerBestPlay("KL","Recovery 2"); }else{ registerBestPlay("KL","Recovery 3"); } } }else{ fprintf(stderr, "\n\nHunters\n"); srand((unsigned) time(NULL)); if(giveMeTheRound(gameState) == 0){ registerBestPlay("MU","Let the games Begin"); }else{ int numLocations = 0; int *places; char message[15]; int i; fprintf(stderr,"huntFrom:%s\n",idToName(whereIs(gameState, playerID))); fprintf(stderr, "\n\n\n"); places = whereCanIgo(gameState, &numLocations, 1, 1, 0); fprintf(stderr, "Free\nnumLoc:%d\n", numLocations); for(i=0; i<numLocations; i++){ fprintf(stderr, "%s,",idToName(places[i])); } srand(time(NULL)); registerBestPlay(idToAbbrev(places[rand()%numLocations]),message); //if(places[0]) // printf("a"); sprintf(message, "\n\n"); //registerBestPlay("MU",""); } } //printf("\n\n\n\n"); //egisterBestPlay("GE","I'm on holiday in Geneva"); }
int board_init (void) { DECLARE_GLOBAL_DATA_PTR; int clock_divisor; unsigned int i; MV_GPP_HAL_DATA gppHalData; clock_divisor = (CONFIG_SYS_TCLK / 16)/115200; /* muti-core support, initiate each Uart to each cpu */ mvUartInit(whoAmI(), clock_divisor, mvUartBase(whoAmI())); if (whoAmI() != 0) return 0; #if defined(MV_INCLUDE_TWSI) MV_TWSI_ADDR slave; #endif maskAllInt(); /* must initialize the int in order for udelay to work */ /* interrupt_init(); - no interrupt handling in u-boot */ timer_init(); /* Init the Board environment module (device bank params init) */ mvBoardEnvInit(); #if defined(MV_INCLUDE_TWSI) slave.type = ADDR7_BIT; slave.address = 0; mvTwsiInit(0, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_TCLK, &slave, 0); #endif /* Init the Controlloer environment module (MPP init) */ mvCtrlEnvInit(); #if defined(CONFIG_DISPLAY_CPUINFO) late_print_cpuinfo(); /* display cpu info (and speed) */ #endif mvBoardDebugLed(2); /* Init the Controller CPU interface */ mvCpuIfInit(mvCpuAddrWinMap); #if defined(MV_NOR_BOOT) env_init(); #endif if (mvBoardCpssBoardIdSet(mvBoardIdGet()) != MV_OK) printf("%s: Error: Failed to set Board ID for CPSS!\n", __func__); /* Init the GPIO sub-system */ gppHalData.ctrlRev = mvCtrlRevGet(); mvGppInit(&gppHalData); /* arch number of Integrator Board */ gd->bd->bi_arch_number=mv_get_arch_number(); /* adress of boot parameters */ gd->bd->bi_boot_params = 0x00000100; /* relocate the exception vectors */ /* U-Boot is running from DRAM at this stage */ for(i = 0; i < 0x100; i+=4) { *(unsigned int *)(0x0 + i) = *(unsigned int*)(CONFIG_SYS_TEXT_BASE + i); } mvBoardDebugLed(4); return 0; }
// find a path between two vertices using breadth-first traversal int findPath(HunterView h, LocationID src, LocationID dest, int *path, int road, int rail, int sea) { printf("finding path from %d to %d\n",src,dest); if(src==dest) { printf("trying to get to where you are\n"); path[1] = dest; return 1; } int tmp_city = src; // Temporary store of path_distance for calculations int tmp_distance = 0; int path_distance = 0; // Array of visited cities, if not visited 0, else 1 int visited[NUM_MAP_LOCATIONS] = {0}; // Stores index of the previous city, default value -1 int prev[NUM_MAP_LOCATIONS] = {[0 ... (NUM_MAP_LOCATIONS-1)] = -1}; Queue cityQ = newQueue(); QueueJoin(cityQ, src); // While Queue is not empty and the tmp_city is not the destination city (e.g. when path to destination city from src is found) while (QueueIsEmpty(cityQ) == 0 && tmp_city != dest) { tmp_city = QueueLeave(cityQ); int num_locs; int *locs = connectedLocations(h->g, &num_locs,tmp_city, whoAmI(h), giveMeTheRound(h),road,rail,sea); int i; for (i=0;i<num_locs;i++) { if (!visited[locs[i]]) { QueueJoin(cityQ, locs[i]); prev[locs[i]] = tmp_city; visited[locs[i]] = 1; } } if (tmp_city == dest) { prev[locs[i]] = tmp_city; // Calculating size of path int index = locs[i]; while (index != src) { index = prev[index]; path_distance++; } // Building path array, storing destination first tmp_distance = path_distance-1; path[tmp_distance] = dest; tmp_distance--; // Storing rest of array index = prev[dest]; while (tmp_distance >= 0) { path[tmp_distance] = index; index = prev[index]; tmp_distance--; } break; } } printf("path->"); int j; for(j=0;j<path_distance;j++) { printf("%d->",path[j]); } printf("x\n"); return path_distance; }
int main() { int i; HunterView hv; printf("Test basic empty initialisation\n"); hv = newHunterView("", NULL); assert(whoAmI(hv) == PLAYER_LORD_GODALMING); assert(giveMeTheRound(hv) == 0); assert(howHealthyIs(hv,PLAYER_DR_SEWARD) == GAME_START_HUNTER_LIFE_POINTS); assert(howHealthyIs(hv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS); assert(giveMeTheScore(hv) == GAME_START_SCORE); assert(whereIs(hv,PLAYER_LORD_GODALMING) == UNKNOWN_LOCATION); printf("passed\n"); disposeHunterView(hv); printf("Test for Dracula trail and basic functions\n"); PlayerMessage messages2[] = {"Hello","Rubbish","Stuff","","Mwahahah"}; hv = newHunterView("GST.... SAO.... HZU.... MBB.... DC?....", messages2); assert(whoAmI(hv) == PLAYER_LORD_GODALMING); assert(giveMeTheRound(hv) == 1); assert(whereIs(hv,PLAYER_LORD_GODALMING) == STRASBOURG); assert(whereIs(hv,PLAYER_DR_SEWARD) == ATLANTIC_OCEAN); assert(whereIs(hv,PLAYER_VAN_HELSING) == ZURICH); assert(whereIs(hv,PLAYER_MINA_HARKER) == BAY_OF_BISCAY); assert(whereIs(hv,PLAYER_DRACULA) == CITY_UNKNOWN); assert(howHealthyIs(hv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS); printf("passed\n"); disposeHunterView(hv); printf("Test for encountering Dracula and hunter history\n"); PlayerMessage messages3[] = {"Hello","Rubbish","Stuff","","Mwahahah","Aha!"}; hv = newHunterView("GST.... SAO.... HCD.... MAO.... DGE.... GGED...", messages3); assert(whereIs(hv,PLAYER_DRACULA) == GENEVA); assert(howHealthyIs(hv,PLAYER_LORD_GODALMING) == 5); assert(howHealthyIs(hv,PLAYER_DRACULA) == 30); assert(whereIs(hv,PLAYER_LORD_GODALMING) == GENEVA); LocationID history[TRAIL_SIZE]; giveMeTheTrail(hv,PLAYER_DRACULA,history); assert(history[0] == GENEVA); assert(history[1] == UNKNOWN_LOCATION); giveMeTheTrail(hv,PLAYER_LORD_GODALMING,history); assert(history[0] == GENEVA); assert(history[1] == STRASBOURG); assert(history[2] == UNKNOWN_LOCATION); giveMeTheTrail(hv,PLAYER_DR_SEWARD,history); assert(history[0] == ATLANTIC_OCEAN); assert(history[1] == UNKNOWN_LOCATION); printf("passed\n"); disposeHunterView(hv); printf("Test for Dracula doubling back at sea, and losing blood points (Hunter View)\n"); PlayerMessage messages4[] = {"Hello","Rubbish","Stuff","","Mwahahah","Aha!","","","","Back I go"}; hv = newHunterView("GGE.... SGE.... HGE.... MGE.... DS?.... " "GST.... SST.... HST.... MST.... DD1....", messages4); assert(whereIs(hv,PLAYER_DRACULA) == DOUBLE_BACK_1); giveMeTheTrail(hv,PLAYER_DRACULA,history); assert(history[0] == DOUBLE_BACK_1); assert(history[1] == SEA_UNKNOWN); assert(howHealthyIs(hv,PLAYER_DRACULA) == GAME_START_BLOOD_POINTS - 4); assert(whoAmI(hv) == 0); printf("passed\n"); disposeHunterView(hv); printf("Test for connections\n"); int size, seen[NUM_MAP_LOCATIONS], *edges; printf("Checking Galatz road connections\n"); PlayerMessage messages5[] = {"Gone to Galatz"}; hv = newHunterView("GGA....", messages5); edges = whereCanTheyGo(hv,&size,PLAYER_LORD_GODALMING,1,0,0); memset(seen, 0, NUM_MAP_LOCATIONS*sizeof(int)); for (i = 0; i< size ; i++) seen[edges[i]] = 1; assert(size == 5); assert(seen[GALATZ]); assert(seen[CONSTANTA]); assert(seen[BUCHAREST]); assert(seen[KLAUSENBURG]); assert(seen[CASTLE_DRACULA]); free(edges); disposeHunterView(hv); printf("Checking Ionian Sea sea connections\n"); PlayerMessage messages6[] = {"Sailing the Ionian"}; hv = newHunterView("GIO....", messages6); edges = whereCanTheyGo(hv,&size,PLAYER_LORD_GODALMING,0,0,1); memset(seen, 0, NUM_MAP_LOCATIONS*sizeof(int)); for (i = 0; i < size; i++) seen[edges[i]] = 1; assert(size == 7); assert(seen[IONIAN_SEA]); assert(seen[BLACK_SEA]); assert(seen[ADRIATIC_SEA]); assert(seen[TYRRHENIAN_SEA]); assert(seen[ATHENS]); assert(seen[VALONA]); assert(seen[SALONICA]); free(edges); disposeHunterView(hv); printf("Checking Athens rail connections (none)\n"); PlayerMessage messages7[] = {"Leaving Athens by train"}; hv = newHunterView("GAT....", messages7); edges = whereCanTheyGo(hv,&size,PLAYER_LORD_GODALMING,0,1,0); assert(size == 1); assert(edges[0] == ATHENS); free(edges); disposeHunterView(hv); printf("passed\n"); return 0; }