From patchwork Sat Jan 12 17:48:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 211527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A8CFA2C00FF for ; Sun, 13 Jan 2013 04:49:45 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 06C2B4A10B; Sat, 12 Jan 2013 18:49:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3jWKkCEKsQMa; Sat, 12 Jan 2013 18:49:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 79AE94A10D; Sat, 12 Jan 2013 18:49:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99FD04A0FF for ; Sat, 12 Jan 2013 18:49:29 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5eRDiJ+mv6YN for ; Sat, 12 Jan 2013 18:49:28 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wi0-f202.google.com (mail-wi0-f202.google.com [209.85.212.202]) by theia.denx.de (Postfix) with ESMTPS id 29FE34A104 for ; Sat, 12 Jan 2013 18:49:23 +0100 (CET) Received: by mail-wi0-f202.google.com with SMTP id hn17so41653wib.5 for ; Sat, 12 Jan 2013 09:49:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=N47H/ly/hMAWGK9CvzcKs49ZiobQ9eyZhIF20yQSNSs=; b=JRKP3GD6ghQamgJFF4CZmX/iuxD5lqlmdJ0Hz1Ai9yR0N1ewQt+9erBv1E7HDwiB5b K9sHFYabgmg6394O/OpESxqO7n5zWobjyux7ttlE8jL0/hfhhmGvHd568cxi2Kdi89y0 jBIQ2bJ90dL2oI+ZWCr3yzfQBvFBlzO8PvWRkyBwOf4u7XECbeu4RNUgSFymDVMRl2sB q9/yNKs87gw/2+w07aMYcGcHkUSuM6L4ImYV3Pm0a6rzSVEV+o3G2Qh5Xg6alqVjndAl EoRzAaDXpmGpNZlYINvmhJ2k7woyjFaK+0ORVwI5J+zBA2dYuPOAGNcEz2C1lOk0H3ko QH/g== X-Received: by 10.14.0.196 with SMTP id 44mr100907809eeb.6.1358012963477; Sat, 12 Jan 2013 09:49:23 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id g9si3260026eeo.1.2013.01.12.09.49.23 (version=TLSv1 cipher=AES128-SHA bits=128/128); Sat, 12 Jan 2013 09:49:23 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id CECFC200059; Sat, 12 Jan 2013 09:49:22 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 31FE1160A1E; Sat, 12 Jan 2013 09:49:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sat, 12 Jan 2013 09:48:48 -0800 Message-Id: <1358012928-2112-5-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1358012928-2112-1-git-send-email-sjg@chromium.org> References: <1358012928-2112-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQncM1sxUjSDbPxxWrZlPzK2YsdSNiPVs+EZz1vzcG+JyF1TNZsL8+jw69FpUWVx479wB5Z+bLE8x+LXb/zpRhGdhwQi0u9JPiCRZA7Q5vtIMKR7anJh2NrMg/iaqUDyUibbc/BPpWK3kAbozTSs2lpxcY6u9IGJZsA/VkH4IxS8eTdcsPPYD8an40duXE1laLepFdtt Cc: Graeme Russ , Vadim Bendebury Subject: [U-Boot] [RFC PATCH 4/4] x86: Support loading kernel setup from a FIT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Add a new setup@ section to the FIT which can be used to provide a setup binary for booting Linux on x86. This makes it possible to boot x86 from a FIT. Signed-off-by: Simon Glass --- common/cmd_bootm.c | 22 +++++++++++++- common/image-fit.c | 20 +++++++++++++ common/image.c | 11 +++++++ doc/uImage.FIT/kernel.its | 50 +++++++++++++++++++++++++++++++++ doc/uImage.FIT/source_file_format.txt | 23 ++++++++------ include/bootstage.h | 3 ++ include/image.h | 13 ++++++++ 7 files changed, 130 insertions(+), 12 deletions(-) diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index de3dfc5..35fc4bf 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -215,6 +216,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] images.os.end = image_get_image_end(os_hdr); images.os.load = image_get_load(os_hdr); + images.os.arch = image_get_arch(os_hdr); break; #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: @@ -239,6 +241,12 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] return 1; } + if (fit_image_get_arch(images.fit_hdr_os, + images.fit_noffset_os, &images.os.arch)) { + puts("Can't get image ARCH!\n"); + return 1; + } + images.os.end = fit_get_end(images.fit_hdr_os); if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os, @@ -254,8 +262,18 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] return 1; } - /* find kernel entry point */ - if (images.legacy_hdr_valid) { + /* If we have a valid setup.bin, we will use that for entry (x86) */ + if (images.os.arch == IH_ARCH_I386) { + ulong len; + + puts("Looking for setup\n"); + ret = boot_get_setup(&images, IH_ARCH_I386, &images.ep, &len); + if (ret < 0 && ret != -ENOENT) { + puts("Could not find a valid setup.bin for x86n"); + return 1; + } + /* Kernel entry point is the setup.bin */ + } else if (images.legacy_hdr_valid) { images.ep = image_get_ep(&images.legacy_hdr_os_copy); #if defined(CONFIG_FIT) } else if (images.fit_uname_os) { diff --git a/common/image-fit.c b/common/image-fit.c index 9f3ece2..04093a0 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1654,3 +1654,23 @@ int fit_image_load(bootm_headers_t *images, const char *prop_name, ulong addr, return noffset; } + +int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch, + ulong *setup_start, ulong *setup_len) +{ + int noffset; + ulong addr; + ulong len; + int ret; + + addr = map_to_sysmem(images->fit_hdr_os); + noffset = fit_get_node_from_config(images, FIT_SETUP_PROP, addr); + if (noffset < 0) + return noffset; + + ret = fit_image_load(images, FIT_SETUP_PROP, addr, NULL, NULL, + arch, IH_TYPE_X86_SETUP, BOOTSTAGE_ID_FIT_SETUP_START, + FIT_LOAD_REQUIRED, setup_start, &len); + + return ret; +} diff --git a/common/image.c b/common/image.c index 26b9653..7c44bc7 100644 --- a/common/image.c +++ b/common/image.c @@ -151,6 +151,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_SCRIPT, "script", "Script", }, { IH_TYPE_STANDALONE, "standalone", "Standalone Program", }, { IH_TYPE_UBLIMAGE, "ublimage", "Davinci UBL image",}, + { IH_TYPE_X86_SETUP, "x86_setup", "x86 setup.bin", }, { -1, "", "", }, }; @@ -1064,6 +1065,16 @@ error: } #endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */ +int boot_get_setup(bootm_headers_t *images, uint8_t arch, + ulong *setup_start, ulong *setup_len) +{ +#if defined(CONFIG_FIT) + return boot_get_setup_fit(images, arch, setup_start, setup_len); +#else + return -ENOENT; +#endif +} + #ifdef CONFIG_SYS_BOOT_GET_CMDLINE /** * boot_get_cmdline - allocate and initialize kernel cmdline diff --git a/doc/uImage.FIT/kernel.its b/doc/uImage.FIT/kernel.its index ef3ab8f..1b662aa 100644 --- a/doc/uImage.FIT/kernel.its +++ b/doc/uImage.FIT/kernel.its @@ -35,3 +35,53 @@ }; }; }; + + + +For x86 a setup node is also required: + +/dts-v1/; + +/ { + description = "Simple image with single Linux kernel on x86"; + #address-cells = <1>; + + images { + kernel@1 { + description = "Vanilla Linux kernel"; + data = /incbin/("./Image"); + type = "kernel"; + arch = "x86"; + os = "linux"; + compression = "lzo"; + load = <00000000>; + entry = <00000000>; + hash@2 { + algo = "sha1"; + }; + }; + + setup@1 { + description = "Linux setup.bin"; + data = /incbin/("./setup.bin"); + type = "setup"; + arch = "x86"; + os = "linux"; + compression = "none"; + load = <00100000>; + entry = <00100000>; + hash@2 { + algo = "sha1"; + }; + }; + }; + + configurations { + default = "config@1"; + config@1 { + description = "Boot Linux kernel"; + kernel = "kernel@1"; + setup = "setup@1"; + }; + }; +}; diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt index 6d20707..b0d9a71 100644 --- a/doc/uImage.FIT/source_file_format.txt +++ b/doc/uImage.FIT/source_file_format.txt @@ -55,7 +55,7 @@ FIT is formally a flattened device tree (in the libfdt meaning), which conforms to bindings defined in this document. .its - image tree source -.itb - image tree blob +.fit - flattened image tree blob c) Image building procedure @@ -101,15 +101,15 @@ Root node of the uImage Tree should have the following layout: | o images | | - | o img@1 {...} - | o img@2 {...} + | o image@1 {...} + | o image@2 {...} | ... | o configurations - |- default = "cfg@1" + |- default = "conf@1" | - o cfg@1 {...} - o cfg@2 {...} + o conf@1 {...} + o conf@2 {...} ... @@ -159,11 +159,11 @@ the '/images' node should have the following layout: - description : Textual description of the component sub-image - type : Name of component sub-image type, supported types are: "standalone", "kernel", "ramdisk", "firmware", "script", "filesystem", - "fdt". + "fdt" and others (see uimage_type in common/images.c). - data : Path to the external file which contains this node's binary data. - compression : Compression used by included data. Supported compressions - are "gzip" and "bzip2". If no compression is used compression property - should be set to "none". + include "gzip" and "bzip2" (see uimage_comp in common/images.c). If no + compression is used, the compression property should be set to "none". Conditionally mandatory property: - os : OS name, mandatory for type="kernel", valid OS names are: "openbsd", @@ -173,7 +173,8 @@ the '/images' node should have the following layout: - arch : Architecture name, mandatory for types: "standalone", "kernel", "firmware", "ramdisk" and "fdt". Valid architecture names are: "alpha", "arm", "i386", "ia64", "mips", "mips64", "ppc", "s390", "sh", "sparc", - "sparc64", "m68k", "microblaze", "nios2", "blackfin", "avr32", "st200". + "sparc64", "m68k", "microblaze", "nios2", "blackfin", "avr32", "st200", + "sandbox". - entry : entry point address, address size is determined by '#address-cells' property of the root node. Mandatory for for types: "standalone" and "kernel". @@ -246,6 +247,8 @@ o config@1 node of a "ramdisk" type). - fdt : Unit name of the corresponding fdt blob (component image node of a "fdt type"). + - setup : Unit name of the corresponding setup binary (used for booting + an x86 kernel). This contains the setup.bin file built by the kernel. The FDT blob is required to properly boot FDT based kernel, so the minimal configuration for 2.6 FDT kernel is (kernel, fdt) pair. diff --git a/include/bootstage.h b/include/bootstage.h index 2a28e23..a7f41ce 100644 --- a/include/bootstage.h +++ b/include/bootstage.h @@ -174,6 +174,9 @@ enum bootstage_id { /* Next 10 IDs used by BOOTSTAGE_SUB_... */ BOOTSTAGE_ID_FIT_RD_START = 120, /* Ramdisk stages */ + /* Next 10 IDs used by BOOTSTAGE_SUB_... */ + BOOTSTAGE_ID_FIT_SETUP_START = 130, /* x86 setup stages */ + BOOTSTAGE_ID_IDE_FIT_READ = 140, BOOTSTAGE_ID_IDE_FIT_READ_OK, diff --git a/include/image.h b/include/image.h index a724926..dc61823 100644 --- a/include/image.h +++ b/include/image.h @@ -201,6 +201,7 @@ struct lmb; #define IH_TYPE_AISIMAGE 13 /* TI Davinci AIS Image */ #define IH_TYPE_KERNEL_NOLOAD 14 /* OS Kernel Image, can run from any load address */ #define IH_TYPE_PBLIMAGE 15 /* Freescale PBL Boot Image */ +#define IH_TYPE_X86_SETUP 16 /* x86 setup.bin Image */ /* * Compression Types @@ -241,6 +242,7 @@ typedef struct image_info { ulong image_start, image_len; /* start of image within blob, len of image */ ulong load; /* load addr for the image */ uint8_t comp, type, os; /* compression, type of image, os type */ + uint8_t arch; /* CPU architecture */ } image_info_t; /* @@ -271,6 +273,10 @@ typedef struct bootm_headers { void *fit_hdr_fdt; /* FDT blob FIT image header */ const char *fit_uname_fdt; /* FDT blob subimage node unit name */ int fit_noffset_fdt;/* FDT blob subimage node offset */ + + void *fit_hdr_setup; /* x86 setup FIT image header */ + const char *fit_uname_setup; /* x86 setup subimage node name */ + int fit_noffset_setup;/* x86 setup subimage node offset */ #endif #ifndef USE_HOSTCC @@ -381,6 +387,9 @@ enum fit_load_op { FIT_LOAD_REQUIRED, /* Must be provided */ }; +int boot_get_setup(bootm_headers_t *images, uint8_t arch, ulong *setup_start, + ulong *setup_len); + #ifndef USE_HOSTCC /* Image format types, returned by _get_format() routine */ #define IMAGE_FORMAT_INVALID 0x00 @@ -394,6 +403,9 @@ ulong genimg_get_image(ulong img_addr); int boot_get_ramdisk(int argc, char * const argv[], bootm_headers_t *images, uint8_t arch, ulong *rd_start, ulong *rd_end); +int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch, + ulong *setup_start, ulong *setup_len); + /** * fit_image_load() - load an image from a FIT * @@ -662,6 +674,7 @@ int image_setup_linux(bootm_headers_t *images); #define FIT_RAMDISK_PROP "ramdisk" #define FIT_FDT_PROP "fdt" #define FIT_DEFAULT_PROP "default" +#define FIT_SETUP_PROP "setup" #define FIT_MAX_HASH_LEN 20 /* max(crc32_len(4), sha1_len(20)) */