static void ui_handle_command(void) { char command[32]; struct menu_item *chosen_item = ui_get_menu_selection(); if (chosen_item == NULL) { return; } strcpy(command, chosen_item->menu_cmd); if (!memcmp(command,"boot_recv", strlen(command))) { boot_into_sboot = 0; boot_into_recovery = 1; boot_linux_from_flash(); } else if (!memcmp(command,"prnt_part", strlen(command))) { htcleo_ptable_dump(&flash_ptable); } else if (!memcmp(command,"prnt_clrs", strlen(command))) { fbcon_reset(); } else if (!memcmp(command,"boot_sbot", strlen(command))) { boot_into_sboot = 1; boot_into_recovery = 0; boot_linux_from_flash(); } else if (!memcmp(command,"boot_nand", strlen(command))) { boot_into_sboot = 0; boot_into_recovery = 0; boot_linux_from_flash(); } else if (!memcmp(command,"acpu_ggwp", strlen(command))) { reboot_device(0); } else if (!memcmp(command,"acpu_bgwp", strlen(command))) { reboot_device(FASTBOOT_MODE); } else if (!memcmp(command,"acpu_pawn", strlen(command))) { shutdown(); } else { dprintf(CRITICAL, "Unimplemented command...\n"); } }
void htcleo_fastboot_init() { // off charge and recovery boot failed, reboot to normal mode if(get_boot_reason()==2) reboot(0); // display not initialized if(fbcon_display()==NULL) { display_init(); display_lk_version(); htcleo_ptable_dump(&flash_ptable); } cmd_oem_register(); }
void target_init(void) { struct flash_info *flash_info; unsigned start_block; unsigned blocks_per_plen = 1; //blocks per partition length unsigned nand_num_blocks; keys_init(); keypad_init(); uint16_t keys[] = {KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SOFT1, KEY_SEND, KEY_CLEAR, KEY_BACK, KEY_HOME}; for(unsigned i=0; i< sizeof(keys)/sizeof(uint16_t); i++) if (keys_get_state(keys[i]) != 0) { display_init(); display_lk_version(); //dprintf(ALWAYS,"key %d pressed\n", i); break; } dprintf(INFO, "htcleo_init\n"); if(get_boot_reason()==2) // booting for offmode charging, start recovery so kernel will charge phone { boot_into_recovery = 1; //dprintf(INFO, "reboot needed... \n"); //reboot(0); } dprintf(ALWAYS, "load address %x\n", load_address); dprintf(INFO, "flash init\n"); flash_init(); flash_info = flash_get_info(); ASSERT(flash_info); ASSERT(flash_info->num_blocks); nand_num_blocks = flash_info->num_blocks; ptable_init(&flash_ptable); if( strcmp(board_part_list[0].name,"PTABLE-BLK")==0 ) blocks_per_plen =1 ; else if( strcmp(board_part_list[0].name,"PTABLE-MB")==0 ) blocks_per_plen = (1024*1024)/flash_info->block_size; else panic("Invalid partition table\n"); start_block = HTCLEO_FLASH_OFFSET; for (unsigned i = 1; i < num_parts; i++) { struct ptentry *ptn = &board_part_list[i]; if( IS_PART_EMPTY(ptn) ) break; int len = ((ptn->length) * blocks_per_plen); if( ptn->start == 0 ) ptn->start = start_block; else if( ptn->start < start_block) panic("Partition %s start %x < %x\n", ptn->name, ptn->start, start_block); if(ptn->length == 0) { unsigned length_for_prt = 0; if( i<num_parts && !IS_PART_EMPTY((&board_part_list[i+1])) && board_part_list[i+1].start!=0) { length_for_prt = board_part_list[i+1].start - ptn->start; } else { for (unsigned j = i+1; j < num_parts; j++) { struct ptentry *temp_ptn = &board_part_list[j]; if( IS_PART_EMPTY(temp_ptn) ) break; if( temp_ptn->length==0 ) panic("partition %s and %s have variable length\n", ptn->name, temp_ptn->name); length_for_prt += ((temp_ptn->length) * blocks_per_plen); } } len = (nand_num_blocks - 1 - 186 - 4) - (ptn->start + length_for_prt); ASSERT(len >= 0); } start_block = ptn->start + len; ptable_add(&flash_ptable, ptn->name, ptn->start, len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE); } htcleo_ptable_dump(&flash_ptable); flash_set_ptable(&flash_ptable); }