int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { void (*theKernel) (int, char **, char **, int *); char *bootargs = getenv("bootargs"); char *start; uint len; /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep; bootstage_mark(BOOTSTAGE_ID_RUN_OS); debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); gd->bd->bi_boot_params = gd->bd->bi_memstart + (16 << 20) - 256; debug("%-12s= 0x%08lX\n", "boot_params", (ulong)gd->bd->bi_boot_params); /* set Magic */ *(int32_t *)(gd->bd->bi_boot_params - 4) = 0x12345678; /* set ram_size */ *(int32_t *)(gd->bd->bi_boot_params - 8) = gd->ram_size; start = (char *)gd->bd->bi_boot_params; len = strlen(bootargs); strncpy(start, bootargs, len + 1); start += len; len = images->rd_end - images->rd_start; if (len > 0) { start += sprintf(start, " rd_start=0x%08X rd_size=0x%0X", (uint) UNCACHED_SDRAM(images->rd_start), (uint) len); } /* we assume that the kernel is in place */ printf("\nStarting kernel ...\n\n"); theKernel(0, NULL, NULL, 0); /* does not return */ return 1; }
void boot_kernel(void) { void (*theKernel)(int zero, int arch, unsigned int params); /* 将Linux内核读取到DDR中 */ printf("\n\rRead kernel from Nand Flash\n\r"); nand_read(0x21000000, 0x400000, 0x800000); /* 设置启动参数 */ printf("Set boot params\n\r"); init_taglist(); /* 跳转执行*/ printf("Boot kernel...\n\r"); theKernel = (void (*)(int, int, unsigned int))0x21000040;/* Linux 内核入口地址 */ theKernel(0, 3466, 0x22000000); /* 第一个参数是0,第二个参数是机器码,第三个参数是启动参数地址 */ }
int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { void (*theKernel)(int magic, void *tagtable); struct tag *params, *params_start; char *commandline = getenv("bootargs"); /* * allow the PREP bootm subcommand, it is required for bootm to work * * TODO: Andreas Bießmann <*****@*****.**> refactor the * do_bootm_linux() for avr32 */ if (flag & BOOTM_STATE_OS_PREP) return 0; if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; theKernel = (void *)images->ep; bootstage_mark(BOOTSTAGE_ID_RUN_OS); params = params_start = (struct tag *)gd->bd->bi_boot_params; params = setup_start_tag(params); params = setup_memory_tags(params); if (images->rd_start) { params = setup_ramdisk_tag(params, PHYSADDR(images->rd_start), PHYSADDR(images->rd_end)); } params = setup_commandline_tag(params, commandline); params = setup_clock_tags(params); params = setup_ethernet_tags(params); params = setup_boardinfo_tag(params); setup_end_tag(params); printf("\nStarting kernel at %p (params at %p)...\n\n", theKernel, params_start); prepare_to_boot(); theKernel(ATAG_MAGIC, params_start); /* does not return */ return 1; }
static void boot_jump_linux(bootm_headers_t *images) { void (*theKernel) (int, char **, char **, int *); /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep; debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); bootstage_mark(BOOTSTAGE_ID_RUN_OS); /* we assume that the kernel is in place */ printf("\nStarting kernel ...\n\n"); theKernel(linux_argc, linux_argv, linux_env, 0); }
void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], bootm_headers_t *images) { /* First parameter is mapped to $r5 for kernel boot args */ void (*theKernel) (char *); char *commandline = getenv ("bootargs"); ulong ep = 0; /* find kernel entry point */ if (images->legacy_hdr_valid) { ep = image_get_ep (images->legacy_hdr_os); #if defined(CONFIG_FIT) } else if (images->fit_uname_os) { int 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 (*)(char *))ep; show_boot_progress (15); #ifdef DEBUG printf ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); #endif if (!images->autostart) return ; theKernel (commandline); /* does not return */ return; error: if (images->autostart) do_reset (cmdtp, flag, argc, argv); return; }
void down_kernel(void) { void (*theKernel)(int zero, int arch, unsigned int params); printf("download linux kernel through ymodem\n\r"); char *addr = (char *)0x21000000; ymodem_recv(addr); /* 设置启动参数 */ printf("Set boot params\n\r"); init_taglist(); /* 跳转执行*/ printf("Boot kernel...\n\r"); theKernel = (void (*)(int, int, unsigned int))0x21000040;/* Linux 内核入口地址 */ theKernel(0, 3466, 0x22000000); /* 第一个参数是0,第二个参数是机器码,第三个参数是启动参数地址 */ }
void boot_linux() { //1. 获取Linux启动地址 theKernel = (void (*)(int , int , unsigned int ))SDRAM_KERNEL_START; //2. 设置启动参数 //2.1 设置核心启动参数 setup_core_tag(); //2.2 设置内存参数 setup_mem_tag(); //2.3 设置命令行参数 setup_cmdline_tag(); //2.4 设置参数结束标志 setup_end_tag(); //3. 启动Linux系统 theKernel(0,168,SDRAM_TAGS_START); }
int start_linux(void) { void (*theKernel)(uint32_t zero, uint32_t arch, uint32_t *params); uint32_t i = 0, j = 0,ret; uint32_t *exec_at = ZIMAGE_LOAD_ADDRESS; uint32_t *parm_at = (uint32_t *)( DRAM_BASE + 0x100) ; // 256 bytes away from the base address of DRAM uint32_t machine_type; debug_print("about to copy linux image to load address: "); uart_print_address(exec_at); ret = load_image((uint32_t)ZIMAGE_START_BLOCK_NUMBER,(uint32_t*)exec_at,(uint16_t)ZIMAGE_BLOCK_SIZE); /* copy image into RAM */ debug_print("done copying linux image ...\n\r\0"); // debug_print("about to copy ramdisk image ..."); // load_image((uint32_t*) INITRD_LOAD_ADDRESS, INITRD_LOAD_END_ADDRESS);/* copy initial ramdisk image into RAM */ // debug_print("done copying ramdisk image ..."); debug_print("setting up ATAGS ...\n\r\0"); setup_tags(parm_at); /* sets up parameters */ machine_type = 3466; /* get machine type */ theKernel = (void (*)(uint32_t, uint32_t, uint32_t*))exec_at; /* set the kernel address */ debug_print("jumping to the kernel ... brace yourself!\n\r\0"); asm("mrc p15, 0, r1, c1, c0, 0"); /* Read Control Register configuration data*/ asm("bic r1, r1, #(0x1 << 12)"); /* Disable I Cache*/ asm("bic r1, r1, #(0x1 << 2)"); /* Disable D Cache*/ asm("mcr p15, 0, r1, c1, c0, 0"); /* Write Control Register configuration data*/ theKernel(0, machine_type, parm_at); /* jump to kernel with register set */ return 0; }
//control passed here from bootTestCrt.S after creating stack int boot(){ uint32 *STORE1 = (uint32 *)0x4090002c; //Use RTC alarms as uint32 *STORE2 = (uint32 *)0x40900030; // storage for debugging int i,j; *STORE1 = 0x98765; setupLEDs(); setLEDs(GREEN); uint32 *kernel = (uint32 *)(RAM_START + KERNEL_OFFSET); uint32 *tags = (uint32 *)(RAM_START + TAGS_OFFSET); uint32 cs; setLEDs(GREEN); //now we need to copy the kernel code to where it likes to be cs = copyMem((uint32*)kernel_start,kernel, (kernel_end - kernel_start)); if(cs != KERN_CHECKSUM) error(5,0); setup_tags(tags); setLEDs(BLUE); uint32 mtype = MACH_TYPE_HPIPAQ214; void (*theKernel)(uint32 zero, uint32 mtype, uint32 *tags); theKernel = (void (*)(uint32, uint32, uint32 *))kernel; /* set the kernel address */ theKernel(0, mtype, tags); /* jump to kernel with register set */ death: __asm("nop"); goto death; }
int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images) { void (*theKernel)(int magic, void *tagtable); struct tag *params, *params_start; char *commandline = getenv("bootargs"); if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; theKernel = (void *)images->ep; show_boot_progress (15); params = params_start = (struct tag *)gd->bd->bi_boot_params; params = setup_start_tag(params); params = setup_memory_tags(params); if (images->rd_start) { params = setup_ramdisk_tag(params, PHYSADDR(images->rd_start), PHYSADDR(images->rd_end)); } params = setup_commandline_tag(params, commandline); params = setup_clock_tags(params); params = setup_ethernet_tags(params); params = setup_boardinfo_tag(params); setup_end_tag(params); printf("\nStarting kernel at %p (params at %p)...\n\n", theKernel, params_start); prepare_to_boot(); theKernel(ATAG_MAGIC, params_start); /* does not return */ return 1; }
int do_booti(struct bootloader_ops *boot_ops, char *info, void *download_addr) { boot_img_hdr *hdr; u32 addr; u64 sector1, sector2; char *ptn = "boot"; int boot_from_mmc = 0; u64 num_sectors = 0; int sector_sz = 0; int ret = 0; unsigned dbt_addr = CONFIG_ADDR_ATAGS; unsigned cfg_machine_type = CONFIG_BOARD_MACH_TYPE; void (*theKernel)(int zero, int arch, void *); if (!(strcmp(info, "storage"))) boot_from_mmc = 1; if (download_addr != NULL) addr = (u32) download_addr; else addr = CONFIG_ADDR_DOWNLOAD; hdr = (boot_img_hdr *) addr; if (boot_from_mmc) { struct fastboot_ptentry *pte; ret = load_ptbl(boot_ops->storage_ops, 0); if (ret != 0) goto fail; dbt_addr = load_dev_tree(boot_ops, dbt_addr); if (dbt_addr < 0) goto fail; pte = fastboot_flash_find_ptn(ptn); if (!pte) { printf("booti: cannot find '%s' partition\n", ptn); goto fail; } sector_sz = boot_ops->storage_ops->get_sector_size(); num_sectors = sizeof(boot_img_hdr) / sector_sz; ret = boot_ops->storage_ops->read(pte->start, num_sectors, (void *) hdr); if (ret != 0) { printf("booti: failed to read bootimg header\n"); goto fail; } else bootimg_print_image_hdr(hdr); ret = memcmp(hdr->magic, BOOT_MAGIC, 8); if (ret != 0) { printf("booti: bad boot image magic\n"); goto fail; } sector1 = pte->start + (hdr->page_size / sector_sz); sector2 = sector1 + ALIGN(hdr->kernel_size, hdr->page_size) / sector_sz; num_sectors = CEIL(hdr->kernel_size, sector_sz); if (num_sectors <= (hdr->kernel_size / sector_sz)) num_sectors = (hdr->kernel_size / sector_sz); DBG("Reading kernel from start sector %d and reading %d " "number of sectors\n", (int)sector1, (int)num_sectors); ret = boot_ops->storage_ops->read(sector1, num_sectors, (void *) hdr->kernel_addr); if (ret != 0) { printf("mmc read failed\n"); goto fail; } DBG("Done reading kernel from mmc\n"); num_sectors = CEIL(hdr->ramdisk_size, sector_sz); if (num_sectors <= (hdr->ramdisk_size / sector_sz)) num_sectors = (hdr->ramdisk_size / sector_sz); DBG("Reading ramdisk from start sector %d and reading %d " "number of sectors\n", (int)sector2, (int)num_sectors); ret = boot_ops->storage_ops->read(sector2, num_sectors, (void *) hdr->ramdisk_addr); if (ret != 0) { printf("mmc read failed\n"); goto fail; } DBG("Done reading ramdisk from mmc\n"); } else { u32 kaddr, raddr; DBG("user wants to boot an image downloaded using " "fastboot\n"); ret = memcmp(hdr->magic, BOOT_MAGIC, 8); if (ret != 0) { printf("booti: bad boot image magic\n"); goto fail; } bootimg_print_image_hdr(hdr); kaddr = addr + hdr->page_size; raddr = kaddr + ALIGN(hdr->kernel_size, hdr->page_size); memmove((void *) hdr->kernel_addr, (void *)kaddr, hdr->kernel_size); memmove((void *) hdr->ramdisk_addr, (void *)raddr, hdr->ramdisk_size); } printf("kernel @ %08x (%d)\n", hdr->kernel_addr, hdr->kernel_size); printf("ramdisk @ %08x (%d)\n", hdr->ramdisk_addr, hdr->ramdisk_size); #if defined CONFIG_OMAP4_ANDROID_CMD_LINE || \ defined CONFIG_OMAP5_ANDROID_CMD_LINE boot_settings(boot_ops, &hdr[0], CONFIG_ADDR_ATAGS); #endif #if defined START_HYPERVISOR_MODE && defined CONFIG_IS_OMAP5 if (!(strcmp(boot_ops->proc_ops->proc_get_type(), "GP"))) { printf("Starting ARM Hyp mode\n"); start_hyp_mode(MONITOR_API_START_HYPERVISOR); } #endif theKernel = (void (*)(int, int, void *))(hdr->kernel_addr); printf("booting kernel...\n"); theKernel(0, cfg_machine_type, (void *)dbt_addr); fail: ret = boot_ops->usb_ops->usb_open(boot_ops->usb_ops->usb, INIT_USB, boot_ops->proc_ops); if (ret != 0) { printf("\nusb_open failed\n"); return ret; } do_fastboot(boot_ops); 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; void (*theKernel)(int magic, void *tagtable); struct tag *params, *params_start; char *commandline = getenv("bootargs"); int ret; /* find kernel entry point */ if (images->legacy_hdr_valid) { ep = image_get_ep (images->legacy_hdr_os); #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 *)ep; ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_AVR32, &initrd_start, &initrd_end); if (ret) goto error; show_boot_progress (15); params = params_start = (struct tag *)gd->bd->bi_boot_params; params = setup_start_tag(params); params = setup_memory_tags(params); if (initrd_start) { params = setup_ramdisk_tag(params, PHYSADDR(initrd_start), PHYSADDR(initrd_end)); } params = setup_commandline_tag(params, commandline); params = setup_clock_tags(params); params = setup_ethernet_tags(params); setup_end_tag(params); if (!images->autostart) return ; printf("\nStarting kernel at %p (params at %p)...\n\n", theKernel, params_start); prepare_to_boot(); theKernel(ATAG_MAGIC, params_start); /* does not return */ return; error: if (images->autostart) do_reset (cmdtp, flag, argc, argv); return; }
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); }
int start_linux(void) { void (*theKernel)(uint32_t zero, uint32_t arch, uint32_t *params); uint32_t i = 0, j = 0,ret; load_addr = (uint32_t) ZIMAGE_LOAD_ADDRESS; uint32_t *exec_at = ZIMAGE_LOAD_ADDRESS; uint32_t *parm_at = (uint32_t *)( DRAM_BASE + 0x100) ; // 256 bytes away from the base address of DRAM uint32_t machine_type; // debug_print("about to copy linux image to load address: "); // uart_print_address(exec_at); // ret = load_image((uint32_t)ZIMAGE_START_BLOCK_NUMBER,(uint32_t*)exec_at,(uint16_t)2666); /* copy image into RAM */ // debug_print("done copying linux image ...\n\r"); // debug_print("about to copy ramdisk image ..."); // load_image((uint32_t*) INITRD_LOAD_ADDRESS, INITRD_LOAD_END_ADDRESS);/* copy initial ramdisk image into RAM */ // debug_print("done copying ramdisk image ..."); theKernel = (void (*)(uint32_t, uint32_t, uint32_t*))exec_at; /* set the kernel address */ print_format("Setting up timers next ...\n\r"); init_system_timer(); init_timer(); // uint32_t start_time = get_timer(0); // // while(1){ // print_format("time difference in ms is %d\n\r",start_time - get_timer(0)); // udelay(1000000); // } print_format("fetching kernel ... \n\r"); net_loop(TFTPGET); // net_loop(ARP); print_format("kernel loaded to RAM ...\n\r"); debug_print("setting up ATAGS ...\n\r"); setup_tags(parm_at); /* sets up parameters */ machine_type = 3466; /* get machine type */ debug_print("jumping to the kernel ... brace yourself!\n\r\0"); asm("mrc p15, 0, r1, c1, c0, 0"); /* Read Control Register configuration data*/ asm("bic r1, r1, #(0x1 << 12)"); /* Disable I Cache*/ asm("bic r1, r1, #(0x1 << 2)"); /* Disable D Cache*/ asm("mcr p15, 0, r1, c1, c0, 0"); /* Write Control Register configuration data*/ theKernel(0, machine_type, parm_at); /* jump to kernel with registers set */ // uint32_t start_time = get_timer(0); // while(1){ // print_format("time difference in ms is %d\n\r",get_timer(start_time)); // udelay(1000000); // } 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"); #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; }
void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], unsigned long addr, unsigned long *len_ptr, int verify) { unsigned long data, len = 0; unsigned long initrd_start, initrd_end; unsigned long image_start, image_end; unsigned long checksum; void (*theKernel)(int magic, void *tagtable); image_header_t *hdr; struct tag *params, *params_start; char *commandline = getenv("bootargs"); hdr = (image_header_t *)addr; image_start = addr; image_end = addr + hdr->ih_size; theKernel = (void *)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); memcpy(&header, (char *)addr, sizeof(header)); hdr = &header; if (ntohl(hdr->ih_magic) != IH_MAGIC) { puts("Bad Magic Number\n"); show_boot_progress (-10); do_reset(cmdtp, flag, argc, argv); } data = (unsigned long)hdr; len = sizeof(*hdr); checksum = ntohl(hdr->ih_hcrc); hdr->ih_hcrc = 0; if (crc32(0, (unsigned char *)data, len) != checksum) { puts("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(header); len = ntohl(hdr->ih_size); if (verify) { unsigned long csum = 0; puts(" Verifying Checksum ... "); csum = crc32(0, (unsigned char *)data, len); if (csum != ntohl(hdr->ih_dcrc)) { puts("Bad Data CRC\n"); show_boot_progress (-12); do_reset(cmdtp, flag, argc, argv); } puts("OK\n"); } show_boot_progress (11); if ((hdr->ih_os != IH_OS_LINUX) || (hdr->ih_arch != IH_CPU_AVR32) || (hdr->ih_type != IH_TYPE_RAMDISK)) { puts("Not a Linux/AVR32 RAMDISK image\n"); show_boot_progress (-13); do_reset(cmdtp, flag, argc, argv); } } 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; } if (data) { initrd_start = data; initrd_end = initrd_start + len; } else { initrd_start = 0; initrd_end = 0; } show_boot_progress (15); params = params_start = (struct tag *)gd->bd->bi_boot_params; params = setup_start_tag(params); params = setup_memory_tags(params); if (initrd_start) { params = setup_ramdisk_tag(params, PHYSADDR(initrd_start), PHYSADDR(initrd_end)); } params = setup_commandline_tag(params, commandline); params = setup_clock_tags(params); params = setup_ethernet_tags(params); setup_end_tag(params); printf("\nStarting kernel at %p (params at %p)...\n\n", theKernel, params_start); prepare_to_boot(); theKernel(ATAG_MAGIC, params_start); }
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"); #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; }
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_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; }
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); }
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 * const argv[], bootm_headers_t *images) { void (*theKernel) (int, char **, char **, int *); char *commandline = getenv("bootargs"); char env_buf[12]; char *cp; if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; /* find kernel entry point */ theKernel = (void (*)(int, char **, char **, int *))images->ep; bootstage_mark(BOOTSTAGE_ID_RUN_OS); #ifdef DEBUG printf("## Transferring control to Linux (at address %08lx) ...\n", (ulong) theKernel); #endif linux_params_init(UNCACHED_SDRAM(gd->bd->bi_boot_params), commandline); #ifdef CONFIG_MEMSIZE_IN_BYTES sprintf(env_buf, "%lu", (ulong)gd->ram_size); debug("## Giving linux memsize in bytes, %lu\n", (ulong)gd->ram_size); #else sprintf(env_buf, "%lu", (ulong)(gd->ram_size >> 20)); debug("## Giving linux memsize in MB, %lu\n", (ulong)(gd->ram_size >> 20)); #endif /* CONFIG_MEMSIZE_IN_BYTES */ linux_env_set("memsize", env_buf); sprintf(env_buf, "0x%08X", (uint) UNCACHED_SDRAM(images->rd_start)); linux_env_set("initrd_start", env_buf); sprintf(env_buf, "0x%X", (uint) (images->rd_end - images->rd_start)); linux_env_set("initrd_size", env_buf); sprintf(env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart)); linux_env_set("flash_start", env_buf); sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize)); linux_env_set("flash_size", env_buf); cp = getenv("ethaddr"); if (cp) linux_env_set("ethaddr", cp); cp = getenv("eth1addr"); if (cp) linux_env_set("eth1addr", cp); /* we assume that the kernel is in place */ printf("\nStarting kernel ...\n\n"); theKernel(linux_argc, linux_argv, linux_env, 0); /* does not return */ return 1; }