void fit_init(fitinfo *fit) { beam_init(&fit->beam); pars_init(&fit->pars); profile_init(&fit->p); model_init(&fit->m); interface_init(&fit->rm); fit->m.rm = &fit->rm; fit->capacity = -1; fit->nQ = 0; data_init(&fit->dataA); data_init(&fit->dataB); data_init(&fit->dataC); data_init(&fit->dataD); fit->worksize = 0; fit->datatype = FIT_MAGNITUDE; fit->weight = 1.; fit->penalty = 0.; /* Parameters to support incoherent sum of models */ fit->number_incoherent = 0; fit->incoherent_models = NULL; fit->incoherent_weights = NULL; }
// Main setup code. static void maininit(void) { // Initialize internal interfaces. interface_init(); // Setup platform devices. platform_hardware_setup(); // call a payload if (CONFIG_RUN_PAYLOAD) { dprintf(1, "Looking for payload %s\n", CONFIG_RUN_PAYLOAD_FILE); struct romfile_s *file = NULL; file = romfile_find( CONFIG_RUN_PAYLOAD_FILE ); if (!file) printf("Could not find payload\n"); else { struct cbfs_romfile_s *cfile; cfile = container_of(file, struct cbfs_romfile_s, file); cbfs_run_payload(cfile->fhdr); } } // Start hardware initialization (if optionrom threading) if (CONFIG_THREAD_OPTIONROMS) device_hardware_setup(); // Run vga option rom vgarom_setup(); // Do hardware initialization (if running synchronously) if (!CONFIG_THREAD_OPTIONROMS) { device_hardware_setup(); wait_threads(); } // Run option roms optionrom_setup(); // show system info before the F12 menu if (CONFIG_DISPLAY_SYSTEM_INFO) dprintf(1, "\nBuild date: %s\n", __DATE__); // Allow user to modify overall boot order. interactive_bootmenu(); wait_threads(); // Prepare for boot. prepareboot(); // Write protect bios memory. make_bios_readonly(); // Invoke int 19 to start boot process. startBoot(); }
static void player_interface_init() { game.frame = &screen_frame; int width = sdl_frame_get_width(game.frame); int height = sdl_frame_get_height(game.frame); interface_init(&interface); gui_object_set_size((gui_object_t *)&interface, width, height); gui_object_set_displayed((gui_object_t *)&interface, 1); }
/** * Initializes all the modules of the system */ static inline void init_modules() { TRACE_FUNC_START(); TRACE_DEBUG_LOG("Initializing the engines module \n"); pktengine_init(); interface_init(); initBricks(); TRACE_FUNC_END(); }
int main() { load_strings(); interface_init(); game_over = false; start_start_scene(); update_scene = &update_start_scene; while (game_over == false) { int key = getch(); update_scene(key); } interface_uninit(); printf("Thanks for playing!\n"); }
static void csm_maininit(struct bregs *regs) { interface_init(); pci_probe_devices(); csm_compat_table.PnPInstallationCheckSegment = SEG_BIOS; csm_compat_table.PnPInstallationCheckOffset = get_pnp_offset(); regs->ax = 0; csm_return(regs); }
main(void) { /**********INITIALIZATIONS AND CONFIGURATIONS****************/ /* Initialize communications */ interface_init(); lcd_init(); /*********** RUNNING ****************************************/ welcome(); while (1) { if (updateFlag()) updateLCD(); } }
vsf_err_t interface_assert(struct interfaces_info_t **ifs) { if (NULL == cur_interface) { if (interface_init(NULL) || (NULL == cur_interface)) { cur_interface = NULL; vss_set_fatal_error(); return VSFERR_FAIL; } } if (ifs != NULL) { *ifs = cur_interface; } return VSFERR_NONE; }
// Main setup code. static void maininit(void) { // Initialize internal interfaces. interface_init(); // Setup platform devices. platform_hardware_setup(); // Start hardware initialization (if threads allowed during optionroms) if (threads_during_optionroms()) device_hardware_setup(); // Run vga option rom vgarom_setup(); sercon_setup(); enable_vga_console(); // Do hardware initialization (if running synchronously) if (!threads_during_optionroms()) { device_hardware_setup(); wait_threads(); } // Run option roms optionrom_setup(); // Allow user to modify overall boot order. interactive_bootmenu(); wait_threads(); // Prepare for boot. prepareboot(); // Write protect bios memory. make_bios_readonly(); // Invoke int 19 to start boot process. startBoot(); }
void sr_integ_init(struct sr_instance* sr) { printf(" ** sr_integ_init(..) called \n"); sr_router* subsystem = (sr_router*)malloc(sizeof(sr_router)); assert(subsystem); sr_set_subsystem(get_sr(), subsystem); // initialize arp and interfaces and routing table arp_cache_init(subsystem); interface_init(subsystem); rrtable_init(subsystem); hw_rrtable_init(subsystem); //enable ospf by default toggle_ospf_status(subsystem, TRUE); //disable reroute/multipath toggle_reroute_multipath_status(subsystem, FALSE); //flush hw registers #ifdef _CPUMODE_ hw_init(subsystem); writeReg(&subsystem->hw_device, CPCI_REG_CTRL, 0x00010100); usleep(2000); #endif } /* -- sr_integ_init -- */
void static inline go_to_sleep(){ // stop / disable peripherals cli(); // disable interrupts sys_timer_stop(); _delay_us(300); // small delay in order for the colorduino to be ready for transmission display_sleep(); while(uart_async_run()); // put display to sleep _delay_us(60); p_out_low(); interface_disable(); // turn leds + display off // disable UART UCSRnB = 0x00; //disable Rx and Tx // enable external pin change interrupt on PA7: PCINT7 PCMSK0 |= (1<<PCINT7); // set interrupt mask for PA7 PCICR |= (1<<PCIE0); // enable pin change interrupt 0 // go to sleep set_sleep_mode(SLEEP_MODE_STANDBY); sleep_enable(); sei(); sleep_cpu(); sleep_disable(); // wake up cli(); // disable interrupts PCICR = 0x00; // disable pin change interrupt PCMSK0 = 0x00; // restart peripherals UCSRnB = (1<<RXENn) | (1<<TXENn); //enable Rx and Tx interface_init(); display_wake_up(); sys_timer_start(); green_led_on(); sei(); // reenable interrupts }
int main(void) { BootLoaderStart(); firstInit(); set_defaults_all(&Preset, &Calibration); if (!start_load_all(&Preset, &Calibration)) set_errIO(ERRIO_LOADALL); interface_init(Current_state.preset_name); calibration_init(Current_state.calibration_name); noteOffStoreInit(); TIM4_init();//keyboard timer TIM6_init();//delay for temp messages TIM7_init(); //delay for MSC //Main loop while (1) { //Check note array to calculate velocity checkNoteArray(&Preset); checkSliders_events(Preset.sliders, Preset.AnalogMidiEnable); checkButtons_events(Preset.buttons, Preset.AnalogMidiEnable); receiveMidiData(); sendMidiData(); } }
/** * main function for FOSSology scheduler, does command line parsing, * Initialization and then simply enters the event loop. * * @param argc the command line argument cound * @param argv the command line argument values * @return if the program ran correctly */ int main(int argc, char** argv) { /* locals */ gboolean db_reset = FALSE; // flag to reset the job queue upon database connection gboolean ki_kill = FALSE; // flag that indicates all schedulers should be forcibly shutdown gboolean ki_shut = FALSE; // flag that indicates all schedulers should be gracefully shutdown gboolean db_init = FALSE; // flag indicating a database test gboolean test_die = FALSE; // flag to run the tests then die gboolean s_daemon = FALSE; // falg to run the scheduler as a daemon gchar* logdir = NULL; // used when a different log from the default is used GOptionContext* options; // option context used for command line parsing GError* error = NULL; // error object used during parsing uint16_t port = 0; gchar* sysconfigdir = DEFAULT_SETUP; /* THE SCHEDULER */ scheduler_t* scheduler; if(getenv("FO_SYSCONFDIR") != NULL) sysconfigdir = getenv("FO_SYSCONFDIR"); /* get this done first */ srand(time(NULL)); #if !(GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 32) g_thread_init(NULL); #endif #if !(GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 36) g_type_init(); #endif /* the options for the command line parser */ GOptionEntry entries[] = { { "daemon", 'd', 0, G_OPTION_ARG_NONE, &s_daemon, " Run scheduler as daemon" }, { "database", 'i', 0, G_OPTION_ARG_NONE, &db_init, " Initialize database connection and exit" }, { "kill", 'k', 0, G_OPTION_ARG_NONE, &ki_kill, " Forcibly kills all running schedulers" }, { "shutdown", 's', 0, G_OPTION_ARG_NONE, &ki_shut, " Gracefully shutdown of all running schedulers" }, { "log", 'L', 0, G_OPTION_ARG_STRING, &logdir, "[str] Specify location of log file" }, { "port", 'p', 0, G_OPTION_ARG_INT, &port, "[num] Set the interface port" }, { "reset", 'R', 0, G_OPTION_ARG_NONE, &db_reset, " Reset the job queue upon startup" }, { "test", 't', 0, G_OPTION_ARG_NONE, &test_die, " Close the scheduler after running tests" }, { "verbose", 'v', 0, G_OPTION_ARG_INT, &verbose, "[num] Set the scheduler verbose level" }, { "config", 'c', 0, G_OPTION_ARG_STRING, &sysconfigdir, "[str] Specify system configuration directory" }, {NULL} }; /* ********************* */ /* *** parse options *** */ /* ********************* */ options = g_option_context_new("- scheduler for FOSSology"); g_option_context_add_main_entries(options, entries, NULL); g_option_context_parse(options, &argc, &argv, &error); if(error) { fprintf(stderr, "ERROR: %s\n", error->message); fprintf(stderr, "%s", g_option_context_get_help(options, FALSE, NULL)); fflush(stderr); return -1; } g_option_context_free(options); /* check changes to the process first */ if(ki_shut) { return kill_scheduler(FALSE); } if(ki_kill) { return kill_scheduler(TRUE); } /* initialize the scheduler */ scheduler = scheduler_init(sysconfigdir, log_new("stdout", "initializing", getpid())); if(logdir) { scheduler->logdir = logdir; scheduler->logcmdline = TRUE; scheduler->main_log = log_new(scheduler->logdir, NULL, scheduler->s_pid); log_destroy(main_log); main_log = scheduler->main_log; } scheduler->process_name = g_strdup(argv[0]); scheduler->s_daemon = s_daemon; scheduler_foss_config(scheduler); if(s_daemon && scheduler_daemonize(scheduler) == -1) { return -1; } scheduler_agent_config(scheduler); database_init(scheduler); email_init(scheduler); NOTIFY("*****************************************************************"); NOTIFY("*** FOSSology scheduler started ***"); NOTIFY("*** pid: %-33d ***", getpid()); NOTIFY("*** verbose: %-33d ***", verbose); NOTIFY("*** config: %-33s ***", sysconfigdir); NOTIFY("*****************************************************************"); interface_init(scheduler); fo_RepOpenFull(scheduler->sysconfig); signal(SIGCHLD, scheduler_sig_handle); signal(SIGTERM, scheduler_sig_handle); signal(SIGQUIT, scheduler_sig_handle); signal(SIGHUP, scheduler_sig_handle); /* ***************************************************** */ /* *** we have finished initialization without error *** */ /* ***************************************************** */ if(db_reset) database_reset_queue(scheduler); if(test_die) closing = 1; event_loop_enter(scheduler, scheduler_update, scheduler_signal); NOTIFY("*****************************************************************"); NOTIFY("*** FOSSology scheduler closed ***"); NOTIFY("*** pid: %-34d ***", scheduler->s_pid); NOTIFY("*****************************************************************\n"); interface_destroy(scheduler); scheduler_destroy(scheduler); return 0; }
vsf_err_t virtual_interface_init(const char *vifs, const char mode) { struct interfaces_info_t *interface_tmp; interface_tmp = find_interface_by_name(vifs); if ((vifs != NULL) && (NULL == interface_tmp)) { return VSFERR_FAIL; } if (NULL == interface_tmp) { if (cur_real_interface != NULL) { cur_interface = cur_real_interface; } } else if (interface_tmp->is_virtual) { uint32_t i = 0; if (interface_tmp->mode != NULL) { while (interface_tmp->mode[i].name != 0) { if (mode == interface_tmp->mode[i].name) { break; } i++; } if (!interface_tmp->mode[i].name) { return VSFERR_FAIL; } } if (NULL == cur_interface) { if (interface_init(NULL)) { return VSFERR_FAIL; } } if (cur_interface->is_virtual) { cur_interface = interface_tmp; } else { cur_real_interface = cur_interface; cur_interface = interface_tmp; } cur_interface->core.init(&i); } else { return VSFERR_FAIL; } return VSFERR_NONE; }
int main (int argc, char *argv[]) { //srandom(time(NULL)); /* default arguments */ struct passwd *pw = getpwuid(getuid()); struct stat sts; const char *homedir = pw->pw_dir; char brd_buf[1024]; #ifndef CONFDIR /* if not working with autotools */ #define CONFDIR "/etc" #endif snprintf(brd_buf, 1024, "%s/.robotxq/xq.brd", homedir); if (stat(brd_buf, &sts) == -1 && errno == ENOENT) strncpy(brd_buf, CONFDIR "/xq.brd", 1024); char *engine = "eleeye_xb"; char *reader = "io_board"; char *handctl = "io_hand"; char *brd_file = brd_buf; /* argument parsing */ int opt; while ((opt = getopt(argc, argv, "he:r:w:b:")) != -1) { switch (opt) { case 'e': engine = optarg; break; case 'r': reader = optarg; break; case 'w': handctl = optarg; break; case 'b': brd_file = optarg; break; case 'h': print_help(argv[0]); exit(EXIT_SUCCESS); default: print_help(argv[0]); exit(EXIT_FAILURE); } } if (optind + 1 >= argc) { fprintf(stderr, "expect device node after options\n"); print_help(argv[0]); exit(EXIT_FAILURE); } char *board_dev = argv[optind]; char *hand_dev = argv[optind+1]; /* init board reader */ char reader_buf[1024]; snprintf(reader_buf, 1024, "%s %s", reader, board_dev); if (init_read_board(reader_buf, brd_file) != 0) exit(EXIT_FAILURE); /* init hand controler */ char handctl_buf[1024]; snprintf(handctl_buf, 1024, "%s %s", handctl, hand_dev); FILE *handctl_fp[2]; if ((handctl_pid = cpopen(handctl_fp, handctl_buf)) < 0) exit(EXIT_FAILURE); /* init interface */ interface_init(); /* set stdin to non-canonical mode */ if (tcset_noncanonical(STDIN_FILENO) != 0) exit(EXIT_FAILURE); char fen_setup[128]; /* main loop */ while(1) { switch (one_chess_game(fen_setup, engine, handctl_fp)) { case 1: interface_prompt(ILL_MOVE); puts("dump board:"); print_board(read_phyboard(0)); break; case 2: interface_prompt(OPP_RESIGN); break; case 3: interface_prompt(WIN); break; case 4: interface_prompt(LOSE); break; case 5: interface_prompt(DRAW); break; case 6: interface_prompt(ILL_START); puts("dump board:"); print_board(read_phyboard(0)); break; } } }
int main() { int i; interface_init(); start_timing(); print_value("Timestamp bias", end_timing()); for (i = 0; i < TESTCASES1_COUNT; i++) { fix16_t input = testcases1[i].a; fix16_t result; fix16_t expected = testcases1[i].sqrt; MEASURE(sqrt_cycles, result = fix16_sqrt(input)); if (input > 0 && delta(result, expected) > max_delta) { print_value("Failed SQRT, i", i); print_value("Failed SQRT, input", input); print_value("Failed SQRT, output", result); print_value("Failed SQRT, expected", expected); } expected = testcases1[i].exp; MEASURE(exp_cycles, result = fix16_exp(input)); if (delta(result, expected) > 400) { print_value("Failed EXP, i", i); print_value("Failed EXP, input", input); print_value("Failed EXP, output", result); print_value("Failed EXP, expected", expected); } } PRINT(sqrt_cycles, "fix16_sqrt"); PRINT(exp_cycles, "fix16_exp"); for (i = 0; i < TESTCASES2_COUNT; i++) { fix16_t a = testcases2[i].a; fix16_t b = testcases2[i].b; volatile fix16_t result; fix16_t expected = testcases2[i].add; MEASURE(add_cycles, result = fix16_add(a, b)); if (delta(result, expected) > max_delta) { print_value("Failed ADD, i", i); print_value("Failed ADD, a", a); print_value("Failed ADD, b", b); print_value("Failed ADD, output", result); print_value("Failed ADD, expected", expected); } expected = testcases2[i].sub; MEASURE(sub_cycles, result = fix16_sub(a, b)); if (delta(result, expected) > max_delta) { print_value("Failed SUB, i", i); print_value("Failed SUB, a", a); print_value("Failed SUB, b", b); print_value("Failed SUB, output", result); print_value("Failed SUB, expected", expected); } expected = testcases2[i].mul; MEASURE(mul_cycles, result = fix16_mul(a, b)); if (delta(result, expected) > max_delta) { print_value("Failed MUL, i", i); print_value("Failed MUL, a", a); print_value("Failed MUL, b", b); print_value("Failed MUL, output", result); print_value("Failed MUL, expected", expected); } if (b != 0) { expected = testcases2[i].div; MEASURE(div_cycles, result = fix16_div(a, b)); if (delta(result, expected) > max_delta) { print_value("Failed DIV, i", i); print_value("Failed DIV, a", a); print_value("Failed DIV, b", b); print_value("Failed DIV, output", result); print_value("Failed DIV, expected", expected); } } } PRINT(add_cycles, "fix16_add"); PRINT(sub_cycles, "fix16_sub"); PRINT(mul_cycles, "fix16_mul"); PRINT(div_cycles, "fix16_div"); /* Compare with floating point performance */ #ifndef NO_FLOAT for (i = 0; i < TESTCASES1_COUNT; i++) { float input = fix16_to_float(testcases1[i].a); volatile float result; MEASURE(float_sqrtf_cycles, result = sqrtf(input)); } PRINT(float_sqrtf_cycles, "float sqrtf"); for (i = 0; i < TESTCASES2_COUNT; i++) { float a = fix16_to_float(testcases2[i].a); float b = fix16_to_float(testcases2[i].b); volatile float result; MEASURE(float_add_cycles, result = a + b); MEASURE(float_sub_cycles, result = a - b); MEASURE(float_mul_cycles, result = a * b); if (b != 0) { MEASURE(float_div_cycles, result = a / b); } } PRINT(float_add_cycles, "float add"); PRINT(float_sub_cycles, "float sub"); PRINT(float_mul_cycles, "float mul"); PRINT(float_div_cycles, "float div"); #endif return 0; }
/* snappy's main function */ int main (int argc, char *argv[]) { UserInterface *ui = NULL; GstEngine *engine = NULL; ClutterActor *video_texture; ClutterGstVideoSink *sink; gboolean ok, blind = FALSE, fullscreen = FALSE, hide = FALSE, loop = FALSE; gboolean secret = FALSE, tags = FALSE; gint ret = 0; gchar *uri = NULL; gchar *suburi = NULL; GList *uri_list; GOptionContext *context; gchar *data_dir; ClutterInitError ci_err; #ifdef ENABLE_DBUS SnappyMP *mp_obj = NULL; #endif context = g_option_context_new ("<media file> - Play movie files"); clutter_set_windowing_backend (CLUTTER_WINDOWING_X11); ci_err = gtk_clutter_init (&argc, &argv); if (ci_err != CLUTTER_INIT_SUCCESS) goto quit; /* Try to find the path for our resources in case snappy was relocated */ data_dir = g_strdup (SNAPPY_DATA_DIR); if (!g_file_test (data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { gchar *root_dir; #ifdef G_OS_WIN32 root_dir = g_win32_get_package_installation_directory_of_module (NULL); #elif !defined(G_OS_UNIX) gchar *exec_path; gchar *bin_dir; exec_path = g_file_read_link ("/proc/self/exe", NULL); bin_dir = g_path_get_dirname (exec_path); root_dir = g_build_filename (bin_dir, "..", NULL); g_free (exec_path); g_free (bin_dir); #else root_dir = NULL; #endif if (root_dir != NULL) { data_dir = g_build_filename (root_dir, "share", "snappy", NULL); g_free (root_dir); } } /* Process command arguments */ uri_list = process_args (argc, argv, &blind, &fullscreen, &hide, &loop, &secret, &suburi, &tags, context); gst_init (&argc, &argv); clutter_gst_init (NULL, NULL); /* User Interface */ ui = g_new (UserInterface, 1); ui->uri_list = uri_list; ui->blind = blind; ui->fullscreen = fullscreen; ui->hide = hide; ui->tags = tags; ui->data_dir = data_dir; interface_init (ui); /* Gstreamer engine */ engine = g_new (GstEngine, 1); sink = clutter_gst_video_sink_new (); if (sink == NULL) { g_print ("ERROR: Failed to create clutter-gst sink element\n"); return FALSE; } video_texture = g_object_new (CLUTTER_TYPE_ACTOR, "content", g_object_new (CLUTTER_GST_TYPE_CONTENT, "sink", sink, NULL), "name", "texture", NULL); ok = engine_init (engine, sink); if (!ok) goto quit; engine->secret = secret; engine->loop = loop; ui->engine = engine; ui->texture = video_texture; gst_bus_add_watch (engine->bus, bus_call, ui); gst_object_unref (engine->bus); /* Get uri to load */ if (uri_list) { uri = g_list_first (uri_list)->data; /* based on video filename we can guess subtitle file (.srt files only) */ if (NULL == suburi) { gchar suburi_path_guessing[1024]; //buffer gchar *uri_no_extension = strip_filename_extension (uri); sprintf (suburi_path_guessing, "%s.srt", uri_no_extension); /* subtitle file exists, defaults for it */ if (g_file_test (g_filename_from_uri (suburi_path_guessing, NULL, NULL), G_FILE_TEST_EXISTS)) suburi = suburi_path_guessing; } } /* Load engine and start interface */ engine_load_uri (engine, uri); interface_start (ui, uri); /* Load subtitle file if available */ if (suburi != NULL) { suburi = clean_uri (suburi); set_subtitle_uri (engine, suburi); } /* Start playing if we have a URI to play */ if (uri) { change_state (engine, "Paused"); change_state (engine, "Playing"); } #ifdef ENABLE_DBUS /* Start MPRIS Dbus object */ mp_obj = g_new (SnappyMP, 1); mp_obj->engine = engine; mp_obj->ui = ui; load_dlna (mp_obj); #endif /* Main loop */ gtk_main (); /* Close snappy */ close_down (ui, engine); #ifdef ENABLE_DBUS close_dlna (mp_obj); #endif quit: g_list_free (uri_list); g_option_context_free (context); return ret; }
int main(int argc, char *argv[]) { int r; char *data_file = NULL; char *save_file = NULL; int map_generator = 0; log_set_file(stdout); init_config_data(); //- read config data int screen_width = get_config_int(CONFIG_SCREEN_WIDTH, DEFAULT_SCREEN_WIDTH); int screen_height = get_config_int(CONFIG_SCREEN_HEIGHT, DEFAULT_SCREEN_HEIGHT); int fullscreen = get_config_bool(CONFIG_FULLSCREEN, 0); int log_level = get_config_int(CONFIG_LOGGLEVEL, DEFAULT_LOG_LEVEL); enum_lng_t language = str_to_lagEnum((char *)get_config_string(CONFIG_LANGUAGE, "EN")); int play_midi = get_config_bool(CONFIG_MUSIC, 1); int play_SFX = get_config_bool(CONFIG_SFX, 1); int volume = get_config_int(CONFIG_VOLUME, 75); //- read command line parameters int opt; while (1) { opt = getopt(argc, argv, "d:fg:hl:r:t:s:"); if (opt < 0) break; switch (opt) { case 'd': { int d = atoi(optarg); if (d >= 0 && d < LOG_LEVEL_MAX) { log_level = d; } } break; case 'f': fullscreen = 1; break; case 'g': data_file = (char *)malloc(strlen(optarg)+1); if (data_file == NULL) exit(EXIT_FAILURE); strcpy(data_file, optarg); break; case 'h': fprintf(stdout, HELP, argv[0]); exit(EXIT_SUCCESS); break; case 'l': save_file = (char *)malloc(strlen(optarg)+1); if (save_file == NULL) exit(EXIT_FAILURE); strcpy(save_file, optarg); break; case 'r': { char *hstr = strchr(optarg, 'x'); if (hstr == NULL) { fprintf(stderr, USAGE, argv[0]); exit(EXIT_FAILURE); } screen_width = atoi(optarg); screen_height = atoi(hstr+1); } break; case 't': map_generator = atoi(optarg); break; case 's': { char * tmp_language_str = (char *) malloc(strlen(optarg) + 1); if (tmp_language_str != NULL) { strcpy(tmp_language_str, optarg); language = str_to_lagEnum(tmp_language_str); } } break; default: fprintf(stderr, USAGE, argv[0]); exit(EXIT_FAILURE); break; } } /* Set up logging */ log_set_level((log_level_t)log_level); LOGI("main", "freeserf %s", FREESERF_VERSION); /* load language */ init_language_data(language); r = load_data_file(data_file); if (r < 0) { LOGE("main", "Could not load game data."); exit(EXIT_FAILURE); } free(data_file); gfx_data_fixup(); LOGI("main", "SDL init..."); r = sdl_init(); if (r < 0) exit(EXIT_FAILURE); /* TODO move to right place */ midi_play_track(MIDI_TRACK_0); audio_set_volume(volume); midi_enable(play_midi); sfx_enable(play_SFX); /*gfx_set_palette(DATA_PALETTE_INTRO);*/ gfx_set_palette(DATA_PALETTE_GAME); LOGI("main", "SDL resolution %ix%i...", screen_width, screen_height); r = sdl_set_resolution(screen_width, screen_height, fullscreen); if (r < 0) exit(EXIT_FAILURE); game.map_generator = map_generator; /* Initialize global lookup tables */ init_spiral_pattern(); game_init(); /* Initialize Missions*/ init_mission("missions.xml"); /* Initialize interface */ interface_init(&interface); gui_object_set_size((gui_object_t *)&interface, screen_width, screen_height); gui_object_set_displayed((gui_object_t *)&interface, 1); /* Either load a save game if specified or start a new game. */ if (save_file != NULL) { int r = game_load_save_game(save_file); if (r < 0) exit(EXIT_FAILURE); free(save_file); interface_set_player(&interface, 0); } else { int r = game_load_random_map(3, &interface.random); if (r < 0) exit(EXIT_FAILURE); /* Add default player */ r = game_add_player(12, 64, 40, 40, 40); if (r < 0) exit(EXIT_FAILURE); interface_set_player(&interface, r); } viewport_map_reinit(); if (save_file != NULL) { interface_close_game_init(&interface); } /* Start game loop */ game_loop(); LOGI("main", "Cleaning up..."); /* Clean up */ map_deinit(); viewport_map_deinit(); audio_cleanup(); sdl_deinit(); gfx_unload(); language_cleanup(); mission_cleanup(); config_cleanup(); return EXIT_SUCCESS; }
static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; struct mdp5_kms *mdp5_kms; struct mdp5_cfg *config; u32 major, minor; int ret; mdp5_kms = devm_kzalloc(&pdev->dev, sizeof(*mdp5_kms), GFP_KERNEL); if (!mdp5_kms) { ret = -ENOMEM; goto fail; } platform_set_drvdata(pdev, mdp5_kms); spin_lock_init(&mdp5_kms->resource_lock); mdp5_kms->dev = dev; mdp5_kms->pdev = pdev; drm_modeset_lock_init(&mdp5_kms->state_lock); mdp5_kms->state = kzalloc(sizeof(*mdp5_kms->state), GFP_KERNEL); if (!mdp5_kms->state) { ret = -ENOMEM; goto fail; } mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys", "MDP5"); if (IS_ERR(mdp5_kms->mmio)) { ret = PTR_ERR(mdp5_kms->mmio); goto fail; } /* mandatory clocks: */ ret = get_clk(pdev, &mdp5_kms->axi_clk, "bus", true); if (ret) goto fail; ret = get_clk(pdev, &mdp5_kms->ahb_clk, "iface", true); if (ret) goto fail; ret = get_clk(pdev, &mdp5_kms->core_clk, "core", true); if (ret) goto fail; ret = get_clk(pdev, &mdp5_kms->vsync_clk, "vsync", true); if (ret) goto fail; /* optional clocks: */ get_clk(pdev, &mdp5_kms->lut_clk, "lut", false); /* we need to set a default rate before enabling. Set a safe * rate first, then figure out hw revision, and then set a * more optimal rate: */ clk_set_rate(mdp5_kms->core_clk, 200000000); pm_runtime_enable(&pdev->dev); mdp5_kms->rpm_enabled = true; read_mdp_hw_revision(mdp5_kms, &major, &minor); mdp5_kms->cfg = mdp5_cfg_init(mdp5_kms, major, minor); if (IS_ERR(mdp5_kms->cfg)) { ret = PTR_ERR(mdp5_kms->cfg); mdp5_kms->cfg = NULL; goto fail; } config = mdp5_cfg_get_config(mdp5_kms->cfg); mdp5_kms->caps = config->hw->mdp.caps; /* TODO: compute core clock rate at runtime */ clk_set_rate(mdp5_kms->core_clk, config->hw->max_clk); /* * Some chipsets have a Shared Memory Pool (SMP), while others * have dedicated latency buffering per source pipe instead; * this section initializes the SMP: */ if (mdp5_kms->caps & MDP_CAP_SMP) { mdp5_kms->smp = mdp5_smp_init(mdp5_kms, &config->hw->smp); if (IS_ERR(mdp5_kms->smp)) { ret = PTR_ERR(mdp5_kms->smp); mdp5_kms->smp = NULL; goto fail; } } mdp5_kms->ctlm = mdp5_ctlm_init(dev, mdp5_kms->mmio, mdp5_kms->cfg); if (IS_ERR(mdp5_kms->ctlm)) { ret = PTR_ERR(mdp5_kms->ctlm); mdp5_kms->ctlm = NULL; goto fail; } ret = hwpipe_init(mdp5_kms); if (ret) goto fail; ret = hwmixer_init(mdp5_kms); if (ret) goto fail; ret = interface_init(mdp5_kms); if (ret) goto fail; /* set uninit-ed kms */ priv->kms = &mdp5_kms->base.base; return 0; fail: mdp5_destroy(pdev); return ret; }
int user_start(int argc, char *argv[]) { /* configure the first 8 PWM outputs (i.e. all of them) */ up_pwm_servo_init(0xff); #if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE) /* run C++ ctors before we go any further */ up_cxxinitialize(); # if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE) # error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE. # endif #else # error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined. #endif /* reset all to zero */ memset(&system_state, 0, sizeof(system_state)); /* configure the high-resolution time/callout interface */ hrt_init(); /* calculate our fw CRC so FMU can decide if we need to update */ calculate_fw_crc(); /* * Poll at 1ms intervals for received bytes that have not triggered * a DMA event. */ #ifdef CONFIG_ARCH_DMA hrt_call_every(&serial_dma_call, 1000, 1000, (hrt_callout)stm32_serial_dma_poll, NULL); #endif /* print some startup info */ syslog(LOG_INFO, "\nPX4IO: starting\n"); /* default all the LEDs to off while we start */ LED_AMBER(false); LED_BLUE(false); LED_SAFETY(false); #ifdef GPIO_LED4 LED_RING(false); #endif /* turn on servo power (if supported) */ #ifdef POWER_SERVO POWER_SERVO(true); #endif /* turn off S.Bus out (if supported) */ #ifdef ENABLE_SBUS_OUT ENABLE_SBUS_OUT(false); #endif /* start the safety switch handler */ safety_init(); /* initialise the control inputs */ controls_init(); /* set up the ADC */ adc_init(); /* start the FMU interface */ interface_init(); /* add a performance counter for mixing */ perf_counter_t mixer_perf = perf_alloc(PC_ELAPSED, "mix"); /* add a performance counter for controls */ perf_counter_t controls_perf = perf_alloc(PC_ELAPSED, "controls"); /* and one for measuring the loop rate */ perf_counter_t loop_perf = perf_alloc(PC_INTERVAL, "loop"); struct mallinfo minfo = mallinfo(); r_page_status[PX4IO_P_STATUS_FREEMEM] = minfo.mxordblk; syslog(LOG_INFO, "MEM: free %u, largest %u\n", minfo.mxordblk, minfo.fordblks); /* initialize PWM limit lib */ pwm_limit_init(&pwm_limit); /* * P O L I C E L I G H T S * * Not enough memory, lock down. * * We might need to allocate mixers later, and this will * ensure that a developer doing a change will notice * that he just burned the remaining RAM with static * allocations. We don't want him to be able to * get past that point. This needs to be clearly * documented in the dev guide. * */ if (minfo.mxordblk < 600) { syslog(LOG_ERR, "ERR: not enough MEM"); bool phase = false; while (true) { if (phase) { LED_AMBER(true); LED_BLUE(false); } else { LED_AMBER(false); LED_BLUE(true); } up_udelay(250000); phase = !phase; } } /* Start the failsafe led init */ failsafe_led_init(); /* * Run everything in a tight loop. */ uint64_t last_debug_time = 0; uint64_t last_heartbeat_time = 0; uint64_t last_loop_time = 0; for (;;) { dt = (hrt_absolute_time() - last_loop_time) / 1000000.0f; last_loop_time = hrt_absolute_time(); if (dt < 0.0001f) { dt = 0.0001f; } else if (dt > 0.02f) { dt = 0.02f; } /* track the rate at which the loop is running */ perf_count(loop_perf); /* kick the mixer */ perf_begin(mixer_perf); mixer_tick(); perf_end(mixer_perf); /* kick the control inputs */ perf_begin(controls_perf); controls_tick(); perf_end(controls_perf); /* some boards such as Pixhawk 2.1 made the unfortunate choice to combine the blue led channel with the IMU heater. We need a software hack to fix the hardware hack by allowing to disable the LED / heater. */ if (r_page_setup[PX4IO_P_SETUP_THERMAL] == PX4IO_THERMAL_IGNORE) { /* blink blue LED at 4Hz in normal operation. When in override blink 4x faster so the user can clearly see that override is happening. This helps when pre-flight testing the override system */ uint32_t heartbeat_period_us = 250 * 1000UL; if (r_status_flags & PX4IO_P_STATUS_FLAGS_OVERRIDE) { heartbeat_period_us /= 4; } if ((hrt_absolute_time() - last_heartbeat_time) > heartbeat_period_us) { last_heartbeat_time = hrt_absolute_time(); heartbeat_blink(); } } else if (r_page_setup[PX4IO_P_SETUP_THERMAL] < PX4IO_THERMAL_FULL) { /* switch resistive heater off */ LED_BLUE(false); } else { /* switch resistive heater hard on */ LED_BLUE(true); } update_mem_usage(); ring_blink(); check_reboot(); /* check for debug activity (default: none) */ show_debug_messages(); /* post debug state at ~1Hz - this is via an auxiliary serial port * DEFAULTS TO OFF! */ if (hrt_absolute_time() - last_debug_time > (1000 * 1000)) { isr_debug(1, "d:%u s=0x%x a=0x%x f=0x%x m=%u", (unsigned)r_page_setup[PX4IO_P_SETUP_SET_DEBUG], (unsigned)r_status_flags, (unsigned)r_setup_arming, (unsigned)r_setup_features, (unsigned)mallinfo().mxordblk); last_debug_time = hrt_absolute_time(); } } }
int user_start(int argc, char *argv[]) { /* run C++ ctors before we go any further */ up_cxxinitialize(); /* reset all to zero */ memset(&system_state, 0, sizeof(system_state)); /* configure the high-resolution time/callout interface */ hrt_init(); /* * Poll at 1ms intervals for received bytes that have not triggered * a DMA event. */ #ifdef CONFIG_ARCH_DMA hrt_call_every(&serial_dma_call, 1000, 1000, (hrt_callout)stm32_serial_dma_poll, NULL); #endif /* print some startup info */ lowsyslog("\nPX4IO: starting\n"); /* default all the LEDs to off while we start */ LED_AMBER(false); LED_BLUE(false); LED_SAFETY(false); /* turn on servo power (if supported) */ POWER_SERVO(true); /* start the safety switch handler */ safety_init(); /* configure the first 8 PWM outputs (i.e. all of them) */ up_pwm_servo_init(0xff); /* initialise the control inputs */ controls_init(); /* start the FMU interface */ interface_init(); /* add a performance counter for the interface */ perf_counter_t interface_perf = perf_alloc(PC_ELAPSED, "interface"); /* add a performance counter for mixing */ perf_counter_t mixer_perf = perf_alloc(PC_ELAPSED, "mix"); /* add a performance counter for controls */ perf_counter_t controls_perf = perf_alloc(PC_ELAPSED, "controls"); /* and one for measuring the loop rate */ perf_counter_t loop_perf = perf_alloc(PC_INTERVAL, "loop"); struct mallinfo minfo = mallinfo(); lowsyslog("MEM: free %u, largest %u\n", minfo.mxordblk, minfo.fordblks); #if 0 /* not enough memory, lock down */ if (minfo.mxordblk < 500) { lowsyslog("ERR: not enough MEM"); bool phase = false; if (phase) { LED_AMBER(true); LED_BLUE(false); } else { LED_AMBER(false); LED_BLUE(true); } phase = !phase; usleep(300000); } #endif /* * Run everything in a tight loop. */ uint64_t last_debug_time = 0; for (;;) { /* track the rate at which the loop is running */ perf_count(loop_perf); /* kick the interface */ perf_begin(interface_perf); interface_tick(); perf_end(interface_perf); /* kick the mixer */ perf_begin(mixer_perf); mixer_tick(); perf_end(mixer_perf); /* kick the control inputs */ perf_begin(controls_perf); controls_tick(); perf_end(controls_perf); /* check for debug activity */ show_debug_messages(); /* post debug state at ~1Hz */ if (hrt_absolute_time() - last_debug_time > (1000 * 1000)) { struct mallinfo minfo = mallinfo(); isr_debug(1, "d:%u s=0x%x a=0x%x f=0x%x m=%u", (unsigned)r_page_setup[PX4IO_P_SETUP_SET_DEBUG], (unsigned)r_status_flags, (unsigned)r_setup_arming, (unsigned)r_setup_features, (unsigned)minfo.mxordblk); last_debug_time = hrt_absolute_time(); } } }
int user_start(int argc, char *argv[]) { /* run C++ ctors before we go any further */ up_cxxinitialize(); /* reset all to zero */ memset(&system_state, 0, sizeof(system_state)); /* configure the high-resolution time/callout interface */ hrt_init(); /* calculate our fw CRC so FMU can decide if we need to update */ calculate_fw_crc(); /* * Poll at 1ms intervals for received bytes that have not triggered * a DMA event. */ #ifdef CONFIG_ARCH_DMA hrt_call_every(&serial_dma_call, 1000, 1000, (hrt_callout)stm32_serial_dma_poll, NULL); #endif /* print some startup info */ lowsyslog("\nPX4IO: starting\n"); /* default all the LEDs to off while we start */ LED_AMBER(false); LED_BLUE(false); LED_SAFETY(false); #ifdef GPIO_LED4 LED_RING(false); #endif /* turn on servo power (if supported) */ #ifdef POWER_SERVO POWER_SERVO(true); #endif /* turn off S.Bus out (if supported) */ #ifdef ENABLE_SBUS_OUT ENABLE_SBUS_OUT(false); #endif /* start the safety switch handler */ safety_init(); /* configure the first 8 PWM outputs (i.e. all of them) */ up_pwm_servo_init(0xff); /* initialise the control inputs */ controls_init(); /* set up the ADC */ adc_init(); /* start the FMU interface */ interface_init(); /* add a performance counter for mixing */ perf_counter_t mixer_perf = perf_alloc(PC_ELAPSED, "mix"); /* add a performance counter for controls */ perf_counter_t controls_perf = perf_alloc(PC_ELAPSED, "controls"); /* and one for measuring the loop rate */ perf_counter_t loop_perf = perf_alloc(PC_INTERVAL, "loop"); struct mallinfo minfo = mallinfo(); lowsyslog("MEM: free %u, largest %u\n", minfo.mxordblk, minfo.fordblks); /* initialize PWM limit lib */ pwm_limit_init(&pwm_limit); /* * P O L I C E L I G H T S * * Not enough memory, lock down. * * We might need to allocate mixers later, and this will * ensure that a developer doing a change will notice * that he just burned the remaining RAM with static * allocations. We don't want him to be able to * get past that point. This needs to be clearly * documented in the dev guide. * */ if (minfo.mxordblk < 600) { lowsyslog("ERR: not enough MEM"); bool phase = false; while (true) { if (phase) { LED_AMBER(true); LED_BLUE(false); } else { LED_AMBER(false); LED_BLUE(true); } up_udelay(250000); phase = !phase; } } /* Start the failsafe led init */ failsafe_led_init(); /* * Run everything in a tight loop. */ uint64_t last_debug_time = 0; uint64_t last_heartbeat_time = 0; for (;;) { /* track the rate at which the loop is running */ perf_count(loop_perf); /* kick the mixer */ perf_begin(mixer_perf); mixer_tick(); perf_end(mixer_perf); /* kick the control inputs */ perf_begin(controls_perf); controls_tick(); perf_end(controls_perf); if ((hrt_absolute_time() - last_heartbeat_time) > 250 * 1000) { last_heartbeat_time = hrt_absolute_time(); heartbeat_blink(); } ring_blink(); check_reboot(); /* check for debug activity (default: none) */ show_debug_messages(); /* post debug state at ~1Hz - this is via an auxiliary serial port * DEFAULTS TO OFF! */ if (hrt_absolute_time() - last_debug_time > (1000 * 1000)) { isr_debug(1, "d:%u s=0x%x a=0x%x f=0x%x m=%u", (unsigned)r_page_setup[PX4IO_P_SETUP_SET_DEBUG], (unsigned)r_status_flags, (unsigned)r_setup_arming, (unsigned)r_setup_features, (unsigned)mallinfo().mxordblk); last_debug_time = hrt_absolute_time(); } } }
/* snappy's main function */ int main (int argc, char *argv[]) { UserInterface *ui = NULL; GstEngine *engine = NULL; ClutterActor *video_texture; GstElement *sink; gboolean ok, blind = FALSE, fullscreen = FALSE, hide = FALSE, loop = FALSE; gboolean secret = FALSE, tags = FALSE; gint ret = 0; guint c, index, pos = 0; gchar *uri; gchar *suburi = NULL; gchar *version_str; GList *uri_list; GOptionContext *context; gchar *data_dir; #ifdef ENABLE_DBUS SnappyMP *mp_obj = NULL; #endif /* Try to find the path for our resources in case snappy was relocated */ data_dir = g_strdup(SNAPPY_DATA_DIR); if (!g_file_test(data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { gchar *root_dir; #ifdef G_OS_WIN32 root_dir = g_win32_get_package_installation_directory_of_module(NULL); #elif !defined(G_OS_UNIX) gchar *exec_path; gchar *bin_dir; exec_path = g_file_read_link("/proc/self/exe", NULL); bin_dir = g_path_get_dirname(exec_path); root_dir = g_build_filename(bin_dir, "..", NULL); g_free(exec_path); g_free(bin_dir); #else root_dir = NULL; #endif if (root_dir != NULL) { data_dir = g_build_filename(root_dir, "share", "snappy", NULL); g_free(root_dir); } } if (!g_thread_supported ()) g_thread_init (NULL); context = g_option_context_new ("<media file> - Play movie files"); /* Process command arguments */ uri_list = process_args (argc, argv, &blind, &fullscreen, &hide, &loop, &secret, &suburi, &tags, context); if (uri_list == NULL) goto quit; /* User Interface */ ui = g_new (UserInterface, 1); ui->uri_list = uri_list; ui->blind = blind; ui->fullscreen = fullscreen; ui->hide = hide; ui->tags = tags; ui->data_dir = data_dir; interface_init (ui); video_texture = clutter_texture_new (); clutter_gst_init (&argc, &argv); version_str = gst_version_string (); GST_DEBUG_CATEGORY_INIT (_snappy_gst_debug, "snappy", 0, "snappy media player"); GST_DEBUG ("Initialised %s", version_str); /* Gstreamer engine */ engine = g_new (GstEngine, 1); sink = gst_element_factory_make ("autocluttersink", "cluttersink"); if (sink == NULL) { GST_DEBUG ("autocluttersink not found, falling back to cluttersink\n"); sink = gst_element_factory_make ("cluttersink", "cluttersink"); } g_object_set (G_OBJECT (sink), "texture", CLUTTER_TEXTURE (video_texture), NULL); ok = engine_init (engine, sink); if (!ok) goto quit; engine->secret = secret; engine->loop = loop; ui->engine = engine; ui->texture = video_texture; gst_bus_add_watch (engine->bus, bus_call, ui); gst_object_unref (engine->bus); /* Get uri to load */ uri = g_list_first (uri_list)->data; /* Load engine and start interface */ engine_load_uri (engine, uri); interface_start (ui, uri); /* Load subtitle file if available */ if (suburi != NULL) { suburi = clean_uri (suburi); set_subtitle_uri (engine, suburi); } /* Start playing */ change_state (engine, "Paused"); change_state (engine, "Playing"); #ifdef ENABLE_DBUS /* Start MPRIS Dbus object */ mp_obj = g_new (SnappyMP, 1); mp_obj->engine = engine; mp_obj->ui = ui; load_dlna (mp_obj); #endif /* Main loop */ clutter_main (); /* Close snappy */ close_down (ui, engine); #ifdef ENABLE_DBUS close_dlna (mp_obj); #endif quit: g_list_free (uri_list); g_option_context_free (context); return ret; }
int main(int argc, char *argv[]) { if(interface_init() != 0 || sound_init() != 0) return -1; if(argc < 2) { printf("No input song directory\n"); return -1; } if(FOF_load(argv[1]) != 0) { printf("Unable to open FOF song from folder.\n"); return -1; } score_init(); SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_JoystickOpen(0); controller_xplorer(&joystick); //Start game sound_play(); u32 start_ticks = SDL_GetTicks(); bool quit = false; while(!quit) { static SDL_Event event; while(SDL_PollEvent(&event)) { controller_event_t controller_event; switch(event.type) { case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_q) quit=true; break; case SDL_QUIT: quit=true; break; case SDL_JOYBUTTONDOWN: send_controller_event(joystick.convert_button(event.jbutton.button, BUTTON_DOWN)); break; case SDL_JOYBUTTONUP: send_controller_event(joystick.convert_button(event.jbutton.button, BUTTON_UP)); break; case SDL_JOYHATMOTION: send_controller_event(joystick.convert_hat(event.jhat.hat, event.jhat.value)); break; default: break; } } static unsigned int delta_ticks, ticks, cur_ticks; ticks = SDL_GetTicks(); cur_ticks = SDL_GetTicks(); delta_ticks = cur_ticks - ticks; ticks = cur_ticks; u32 game_ticks = ticks - start_ticks; interface_time(game_ticks); score_time(game_ticks); if(game_ticks > scene.length) break; SDL_Delay(5); interface_draw(); static unsigned int frames = 0; static int t0 = 0; ++frames; int t = SDL_GetTicks(); if (t - t0 >= 1000) { //printf("%d frames in %d milliseconds = %g frames/second\n", Frames, (t - t0), Frames * 1000.0f / (t-t0)); //char foo[256]; fps = frames * 1000.0f / (t-t0); //sprintf(foo, "%s, %g fps", argv[1], frames * 1000.0f / (t-t0)); //SDL_WM_SetCaption(foo, NULL); t0 = t; frames = 0; } } FOF_close(); SDL_JoystickClose(0); interface_quit(); sound_quit(); return 0; }
int main(int argc, const char **argv) { char hostname[32]; gethostname(hostname,32); //FIXME "lightning" is evaluated to 0, // so when bdbm00 is returned to the cluster, // code needs to be modified if ( strstr(hostname, "bdbm") == NULL && strstr(hostname, "umma") == NULL && strstr(hostname, "lightning") == NULL ) { fprintf(stderr, "ERROR: hostname should be bdbm[idx] or lightning\n"); return 1; } int myid = atoi(hostname+strlen("bdbm")); DmaDebugRequestProxy *hostDmaDebugRequest = new DmaDebugRequestProxy(IfcNames_HostDmaDebugRequest); MMUConfigRequestProxy *dmap = new MMUConfigRequestProxy(IfcNames_HostMMUConfigRequest); DmaManager *dma = new DmaManager(hostDmaDebugRequest, dmap); DmaDebugIndication *hostDmaDebugIndication = new DmaDebugIndication(dma, IfcNames_HostDmaDebugIndication); MMUConfigIndication *hostMMUConfigIndication = new MMUConfigIndication(dma, IfcNames_HostMMUConfigIndication); fprintf(stderr, "Main::allocating memory...\n"); interface_init(); printf( "Done initializing hw interfaces\n" ); fflush(stdout); portalExec_start(); printf( "Done portalExec_start\n" ); fflush(stdout); interface_alloc(dma); printf( "Done allocating DMA buffers\n" ); fflush(stdout); printf( "initializing aurora with node id %d\n", myid ); fflush(stdout); auroraifc_start(myid); ///////////////////////////////////////////////////////// fprintf(stderr, "Main::flush and invalidate complete\n"); if ( sem_init(&wait_sem, 1, 0) ) { //error fprintf(stderr, "sem_init failed!\n" ); } for ( int j = 0; j < WRITE_BUFFER_COUNT; j++ ) { for ( int i = 0; i < (8192+64)/4; i++ ) { writeBuffers[j][i] = j; } } for ( int j = 0; j < READ_BUFFER_COUNT; j++ ) { for ( int i = 0; i < (8192+64)/4; i++ ) { readBuffers[j][i] = 8192/4-i; } } sleep(5); printf ( "sending start msg\n" ); fflush(stdout); generalifc_start(/*datasource*/1); //auroraifc_sendTest(); if ( myid == 1 ) { generalifc_readRemotePage(); } printf( "Entering idle loop\n" ); while(1) sleep(10); exit(0); }
int main(){ // Initialize Peripherals interface_init(); red_led_on(); uart_init(BAUDRATE); animation_manager_init(); sys_timer_start(); audio_init(); sei(); // enable global interrupts // Load Default Animation animation_manager_load_animation(START_ANIMATION); // Enter Setup if Requested _delay_ms(100); if(deb_switch_1()){ setup_wb_run(); } else if(deb_switch_2()){ setup_orientation_run(); } // Load Default Animation animation_manager_load_animation(START_ANIMATION); // Set White Balance _delay_ms(300); display_wb_update(); while(uart_async_run()); // setup white balance // Control Panel is Ready => Signal this by Turning the LED Green red_led_off(); green_led_on(); while(1){ // Sleep Mode if(!switch_on_off()){ // if switched off go_to_sleep(); } // Change animations sw_check(); if(sw_check_pressed(SW_LEFT, 200, true)){ animation_manager_dec_animation(); } else if(sw_check_pressed(SW_RIGHT, 200, true)){ animation_manager_inc_animation(); } else if(sw_check_pressed(SW_RAND, 300, true)){ animation_manager_random_animation(); } // Generate Image animation_manager_run(0); // Check Audio audio_start(); while(audio_run()); audio_process(); // Display Image while(uart_async_run()){ interface_async_run(); } } }
/********************** *** Initialization *** **********************/ int main(int argc, char** argv) { gboolean daemon_mode = TRUE; const char* username; const char* password; GMainLoop* main_loop; /* Parse command line options */ int opt; while ((opt = getopt(argc, argv, "dfhv")) != -1) { switch (opt) { case 'd': debug_mode = TRUE; case 'v': verbose_mode = TRUE; case 'f': daemon_mode = FALSE; break; default: printf("Usage: spopd [options]\n" "Options:\n" " -d debug mode (implies -f and -v)\n" " -f run in foreground (default: fork to background)\n" " -v verbose mode (implies -f)\n" " -h display this message\n"); return 0; } } g_set_application_name("spop " SPOP_VERSION); g_set_prgname("spop"); /* PulseAudio properties */ g_setenv("PULSE_PROP_application.name", "spop " SPOP_VERSION, TRUE); g_setenv("PULSE_PROP_media.role", "music", TRUE); //g_setenv("PULSE_PROP_application.icon_name", "music", TRUE); printf("%s\n", copyright_notice); /* Log handler */ logging_init(); if (!daemon_mode) { /* Stay in foreground: do everything here */ if (debug_mode) g_info("Running in debug mode"); } else { /* Run in daemon mode: fork to background */ printf("Switching to daemon mode...\n"); if (daemon(0, 0) != 0) g_error("Error while forking process: %s", g_strerror(errno)); } /* Init essential stuff */ main_loop = g_main_loop_new(NULL, FALSE); exit_handler_init(); /* Read username and password */ username = config_get_string("spotify_username"); password = config_get_string("spotify_password"); /* Init plugins */ plugins_init(); /* Init login */ session_init(); session_login(username, password); /* Init various subsystems */ interface_init(); /* Event loop */ g_main_loop_run(main_loop); return 0; }
int main() { //###################################################################### //TODO get this from config file eventually //host interface my_host_mac_addr = 0x080027445566ull; my_host_ip_addr = IP4_ADR_P2H(192,168,1,20); my_host_mask = IP4_ADR_P2H(255,255,255,0); //loopback interface loopback_ip_addr = IP4_ADR_P2H(127,0,0,1); loopback_mask = IP4_ADR_P2H(255,0,0,0); //any any_ip_addr = IP4_ADR_P2H(0,0,0,0); //###################################################################### sem_init(&control_serial_sem, 0, 1); //TODO remove after gen_control_serial_num() converted to RNG signal(SIGINT, termination_handler); //register termination handler // Start the driving thread of each module PRINT_DEBUG("Initialize Modules"); switch_init(); //should always be first daemon_init(); //TODO improve how sets mac/ip interface_init(); arp_init(); arp_register_interface(my_host_mac_addr, my_host_ip_addr); ipv4_init(); set_interface(my_host_ip_addr, my_host_mask); set_loopback(loopback_ip_addr, loopback_mask); icmp_init(); tcp_init(); udp_init(); //rtm_init(); //TODO when updated/fully implemented pthread_attr_t fins_pthread_attr; pthread_attr_init(&fins_pthread_attr); PRINT_DEBUG("Run/start Modules"); switch_run(&fins_pthread_attr); daemon_run(&fins_pthread_attr); interface_run(&fins_pthread_attr); arp_run(&fins_pthread_attr); ipv4_run(&fins_pthread_attr); icmp_run(&fins_pthread_attr); tcp_run(&fins_pthread_attr); udp_run(&fins_pthread_attr); //rtm_run(&fins_pthread_attr); //############################# //TODO custom test, remove later /* if (0) { char recv_data[4000]; while (1) { gets(recv_data); PRINT_DEBUG("Sending ARP req"); metadata *params_req = (metadata *) malloc(sizeof(metadata)); if (params_req == NULL) { PRINT_ERROR("metadata alloc fail"); exit(-1); } metadata_create(params_req); uint32_t dst_ip = IP4_ADR_P2H(192, 168, 1, 11); //uint32_t dst_ip = IP4_ADR_P2H(172, 31, 50, 152); uint32_t src_ip = IP4_ADR_P2H(192, 168, 1, 20); //uint32_t src_ip = IP4_ADR_P2H(172, 31, 50, 160); metadata_writeToElement(params_req, "dst_ip", &dst_ip, META_TYPE_INT32); metadata_writeToElement(params_req, "src_ip", &src_ip, META_TYPE_INT32); struct finsFrame *ff_req = (struct finsFrame*) malloc(sizeof(struct finsFrame)); if (ff_req == NULL) { PRINT_ERROR("todo error"); //metadata_destroy(params_req); exit(-1); } ff_req->dataOrCtrl = CONTROL; ff_req->destinationID.id = ARP_ID; ff_req->destinationID.next = NULL; ff_req->metaData = params_req; ff_req->ctrlFrame.senderID = IP_ID; ff_req->ctrlFrame.serial_num = gen_control_serial_num(); ff_req->ctrlFrame.opcode = CTRL_EXEC; ff_req->ctrlFrame.param_id = EXEC_ARP_GET_ADDR; ff_req->ctrlFrame.data_len = 0; ff_req->ctrlFrame.data = NULL; arp_to_switch(ff_req); //doesn't matter which queue } } //############################# */ while (1) ; return (1); }