void do_booti_linux (boot_img_hdr *hdr) { char *bootargs; ulong initrd_start, initrd_end; void (*theKernel)(int zero, int arch, uint params); bd_t *bd = gd->bd; theKernel = (void (*)(int, int, uint))(hdr->kernel_addr); initrd_start = hdr->ramdisk_addr; initrd_end = initrd_start + hdr->ramdisk_size; printf(" Initrd start : %p , Initrd end : %p",initrd_start, initrd_end); #if defined (CONFIG_SETUP_MEMORY_TAGS) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG bootargs = getenv("bootargs"); if (bootargs == NULL || *bootargs == '\0') { bootargs = hdr->cmdline; } setup_commandline_tag (bd, bootargs); #endif #ifdef CONFIG_INITRD_TAG if (hdr->ramdisk_size) setup_initrd_tag (bd, initrd_start, initrd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif setup_modelid_tag (¶ms); setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, bd->bi_arch_number, bd->bi_boot_params); }
void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], ulong addr, ulong *len_ptr, int verify) { ulong len = 0, checksum; ulong initrd_start, initrd_end; ulong data; void (*theKernel)(int zero, int arch, uint params); image_header_t *hdr = &header; bd_t *bd = gd->bd; #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #endif theKernel = (void (*)(int, int, uint))ntohl(hdr->ih_ep); /* * Check if there is an initrd image */ if (argc >= 3) { SHOW_BOOT_PROGRESS (9); addr = simple_strtoul (argv[2], NULL, 16); printf ("## Loading Ramdisk Image at %08lx ...\n", addr); /* Copy header so we can blank CRC field for re-calculation */ #ifdef CONFIG_HAS_DATAFLASH if (addr_dataflash (addr)) { read_dataflash (addr, sizeof (image_header_t), (char *) &header); } else #endif memcpy (&header, (char *) addr, sizeof (image_header_t)); if (ntohl (hdr->ih_magic) != IH_MAGIC) { printf ("Bad Magic Number\n"); SHOW_BOOT_PROGRESS (-10); do_reset (cmdtp, flag, argc, argv); } data = (ulong) & header; len = sizeof (image_header_t); checksum = ntohl (hdr->ih_hcrc); hdr->ih_hcrc = 0; if (crc32 (0, (unsigned char *) data, len) != checksum) { printf ("Bad Header Checksum\n"); SHOW_BOOT_PROGRESS (-11); do_reset (cmdtp, flag, argc, argv); } SHOW_BOOT_PROGRESS (10); print_image_hdr (hdr); data = addr + sizeof (image_header_t); len = ntohl (hdr->ih_size); #ifdef CONFIG_HAS_DATAFLASH if (addr_dataflash (addr)) { read_dataflash (data, len, (char *) CFG_LOAD_ADDR); data = CFG_LOAD_ADDR; } #endif if (verify) { ulong csum = 0; printf (" Verifying Checksum ... "); csum = crc32 (0, (unsigned char *) data, len); if (csum != ntohl (hdr->ih_dcrc)) { printf ("Bad Data CRC\n"); SHOW_BOOT_PROGRESS (-12); do_reset (cmdtp, flag, argc, argv); } printf ("OK\n"); } SHOW_BOOT_PROGRESS (11); if ((hdr->ih_os != IH_OS_LINUX) || (hdr->ih_arch != IH_CPU_ARM) || (hdr->ih_type != IH_TYPE_RAMDISK)) { printf ("No Linux ARM Ramdisk Image\n"); SHOW_BOOT_PROGRESS (-13); do_reset (cmdtp, flag, argc, argv); } #if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) /* *we need to copy the ramdisk to SRAM to let Linux boot */ memmove ((void *) ntohl(hdr->ih_load), (uchar *)data, len); data = ntohl(hdr->ih_load); #endif /* CONFIG_B2 || CONFIG_EVB4510 */ /* * Now check if we have a multifile image */ } else if ((hdr->ih_type == IH_TYPE_MULTI) && (len_ptr[1])) { ulong tail = ntohl (len_ptr[0]) % 4; int i; SHOW_BOOT_PROGRESS (13); /* skip kernel length and terminator */ data = (ulong) (&len_ptr[2]); /* skip any additional image length fields */ for (i = 1; len_ptr[i]; ++i) data += 4; /* add kernel length, and align */ data += ntohl (len_ptr[0]); if (tail) { data += 4 - tail; } len = ntohl (len_ptr[1]); } else { /* * no initrd image */ SHOW_BOOT_PROGRESS (14); len = data = 0; } #ifdef DEBUG if (!data) { printf ("No initrd\n"); } #endif if (data) { initrd_start = data; initrd_end = initrd_start + len; } else { initrd_start = 0; initrd_end = 0; } SHOW_BOOT_PROGRESS (15); debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) || \ defined (CONFIG_LCD) || \ defined (CONFIG_VFD) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (initrd_start && initrd_end) setup_initrd_tag (bd, initrd_start, initrd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif setup_modelid_tag(¶ms); setup_cpuid_tag(¶ms); setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, bd->bi_arch_number, bd->bi_boot_params); }
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; void (*theKernel)(int zero, int arch, uint params); #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv("bootargs"); #endif /* * allow the PREP bootm subcommand, it is required for bootm to work */ if (flag & BOOTM_STATE_OS_PREP) return 0; if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; theKernel = (void (*)(int, int, uint))images->ep; s = getenv("machid"); if (s) { machid = simple_strtoul(s, NULL, 16); printf("Using machid 0x%x from environment\n", machid); } bootstage_mark(BOOTSTAGE_ID_RUN_OS); debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong)theKernel); #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ defined(CONFIG_CMDLINE_TAG) || \ defined(CONFIG_INITRD_TAG) || \ defined(CONFIG_SERIAL_TAG) || \ defined(CONFIG_REVISION_TAG) setup_start_tag(bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag(¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag(¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags(bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag(bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (images->rd_start && images->rd_end) setup_initrd_tag(bd, images->rd_start, images->rd_end); #endif setup_end_tag(bd); #endif /* we assume that the kernel is in place */ printf("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect(void); udc_disconnect(); } #endif cleanup_before_linux(); theKernel(0, machid, bd->bi_boot_params); /* does not return */ return 1; }
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { struct bp_tag *params, *params_start; ulong initrd_start, initrd_end; char *commandline = env_get("bootargs"); if (!(flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO))) return 0; show_boot_progress(15); if (images->rd_start) { initrd_start = images->rd_start; initrd_end = images->rd_end; } else { initrd_start = 0; initrd_end = 0; } params_start = (struct bp_tag *)gd->bd->bi_boot_params; params = params_start; params = setup_first_tag(params); params = setup_memory_tag(params); params = setup_commandline_tag(params, commandline); params = setup_serial_tag(params); if (initrd_start) params = setup_ramdisk_tag(params, initrd_start, initrd_end); #ifdef CONFIG_OF_LIBFDT if (images->ft_addr) params = setup_fdt_tag(params, images->ft_addr); #endif printf("\n"); params = setup_last_tag(params); show_boot_progress(15); printf("Transferring Control to Linux @0x%08lx ...\n\n", (ulong)images->ep); flush_dcache_range((unsigned long)params_start, (unsigned long)params); if (flag & BOOTM_STATE_OS_FAKE_GO) return 0; /* * _start() in vmlinux expects boot params in register a2. * NOTE: * Disable/delete your u-boot breakpoints before stepping into linux. */ asm volatile ("mov a2, %0\n\t" "jx %1\n\t" : : "a" (params_start), "a" (images->ep) : "a2"); /* Does not return */ return 1; }
int main(runMode_t mode) { void* kernelImage = L"/e/zImage"; char* cmdlnRM = "bootmode=2 loglevel=4"; char* cmdlnBG = "bootmode=10 loglevel=4"; char* cmdln = "loglevel=4"; unsigned char ATAG_buf[512]={0}; t_stat filestat; fun_t kernel; int fd; unsigned long kernelSize=0; //here we start the real deal :) int mmuctrl = MemMMUCacheEnable(gMMUL1PageTable, 1); disp_FOTA_Init(); disp_FOTA_Printf("*----------------------------*"); disp_FOTA_Printf("| Booting Android |"); disp_FOTA_Printf("*----------------------------*"); //there was a ascii art forgatted it on other pc disp_FOTA_Printf("| |"); disp_FOTA_Printf("*----------------------------*"); disp_FOTA_Printf(""); //.... Your code here... __PfsNandInit(); __PfsMassInit(); MemoryCardMount(); tfs4_stat(kernelImage, &filestat); kernelSize = filestat.st_size; if ((fd=tfs4_open(kernelImage, 4)) >= 0) { tfs4_read(fd, &KERNEL_BUF, kernelSize); tfs4_close(fd); } if (kernelSize <= 0) { disp_FOTA_Printf("Kernel Not Found"); } DisableMmuCache(mmuctrl); _CoDisableMmu(); setup_core_tag(ATAG_buf); setup_serial_tag(0x123, 0x456); setup_rev_tag('0'); if(mode == rm_BIGMEM) { setup_cmdline_tag(cmdlnBG); disp_FOTA_Printf("Bigmem mode"); DRV_Modem_BootingStart(); } if(mode == rm_FPFK) { disp_FOTA_Printf("Under Maintise :D"); } if(mode == rm_FOTA_RECOVERY) { setup_cmdline_tag(cmdlnRM); disp_FOTA_Printf("recovery mode Activated"); } else { setup_cmdline_tag(cmdln); DRV_Modem_BootingStart(); } setup_end_tag(); //copy kernel to the right position memcpy(&KERNEL_START, &KERNEL_BUF, kernelSize); //SYSCON operations *((unsigned int*)SYSCON_NORMAL_CFG) = 0xFFFFFFFF; _CoDisableDCache(); _System_DisableVIC(); _System_DisableIRQ(); _System_DisableFIQ(); kernel = (fun_t)&KERNEL_START; kernel(0, 8500, ATAG_buf); //loop forever while(1); return 0; }
void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images) { ulong initrd_start, initrd_end; ulong ep = 0; bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; void (*theKernel)(int zero, int arch, uint params); int ret; #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #endif /* find kernel entry point */ if (images->legacy_hdr_valid) { ep = image_get_ep (&images->legacy_hdr_os_copy); #if defined(CONFIG_FIT) } else if (images->fit_uname_os) { ret = fit_image_get_entry (images->fit_hdr_os, images->fit_noffset_os, &ep); if (ret) { puts ("Can't get entry point property!\n"); goto error; } #endif } else { puts ("Could not find kernel entry point!\n"); goto error; } theKernel = (void (*)(int, int, uint))ep; s = getenv ("machid"); if (s) { machid = simple_strtoul (s, NULL, 16); printf ("Using machid 0x%x from environment\n", machid); } ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_ARM, &initrd_start, &initrd_end); if (ret) goto error; show_boot_progress (15); debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) || \ defined (CONFIG_LCD) || \ defined (CONFIG_VFD) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (initrd_start && initrd_end) setup_initrd_tag (bd, initrd_start, initrd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, machid, bd->bi_boot_params); /* does not return */ return; error: do_reset (cmdtp, flag, argc, argv); return; }
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; void (*kernel_entry)(int zero, int arch, uint params); #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #endif if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; s = getenv ("machid"); if (s) { machid = simple_strtoul (s, NULL, 16); printf ("Using machid 0x%x from environment\n", machid); } show_boot_progress (15); #ifdef CONFIG_OF_LIBFDT if (images->ft_len) return bootm_linux_fdt(machid, images); #endif kernel_entry = (void (*)(int, int, uint))images->ep; debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel_entry); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) || \ defined (CONFIG_LCD) || \ defined (CONFIG_VFD) || \ defined (CONFIG_DMAMEM) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (images->rd_start && images->rd_end) setup_initrd_tag (bd, images->rd_start, images->rd_end); #endif #if defined (CONFIG_SETUP_VIDEOLFB_TAG) && (defined (CONFIG_VFD) || defined (CONFIG_LCD)) setup_videolfb_tag ((gd_t *) gd); #endif #ifdef CONFIG_DMAMEM setup_dmamem_tag(); #endif setup_end_tag(bd); #endif announce_and_cleanup(); kernel_entry(0, machid, bd->bi_boot_params); /* does not return */ return 1; }
void do_booti_linux (boot_img_hdr *hdr) { ulong initrd_start, initrd_end; void (*theKernel)(int zero, int arch, uint params); bd_t *bd = gd->bd; int machid = bd->bi_arch_number; #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv("bootargs"); char *machidString = getenv("machid"); /* If no bootargs env, just use hdr command line */ if (!commandline) commandline = (char *)hdr->cmdline; if (machidString) machid = simple_strtoul(machidString, NULL, 16); /* XXX: in production, you should always use boot.img 's cmdline !!! */ printf("kernel cmdline: \n"); printf("\tuse %s ", getenv("bootargs") ? "uboot" : "boot.img"); printf("command line:\n\t%s \n", commandline); printf ("\tUsing machid 0x%x\n", machid); #endif theKernel = (void (*)(int, int, uint))(hdr->kernel_addr); initrd_start = hdr->ramdisk_addr; initrd_end = initrd_start + hdr->ramdisk_size; #if defined (CONFIG_SETUP_MEMORY_TAGS) setup_start_tag(bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (hdr->ramdisk_size) setup_initrd_tag (bd, initrd_start, initrd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, machid, bd->bi_boot_params); }
void do_booti_linux (boot_img_hdr *hdr) { ulong initrd_start, initrd_end; void (*theKernel)(int zero, int arch, uint params); bd_t *bd = gd->bd; theKernel = (void (*)(int, int, uint))(hdr->kernel_addr); initrd_start = hdr->ramdisk_addr; initrd_end = initrd_start + hdr->ramdisk_size; #if defined (CONFIG_SETUP_MEMORY_TAGS) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_REVISION16_TAG setup_revision16_tag (¶ms); #endif #ifdef CONFIG_SERIAL16_TAG setup_serial16_tag (¶ms); #endif #ifdef CONFIG_MACADDR_TAG setup_macaddr_tag (¶ms); #endif #ifdef CONFIG_BOOTMODE_TAG setup_bootmode_tag (¶ms); #endif #ifdef CONFIG_GYROCAL_TAG setup_gyrocal_tag (¶ms); #endif #ifdef CONFIG_PRODUCTID_TAG setup_productid_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, hdr->cmdline); #endif #ifdef CONFIG_INITRD_TAG if (hdr->ramdisk_size) setup_initrd_tag (bd, initrd_start, initrd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, bd->bi_arch_number, bd->bi_boot_params); }
int do_nand_boot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { DECLARE_GLOBAL_DATA_PTR; int ret; bd_t *bd = gd->bd; ulong addr, data, len, initrd_start, initrd_end; void (*theKernel)(int zero, int arch, uint params); int strlen; #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #endif #ifdef CFG_UBOOT_PROFILING extern unsigned int boot_time; unsigned int time_do_nand_boot= get_timer(0); unsigned int time_rootfs; unsigned int time_load_bootimg; unsigned int ubt; #endif #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) || \ defined (CONFIG_LCD) || \ defined (CONFIG_VFD) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS if(g_boot_mode == FACTORY_BOOT) { setup_memory_tags_factory(bd); } else { setup_memory_tags (bd); } #endif //#ifdef CONFIG_CMDLINE_TAG //**************** //* according to current boot mode to set boot tag and related boot args //* switch(g_boot_mode) { //******************************************************************** //* NORMAL BOOT //******************************************************************** case NORMAL_BOOT: #if defined(CFG_NAND_BOOT) strlen += sprintf(commandline, "%s%s%x%s%x", commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id); #endif setup_boot_tag(NORMAL_BOOT); ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } #ifdef CFG_UBOOT_PROFILING time_load_bootimg= get_timer(0); #endif ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- load boot.img takes %d ms -------- \n", get_timer(time_load_bootimg)); #endif if (ret < 0) { msg_img_error("Android Boot Image"); } break; //******************************************************************** //* META //******************************************************************** case META_BOOT: #ifdef CFG_META_MODE printf("[META] - Old bootargs : %s\n",commandline); commandline=strcat(commandline,META_BOOTARGS); printf("[META] - New bootargs : %s\n",commandline); setup_boot_tag(META_BOOT); #endif ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Boot Image"); } break; //******************************************************************** //* ADVANCED META MODE //******************************************************************** case ADVMETA_BOOT: printf("[META] - Old bootargs : %s\n",commandline); commandline=strcat(commandline, ADV_META_BOOTARGS); printf("[META] - New bootargs : %s\n",commandline); setup_boot_tag(ADVMETA_BOOT); ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Boot Image"); } break; //******************************************************************** //* ANDROID RECOVERY //******************************************************************** case RECOVERY_BOOT: #ifdef CFG_RECOVERY_MODE setup_boot_tag(RECOVERY_BOOT); #endif ret = mboot_android_load_recoveryimg_hdr(PART_RECOVERY, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Recovery Image"); } ret = mboot_android_load_recoveryimg(PART_RECOVERY, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Recovery Image"); } break; //******************************************************************** //* FACTORY //******************************************************************** case FACTORY_BOOT: #if defined(CFG_NAND_BOOT) strlen += sprintf(commandline, "%s%s%x%s%x", commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id); #endif #ifdef CFG_FACTORY_MODE setup_boot_tag(FACTORY_BOOT); #endif //************* //* parse recovery image header //* ret = mboot_android_load_factoryimg_hdr(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { printf("factory image doesn't exist in SD card\n"); // load boot image from nand ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Boot Image"); } } else { // load the factory image ret = mboot_android_load_factoryimg(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Factory Image"); } } break; //******************************************************************** //* ATE_FACTORY_BOOT //******************************************************************** case ATE_FACTORY_BOOT: #if defined(CFG_NAND_BOOT) strlen += sprintf(commandline, "%s%s%x%s%x", commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id); #endif #ifdef CFG_FACTORY_MODE setup_boot_tag(ATE_FACTORY_BOOT); #endif //************* //* parse recovery image header //* ret = mboot_android_load_factoryimg_hdr(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { printf("factory image doesn't exist in SD card\n"); // load boot image from nand ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Boot Image"); } } else { // load the factory image ret = mboot_android_load_factoryimg(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Factory Image"); } } break; //******************************************************************** //* SW BOOT //******************************************************************** case SW_REBOOT: setup_boot_tag(SW_REBOOT); ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_img_error("Android Boot Image"); } break; //******************************************************************** //* ALARM BOOT //******************************************************************** case ALARM_BOOT: #if defined(CFG_NAND_BOOT) strlen += sprintf(commandline, "%s%s%x%s%x", commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id); #endif setup_boot_tag(ALARM_BOOT); ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); if (ret < 0) { msg_header_error("Android Boot Image"); } #ifdef CFG_UBOOT_PROFILING time_load_bootimg= get_timer(0); #endif ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR); #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- load boot.img takes %d ms -------- \n", get_timer(time_load_bootimg)); #endif if (ret < 0) { msg_img_error("Android Boot Image"); } break; } //************* //* relocate rootfs (ignore rootfs header) //* #ifdef CFG_UBOOT_PROFILING time_rootfs = get_timer(0); #endif //if(g_boot_mode == RECOVERY_BOOT) //{ memcpy((char *)CFG_RAMDISK_LOAD_ADDR, (char *)(g_rmem_off), g_rimg_sz); //} g_rmem_off = CFG_RAMDISK_LOAD_ADDR; #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- reloate rootfs takes %d ms -------- \n", get_timer(time_rootfs)); #endif strlen += sprintf(commandline, "%s%s%s", commandline, " uboot_ver=" UBOOT_VERSION_CLI, " uboot_build_ver=" BUILD_VERSION_CLI ); #ifdef CFG_UBOOT_PROFILING ubt = ((unsigned int)get_timer(boot_time)) + 810; strlen += sprintf(commandline, "%s%s%d", commandline, ".ubt.", ubt); #endif custom_port_in_kernel(g_boot_mode, commandline); strlen += sprintf(commandline, "%s lcm=%1d-%s", commandline, DISP_IsLcmFound(), mt65xx_disp_get_lcm_id()); setup_commandline_tag (bd, commandline); //#endif //CONFIG_CMDLINE_TAG //************* //* dump some starting instruction for debug //* //printf(" theKernel (0x%x)\n",g_kmem_off); //printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off,DRV_Reg32(g_kmem_off)); //printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off+0x4,DRV_Reg32(g_kmem_off+0x4)); //printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off+0x8,DRV_Reg32(g_kmem_off+0x8)); //************* //* dump some starting instruction for debug //* //printf("\n rootfs (0x%x)\n",g_rmem_off); //printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off,DRV_Reg32(g_rmem_off)); //printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off+0x4,DRV_Reg32(g_rmem_off+0x4)); //printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off+0x8,DRV_Reg32(g_rmem_off+0x8)); //************* //* specify the kernel jumping address //* theKernel = (void (*)(int, int, uint)) (g_kmem_off); //printf("\n > kernel mem offset (not include header) = 0x%x\n",theKernel); //************* //* specify the rootfs starting address //* initrd_start = g_rmem_off; initrd_end = initrd_start + g_rimg_sz; //printf(" > rootfs mem offset (not include header) = 0x%x\n\n",initrd_start); #ifdef CONFIG_INITRD_TAG if (initrd_start && initrd_end) setup_initrd_tag (bd, initrd_start, initrd_end); #endif #if CONFIG_VIDEOLFB_TAG setup_videolfb_tag ((gd_t *) gd); #endif setup_end_tag (bd); #endif #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- do_nand_boot takes %d ms -------- \n", get_timer(time_do_nand_boot)); printf("[MBOOT] ------- UBoot boot kernel takes %d ms -------- \n", get_timer(boot_time)); #endif printf("NAND BOOT\n"); #ifdef CONFIG_LCD video_printf("NAND BOOT\n"); video_printf("Boot Linux Kernel\n"); #endif //***************** //* to centralize deinit process, moving //* "Uboot_power_saving" to "cleanup_before_linux" //* cleanup_before_linux(); printf(" > kernel mem offset (not include header) = 0x%x\n",theKernel); //***************** //* jump to kernel //* theKernel (0, bd->bi_arch_number, bd->bi_boot_params); return 0; }
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; void (*theKernel)(int zero, int arch, uint params); #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #endif #ifdef CONFIG_MARVELL_TAG char *env; #endif if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; theKernel = (void (*)(int, int, uint))images->ep; s = getenv ("machid"); if (s) { machid = simple_strtoul (s, NULL, 16); printf ("Using machid 0x%x from environment\n", machid); } show_boot_progress (15); debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) || \ defined (CONFIG_LCD) || \ defined (CONFIG_VFD) || \ defined (CONFIG_MARVELL_TAG) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (images->rd_start && images->rd_end) setup_initrd_tag (bd, images->rd_start, images->rd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif #if defined (CONFIG_MARVELL_TAG) env = getenv("passDramInitTag"); if(((strcmp(env,"yes") == 0) || (strcmp(env,"Yes") == 0))) { setup_marvell_tag(); } #endif setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, machid, bd->bi_boot_params); /* does not return */ return 1; }
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; void (*theKernel)(int zero, int arch, uint params); #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #if !CONFIG_MFG #if defined(CONFIG_MX53_BEJ) || defined(CONFIG_MX53_BEJ2) extern char key_status_at_startup[6]; extern char *mx53_bej_boot_version; extern int kernel_dev; char *autorun,*serialno,*macaddr,*testkey; char kpp[16],ver[32],buff[1024]; strncpy(buff,commandline,sizeof(buff)); buff[(sizeof(buff)/sizeof(buff[0]))-1]='\0'; #ifdef CONFIG_SDTEST if((testkey=getenv("testkey")) != NULL){ strncat(buff," kpp=",sizeof(buff)); strncat(buff,testkey,sizeof(buff)); } else { strncat(buff," kpp=M_R-_",sizeof(buff)); } // printf(" %s\n",buff); #else sprintf(kpp," kpp=%s",key_status_at_startup); strncat(buff,kpp,sizeof(buff)); printf(kpp); #endif puts("\n"); sprintf(ver," bootVer=%s",mx53_bej_boot_version); strncat(buff,ver,sizeof(buff)); printf(ver); puts("\n"); if(autorun=getenv("autorun")){ strncat(buff," autorun=\"",sizeof(buff)); strncat(buff,autorun,sizeof(buff)); strncat(buff,"\"",sizeof(buff)); printf(" autorun=\"%s\"\n",autorun); } switch(kernel_dev){ case 10: strncat(buff," kernelfrom=eMMC",sizeof(buff)); printf(" kernelfrom=eMMC\n"); break; case 20: #ifdef CONFIG_SDTEST strncat(buff," kernelfrom=SDcard_test",sizeof(buff)); printf(" kernelfrom=SDcard_test\n"); #else strncat(buff," kernelfrom=SDcard",sizeof(buff)); printf(" kernelfrom=SDcard\n"); #endif break; } if(macaddr=getenv("macaddr")) { strncat(buff," macaddr=",sizeof(buff)); strncat(buff,macaddr,sizeof(buff)); printf(" macaddr=%s\n",macaddr); } if(serialno=getenv("serialno")) { strncat(buff," androidboot.serialno=",sizeof(buff)); strncat(buff,serialno,sizeof(buff)); printf(" serialno=%s\n",serialno); } commandline=buff; #endif #endif #endif if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; theKernel = (void (*)(int, int, uint))images->ep; s = getenv ("machid"); if (s) { machid = simple_strtoul (s, NULL, 16); printf ("Using machid 0x%x from environment\n", machid); } show_boot_progress (15); debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) || \ defined (CONFIG_LCD) || \ defined (CONFIG_VFD) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (¶ms); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (¶ms); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (images->rd_start && images->rd_end) setup_initrd_tag (bd, images->rd_start, images->rd_end); #endif #if defined (CONFIG_VFD) || defined (CONFIG_LCD) setup_videolfb_tag ((gd_t *) gd); #endif setup_end_tag (bd); #endif /* we assume that the kernel is in place */ printf ("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect (void); udc_disconnect (); } #endif cleanup_before_linux (); theKernel (0, machid, bd->bi_boot_params); /* does not return */ return 1; }