hdr = (image_header_t *) (CFG_MONITOR_BASE - image_get_header_size ());
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
info = &flash_info[0];
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405) || defined(CONFIG_PATI)
- if (image_to_cpu (magic[0]) != IH_MAGIC) {
+ if (uimage_to_cpu (magic[0]) != IH_MAGIC) {
puts("Bad Magic number\n");
return -1;
}
int rc;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
int verify, i;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)addr;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
hdr = (image_header_t *)LOAD_ADDR;
#if defined(CONFIG_FIT)
- if (gen_image_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
+ if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) {
puts ("Non legacy image format not supported\n");
return -1;
}
verify = getenv_verify ();
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
/* get length of script */
data = (ulong *)image_get_data (hdr);
- if ((len = image_to_cpu (*data)) == 0) {
+ if ((len = uimage_to_cpu (*data)) == 0) {
puts ("Empty Script\n");
return 1;
}
static void fixup_silent_linux (void);
#endif
-static void *get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[],
+static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag,int argc, char *argv[],
bootm_headers_t *images, ulong *os_data, ulong *os_len);
extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
board_lmb_reserve(&lmb);
/* get kernel image header, start address and length */
- os_hdr = get_kernel (cmdtp, flag, argc, argv,
+ os_hdr = boot_get_kernel (cmdtp, flag, argc, argv,
&images, &os_data, &os_len);
if (os_len == 0)
return 1;
show_boot_progress (6);
/* get image parameters */
- switch (gen_image_get_format (os_hdr)) {
+ switch (genimg_get_format (os_hdr)) {
case IMAGE_FORMAT_LEGACY:
type = image_get_type (os_hdr);
comp = image_get_comp (os_hdr);
image_start = (ulong)os_hdr;
load_end = 0;
- type_name = image_get_type_name (type);
+ type_name = genimg_get_type_name (type);
/*
* We have reached the point of no return: we are going to
}
/**
- * get_kernel - find kernel image
- * @os_data: pointer to a ulong variable, will hold os data start address
- * @os_len: pointer to a ulong variable, will hold os data length
+ * image_get_kernel - verify legacy format kernel image
+ * @img_addr: in RAM address of the legacy format image to be verified
+ * @verify: data CRC verification flag
*
- * get_kernel() tries to find a kernel image, verifies its integrity
- * and locates kernel data.
+ * image_get_kernel() verifies legacy image integrity and returns pointer to
+ * legacy image header if image verification was completed successfully.
*
* returns:
- * pointer to image header if valid image was found, plus kernel start
- * address and length, otherwise NULL
+ * pointer to a legacy image header if valid image was found
+ * otherwise return NULL
*/
static image_header_t *image_get_kernel (ulong img_addr, int verify)
{
}
/**
- * get_kernel - find kernel image
+ * boot_get_kernel - find kernel image
* @os_data: pointer to a ulong variable, will hold os data start address
* @os_len: pointer to a ulong variable, will hold os data length
*
- * get_kernel() tries to find a kernel image, verifies its integrity
+ * boot_get_kernel() tries to find a kernel image, verifies its integrity
* and locates kernel data.
*
* returns:
* pointer to image header if valid image was found, plus kernel start
* address and length, otherwise NULL
*/
-static void *get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+static void *boot_get_kernel (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, ulong *os_data, ulong *os_len)
{
image_header_t *hdr;
printf ("## Booting kernel image at %08lx ...\n", img_addr);
/* copy from dataflash if needed */
- img_addr = gen_get_image (img_addr);
+ img_addr = genimg_get_image (img_addr);
/* check image type, for FIT images get FIT kernel node */
- switch (gen_image_get_format ((void *)img_addr)) {
+ switch (genimg_get_format ((void *)img_addr)) {
case IMAGE_FORMAT_LEGACY:
debug ("* kernel: legacy format image\n");
printf ("\n## Checking Image at %08lx ...\n", addr);
- switch (gen_image_get_format (hdr)) {
+ switch (genimg_get_format (hdr)) {
case IMAGE_FORMAT_LEGACY:
puts (" Legacy image found\n");
if (!image_check_magic (hdr)) {
if (!hdr)
goto next_sector;
- switch (gen_image_get_format (hdr)) {
+ switch (genimg_get_format (hdr)) {
case IMAGE_FORMAT_LEGACY:
if (!image_check_magic (hdr))
goto next_sector;
}
show_boot_progress (38);
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
return 1;
}
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
if (!image_check_magic (hdr)) {
break;
case FPGA_LOADMK:
- switch (gen_image_get_format (fpga_data)) {
+ switch (genimg_get_format (fpga_data)) {
case IMAGE_FORMAT_LEGACY:
{
image_header_t *hdr = (image_header_t *)fpga_data;
}
show_boot_progress (48);
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
}
show_boot_progress (56);
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
}
show_boot_progress (56);
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
return 1;
}
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
return 1;
}
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
hdr = (image_header_t *)addr;
}
- switch (gen_image_get_format ((void *)addr)) {
+ switch (genimg_get_format ((void *)addr)) {
case IMAGE_FORMAT_LEGACY:
printf("## Copying from legacy image at %08lx ...\n", addr);
data += 4;
if (argc > 2 && part > i) {
u_long tail;
- len = image_to_cpu (len_ptr[i]);
+ len = uimage_to_cpu (len_ptr[i]);
tail = len % 4;
data += len;
if (tail) {
printf("Bad Image Part\n");
return 1;
}
- len = image_to_cpu (len_ptr[part]);
+ len = uimage_to_cpu (len_ptr[part]);
#if defined(CONFIG_FIT)
case IMAGE_FORMAT_FIT:
fit_unsupported ("imxtract");
unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
+/*****************************************************************************/
+/* Legacy format routines */
+/*****************************************************************************/
int image_check_hcrc (image_header_t *hdr)
{
ulong hcrc;
return (dcrc == image_get_dcrc (hdr));
}
-int getenv_verify (void)
-{
- char *s = getenv ("verify");
- return (s && (*s == 'n')) ? 0 : 1;
-}
-
-int getenv_autostart (void)
-{
- char *s = getenv ("autostart");
- return (s && (*s == 'n')) ? 0 : 1;
-}
-
-ulong getenv_bootm_low(void)
-{
- char *s = getenv ("bootm_low");
- if (s) {
- ulong tmp = simple_strtoul (s, NULL, 16);
- return tmp;
- }
-
-#ifdef CFG_SDRAM_BASE
- return CFG_SDRAM_BASE;
-#else
- return 0;
-#endif
-}
-
-ulong getenv_bootm_size(void)
-{
- char *s = getenv ("bootm_size");
- if (s) {
- ulong tmp = simple_strtoul (s, NULL, 16);
- return tmp;
- }
-
- return gd->bd->bi_memsize;
-}
-
-void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
-{
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
- while (len > 0) {
- size_t tail = (len > chunksz) ? chunksz : len;
- WATCHDOG_RESET ();
- memmove (to, from, tail);
- to += tail;
- from += tail;
- len -= tail;
- }
-#else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
- memmove (to, from, len);
-#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
-}
-#endif /* USE_HOSTCC */
-
/**
* image_multi_count - get component (sub-image) count
* @hdr: pointer to the header of the multi component image
}
#ifndef USE_HOSTCC
-const char* image_get_os_name (uint8_t os)
+static void image_print_type (image_header_t *hdr)
+{
+ const char *os, *arch, *type, *comp;
+
+ os = genimg_get_os_name (image_get_os (hdr));
+ arch = genimg_get_arch_name (image_get_arch (hdr));
+ type = genimg_get_type_name (image_get_type (hdr));
+ comp = genimg_get_comp_name (image_get_comp (hdr));
+
+ printf ("%s %s %s (%s)", arch, os, type, comp);
+}
+
+void image_print_contents (image_header_t *hdr)
+{
+#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
+ time_t timestamp = (time_t)image_get_time (hdr);
+ struct rtc_time tm;
+#endif
+
+ printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr));
+
+#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
+ to_tm (timestamp, &tm);
+ printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
+ tm.tm_year, tm.tm_mon, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+#endif
+ puts (" Image Type: ");
+ image_print_type (hdr);
+
+ printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr));
+ print_size (image_get_data_size (hdr), "\n");
+ printf (" Load Address: %08x\n"
+ " Entry Point: %08x\n",
+ image_get_load (hdr), image_get_ep (hdr));
+
+ if (image_check_type (hdr, IH_TYPE_MULTI)) {
+ int i;
+ ulong data, len;
+ ulong count = image_multi_count (hdr);
+
+ puts (" Contents:\n");
+ for (i = 0; i < count; i++) {
+ image_multi_getimg (hdr, i, &data, &len);
+ printf (" Image %d: %8ld Bytes = ", i, len);
+ print_size (len, "\n");
+ }
+ }
+}
+
+/**
+ * image_get_ramdisk - get and verify ramdisk image
+ * @cmdtp: command table pointer
+ * @flag: command flag
+ * @argc: command argument count
+ * @argv: command argument list
+ * @rd_addr: ramdisk image start address
+ * @arch: expected ramdisk architecture
+ * @verify: checksum verification flag
+ *
+ * image_get_ramdisk() returns a pointer to the verified ramdisk image
+ * header. Routine receives image start address and expected architecture
+ * flag. Verification done covers data and header integrity and os/type/arch
+ * fields checking.
+ *
+ * If dataflash support is enabled routine checks for dataflash addresses
+ * and handles required dataflash reads.
+ *
+ * returns:
+ * pointer to a ramdisk image header, if image was found and valid
+ * otherwise, return NULL
+ */
+static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
+ int argc, char *argv[],
+ ulong rd_addr, uint8_t arch, int verify)
+{
+ image_header_t *rd_hdr;
+
+ show_boot_progress (9);
+ rd_hdr = (image_header_t *)rd_addr;
+
+ if (!image_check_magic (rd_hdr)) {
+ puts ("Bad Magic Number\n");
+ show_boot_progress (-10);
+ return NULL;
+ }
+
+ if (!image_check_hcrc (rd_hdr)) {
+ puts ("Bad Header Checksum\n");
+ show_boot_progress (-11);
+ return NULL;
+ }
+
+ show_boot_progress (10);
+ image_print_contents (rd_hdr);
+
+ if (verify) {
+ puts(" Verifying Checksum ... ");
+ if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
+ puts ("Bad Data CRC\n");
+ show_boot_progress (-12);
+ return NULL;
+ }
+ puts("OK\n");
+ }
+
+ show_boot_progress (11);
+
+ if (!image_check_os (rd_hdr, IH_OS_LINUX) ||
+ !image_check_arch (rd_hdr, arch) ||
+ !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) {
+ printf ("No Linux %s Ramdisk Image\n",
+ genimg_get_arch_name(arch));
+ show_boot_progress (-13);
+ return NULL;
+ }
+
+ return rd_hdr;
+}
+
+/*****************************************************************************/
+/* Shared dual-format routines */
+/*****************************************************************************/
+int getenv_verify (void)
+{
+ char *s = getenv ("verify");
+ return (s && (*s == 'n')) ? 0 : 1;
+}
+
+int getenv_autostart (void)
+{
+ char *s = getenv ("autostart");
+ return (s && (*s == 'n')) ? 0 : 1;
+}
+
+ulong getenv_bootm_low(void)
+{
+ char *s = getenv ("bootm_low");
+ if (s) {
+ ulong tmp = simple_strtoul (s, NULL, 16);
+ return tmp;
+ }
+
+#ifdef CFG_SDRAM_BASE
+ return CFG_SDRAM_BASE;
+#else
+ return 0;
+#endif
+}
+
+ulong getenv_bootm_size(void)
+{
+ char *s = getenv ("bootm_size");
+ if (s) {
+ ulong tmp = simple_strtoul (s, NULL, 16);
+ return tmp;
+ }
+
+ return gd->bd->bi_memsize;
+}
+
+void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
+{
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+ while (len > 0) {
+ size_t tail = (len > chunksz) ? chunksz : len;
+ WATCHDOG_RESET ();
+ memmove (to, from, tail);
+ to += tail;
+ from += tail;
+ len -= tail;
+ }
+#else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
+ memmove (to, from, len);
+#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+}
+#endif /* USE_HOSTCC */
+
+const char* genimg_get_os_name (uint8_t os)
{
const char *name;
return name;
}
-const char* image_get_arch_name (uint8_t arch)
+const char* genimg_get_arch_name (uint8_t arch)
{
const char *name;
return name;
}
-const char* image_get_type_name (uint8_t type)
+const char* genimg_get_type_name (uint8_t type)
{
const char *name;
return name;
}
-const char* image_get_comp_name (uint8_t comp)
+const char* genimg_get_comp_name (uint8_t comp)
{
const char *name;
return name;
}
-static void image_print_type (image_header_t *hdr)
-{
- const char *os, *arch, *type, *comp;
-
- os = image_get_os_name (image_get_os (hdr));
- arch = image_get_arch_name (image_get_arch (hdr));
- type = image_get_type_name (image_get_type (hdr));
- comp = image_get_comp_name (image_get_comp (hdr));
-
- printf ("%s %s %s (%s)", arch, os, type, comp);
-}
-
-void image_print_contents (image_header_t *hdr)
-{
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
- time_t timestamp = (time_t)image_get_time (hdr);
- struct rtc_time tm;
-#endif
-
- printf (" Image Name: %.*s\n", IH_NMLEN, image_get_name (hdr));
-
-#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
- to_tm (timestamp, &tm);
- printf (" Created: %4d-%02d-%02d %2d:%02d:%02d UTC\n",
- tm.tm_year, tm.tm_mon, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
-#endif
- puts (" Image Type: ");
- image_print_type (hdr);
-
- printf ("\n Data Size: %d Bytes = ", image_get_data_size (hdr));
- print_size (image_get_data_size (hdr), "\n");
- printf (" Load Address: %08x\n"
- " Entry Point: %08x\n",
- image_get_load (hdr), image_get_ep (hdr));
-
- if (image_check_type (hdr, IH_TYPE_MULTI)) {
- int i;
- ulong data, len;
- ulong count = image_multi_count (hdr);
-
- puts (" Contents:\n");
- for (i = 0; i < count; i++) {
- image_multi_getimg (hdr, i, &data, &len);
- printf (" Image %d: %8ld Bytes = ", i, len);
- print_size (len, "\n");
- }
- }
-}
-
/**
- * gen_image_get_format - get image format type
+ * genimg_get_format - get image format type
* @img_addr: image start address
*
- * gen_image_get_format() checks whether provided address points to a valid
+ * genimg_get_format() checks whether provided address points to a valid
* legacy or FIT image.
*
* New uImage format and FDT blob are based on a libfdt. FDT blob
* may be passed directly or embedded in a FIT image. In both situations
- * gen_image_get_format() must be able to dectect libfdt header.
+ * genimg_get_format() must be able to dectect libfdt header.
*
* returns:
* image format type or IMAGE_FORMAT_INVALID if no image is present
*/
-int gen_image_get_format (void *img_addr)
+int genimg_get_format (void *img_addr)
{
ulong format = IMAGE_FORMAT_INVALID;
image_header_t *hdr;
}
/**
- * gen_get_image - get image from special storage (if necessary)
+ * genimg_get_image - get image from special storage (if necessary)
* @img_addr: image start address
*
- * gen_get_image() checks if provided image start adddress is located
+ * genimg_get_image() checks if provided image start adddress is located
* in a dataflash storage. If so, image is moved to a system RAM memory.
*
* returns:
* image start address after possible relocation from special storage
*/
-ulong gen_get_image (ulong img_addr)
+ulong genimg_get_image (ulong img_addr)
{
ulong ram_addr = img_addr;
read_dataflash (img_addr, h_size, (char *)ram_addr);
/* get data size */
- switch (gen_image_get_format ((void *)ram_addr)) {
+ switch (genimg_get_format ((void *)ram_addr)) {
case IMAGE_FORMAT_LEGACY:
d_size = image_get_data_size ((image_header_t *)ram_addr);
debug (" Legacy format image found at 0x%08lx, size 0x%08lx\n",
}
/**
- * image_get_ramdisk - get and verify ramdisk image
- * @cmdtp: command table pointer
- * @flag: command flag
- * @argc: command argument count
- * @argv: command argument list
- * @rd_addr: ramdisk image start address
- * @arch: expected ramdisk architecture
- * @verify: checksum verification flag
- *
- * image_get_ramdisk() returns a pointer to the verified ramdisk image
- * header. Routine receives image start address and expected architecture
- * flag. Verification done covers data and header integrity and os/type/arch
- * fields checking.
- *
- * If dataflash support is enabled routine checks for dataflash addresses
- * and handles required dataflash reads.
- *
- * returns:
- * pointer to a ramdisk image header, if image was found and valid
- * otherwise, return NULL
- */
-static image_header_t* image_get_ramdisk (cmd_tbl_t *cmdtp, int flag,
- int argc, char *argv[],
- ulong rd_addr, uint8_t arch, int verify)
-{
- image_header_t *rd_hdr;
-
- show_boot_progress (9);
- rd_hdr = (image_header_t *)rd_addr;
-
- if (!image_check_magic (rd_hdr)) {
- puts ("Bad Magic Number\n");
- show_boot_progress (-10);
- return NULL;
- }
-
- if (!image_check_hcrc (rd_hdr)) {
- puts ("Bad Header Checksum\n");
- show_boot_progress (-11);
- return NULL;
- }
-
- show_boot_progress (10);
- image_print_contents (rd_hdr);
-
- if (verify) {
- puts(" Verifying Checksum ... ");
- if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) {
- puts ("Bad Data CRC\n");
- show_boot_progress (-12);
- return NULL;
- }
- puts("OK\n");
- }
-
- show_boot_progress (11);
-
- if (!image_check_os (rd_hdr, IH_OS_LINUX) ||
- !image_check_arch (rd_hdr, arch) ||
- !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) {
- printf ("No Linux %s Ramdisk Image\n",
- image_get_arch_name(arch));
- show_boot_progress (-13);
- return NULL;
- }
-
- return rd_hdr;
-}
-
-/**
- * get_ramdisk - main ramdisk handling routine
+ * boot_get_ramdisk - main ramdisk handling routine
* @cmdtp: command table pointer
* @flag: command flag
* @argc: command argument count
* @rd_start: pointer to a ulong variable, will hold ramdisk start address
* @rd_end: pointer to a ulong variable, will hold ramdisk end
*
- * get_ramdisk() is responsible for finding a valid ramdisk image.
+ * boot_get_ramdisk() is responsible for finding a valid ramdisk image.
* Curently supported are the following ramdisk sources:
* - multicomponent kernel/ramdisk image,
* - commandline provided address of decicated ramdisk image.
* rd_start and rd_end are set to 0 if no ramdisk exists
* return 1 if ramdisk image is found but corrupted
*/
-int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, uint8_t arch,
ulong *rd_start, ulong *rd_end)
{
/* copy from dataflash if needed */
printf ("## Loading init Ramdisk Image at %08lx ...\n",
rd_addr);
- rd_addr = gen_get_image (rd_addr);
+ rd_addr = genimg_get_image (rd_addr);
/*
* Check if there is an initrd image at the
* address provided in the second bootm argument
* check image type, for FIT images get FIT node.
*/
- switch (gen_image_get_format ((void *)rd_addr)) {
+ switch (genimg_get_format ((void *)rd_addr)) {
case IMAGE_FORMAT_LEGACY:
debug ("* ramdisk: legacy format image\n");
#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
/**
- * ramdisk_high - relocate init ramdisk
+ * boot_ramdisk_high - relocate init ramdisk
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @rd_data: ramdisk data start address
* @rd_len: ramdisk data length
* @initrd_end: pointer to a ulong variable, will hold final init ramdisk
* end address (after possible relocation)
*
- * ramdisk_high() takes a relocation hint from "initrd_high" environement
+ * boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
* variable and if requested ramdisk data is moved to a specified location.
*
+ * Initrd_start and initrd_end are set to final (after relocation) ramdisk
+ * start/end addresses if ramdisk image start and len were provided,
+ * otherwise set initrd_start and initrd_end set to zeros.
+ *
* returns:
- * - initrd_start and initrd_end are set to final (after relocation) ramdisk
- * start/end addresses if ramdisk image start and len were provided
- * otherwise set initrd_start and initrd_end set to zeros
- * - returns:
- * 0 - success
- * -1 - failure
+ * 0 - success
+ * -1 - failure
*/
-int ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
+int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
ulong *initrd_start, ulong *initrd_end)
{
char *s;
lmb_reserve(lmb, rd_data, rd_len);
} else {
if (initrd_high)
- *initrd_start = lmb_alloc_base(lmb, rd_len, 0x1000, initrd_high);
+ *initrd_start = lmb_alloc_base (lmb, rd_len, 0x1000, initrd_high);
else
- *initrd_start = lmb_alloc(lmb, rd_len, 0x1000);
+ *initrd_start = lmb_alloc (lmb, rd_len, 0x1000);
if (*initrd_start == 0) {
- puts("ramdisk - allocation error\n");
+ puts ("ramdisk - allocation error\n");
goto error;
}
show_boot_progress (12);
printf (" Loading Ramdisk to %08lx, end %08lx ... ",
*initrd_start, *initrd_end);
- memmove_wd((void *)*initrd_start,
+ memmove_wd ((void *)*initrd_start,
(void *)rd_data, rd_len, CHUNKSZ);
puts ("OK\n");
}
debug (" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
*initrd_start, *initrd_end);
+
return 0;
error:
}
/**
- * get_boot_cmdline - allocate and initialize kernel cmdline
+ * boot_get_cmdline - allocate and initialize kernel cmdline
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @cmd_start: pointer to a ulong variable, will hold cmdline start
* @cmd_end: pointer to a ulong variable, will hold cmdline end
* @bootmap_base: ulong variable, holds offset in physical memory to
* base of bootmap
*
- * get_boot_cmdline() allocates space for kernel command line below
+ * boot_get_cmdline() allocates space for kernel command line below
* BOOTMAPSZ + bootmap_base address. If "bootargs" U-boot environemnt
* variable is present its contents is copied to allocated kernel
* command line.
* 0 - success
* -1 - failure
*/
-int get_boot_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
+int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
ulong bootmap_base)
{
char *cmdline;
}
/**
- * get_boot_kbd - allocate and initialize kernel copy of board info
+ * boot_get_kbd - allocate and initialize kernel copy of board info
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @kbd: double pointer to board info data
* @bootmap_base: ulong variable, holds offset in physical memory to
* base of bootmap
*
- * get_boot_kbd() allocates space for kernel copy of board info data below
+ * boot_get_kbd() allocates space for kernel copy of board info data below
* BOOTMAPSZ + bootmap_base address and kernel board info is initialized with
* the current u-boot board info data.
*
* 0 - success
* -1 - failure
*/
-int get_boot_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base)
+int boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base)
{
*kbd = (bd_t *)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
CFG_BOOTMAPSZ + bootmap_base);
#define IH_NMLEN 32 /* Image Name Length */
/*
- * all data in network byte order (aka natural aka bigendian)
+ * Legacy format image header,
+ * all data in network byte order (aka natural aka bigendian).
*/
-
typedef struct image_header {
uint32_t ih_magic; /* Image Header Magic Number */
uint32_t ih_hcrc; /* Image Header CRC Checksum */
typedef struct bootm_headers {
/*
* Legacy os image header, if it is a multi component image
- * then get_ramdisk() and get_fdt() will attempt to get
+ * then boot_get_ramdisk() and get_fdt() will attempt to get
* data from second and third component accordingly.
*/
image_header_t *legacy_hdr_os;
*/
#define CHUNKSZ (64 * 1024)
-#define image_to_cpu(x) ntohl(x)
-#define cpu_to_image(x) htonl(x)
+#define uimage_to_cpu(x) ntohl(x)
+#define cpu_to_uimage(x) htonl(x)
+
+#ifndef USE_HOSTCC
+/* Image format types, returned by _get_format() routine */
+#define IMAGE_FORMAT_INVALID 0x00
+#define IMAGE_FORMAT_LEGACY 0x01 /* legacy image_header based format */
+#define IMAGE_FORMAT_FIT 0x02 /* new, libfdt based format */
+
+int genimg_get_format (void *img_addr);
+ulong genimg_get_image (ulong img_addr);
+
+const char* genimg_get_os_name (uint8_t os);
+const char* genimg_get_arch_name (uint8_t arch);
+const char* genimg_get_type_name (uint8_t type);
+const char* genimg_get_comp_name (uint8_t comp);
+
+int boot_get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+ bootm_headers_t *images, uint8_t arch,
+ ulong *rd_start, ulong *rd_end);
+
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
+int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
+ ulong *initrd_start, ulong *initrd_end);
+
+int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
+ ulong bootmap_base);
+int boot_get_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base);
+#endif /* CONFIG_PPC || CONFIG_M68K */
+#endif /* USE_HOSTCC */
+/*******************************************************************/
+/* Legacy format specific code (prefixed with image_) */
+/*******************************************************************/
static inline uint32_t image_get_header_size (void)
{
return (sizeof (image_header_t));
#define image_get_hdr_l(f) \
static inline uint32_t image_get_##f(image_header_t *hdr) \
{ \
- return image_to_cpu (hdr->ih_##f); \
+ return uimage_to_cpu (hdr->ih_##f); \
}
image_get_hdr_l (magic);
image_get_hdr_l (hcrc);
#define image_set_hdr_l(f) \
static inline void image_set_##f(image_header_t *hdr, uint32_t val) \
{ \
- hdr->ih_##f = cpu_to_image (val); \
+ hdr->ih_##f = cpu_to_uimage (val); \
}
image_set_hdr_l (magic);
image_set_hdr_l (hcrc);
return 1;
}
-const char* image_get_os_name (uint8_t os);
-const char* image_get_arch_name (uint8_t arch);
-const char* image_get_type_name (uint8_t type);
-const char* image_get_comp_name (uint8_t comp);
void image_print_contents (image_header_t *hdr);
-#define IMAGE_FORMAT_INVALID 0x00
-#define IMAGE_FORMAT_LEGACY 0x01 /* legacy image_header based format */
-#define IMAGE_FORMAT_FIT 0x02 /* new, libfdt based format */
-
-int gen_image_get_format (void *img_addr);
-ulong gen_get_image (ulong img_addr);
-
-int get_ramdisk (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
- bootm_headers_t *images, uint8_t arch,
- ulong *rd_start, ulong *rd_end);
-
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
-int ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
- ulong *initrd_start, ulong *initrd_end);
-int get_boot_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end,
- ulong bootmap_base);
-int get_boot_kbd (struct lmb *lmb, bd_t **kbd, ulong bootmap_base);
-#endif /* CONFIG_PPC || CONFIG_M68K */
-
/*******************************************************************/
-/* New uImage format */
+/* New uImage format specific code (prefixed with fit_) */
/*******************************************************************/
#if defined(CONFIG_FIT)
inline int fit_parse_conf (const char *spec, ulong addr_curr,
#define fit_unsupported(msg)
#define fit_unsupported_reset(msg)
#endif /* CONFIG_FIT_VERBOSE */
-
#endif /* CONFIG_FIT */
-
#endif /* USE_HOSTCC */
#endif /* __IMAGE_H__ */
printf ("Using machid 0x%x from environment\n", machid);
}
- get_ramdisk (cmdtp, flag, argc, argv, images,
+ boot_get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_ARM, &initrd_start, &initrd_end);
show_boot_progress (15);
}
theKernel = (void *)ep;
- get_ramdisk (cmdtp, flag, argc, argv, images,
+ boot_get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_AVR32, &initrd_start, &initrd_end);
show_boot_progress (15);
ulong ep;
image_header_t *hdr;
- get_ramdisk (cmdtp, flag, argc, argv, images,
+ boot_get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_I386, &initrd_start, &initrd_end);
if (images->legacy_hdr_valid) {
lmb_reserve(lmb, sp, (CFG_SDRAM_BASE + gd->ram_size - sp));
/* allocate space and init command line */
- ret = get_boot_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
+ ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
if (ret) {
puts("ERROR with allocation of cmdline\n");
goto error;
}
/* allocate space for kernel copy of board info */
- ret = get_boot_kbd (lmb, &kbd, bootmap_base);
+ ret = boot_get_kbd (lmb, &kbd, bootmap_base);
if (ret) {
puts("ERROR with allocation of kernel bd\n");
goto error;
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */
- ret = get_ramdisk (cmdtp, flag, argc, argv, images,
+ ret = boot_get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_M68K, &rd_data_start, &rd_data_end);
if (ret)
goto error;
rd_len = rd_data_end - rd_data_start;
- ret = ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end);
+ ret = boot_ramdisk_high (lmb, rd_data_start, rd_len,
+ &initrd_start, &initrd_end);
if (ret)
goto error;
}
theKernel = (void (*)(int, char **, char **, int *))ep;
- get_ramdisk (cmdtp, flag, argc, argv, images,
+ boot_get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_MIPS, &initrd_start, &initrd_end);
show_boot_progress (15);
#include <fdt_support.h>
static void fdt_error (const char *msg);
-static int get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, char **of_flat_tree, ulong *of_size);
-static int fdt_relocate (struct lmb *lmb, ulong bootmap_base,
+static int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base,
cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
char **of_flat_tree, ulong *of_size);
#endif
#if defined(CONFIG_OF_LIBFDT)
/* find flattened device tree */
- ret = get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size);
+ ret = boot_get_fdt (cmdtp, flag, argc, argv, images, &of_flat_tree, &of_size);
if (ret)
goto error;
if (!of_size) {
/* allocate space and init command line */
- ret = get_boot_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
+ ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
if (ret) {
puts("ERROR with allocation of cmdline\n");
goto error;
}
/* allocate space for kernel copy of board info */
- ret = get_boot_kbd (lmb, &kbd, bootmap_base);
+ ret = boot_get_kbd (lmb, &kbd, bootmap_base);
if (ret) {
puts("ERROR with allocation of kernel bd\n");
goto error;
kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))ep;
/* find ramdisk */
- ret = get_ramdisk (cmdtp, flag, argc, argv, images,
+ ret = boot_get_ramdisk (cmdtp, flag, argc, argv, images,
IH_ARCH_PPC, &rd_data_start, &rd_data_end);
if (ret)
rd_len = rd_data_end - rd_data_start;
#if defined(CONFIG_OF_LIBFDT)
- ret = fdt_relocate (lmb, bootmap_base,
+ ret = boot_relocate_fdt (lmb, bootmap_base,
cmdtp, flag, argc, argv, &of_flat_tree, &of_size);
/*
}
#endif /* CONFIG_OF_LIBFDT */
- ret = ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end);
+ ret = boot_ramdisk_high (lmb, rd_data_start, rd_len, &initrd_start, &initrd_end);
if (ret)
goto error;
return fdt_hdr;
}
-static int get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
+static int boot_get_fdt (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
bootm_headers_t *images, char **of_flat_tree, ulong *of_size)
{
ulong fdt_addr;
fdt_addr);
/* copy from dataflash if needed */
- fdt_addr = gen_get_image (fdt_addr);
+ fdt_addr = genimg_get_image (fdt_addr);
/*
* Check if there is an FDT image at the
* address provided in the second bootm argument
* check image type, for FIT images get a FIT node.
*/
- switch (gen_image_get_format ((void *)fdt_addr)) {
+ switch (genimg_get_format ((void *)fdt_addr)) {
case IMAGE_FORMAT_LEGACY:
debug ("* fdt: legacy format image\n");
return 1;
}
-static int fdt_relocate (struct lmb *lmb, ulong bootmap_base,
+static int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base,
cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
char **of_flat_tree, ulong *of_size)
{
cmdname, file, strerror(errno));
exit (EXIT_FAILURE);
}
- size = cpu_to_image (sbuf.st_size);
+ size = cpu_to_uimage (sbuf.st_size);
} else {
size = 0;
}
pos = image_get_header_size () + ptrs * sizeof(long);
printf ("Contents:\n");
for (i=0; len_ptr[i]; ++i) {
- size = image_to_cpu (len_ptr[i]);
+ size = uimage_to_cpu (len_ptr[i]);
printf (" Image %d: %8d Bytes = %4d kB = %d MB\n",
i, size, size>>10, size>>20);