// 그래픽 출력- void Tetris::Render() { switch( stage ) { case INIT: show_logo(); break; case READY: input_data(); break; case RUNNING: m_block->Draw(); show_gamestat(); if( m_full_line_num != 0 ) full_line_erase(); break; case SUCCESS: m_block->Draw(); show_gamestat(); show_cleargame(); break; case FAILED: m_block->Draw(); show_gamestat(); show_gameover(); break; case RESULT : break; } }
void upgrade_try(void*p) { uchar send[10]={0},recv[10]={0}; int i=0; initialize(); power_screen(true); show_logo(true); if(!prepare_mobile(false)) { post_trace("prepare mobile false"); return; } if(!prepare_transport()) { post_trace("prepare transport false"); return; } while(true){ for(i = 0; i<10; i++){ send[i] = rand(); } if(!communication_test(send,10,recv)){ if(!gprs_connect(SERVER_ADDR, SERVER_PORT)){ prepare_transport(); continue; } } if(memcmp(send, recv, 10)==0 ){ post_trace("send=recv"); }else{ post_trace("send!=recv"); } } }
void cust_show_battery_capacity(UINT32 capacity) { #if MTK_QVGA_LANDSCAPE_SUPPORT // DISP_PROG_BAR_DIRECT direct = DISP_HORIZONTAL_PROG_BAR; #else // DISP_PROG_BAR_DIRECT direct = DISP_VERTICAL_PROG_BAR; #endif DISP_PROG_BAR_DIRECT direct = DISP_VERTICAL_PROG_BAR; UINT32 capacity_grids = 0; if (capacity > 100) capacity = 100; capacity_grids = (capacity * VOLTAGE_SCALE) / 100; show_logo(1); // Fill Occupied Color mt65xx_disp_draw_prog_bar(direct, bar_rect.left + 1, bar_rect.top + 1, bar_rect.right, bar_rect.bottom, bar_occupied_color, bar_bg_color, 0, VOLTAGE_SCALE, capacity_grids); // Fill Empty Color mt65xx_disp_draw_prog_bar(direct, bar_rect.left + 1, bar_rect.top + 1, bar_rect.right, bar_rect.bottom, bar_empty_color, bar_bg_color, capacity_grids, VOLTAGE_SCALE, VOLTAGE_SCALE - capacity_grids); mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); }
int main(void){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY); textColor(WHITE); show_logo(); return 0; }
void Test_I2C_OLED(void) { Clear_Screen(); SH1106_I2COLED_Wcmd(I2COLED_Display_ON);/* set display on */ show_logo(0); while(1); }
static void init_tagcache(void) { bool clear = false; #if CONFIG_CODEC == SWCODEC long talked_tick = 0; #endif tagcache_init(); while (!tagcache_is_initialized()) { int ret = tagcache_get_commit_step(); if (ret > 0) { #if CONFIG_CODEC == SWCODEC /* hwcodec can't use voice here, as the database commit * uses the audio buffer. */ if(global_settings.talk_menu && (talked_tick == 0 || TIME_AFTER(current_tick, talked_tick+7*HZ))) { talked_tick = current_tick; talk_id(LANG_TAGCACHE_INIT, false); talk_number(ret, true); talk_id(VOICE_OF, true); talk_number(tagcache_get_max_commit_step(), true); } #endif #ifdef HAVE_LCD_BITMAP if (lang_is_rtl()) { splashf(0, "[%d/%d] %s", ret, tagcache_get_max_commit_step(), str(LANG_TAGCACHE_INIT)); } else { splashf(0, "%s [%d/%d]", str(LANG_TAGCACHE_INIT), ret, tagcache_get_max_commit_step()); } #else lcd_double_height(false); lcd_putsf(0, 1, " DB [%d/%d]", ret, tagcache_get_max_commit_step()); lcd_update(); #endif clear = true; } sleep(HZ/4); } tagtree_init(); if (clear) { backlight_on(); show_logo(); } }
int ap_init(void) { RET_CODE ret = ERR_FAILURE; __delay(0x10000); hal_dcache_invalidate((void *)&g_ipcfw_f,sizeof(ipc_fw_fun_set_t)); attach_ipcfw_fun_set_concerto(&g_ipcfw_f); ap_ipc_init(32); // ap ipc fifo create mem_cfg(MEMCFG_T_NORMAL); drv_init_concerto(); OS_PRINTF("$$$ %s,%d\n\n",__FUNCTION__,__LINE__); ret = barcode_client_process(); if(ret == SUCCESS) { jump_barcode_app(UPG_TOOL_BLOCK_ID); } ret = sn_client_process(); if(ret == SUCCESS) { jump_app(UPG_TOOL_BLOCK_ID); } else { #if 0 drv_dev_t * p_pic_dev; pic_info_t pic_info = {0}; pdec_ins_t picdec_ins = {0}; load_logo(); mtos_printk("PDEC_OUT_ADDR 0x%x\n",PDEC_OUT_ADDR); p_pic_dev = (drv_dev_t *)dev_find_identifier(NULL, DEV_IDT_TYPE, SYS_DEV_TYPE_PDEC); MT_ASSERT(p_pic_dev != NULL); if (pdec_getinfo(p_pic_dev, g_p_logo_buf, g_logo_size, &pic_info, &picdec_ins) == SUCCESS && pic_info.image_format != IMAGE_FORMAT_UNKNOWN) { OS_PRINTF("LOGO is picture, pic size [%d,%d] ,format %d\n", pic_info.src_width, pic_info.src_height, pic_info.image_format); show_logo(PDEC_OUT_ADDR, g_p_logo_buf, g_logo_size, DRAW_ON_OSD); } else #endif ota_dm_init(); load_jump_policy(); } return 0; }
static bool show_credits(void) { char credits[MAX_PATH] = { '\0' }; snprintf(credits, MAX_PATH, "%s/credits.rock", VIEWERS_DIR); if (plugin_load(credits, NULL) != PLUGIN_OK) { /* show the rockbox logo and version untill a button is pressed */ show_logo(); while (IS_SYSEVENT(get_action(CONTEXT_STD, TIMEOUT_BLOCK))) ; } return false; }
void kmain(void) { task_t *task_shell; int ret; /*************** Init Arch ****************/ arch_early_init(); show_logo(); /*************** Init Platform ****************/ platform_init(); timer_init(); buses_init(); /*************** Init Task ****************/ task_init(); task_create_init(); /*************** Init Workqueu ****************/ init_workqueues(); /*************** Init File System ****************/ register_filesystem(&fat_fs); /*************** Creating Shell TASK ****************/ task_shell = task_alloc("shell", 0x2000, 5); if (NULL == task_shell) { return; } ret = task_create(task_shell, init_shell, 0); if (ret) { printk("Create init shell task failed\n"); } sema_init(&sem, 1); arch_enable_ints(); while(1) { enter_critical_section(); arch_idle(); task_schedule(); exit_critical_section(); } task_free(task_shell); }
void mt_disp_show_charger_ov_logo(void) { mt_logo_get_custom_if(); if(logo_cust_if->show_boot_logo) { logo_cust_if->show_boot_logo(); } else { show_logo(3); mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); } return; }
void mt65xx_disp_show_low_battery(void) { mt65xx_logo_get_custom_if(); if(logo_cust_if->show_boot_logo) { logo_cust_if->show_boot_logo(); } else { show_logo(2); mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); } return; }
void screen_show(void*p) { int nCount=0; initialize(); power_screen(true); show_logo(true); while(true){ power_screen(true); draw_rectangle(0, 0, 64, 128); power_screen(false); ++nCount; sprintf(watcher_data->temp_path,"nCount=%d",nCount); post_trace(watcher_data->temp_path); } }
void mt65xx_disp_show_boot_logo(void) { #ifndef CFG_MT6577_FPGA mt65xx_logo_get_custom_if(); if(logo_cust_if->show_boot_logo) { logo_cust_if->show_boot_logo(); } else { show_logo(0); mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); } return; #endif }
void state_test(void*p) { initialize(); power_screen(true); show_logo(true); while(true){ POWER_Control(dev_mobile, pt_on); mobile_state(); POWER_Control(dev_mobile, pt_hibernation); mobile_state(); POWER_Control(dev_mobile, pt_wakeup); mobile_state(); POWER_Control(dev_mobile, pt_off); mobile_state(); } }
void init_boe(int argc, char* argv[]) { init_directories(argv[0]); init_menubar(); // Do this first of all because otherwise a default File and Window menu will be seen sync_prefs(); init_graph_tool(); init_snd_tool(); cDialog::init(); init_sbar(text_sbar, sbar_rect, 58, 11, 58); init_sbar(item_sbar, item_sbar_rect, 16, 8); init_sbar(shop_sbar, shop_sbar_rect, 16, 8); init_btn(done_btn, BTN_DONE); init_btn(help_btn, BTN_HELP); adjust_window_mode(); // If we don't do this now it'll flash white to start with mainPtr.clear(sf::Color::Black); mainPtr.display(); make_cursor_watch(); boost::thread init_thread([]() { init_buf(); check_for_intel(); srand(time(nullptr)); init_screen_locs(); Set_up_win(); init_startup(); flushingInput = true; }); show_logo(); if(get_bool_pref("ShowStartupSplash", true)) plop_fancy_startup(); init_thread.join(); cUniverse::print_result = iLiving::print_result = add_string_to_buf; cPlayer::give_help = give_help; set_up_apple_events(argc, argv); init_fileio(); init_spell_menus(); init_mini_map(); redraw_screen(REFRESH_NONE); showMenuBar(); }
//-------------------------------------------------------------------------- // print_bios_banner // displays a the bios version //-------------------------------------------------------------------------- void BIOSCALL print_bios_banner(void) { #ifdef VBOX // Skip the logo if a warm boot is requested. uint16_t warm_boot = read_word(0x0040,0x0072); write_word(0x0040,0x0072, 0); if (warm_boot == 0x1234) { /* Only set text mode. */ set_mode(3); return; } /* show graphical logo */ show_logo(); #else /* !VBOX */ char *bios_conf; /* Avoid using preprocessing directives within macro arguments. */ bios_conf = #ifdef __WATCOMC__ "watcom " #endif #if BX_APM "apmbios " #endif #if BX_PCIBIOS "pcibios " #endif #if BX_ELTORITO_BOOT "eltorito " #endif #if BX_ROMBIOS32 "rombios32 " #endif "\n\n"; printf(BX_APPNAME" BIOS - build: %s\n%s\nOptions: ", BIOS_BUILD_DATE, bios_cvs_version_string); printf(bios_conf, 0); #endif /* VBOX */ }
void cust_show_battery_capacity_new(UINT32 capacity) { #if MTK_QVGA_LANDSCAPE_SUPPORT // DISP_PROG_BAR_DIRECT direct = DISP_HORIZONTAL_PROG_BAR; #else // DISP_PROG_BAR_DIRECT direct = DISP_VERTICAL_PROG_BAR; #endif DISP_PROG_BAR_DIRECT direct = DISP_VERTICAL_PROG_BAR; printf("[ChargingAnimation]capacity : %d\n", capacity); if (capacity <= 0) { //show_logo(2); //mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); //return; //capacity_zero ++; // if (capacity_zero > 10) capacity_zero = 2; // if (capacity_zero > 1) // { show_logo(29+capacity_zero_index); #ifndef NO_PERCENT_NEW show_animation_number(number_pic_start_0,1); show_animation(14, percent_location_rect, percent_pic_addr); #endif if(++capacity_zero_index > 1) capacity_zero_index = 0; mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); return; // } } //else // { // capacity_zero = 0; // } if (capacity < 10 && capacity > 0) { charging_low_index ++ ; show_logo(25 + charging_low_index); if (charging_low_index >= 9) charging_low_index = 0; #ifndef NO_PERCENT_NEW show_animation_number(number_pic_start_0+capacity,1); show_animation(14, percent_location_rect, percent_pic_addr); #endif mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); return; } if (capacity >= 100) { show_logo(37); // battery 100 mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); return; } UINT32 capacity_grids = 0; //if (capacity > 100) capacity = 100; capacity_grids = battery_rect.bottom - (battery_rect.bottom - battery_rect.top) * (capacity - 10) / 90; printf("[ChargingAnimation]capacity : %d\n", capacity); printf("[ChargingAnimation]capacity_grids : %d\n", capacity_grids); show_logo(35); // show background show_animation_line(36,capacity_grids); // show battery capacity line top_animation_rect.bottom = capacity_grids; top_animation_rect.top = capacity_grids - top_animation_height; if (capacity <= 90) { charging_animation_index++; printf("[ChargingAnimation]top_animation : left = %d, top = %d, right = %d, bottom = %d\n", top_animation_rect.left, top_animation_rect.top, top_animation_rect.right, top_animation_rect.bottom); show_animation(15 + charging_animation_index, top_animation_rect, top_animation_addr); // show top animation if (charging_animation_index >= 9) charging_animation_index = 0; } if ((capacity >= 0)&&(capacity < 10)) { #ifndef NO_PERCENT_NEW show_animation_number(number_pic_start_0+capacity,1); #endif } if ((capacity >= 10)&&(capacity < 100)) { #ifndef NO_PERCENT_NEW show_animation_number(number_pic_start_0+(capacity/10),0); show_animation_number(number_pic_start_0+(capacity%10),1); #endif } #ifndef NO_PERCENT_NEW show_animation(14, percent_location_rect, percent_pic_addr); #endif mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); }
/**************************************** * TitleScreen: Display the title screen * ***************************************** * display title screen, get input */ void TitleScreen(void) { Uint32 frame = 0; Uint32 start = 0; /* NOTE for 'depth', think pages like a restaurant menu, */ /* not heirarchical depth - choice of term is misleading */ int menu_depth; // how deep we are in the menu int i, j, tux_frame = 0; int done = 0; int firstloop = 1; int menu_opt = NONE; int sub_menu = NONE; int update_locs = 1; int redraw = 0; int key_menu = 1; int old_key_menu = 5; if (settings.sys_sound) { settings.menu_sound = 1; settings.menu_music = 1; } start = SDL_GetTicks(); /* * Display the Standby screen.... */ show_logo(); snd_welcome = LoadSound("harp.wav"); if (snd_welcome && settings.menu_sound) { PlaySound(snd_welcome); } /* Load media and menu data: */ if (!load_media()) { fprintf(stderr, "TitleScreen - load_media() failed!"); return; } SDL_WM_GrabInput(SDL_GRAB_ON); // User input goes to TuxType, not window manager /*************************** * Tux and Title animations * ***************************/ LOG( "->Now Animating Tux and Title onto the screen\n" ); Tuxdest.x = 0; Tuxdest.y = screen->h; Tuxdest.w = Tux->frame[0]->w; Tuxdest.h = Tux->frame[0]->h; Titledest.x = screen->w; Titledest.y = 10; Titledest.w = title->w; Titledest.h = title->h; spkrdest.x = screen->w - speaker->w - 10; spkrdest.y = screen->h - speaker->h - 10; spkrdest.w = speaker->w; spkrdest.h = speaker->h; /* --- wait if the first time in the game --- */ if (settings.show_tux4kids) { while ((SDL_GetTicks() - start) < 2000) { SDL_Delay(50); } settings.show_tux4kids = 0; } SDL_ShowCursor(1); /* FIXME not sure the next line works in Windows: */ TransWipe(CurrentBkgd(), RANDOM_WIPE, 10, 20); /* Make sure background gets drawn (since TransWipe() doesn't */ /* seem to work reliably as of yet): */ SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL); SDL_UpdateRect(screen, 0, 0, 0, 0); /* --- Pull tux & logo onscreen --- */ for (i = 0; i <= (PRE_ANIM_FRAMES * PRE_FRAME_MULT); i++) { start = SDL_GetTicks(); SDL_BlitSurface(CurrentBkgd(), &Tuxdest, screen, &Tuxdest); SDL_BlitSurface(CurrentBkgd(), &Titledest, screen, &Titledest); Tuxdest.y -= Tux->frame[0]->h / (PRE_ANIM_FRAMES * PRE_FRAME_MULT); Titledest.x -= (screen->w) / (PRE_ANIM_FRAMES * PRE_FRAME_MULT); /* Don't go past 0; */ if (Tuxdest.y < 0) Tuxdest.y = 0; if (Titledest.x < 0) Titledest.x = 0; SDL_BlitSurface(Tux->frame[0], NULL, screen, &Tuxdest); SDL_BlitSurface(title, NULL, screen, &Titledest); SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h); SDL_UpdateRect(screen, Titledest.x, Titledest.y, Titledest.w + 40, Titledest.h); while ((SDL_GetTicks() - start) < 33) { SDL_Delay(2); } } recalc_rects(); /* Pick speaker graphic according to whether music is on: */ if ( settings.menu_music ) SDL_BlitSurface(speaker, NULL, screen, &spkrdest); else SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest); /* Start playing menu music if desired: */ if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); LOG( "Tux and Title are in place now\n" ); SDL_WM_GrabInput(SDL_GRAB_OFF); /**************************** * Main Loop Starts Here ... * ****************************/ menu_depth = 1; firstloop = 1; Tuxdest.y = screen->h - Tux->frame[0]->h; while (!done) { start = SDL_GetTicks(); /* ---process input queue --- */ menu_opt = NONE; // clear the option so we don't change twice! old_key_menu = key_menu; /* Retrieve any user interface events: */ while (SDL_PollEvent(&event)) { switch (event.type) { /* Update "selection" if mouse moves within a menu entry: */ case SDL_MOUSEMOTION: { cursor.x = event.motion.x; cursor.y = event.motion.y; for (j = 1; j <= TITLE_MENU_ITEMS; j++) if (inRect(menu_button[j], cursor.x, cursor.y)) key_menu = j; break; } /* Handle mouse clicks based on mouse location: */ case SDL_MOUSEBUTTONDOWN: { cursor.x = event.motion.x; cursor.y = event.motion.y; for (j = 1; j <= TITLE_MENU_ITEMS; j++) { if (inRect(menu_button[j], cursor.x, cursor.y)) { menu_opt = menu_item[j][menu_depth]; if (settings.menu_sound) { PlaySound(snd_select); } DEBUGCODE { fprintf(stderr, "->>BUTTON CLICK menu_opt = %d\n", menu_opt); fprintf(stderr, "->J = %d menu_depth=%d\n", j, menu_depth); } } } /* If mouse over speaker, toggle menu music off or on: */ if (inRect(spkrdest, cursor.x, cursor.y)) { if (settings.menu_music) { MusicUnload(); settings.menu_music = 0; } else { settings.menu_music = 1; MusicLoad("tuxi.ogg", -1); } redraw = 1; } break; } case SDL_QUIT: { menu_opt = QUIT_GAME; break; } /* Handle key press events based on key value: */ case SDL_KEYDOWN: { switch (event.key.keysym.sym) { case SDLK_ESCAPE: { /* Go to main menu (if in submenu) or quit: */ if (menu_depth != 1) menu_opt = MAIN; else menu_opt = QUIT_GAME; if (settings.menu_sound) PlaySound(snd_select); break; } /* Toggle screen mode: */ case SDLK_F10: { SwitchScreenMode(); recalc_rects(); redraw = 1; break; } /* Toggle menu music: */ case SDLK_F11: { if (settings.menu_music) { MusicUnload( ); settings.menu_music = 0; } else { settings.menu_music = 1; MusicLoad("tuxi.ogg", -1); } redraw = 1; break; } /* --- reload translation/graphics/media: for themers/translaters --- */ case SDLK_F12: { unload_media(); LoadLang(); load_media(); redraw = 1; break; } case SDLK_UP: case SDLK_k: { if (settings.menu_sound) PlaySound(snd_move); key_menu--; if (key_menu < 1) key_menu = 5; break; } case SDLK_DOWN: case SDLK_j: { key_menu++; if (settings.menu_sound) PlaySound(snd_move); if (key_menu > 5) key_menu = 1; break; } case SDLK_RETURN: { if (key_menu) { menu_opt = menu_item[key_menu][menu_depth]; if (settings.menu_sound) PlaySound(snd_select); } break; } default: /* Some other key pressed - do nothing: */ { break; } } /* End of switch(event.key.keysym.sym) statement */ } /* End of case: SDL_KEYDOWN: */ default: /* Some other type of SDL event - do nothing; */ { break; } } /* End of switch(event.type) statement */ } /* End of while (SDL_PollEvent(&event)) loop */ /* --- do menu processing --- */ if (menu_opt == QUIT_GAME) done = 1; if (menu_opt == LASER) { menu_depth = LASER_SUBMENU; sub_menu = LASER; update_locs = 1; redraw = 1; } if (menu_opt == CASCADE) { menu_depth = CASCADE_SUBMENU; sub_menu = CASCADE; update_locs = 1; redraw=1; } if (menu_opt == OPTIONS) { menu_depth = OPTIONS_SUBMENU; sub_menu = OPTIONS; update_locs = 1; redraw = 1; } if (menu_opt == MAIN) { menu_depth = ROOTMENU; update_locs = 1; redraw = 1; } if (menu_opt == EDIT_WORDLIST) { ChooseListToEdit(); redraw = 1; } if (menu_opt == PROJECT_INFO) { ProjectInfo(); redraw = 1; } if (menu_opt == LESSONS) { // not_implemented(); SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL); SDL_Flip(screen); unload_media(); if (settings.menu_music) MusicUnload( ); XMLLesson(); load_media(); redraw = 1; if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); } if (menu_opt == SET_LANGUAGE) { unload_media(); ChooseTheme(); LoadLang(); LoadKeyboard(); load_media(); redraw = 1; if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); } if (menu_opt == LEVEL1) { if (chooseWordlist()) { unload_media(); switch (sub_menu) { case CASCADE: PlayCascade( EASY ); break; case LASER: PlayLaserGame( EASY ); break; } } load_media(); if (settings.menu_music) MusicLoad("tuxi.ogg", -1); redraw = 1; } if (menu_opt == LEVEL2) { if (chooseWordlist()) { unload_media(); switch (sub_menu) { case CASCADE: PlayCascade( MEDIUM ); break; case LASER: PlayLaserGame( MEDIUM ); break; } if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); } load_media(); redraw = 1; } if (menu_opt == LEVEL3) { if (chooseWordlist()) { unload_media(); switch (sub_menu) { case CASCADE: PlayCascade( HARD ); break; case LASER: PlayLaserGame( HARD ); break; } if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); } load_media(); redraw = 1; } if (menu_opt == LEVEL4) { if (chooseWordlist()) { unload_media(); switch (sub_menu) { case CASCADE: PlayCascade( INSANE ); break; case LASER: PlayLaserGame( INSANE ); break; } if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); } load_media(); redraw = 1; } if (menu_opt == INSTRUCT) { // not_implemented(); unload_media(); switch (sub_menu) { case CASCADE: InstructCascade(); break; case LASER: InstructLaser(); break; } load_media(); if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); redraw = 1; } if (menu_opt == PHRASE_TYPING) { // not_implemented(); unload_media(); Phrases(NULL); load_media(); if (settings.menu_music) MusicLoad( "tuxi.ogg", -1 ); redraw = 1; } /* ------ End menu_opt processing ----------- */ if (redraw) { LOG("TitleScreen() - redraw requested\n"); recalc_rects(); SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL); SDL_BlitSurface(title, NULL, screen, &Titledest); if ( settings.menu_music ) SDL_BlitSurface(speaker, NULL, screen, &spkrdest); else SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest); /* Screen will be updated due to update_locs - see ~30 lines down: */ // SDL_UpdateRect(screen, 0, 0, 0, 0); frame = redraw = 0; // so we redraw tux update_locs = 1; // so we redraw menu firstloop = 1; } /* --- create new menu screen when needed --- */ if (update_locs) { LOG("TitleScreen() - update_locs requested\n"); /* --- erase the last menu --- */ for (i = 1; i <= TITLE_MENU_ITEMS; i++) { text_dst[i].x = screen->w/2 - 70;//290; text_dst[i].w = reg_text[i][menu_depth]->w; text_dst[i].h = reg_text[i][menu_depth]->h; SDL_BlitSurface(CurrentBkgd(), &menu_button[i], screen, &menu_button[i]); menu_button[i].w = menu_width[menu_depth] + 20; } update_locs = 0; /* --- draw the full menu --- */ for (j = 1; j <= TITLE_MENU_ITEMS; j++) { DOUT(j); DrawButton(&menu_button[j], 10, REG_RGBA); if (reg_text[j][menu_depth] != NULL) SDL_BlitSurface(reg_text[j][menu_depth], NULL, screen, &text_dst[j]); if (menu_gfx[j][menu_depth] != NULL) SDL_BlitSurface(menu_gfx[j][menu_depth]->default_img, NULL, screen, &menu_gfxdest[j]); } SDL_UpdateRect(screen, 0, 0, 0, 0); LOG("TitleScreen() - update_locs completed\n"); } /* --- make tux blink --- */ switch (frame % TUX6) { case 0: tux_frame = 1; break; case TUX1: tux_frame = 2; break; case TUX2: tux_frame = 3; break; case TUX3: tux_frame = 4; break; case TUX4: tux_frame = 3; break; case TUX5: tux_frame = 2; break; default: tux_frame = 0; } if (tux_frame) { SDL_Rect blink_src, blink_dest; blink_src.x = 0; blink_src.y = 0; blink_src.w = Tuxdest.w; blink_src.h = Tuxdest.h; blink_dest.x = Tuxdest.x + blink_src.x; blink_dest.y = Tuxdest.y + blink_src.y; blink_dest.w = blink_src.w; blink_dest.h = blink_src.h; // SDL_BlitSurface(CurrentBkgd(), , screen, &Tuxdest); SDL_BlitSurface(Tux->frame[tux_frame - 1], &blink_src, screen, &blink_dest); } /* --- check if mouse is in a menu option --- */ // key_menu = 0; /* for (j = 1; j <= TITLE_MENU_ITEMS; j++) { if ((cursor.x >= menu_button[j].x && cursor.x <= (menu_button[j].x + menu_button[j].w)) && (cursor.y >= menu_button[j].y && cursor.y <= (menu_button[j].y + menu_button[j].h))) { key_menu = j; // update menu to point break; // Don't need to check rest of menu } }*/ /* --- return old selection to unselected state --- */ if (old_key_menu && (key_menu != old_key_menu)) { SDL_BlitSurface(CurrentBkgd(), &menu_button[old_key_menu], screen, &menu_button[old_key_menu]); DrawButton(&menu_button[old_key_menu], 10, REG_RGBA); SDL_BlitSurface(reg_text[old_key_menu][menu_depth], NULL, screen, &text_dst[old_key_menu]); SDL_BlitSurface(menu_gfx[old_key_menu][menu_depth]->default_img, NULL, screen, &menu_gfxdest[old_key_menu]); } /* --- draw current selection --- */ if ((key_menu != 0) && ((old_key_menu != key_menu) || (frame % 5 == 0))) // Redraw every fifth frame? { if (key_menu != old_key_menu) { REWIND(menu_gfx[key_menu][menu_depth]); PlaySound(snd_move); } SDL_BlitSurface(CurrentBkgd(), &menu_button[key_menu], screen, &menu_button[key_menu]); DrawButton(&menu_button[key_menu], 10, SEL_RGBA); SDL_BlitSurface(sel_text[key_menu][menu_depth], NULL, screen, &text_dst[key_menu]); SDL_BlitSurface(menu_gfx[key_menu][menu_depth]->frame[menu_gfx[key_menu][menu_depth]->cur], NULL, screen, &menu_gfxdest[key_menu]); NEXT_FRAME(menu_gfx[key_menu][menu_depth]); } // HACK This is still more than we need to update every frame but // it cuts cpu on my machine %60 so it seems better... if ( settings.menu_music ) SDL_BlitSurface(speaker, NULL, screen, &spkrdest); else SDL_BlitSurface(speakeroff, NULL, screen, &spkrdest); SDL_UpdateRect(screen, spkrdest.x, spkrdest.y, spkrdest.w, spkrdest.h); for (i = 1; i < 6; i++) { SDL_UpdateRect(screen, menu_button[i].x, menu_button[i].y, menu_button[i].w, menu_button[i].h); } if (tux_frame) SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h); if (firstloop) SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h); firstloop = 0; /* Wait so we keep frame rate constant: */ while ((SDL_GetTicks() - start) < 33) { SDL_Delay(20); } frame++; } /* ----------- End of 'while(!done)' loop ------------ */
void* main(void) { #ifdef TCCBOOT int rc; unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS; #endif system_init(); power_init(); kernel_init(); enable_irq(); lcd_init(); adc_init(); button_init(); backlight_init(); font_init(); lcd_setfont(FONT_SYSFIXED); show_logo(); _backlight_on(); /* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is available for loading the firmware. Otherwise display the debug screen. */ #ifdef TCCBOOT printf("Rockbox boot loader"); printf("Version " RBVERSION); printf("ATA"); rc = storage_init(); if(rc) { reset_screen(); error(EATA, rc, true); } printf("mount"); rc = disk_mount_all(); if (rc<=0) { error(EDISK,rc, true); } rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE); if (rc <= EFILE_EMPTY) { error(EBOOTFILE,rc, true); } else { int(*kernel_entry)(void) = (void *) loadbuffer; disable_irq(); rc = kernel_entry(); } panicf("Boot failed!"); #else show_debug_screen(); #endif return 0; }
void main(void) { int rc; power_init(); system_init(); kernel_init(); lcd_init(); show_logo(); enable_irq(); adc_init(); usb_init(); button_init(); powermgmt_init(); #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) if (charger_inserted() #ifdef ATA_POWER_PLAYERSTYLE && !ide_powered() /* relies on probing result from bootloader */ #endif ) { charging_screen(); /* display a "charging" screen */ show_logo(); /* again, to provide better visual feedback */ } #endif rc = storage_init(); if(rc) { #ifdef HAVE_LCD_BITMAP char str[32]; lcd_clear_display(); snprintf(str, 31, "ATA error: %d", rc); lcd_puts(0, 1, str); lcd_update(); while(!(button_get(true) & BUTTON_REL)); #endif panicf("storage: %d", rc); } usb_start_monitoring(); while (usb_detect() == USB_INSERTED) { /* enter USB mode early, before trying to mount */ if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) { usb_screen(); } } rc = disk_mount_all(); if (rc<=0) { prompt_usb("No partition", "found."); } { // rolo the firmware static const char filename[] = "/" BOOTFILE; rolo_load((char*)filename); /* won't return if started */ prompt_usb("No firmware", filename); } }
void* main(void) { char filename[MAX_PATH]; int i; int btn; int rc; int num_partitions; struct partinfo* pinfo; #if !(CONFIG_STORAGE & STORAGE_SD) char buf[256]; unsigned short* identify_info; #endif int usb = USB_EXTRACTED; chksum_crc32gentab (); system_init(); kernel_init(); #ifdef HAVE_BOOTLOADER_USB_MODE /* loader must service interrupts */ enable_interrupt(IRQ_FIQ_STATUS); #endif lcd_init(); font_init(); show_logo(); adc_init(); #ifdef HAVE_BOOTLOADER_USB_MODE button_init_device(); #else button_init(); #endif #if defined(SANSA_E200) || defined(PHILIPS_SA9200) i2c_init(); _backlight_on(); #endif if (button_hold()) { verbose = true; lcd_clear_display(); printf("Hold switch on"); printf("Shutting down..."); sleep(HZ); power_off(); } btn = button_read_device(); /* Enable bootloader messages if any button is pressed */ #ifdef HAVE_BOOTLOADER_USB_MODE lcd_clear_display(); if (btn) verbose = true; #else if (btn) { lcd_clear_display(); verbose = true; } #endif lcd_setfont(FONT_SYSFIXED); printf("Rockbox boot loader"); printf("Version: " RBVERSION); printf(MODEL_NAME); i=storage_init(); #if !(CONFIG_STORAGE & STORAGE_SD) if (i==0) { identify_info=ata_get_identify(); /* Show model */ for (i=0; i < 20; i++) { ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]); } buf[40]=0; for (i=39; i && buf[i]==' '; i--) { buf[i]=0; } printf(buf); } else { error(EATA, i, true); } #endif disk_init(IF_MV(0)); num_partitions = disk_mount_all(); if (num_partitions<=0) { error(EDISK,num_partitions, true); } /* Just list the first 2 partitions since we don't have any devices yet that have more than that */ for(i=0; i<NUM_PARTITIONS; i++) { pinfo = disk_partinfo(i); printf("Partition %d: 0x%02x %ld MB", i, pinfo->type, pinfo->size / 2048); } /* Now that storage is initialized, check for USB connection */ if ((btn & BOOTLOADER_BOOT_OF) == 0) { usb_pin_init(); usb = handle_usb(HZ*2); if (usb == USB_INSERTED) btn |= BOOTLOADER_BOOT_OF; } /* Try loading Rockbox, if that fails, fall back to the OF */ if((btn & BOOTLOADER_BOOT_OF) == 0) { printf("Loading Rockbox..."); snprintf(filename,sizeof(filename), BOOTDIR "/%s", BOOTFILE); rc = load_mi4(loadbuffer, filename, MAX_LOADSIZE); if (rc <= EFILE_EMPTY) { bool old_verbose = verbose; verbose = true; printf("Can't load " BOOTFILE ": "); printf(loader_strerror(rc)); verbose = old_verbose; btn |= BOOTLOADER_BOOT_OF; sleep(5*HZ); } else goto main_exit; } if(btn & BOOTLOADER_BOOT_OF) { /* Load original mi4 firmware in to a memory buffer called loadbuffer. The rest of the loading is done in crt0.S. 1) First try reading from the hidden partition (on Sansa only). 2) Next try a decrypted mi4 file in /System/OF.mi4 3) Finally, try a raw firmware binary in /System/OF.bin. It should be a mi4 firmware decrypted and header stripped using mi4code. */ printf("Loading original firmware..."); #if (CONFIG_STORAGE & STORAGE_SD) /* First try a (hidden) firmware partition */ printf("Trying firmware partition"); pinfo = disk_partinfo(1); if(pinfo->type == PARTITION_TYPE_OS2_HIDDEN_C_DRIVE) { rc = load_mi4_part(loadbuffer, pinfo, MAX_LOADSIZE, usb == USB_INSERTED); if (rc <= EFILE_EMPTY) { printf("Can't load from partition"); printf(loader_strerror(rc)); } else { goto main_exit; } } else { printf("No hidden partition found."); } #endif #if defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) || defined(PHILIPS_SA9200) printf("Trying /System/OF.ebn"); rc=load_mi4(loadbuffer, "/System/OF.ebn", MAX_LOADSIZE); if (rc <= EFILE_EMPTY) { printf("Can't load /System/OF.ebn"); printf(loader_strerror(rc)); } else { goto main_exit; } #endif printf("Trying /System/OF.mi4"); rc=load_mi4(loadbuffer, "/System/OF.mi4", MAX_LOADSIZE); if (rc <= EFILE_EMPTY) { printf("Can't load /System/OF.mi4"); printf(loader_strerror(rc)); } else { #if defined(SAMSUNG_YH925) lcd_reset(); #endif goto main_exit; } printf("Trying /System/OF.bin"); rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE); if (rc <= EFILE_EMPTY) { printf("Can't load /System/OF.bin"); printf(loader_strerror(rc)); } else { #if defined(SAMSUNG_YH925) lcd_reset(); #endif goto main_exit; } error(0, 0, true); } main_exit: #ifdef HAVE_BOOTLOADER_USB_MODE storage_close(); system_prepare_fw_start(); #endif return (void*)loadbuffer; }
static void init(void) { int rc; bool mounted = false; #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) /* if nobody initialized ATA before, I consider this a cold start */ bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ #endif system_init(); kernel_init(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ set_cpu_frequency(CPUFREQ_NORMAL); #ifdef CPU_COLDFIRE coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); #endif cpu_boost(true); #endif buffer_init(); settings_reset(); i2c_init(); power_init(); enable_irq(); #ifdef CPU_ARM enable_fiq(); #endif /* current_tick should be ticking by now */ CHART("ticking"); lcd_init(); #ifdef HAVE_REMOTE_LCD lcd_remote_init(); #endif font_init(); CHART(">show_logo"); show_logo(); CHART("<show_logo"); lang_init(core_language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY); #ifdef DEBUG debug_init(); #else #ifdef HAVE_SERIAL serial_setup(); #endif #endif #if CONFIG_RTC rtc_init(); #endif #ifdef HAVE_RTC_RAM CHART(">settings_load(RTC)"); settings_load(SETTINGS_RTC); /* early load parts of global_settings */ CHART("<settings_load(RTC)"); #endif adc_init(); usb_init(); #if CONFIG_USBOTG == USBOTG_ISP1362 isp1362_init(); #elif CONFIG_USBOTG == USBOTG_M5636 m5636_init(); #endif backlight_init(); button_init(); powermgmt_init(); #if CONFIG_TUNER radio_init(); #endif /* Keep the order of this 3 (viewportmanager handles statusbars) * Must be done before any code uses the multi-screen API */ CHART(">gui_syncstatusbar_init"); gui_syncstatusbar_init(&statusbars); CHART("<gui_syncstatusbar_init"); CHART(">sb_skin_init"); sb_skin_init(); CHART("<sb_skin_init"); CHART(">gui_sync_wps_init"); gui_sync_wps_init(); CHART("<gui_sync_wps_init"); CHART(">viewportmanager_init"); viewportmanager_init(); CHART("<viewportmanager_init"); #if CONFIG_CHARGING && (CONFIG_CPU == SH7034) /* charger_inserted() can't be used here because power_thread() hasn't checked power_input_status() yet */ if (coldstart && (power_input_status() & POWER_INPUT_MAIN_CHARGER) && !global_settings.car_adapter_mode #ifdef ATA_POWER_PLAYERSTYLE && !ide_powered() /* relies on probing result from bootloader */ #endif ) { rc = charging_screen(); /* display a "charging" screen */ if (rc == 1) /* charger removed */ power_off(); /* "On" pressed or USB connected: proceed */ show_logo(); /* again, to provide better visual feedback */ } #endif CHART(">storage_init"); rc = storage_init(); CHART("<storage_init"); if(rc) { #ifdef HAVE_LCD_BITMAP lcd_clear_display(); lcd_putsf(0, 1, "ATA error: %d", rc); lcd_puts(0, 3, "Press ON to debug"); lcd_update(); while(!(button_get(true) & BUTTON_REL)); /*DO NOT CHANGE TO ACTION SYSTEM */ dbg_ports(); #endif panicf("ata: %d", rc); } #ifdef HAVE_EEPROM_SETTINGS CHART(">eeprom_settings_init"); eeprom_settings_init(); CHART("<eeprom_settings_init"); #endif #ifndef HAVE_USBSTACK usb_start_monitoring(); while (usb_detect() == USB_INSERTED) { #ifdef HAVE_EEPROM_SETTINGS firmware_settings.disk_clean = false; #endif /* enter USB mode early, before trying to mount */ if (button_get_w_tmo(HZ/10) == SYS_USB_CONNECTED) #if (CONFIG_STORAGE & STORAGE_MMC) if (!mmc_touched() || (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED)) #endif { gui_usb_screen_run(); mounted = true; /* mounting done @ end of USB mode */ } #ifdef HAVE_USB_POWER if (usb_powered()) /* avoid deadlock */ break; #endif } #endif if (!mounted) { CHART(">disk_mount_all"); rc = disk_mount_all(); CHART("<disk_mount_all"); if (rc<=0) { lcd_clear_display(); lcd_puts(0, 0, "No partition"); lcd_puts(0, 1, "found."); #ifdef HAVE_LCD_BITMAP lcd_puts(0, 2, "Insert USB cable"); lcd_puts(0, 3, "and fix it."); #endif lcd_update(); while(button_get(true) != SYS_USB_CONNECTED) {}; gui_usb_screen_run(); system_reboot(); } } #if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \ (CONFIG_KEYPAD == IRIVER_H10_PAD) #ifdef SETTINGS_RESET /* Reset settings if holding the reset button. (Rec on Archos, A on Gigabeat) */ if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET) #else /* Reset settings if the hold button is turned on */ if (button_hold()) #endif { splash(HZ*2, str(LANG_RESET_DONE_CLEAR)); settings_reset(); } else #endif { CHART(">settings_load(ALL)"); settings_load(SETTINGS_ALL); CHART("<settings_load(ALL)"); } CHART(">init_dircache(true)"); rc = init_dircache(true); CHART("<init_dircache(true)"); if (rc < 0) { #ifdef HAVE_TAGCACHE remove(TAGCACHE_STATEFILE); #endif } CHART(">settings_apply(true)"); settings_apply(true); CHART("<settings_apply(true)"); CHART(">init_dircache(false)"); init_dircache(false); CHART("<init_dircache(false)"); #ifdef HAVE_TAGCACHE CHART(">init_tagcache"); init_tagcache(); CHART("<init_tagcache"); #endif #ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized) { /* In case we crash. */ firmware_settings.disk_clean = false; CHART(">eeprom_settings_store"); eeprom_settings_store(); CHART("<eeprom_settings_store"); } #endif playlist_init(); tree_mem_init(); filetype_init(); scrobbler_init(); #if CONFIG_CODEC == SWCODEC tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ #if CONFIG_CODEC != SWCODEC /* No buffer allocation (see buffer.c) may take place after the call to audio_init() since the mpeg thread takes the rest of the buffer space */ mp3_init( global_settings.volume, global_settings.bass, global_settings.treble, global_settings.balance, global_settings.loudness, global_settings.avc, global_settings.channel_config, global_settings.stereo_width, global_settings.mdb_strength, global_settings.mdb_harmonics, global_settings.mdb_center, global_settings.mdb_shape, global_settings.mdb_enable, global_settings.superbass); /* audio_init must to know the size of voice buffer so init voice first */ talk_init(); #endif /* CONFIG_CODEC != SWCODEC */ CHART(">audio_init"); audio_init(); CHART("<audio_init"); #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR) pcm_rec_init(); #endif /* runtime database has to be initialized after audio_init() */ cpu_boost(false); #if CONFIG_CHARGING car_adapter_mode_init(); #endif #ifdef IPOD_ACCESSORY_PROTOCOL iap_setup(global_settings.serial_bitrate); #endif #ifdef HAVE_ACCESSORY_SUPPLY accessory_supply_set(global_settings.accessory_supply); #endif #ifdef HAVE_LINEOUT_POWEROFF lineout_set(global_settings.lineout_active); #endif #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN CHART("<check_bootfile(false)"); check_bootfile(false); /* remember write time and filesize */ CHART(">check_bootfile(false)"); #endif CHART("<settings_apply_skins"); settings_apply_skins(); CHART(">settings_apply_skins"); }
int misc_init_r(void) { char *cmdline, *p1; int i, ddr_size = 0, cpu; u32 base, size; u32 max_preferred_freq = 0, max_freq = 0, maxfreqflg = 0; #ifdef CONFIG_RAMDUMP char *s; int ramdump; #endif if (pxa_is_warm_reset()) setenv("bootdelay", "-1"); #if defined(CONFIG_MMP_DISP) if (!fastboot) show_logo(); #endif cmdline = malloc(COMMAND_LINE_SIZE); strncpy(cmdline, getenv("bootargs"), COMMAND_LINE_SIZE); remove_cmdline_param(cmdline, "ddr_mode="); sprintf(cmdline + strlen(cmdline), " ddr_mode=%d", ddr_mode); /* set the cma range, we can change it according to * system configuration */ remove_cmdline_param(cmdline, "cma="); remove_cmdline_param(cmdline, "cgourp_disable="); remove_cmdline_param(cmdline, "androidboot.low_ram="); for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { if (gd->bd->bi_dram[i].size == 0) break; ddr_size += gd->bd->bi_dram[i].size; } /* ION reserved here for uboot running for EMMD protection */ if (ddr_size > SZ_512M + SZ_256M) { sprintf(cmdline + strlen(cmdline), " cma=112M"); /* * cgroup will only enabled for low_ram case, * for high ram case disable cgroup function */ sprintf(cmdline + strlen(cmdline), " cgroup_disable=memory"); } else sprintf(cmdline + strlen(cmdline), " cma=64M androidboot.low_ram=true"); remove_cmdline_param(cmdline, "ioncarv="); base = CONFIG_SYS_TEXT_BASE; size = SZ_16M; if (((base + size) > ddr_size)) printf("ERROR: wrong ION setting!!"); sprintf(cmdline + strlen(cmdline), " ioncarv=%dM@0x%08x", size >> 20, base); #ifdef CONFIG_RAMDUMP rd_mems[0].start = CONFIG_TZ_HYPERVISOR_SIZE; rd_mems[0].end = base; rd_mems[1].start = base + size; rd_mems[1].end = ddr_size; #endif /* if there's new maxfreq request, add it to bootargs */ max_preferred_freq = get_sku_max_freq(); if (max_preferred_freq) { if (max_preferred_freq <= 1183) max_preferred_freq = 1183; else max_preferred_freq = 1248; remove_cmdline_param(cmdline, "max_freq="); sprintf(cmdline + strlen(cmdline), " max_freq=%u", max_preferred_freq); max_freq = max_preferred_freq; maxfreqflg = 1; } else { /* check whether there is sku setting for max_freq previously */ p1 = strstr(cmdline, "max_freq="); if (p1) { p1 = strchr(p1, '='); if (p1) { p1++; max_freq = simple_strtoul(p1, NULL, 10); } if (max_freq) maxfreqflg = 1; } } setenv("bootargs", cmdline); /* if there's new maxfreq request, save env to later boots */ if (max_preferred_freq) saveenv(); free(cmdline); p_recovery_reg_funcs = &helandkb_recovery_reg_funcs; /* set op according to setting by selected, unless by default */ if (maxfreqflg) { set_plat_max_corefreq(max_freq); printf("max_freq is selected as %u\n", max_freq); } pxa988_fc_init(ddr_mode); if (pwr_chg_enable) setop(1); else setop(3); #if defined(CONFIG_MMP_DISP) calculate_dsi_clk(&mmp_mipi_info_saved); #endif for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) set_idle_count(cpu, 0); helandkb_touch_detect(); /* * bus 2 is used by pmic, set here for debug with * "i2c probe", this should be the called just before exit, * in case the default bus number is changed */ i2c_set_bus_num(2); /* for fastboot */ setenv("fbenv", "mmc2"); #ifdef CONFIG_RAMDUMP if (fastboot) { s = getenv("ramdump"); if (!s) { setenv("ramdump", "0"); s = getenv("ramdump"); } ramdump = (int)simple_strtol(s, NULL, 10); if (!ramdump && (0x1 != emmd_page->dump_style)) { #ifdef CONFIG_RAMDUMP_TFFS show_ramdump_logo(RAMDUMP_SD_DUMP); if (run_command("ramdump 0 0 0 2", 0)) { printf("SD dump fail, enter fastboot mode\n"); show_ramdump_logo(RAMDUMP_USB_DUMP); run_command("fb", 0); } else { run_command("reset", 0); } #endif } else { printf("ready to enter fastboot mode\n"); show_ramdump_logo(RAMDUMP_USB_DUMP); run_command("fb", 0); } } #endif return 0; }
static bool HandleClient(t_x11 *x11, int ID, t_gmx *gmx) { t_pulldown *pd; pd = gmx->pd; switch (ID) { /* File Menu */ case IDDUMPWIN: write_gmx(x11, gmx, IDDODUMP); break; case IDDODUMP: if (gmx->man->bAnimate) { hide_but(x11, gmx->man->vbox); } dump_it(gmx->man); if (gmx->man->bAnimate) { show_but(x11, gmx->man->vbox); } break; case IDCLOSE: case IDIMPORT: case IDEXPORT: ShowDlg(gmx->dlgs[edExport]); break; case IDDOEXPORT: write_sto_conf(gmx->confout, *gmx->man->top.name, &(gmx->man->top.atoms), gmx->man->x, NULL, gmx->man->molw->ePBC, gmx->man->box); break; case IDQUIT: show_mb(gmx, emQuit); break; case IDTERM: done_gmx(x11, gmx); return true; /* Edit Menu */ case IDEDITTOP: edit_file("topol.gmx"); break; case IDEDITCOORDS: edit_file("confin.gmx"); break; case IDEDITPARAMS: edit_file("mdparin.gmx"); break; /* Display Menu */ case IDFILTER: if (gmx->filter) { ShowDlg(gmx->dlgs[edFilter]); } break; case IDDOFILTER: do_filter(x11, gmx->man, gmx->filter); break; case IDANIMATE: check_pd_item(pd, IDANIMATE, toggle_animate(x11, gmx->man)); break; case IDLABELSOFF: no_labels(x11, gmx->man); break; case IDRESETVIEW: reset_view(gmx->man->view); ExposeWin(x11->disp, gmx->man->molw->wd.self); break; case IDPHOTO: show_mb(gmx, emNotImplemented); break; case IDBONDOPTS: ShowDlg(gmx->dlgs[edBonds]); break; case IDTHIN: set_bond_type(x11, gmx->man->molw, eBThin); break; case IDFAT: set_bond_type(x11, gmx->man->molw, eBFat); break; case IDVERYFAT: set_bond_type(x11, gmx->man->molw, eBVeryFat); break; case IDBALLS: set_bond_type(x11, gmx->man->molw, eBSpheres); break; case IDNOBOX: set_box_type(x11, gmx->man->molw, esbNone); break; case IDRECTBOX: set_box_type(x11, gmx->man->molw, esbRect); break; case IDTRIBOX: set_box_type(x11, gmx->man->molw, esbTri); break; case IDTOBOX: set_box_type(x11, gmx->man->molw, esbTrunc); break; /* Analysis Menu */ case IDBOND: case IDANGLE: case IDDIH: case IDRMS: case IDRDF: case IDENERGIES: case IDCORR: show_mb(gmx, emNotImplemented); break; /* Help Menu */ case IDHELP: show_mb(gmx, emHelp); break; case IDABOUT: show_logo(x11, gmx->logo); break; default: break; } return false; }
static int init_dircache(bool preinit) { #ifdef HAVE_DIRCACHE int result = 0; bool clear = false; if (preinit) dircache_init(); if (!global_settings.dircache) return 0; # ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized && firmware_settings.disk_clean && preinit) { result = dircache_load(); if (result < 0) { firmware_settings.disk_clean = false; if (global_status.dircache_size <= 0) { /* This will be in default language, settings are not applied yet. Not really any easy way to fix that. */ splash(0, str(LANG_SCANNING_DISK)); clear = true; } dircache_build(global_status.dircache_size); } } else # endif { if (preinit) return -1; if (!dircache_is_enabled() && !dircache_is_initializing()) { if (global_status.dircache_size <= 0) { splash(0, str(LANG_SCANNING_DISK)); clear = true; } result = dircache_build(global_status.dircache_size); } if (result < 0) { /* Initialization of dircache failed. Manual action is * necessary to enable dircache again. */ splashf(0, "Dircache failed, disabled. Result: %d", result); global_settings.dircache = false; } } if (clear) { backlight_on(); show_logo(); global_status.dircache_size = dircache_get_cache_size(); status_save(); } return result; #else (void)preinit; return 0; #endif }
static void init(void) { kernel_init(); buffer_init(); enable_irq(); lcd_init(); #ifdef HAVE_REMOTE_LCD lcd_remote_init(); #endif font_init(); show_logo(); button_init(); backlight_init(); sim_tasks_init(); lang_init(core_language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY); #ifdef DEBUG debug_init(); #endif /* Keep the order of this 3 (viewportmanager handles statusbars) * Must be done before any code uses the multi-screen API */ gui_syncstatusbar_init(&statusbars); gui_sync_wps_init(); sb_skin_init(); viewportmanager_init(); storage_init(); settings_reset(); settings_load(SETTINGS_ALL); settings_apply(true); init_dircache(true); init_dircache(false); #ifdef HAVE_TAGCACHE init_tagcache(); #endif sleep(HZ/2); tree_mem_init(); filetype_init(); playlist_init(); #if CONFIG_CODEC != SWCODEC mp3_init( global_settings.volume, global_settings.bass, global_settings.treble, global_settings.balance, global_settings.loudness, global_settings.avc, global_settings.channel_config, global_settings.stereo_width, global_settings.mdb_strength, global_settings.mdb_harmonics, global_settings.mdb_center, global_settings.mdb_shape, global_settings.mdb_enable, global_settings.superbass); /* audio_init must to know the size of voice buffer so init voice first */ talk_init(); #endif /* CONFIG_CODEC != SWCODEC */ scrobbler_init(); #if CONFIG_CODEC == SWCODEC tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ audio_init(); button_clear_queue(); /* Empty the keyboard buffer */ settings_apply_skins(); }
int main(int argc, char* argv[]) { #ifdef HAVE_EXECINFO_H signal(SIGSEGV, crash_sig); signal(SIGABRT, crash_sig); signal(SIGPIPE, SIG_IGN); #endif #ifdef WIN32 HANDLE localfd; WSADATA wsa; enum_device_t devs[MAX_DEVICE_COUNT]; #else int localfd; #endif char cmd[1024]; int remotefd; library_conf_t conf; int opt; struct in_addr a; struct option long_options[] = { { "conf", 1, NULL, 'c' }, { NULL, 0, NULL, 0 } }; char short_options[512] = {0}; longopt2shortopt(long_options, sizeof(long_options) / sizeof(struct option), short_options); #ifdef HAVE_SYSLOG_H openlog(argv[0], LOG_PERROR | LOG_CONS | LOG_PID, LOG_LOCAL0); #endif qtun = calloc(sizeof(*qtun), 1); #ifdef WIN32 remotefd = -1; localfd = INVALID_HANDLE_VALUE; #else localfd = remotefd = -1; #endif { char path[MAX_PATH] = {0}; #ifdef WIN32 strcpy(path, argv[0]); #elif defined(__APPLE__) char tmp_path[sizeof(path)] = {0}; uint32_t len = sizeof(path); if (_NSGetExecutablePath(tmp_path, &len) == -1) { perror("_NSGetExecutablePath"); return 1; } if (readlink(tmp_path, path, sizeof(path)) == -1) { if (errno == EINVAL) strcpy(path, tmp_path); else { perror("readlink"); return 1; } } #else if (readlink("/proc/self/exe", path, sizeof(path)) == -1) { perror("readlink"); return 1; } #endif init_path(path); } conf_init(&conf); while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) { switch (opt) { case 'c': { char* path = realpath(optarg, NULL); if (path == NULL) { perror("realpath"); return 1; } strcpy(conf.conf_file, path); free(path); } break; default: fprintf(stderr, "param error\n"); return 1; } } #ifdef WIN32 { size_t count = enum_devices(devs); if (count == 0) { fprintf(stderr, "have no QTun Virtual Adapter\n"); return 1; } else if (count == 1) { strcpy(conf.dev_symbol, devs[0].dev_path); strcpy(conf.dev_name, devs[0].dev_name); } else { size_t i; char str[20] = { 0 }; int n = -1; printf("Have Adapters:\n"); for (i = 0; i < count; ++i) { printf("%lu: %s\n", i + 1, devs[i].dev_name); } printf("Choose One[1]: "); while (n == -1) { if (str[0] == '\n' && str[1] == 0) n = 1; else { if (!is_int(str, sizeof(str))) continue; n = atoi(str); if (n < 1 || n > (int)count) { fprintf(stderr, "Invalid Number must >= 1 and <= %lu\n", count); n = -1; continue; } } } strcpy(conf.dev_symbol, devs[n].dev_path); strcpy(conf.dev_name, devs[n].dev_name); } } #endif init_lua(); show_logo(); script_load_config(qtun->lua, &conf, conf.conf_file); #ifdef WIN32 if (strlen(conf.dev_symbol) == 0) { fprintf(stderr, "Missing param [-e] or [--device]\n"); return 1; } #endif #ifdef WIN32 localfd = tun_open(conf.dev_symbol); if (localfd == INVALID_HANDLE_VALUE) return 1; fprintf(stdout, "%s opened\n", conf.dev_name); #else memset(qtun->dev_name, 0, IFNAMSIZ); localfd = tun_open(qtun->dev_name); if (localfd == -1) return 1; syslog(LOG_INFO, "%s opened\n", qtun->dev_name); #endif a.s_addr = conf.localip; #ifdef WIN32 WSAStartup(MAKEWORD(2, 2), &wsa); #endif if (strlen(conf.server) == 0) { if (conf.netmask == 0 || conf.netmask > 31) { #ifdef WIN32 WSACleanup(); #endif fprintf(stderr, "netmask must > 0 and <= 31\n"); return 1; } library_init(conf); if (conf.localip == 0) { fprintf(stderr, "localip is zero\n"); return 1; } if (strlen(conf.signature_file) == 0) { fprintf(stderr, "missing signature file\n"); return 1; } qtun->is_server = 1; remotefd = bind_and_listen(conf.server_port); if (remotefd == -1) { #ifdef WIN32 WSACleanup(); #endif return 1; } #ifdef WIN32 { a.s_addr = conf.localip; sprintf(cmd, "netsh interface ip set address name=\"%s\" static %s %s", conf.dev_name, inet_ntoa(a), STR_LEN2MASK(conf.netmask)); SYSTEM_EXIT(cmd); } #elif defined(__APPLE__) { sprintf(cmd, "ifconfig %s %s/%u up", qtun->dev_name, inet_ntoa(a), conf.netmask); SYSTEM_EXIT(cmd); a.s_addr = conf.localip & LEN2MASK(conf.netmask); sprintf(cmd, "route add -net %s/%u %s", inet_ntoa(a), conf.netmask, inet_ntoa(a)); SYSTEM_EXIT(cmd); } #else { sprintf(cmd, "ifconfig %s %s/%u up", qtun->dev_name, inet_ntoa(a), conf.netmask); SYSTEM_EXIT(cmd); a.s_addr = conf.localip & LEN2MASK(conf.netmask); sprintf(cmd, "route add -net %s/%u dev %s", inet_ntoa(a), conf.netmask, qtun->dev_name); SYSTEM_EXIT(cmd); } #endif server_loop(remotefd, localfd); } else { #ifdef unix unsigned char mask; #endif int inited = 0; library_init(conf); qtun->is_server = 0; while (1) { remotefd = connect_server(conf.server, conf.server_port); if (remotefd == -1) { SLEEP(5); continue; } a.s_addr = qtun->localip; if (qtun->localip == 0) { fprintf(stderr, "localip is zero\n"); return 1; } if (strlen(conf.signature_file) == 0) { fprintf(stderr, "missing signature file\n"); return 1; } if (!inited) { #ifdef WIN32 { sprintf(cmd, "netsh interface ip set address name=\"%s\" static %s %s", conf.dev_name, inet_ntoa(a), STR_LEN2MASK(conf.netmask)); SYSTEM_EXIT(cmd); } #elif defined(__APPLE__) { char ip1[16], ip2[16]; a.s_addr = qtun->localip; strcpy(ip1, inet_ntoa(a)); a.s_addr = qtun->client.local_ip; strcpy(ip2, inet_ntoa(a)); sprintf(cmd, "ifconfig %s inet %s %s up", qtun->dev_name, ip1, ip2); SYSTEM_EXIT(cmd); mask = netmask(); a.s_addr = qtun->localip & LEN2MASK(mask); sprintf(cmd, "route add -net %s/%u %s", inet_ntoa(a), mask, ip2); SYSTEM_EXIT(cmd); } #else { sprintf(cmd, "ifconfig %s %s up", qtun->dev_name, inet_ntoa(a)); SYSTEM_EXIT(cmd); mask = netmask(); a.s_addr = qtun->localip & LEN2MASK(mask); sprintf(cmd, "route add -net %s/%u dev %s", inet_ntoa(a), mask, qtun->dev_name); SYSTEM_EXIT(cmd); } #endif inited = 1; } client_loop(remotefd, localfd); close(remotefd); SYSLOG(LOG_WARNING, "retry"); } } #ifdef WIN32 WSACleanup(); #endif #ifdef HAVE_SYSLOG_H closelog(); #endif library_free(); return 0; }