int main(void) { u8 cnt; board_setup(); configure_leds(C); light_leds(C, 0x0); enable_interrupt(0, IT_RAISING_EDGE); enable_interrupt(1, IT_LEVEL); usart_init(9600); sei(); light_leds(C, 0x1); { u8 hw[] = "HELLO WORLD\n"; usart_write(hw, sizeof(hw)-1); } for (;;) { int_clear_ack(0); int_clear_ack(1); led_cbk[cur_led_cbk](); _delay_ms(1000); } return 0; }
void __init plat_mem_setup(void) { board_time_init = nxc2600_tick_timer_init; set_io_port_base(KSEG1); board_setup(); }
static void board_init_data(struct board *board) { int size = board_size(board); board_setup(board); board_resize(board, size - 2 /* S_OFFBOARD margin */); /* Setup neighborhood iterators */ board->nei8[0] = -size - 1; // (-1,-1) board->nei8[1] = 1; board->nei8[2] = 1; board->nei8[3] = size - 2; // (-1,0) board->nei8[4] = 2; board->nei8[5] = size - 2; // (-1,1) board->nei8[6] = 1; board->nei8[7] = 1; board->dnei[0] = -size - 1; board->dnei[1] = 2; board->dnei[2] = size*2 - 2; board->dnei[3] = 2; /* Setup initial symmetry */ if (size % 2) { board->symmetry.d = 1; board->symmetry.x1 = board->symmetry.y1 = board_size(board) / 2; board->symmetry.x2 = board->symmetry.y2 = board_size(board) - 1; board->symmetry.type = SYM_FULL; } else { /* TODO: We do not handle board symmetry on boards * with no tengen yet. */ board->symmetry.d = 0; board->symmetry.x1 = board->symmetry.y1 = 1; board->symmetry.x2 = board->symmetry.y2 = board_size(board) - 1; board->symmetry.type = SYM_NONE; } /* Set up coordinate cache */ foreach_point(board) { board->coord[c][0] = c % board_size(board); board->coord[c][1] = c / board_size(board); } foreach_point_end; /* Draw the offboard margin */ int top_row = board_size2(board) - board_size(board); int i; for (i = 0; i < board_size(board); i++) board->b[i] = board->b[top_row + i] = S_OFFBOARD; for (i = 0; i <= top_row; i += board_size(board)) board->b[i] = board->b[board_size(board) - 1 + i] = S_OFFBOARD; foreach_point(board) { coord_t coord = c; if (board_at(board, coord) == S_OFFBOARD) continue; foreach_neighbor(board, c, { inc_neighbor_count_at(board, coord, board_at(board, c)); } ); } foreach_point_end;
/** \brief Sets up system hardware */ static void prvSetupHardware(void) { /* Setup board including GPIOs and pin muxing */ board_setup(); led_set(0); /* Initialize debug output via serial port */ debug_frmwrk_init(); }
void __init plat_mem_setup(void) { int i; char* argptr; board_setup(); /* board specific setup */ _machine_restart = pnx8550_machine_restart; _machine_halt = pnx8550_machine_halt; pm_power_off = pnx8550_machine_power_off; /* Clear the Global 2 Register, PCI Inta Output Enable Registers Bit 1:Enable DAC Powerdown -> 0:DACs are enabled and are working normally 1:DACs are powerdown Bit 0:Enable of PCI inta output -> 0 = Disable PCI inta output 1 = Enable PCI inta output */ PNX8550_GLB2_ENAB_INTA_O = 0; /* IO/MEM resources. */ set_io_port_base(PNX8550_PORT_BASE); ioport_resource.start = 0; ioport_resource.end = ~0; iomem_resource.start = 0; iomem_resource.end = ~0; /* Request I/O space for devices on this board */ for (i = 0; i < STANDARD_IO_RESOURCES; i++) request_resource(&ioport_resource, standard_io_resources + i); /* Place the Mode Control bit for GPIO pin 16 in primary function */ /* Pin 16 is used by UART1, UA1_TX */ outl((PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_16_BIT) | (PNX8550_GPIO_MODE_PRIMOP << PNX8550_GPIO_MC_17_BIT), PNX8550_GPIO_MC1); argptr = prom_getcmdline(); if ((argptr = strstr(argptr, "console=ttyS")) != NULL) { argptr += strlen("console=ttyS"); pnx8550_console_port = *argptr == '0' ? 0 : 1; /* We must initialize the UART (console) before early printk */ /* Set LCR to 8-bit and BAUD to 38400 (no 5) */ ip3106_lcr(UART_BASE, pnx8550_console_port) = PNX8XXX_UART_LCR_8BIT; ip3106_baud(UART_BASE, pnx8550_console_port) = 5; } return; }
struct board * board_init(char *fbookfile) { struct board *b = malloc2(sizeof(struct board)); board_setup(b); b->fbookfile = fbookfile; // Default setup b->size = 9 + 2; board_clear(b); return b; }
int main(void) { rtc_setup(); board_setup(); mch_net_init(); testapp_init(); while (1) { mch_net_poll(); sys_check_timeouts(); } }
void __init plat_mem_setup(void) { struct cpu_spec *sp; char *argptr; unsigned long prid, cpufreq, bclk = 1; set_cpuspec(); sp = cur_cpu_spec[0]; board_setup(); /* board specific setup */ prid = read_c0_prid(); if (sp->cpu_pll_wo) #ifdef CONFIG_SOC_AU1000_FREQUENCY cpufreq = CONFIG_SOC_AU1000_FREQUENCY / 1000000; #else cpufreq = 396; #endif else
int main() { char *cp, *file; int ask = 0, howto, ret; board_setup(); printf("\n>> OpenBSD/mvme88k netboot [%s]\n", version); ret = parse_args(&file, &howto); for (;;) { if (ask) { printf("boot: "); gets(line); if (line[0]) { bugargs.arg_start = line; cp = line; while (cp < (line + sizeof(line) - 1) && *cp) cp++; bugargs.arg_end = cp; ret =parse_args(&file, &howto); } } if (ret) { printf("boot: -q returning to MVME-Bug\n"); break; } exec_mvme(file, howto); printf("boot: %s: %s\n", file, strerror(errno)); ask = 1; } _rtt(); return (0); }
int main ( void ) { int8_t status; uint32_t loop; /** * Brief delay to give the debugger a chance to stop the core before we * muck around with the chip's configuration. */ for(loop = 0; loop < 1000000; ++loop){ __asm__("nop"); } /** * Note: to protect OS structures and data during initialisation, * interrupts must remain disabled until the first thread * has been restored. They are reenabled at the very end of * the first thread restore, at which point it is safe for a * reschedule to take place. */ board_setup(); /** * Initialise the OS before creating our threads. * * Note that we cannot enable stack-checking on the idle thread on * this platform because we are already using part of the idle * thread's stack now as our startup stack. Prefilling for stack * checking would overwrite our current stack. * * If you are not reusing the idle thread's stack during startup then * you are free to enable stack-checking here. */ status = atomOSInit(&idle_thread_stack[0], IDLE_STACK_SIZE_BYTES, FALSE); if (status == ATOM_OK) { /* Create an application thread */ status = atomThreadCreate(&main_tcb, TEST_THREAD_PRIO, main_thread_func, 0, &main_thread_stack[0], MAIN_STACK_SIZE_BYTES, TRUE); if (status == ATOM_OK) { /** * First application thread successfully created. It is * now possible to start the OS. Execution will not return * from atomOSStart(), which will restore the context of * our application thread and start executing it. * * Note that interrupts are still disabled at this point. * They will be enabled as we restore and execute our first * thread in archFirstThreadRestore(). */ atomOSStart(); } } while (1) ; /* There was an error starting the OS if we reach here */ return (0); }
int main(int argc, char **argv) { cl_options_t cl_options = {0}; dbg_init(); DBG_LOG("Version %s", g_version); ui = &ui_sdlgl; printf("DreamChess %s\n", g_version); parse_options(argc, argv, &ui, &cl_options); config_init(); set_cl_options(&cl_options); if (!ui) { DBG_ERROR("Failed to find a user interface driver"); exit(1); } ui->init(); init_resolution(); while (1) { board_t board; int pgn_slot; option_t *option; if (!(config = ui->config(&pgn_slot))) break; ch_userdir(); option = config_get_option("first_engine"); #ifdef __APPLE__ char temp1[200]; char temp2[200]; if (!strcmp(option->string, "dreamer") || !strcmp(option->string, "Dreamer")) { CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef bundledir = CFBundleCopyBundleURL(mainBundle); CFStringRef stringref = CFURLCopyFileSystemPath(bundledir, kCFURLPOSIXPathStyle); CFStringGetCString(stringref, temp1, 200, kCFStringEncodingMacRoman); snprintf(temp2, sizeof(temp2), "%s/contents/MacOS/dreamer", temp1); game_set_engine_error(comm_init(temp2)); } else game_set_engine_error(comm_init(option->string)); #else game_set_engine_error(comm_init(option->string)); #endif comm_send("xboard\n"); comm_send("new\n"); comm_send("random\n"); comm_send("sd %i\n", config->cpu_level); comm_send("depth %i\n", config->cpu_level); if (config->difficulty == 0) comm_send("noquiesce\n"); if (config->player[WHITE] == PLAYER_UI && config->player[BLACK] == PLAYER_UI) comm_send("force\n"); if (config->player[WHITE] == PLAYER_ENGINE) comm_send("go\n"); in_game = 1; board_setup(&board); history = history_init(&board); move_list_init(&san_list); move_list_init(&fan_list); move_list_init(&fullalg_list); if (pgn_slot >= 0) if (game_load(pgn_slot)) { DBG_ERROR("Failed to load savegame in slot %i", pgn_slot); exit(1); } ui->update(history->view->board, NULL); while (in_game) { char *s; if ((s = comm_poll())) { DBG_LOG("Message from engine: '%s'", s); if (!history->result) { if ((!strncmp(s, "move ", 4) || strstr(s, "... ")) && config->player[history->last->board->turn] == PLAYER_ENGINE) { char *move_str = strrchr(s, ' ') + 1; board_t new_board = *history->last->board; move_t *engine_move; DBG_LOG("Parsing move string '%s'", move_str); engine_move = san_to_move(&new_board, move_str); if (!engine_move) engine_move = fullalg_to_move(&new_board, move_str); if (engine_move) { audio_play_sound(AUDIO_MOVE); do_move(engine_move, 1); free(engine_move); } else DBG_ERROR("Failed to parse move string '%s'", move_str); } else if (strstr(s, "llegal move")) game_undo(); /* Ignore result message if we've already determined a result ourselves. */ else { char *start = strchr(s, '{'); char *end = strchr(s, '}'); if (start && end && end > start) { char *comment = malloc(end - start); history->result = malloc(sizeof(result_t)); strncpy(comment, start + 1, end - start - 1); comment[end - start - 1] = '\0'; history->result->reason = comment; if (strstr(s, "1-0")) { history->result->code = RESULT_WHITE_WINS; ui->show_result(history->result); } else if (strstr(s, "1/2-1/2")) { history->result->code = RESULT_DRAW; ui->show_result(history->result); } else if (strstr(s, "0-1")) { history->result->code = RESULT_BLACK_WINS; ui->show_result(history->result); } else { free(history->result->reason); free(history->result); history->result = NULL; } } } } free(s); } ui->poll(); } comm_send("quit\n"); comm_exit(); history_exit(history); move_list_exit(&san_list); move_list_exit(&fan_list); move_list_exit(&fullalg_list); } ui->exit(); dbg_exit(); return 0; }