From c530d9188dbf0d97cab4b38f0a53a28c56a6bd6c Mon Sep 17 00:00:00 2001 From: Zhang Jiejing Date: Wed, 15 Feb 2012 16:40:33 +0800 Subject: ENGR00174536-1 booti: add booti command support. Support booti command which can boot from a boot.img boot.img is a zImage + ramdisk.img + bootargs + boot addr which include these info can be used to avoid mis match between kernel and ramdisk, also can avoid commit to chagne default bootargs. For example: > booti mmc1 command will read the boot.img from 1M offset, and then parser the bootargs and ramdisk then do the boot from that zImage. > booti mmc1 recovery will going to read the recovery's partition no and offset and boot from recovery image. this recovery image also a zImage + ramdisk bootargs: if uboot have define a env var 'bootargs', booti command will use this bootargs as kernel cmdline if you want use boot.img 's bootargs, just type: > setenv bootargs in uboot to clear the bootargs in uboot env. our default uboot env will be NULL in config file. also, android use boot.img to support OTA. Signed-off-by: Zhang Jiejing --- lib_arm/bootm.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'lib_arm') diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c index 128b7e3..f301edb 100644 --- a/lib_arm/bootm.c +++ b/lib_arm/bootm.c @@ -4,6 +4,7 @@ * Marius Groeger * * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) + * Copyright (C) 2012 Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +28,8 @@ #include #include +#include + DECLARE_GLOBAL_DATA_PTR; #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ @@ -131,6 +134,68 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) 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; +#ifdef CONFIG_CMDLINE_TAG + char *commandline = getenv("bootargs"); + + /* If no bootargs env, just use hdr command line */ + if (!commandline) + commandline = hdr->cmdline; + + /* XXX: in production, you should always use boot.img 's cmdline !!! */ + + printf("kernel cmdline: \n\tuse %s command line:\n\t%s \n", + getenv("bootargs") ? "uboot" : "boot.img", + commandline); +#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, bd->bi_arch_number, bd->bi_boot_params); +} #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ @@ -277,3 +342,4 @@ static void setup_end_tag (bd_t *bd) } #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ + -- cgit v1.1