2 * (C) Copyright 2007 Michal Simek
3 * (C) Copyright 2004 Atmark Techno, Inc.
5 * Michal SIMEK <monstr@monstr.eu>
6 * Yasushi SHOJI <yashi@atmark-techno.com>
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/byteorder.h>
33 DECLARE_GLOBAL_DATA_PTR;
35 extern image_header_t header; /* from cmd_bootm.c */
37 extern int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
39 void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
40 ulong addr, ulong * len_ptr, int verify)
42 ulong len = 0, checksum;
43 ulong initrd_start, initrd_end;
45 /* First parameter is mapped to $r5 for kernel boot args */
46 void (*theKernel) (char *);
47 image_header_t *hdr = &header;
48 char *commandline = getenv ("bootargs");
51 theKernel = (void (*)(char *))image_get_ep (hdr);
53 /* Check if there is an initrd image */
55 show_boot_progress (9);
57 addr = simple_strtoul (argv[2], NULL, 16);
58 hdr = (image_header_t *)addr;
60 printf ("## Loading Ramdisk Image at %08lx ...\n", addr);
62 if (!image_check_magic (hdr)) {
63 printf ("Bad Magic Number\n");
64 show_boot_progress (-10);
65 do_reset (cmdtp, flag, argc, argv);
68 if (!image_check_magic (hdr)) {
69 printf ("Bad Header Checksum\n");
70 show_boot_progress (-11);
71 do_reset (cmdtp, flag, argc, argv);
74 show_boot_progress (10);
76 print_image_hdr (hdr);
78 data = image_get_data (hdr);
79 len = image_get_data_size (hdr);
82 printf (" Verifying Checksum ... ");
83 if (!image_check_dcrc (hdr)) {
84 printf ("Bad Data CRC\n");
85 show_boot_progress (-12);
86 do_reset (cmdtp, flag, argc, argv);
91 show_boot_progress (11);
93 if (!image_check_os (hdr, IH_OS_LINUX) ||
94 !image_check_arch (hdr, IH_ARCH_MICROBLAZE) ||
95 !image_check_type (hdr, IH_TYPE_RAMDISK)) {
96 printf ("No Linux Microblaze Ramdisk Image\n");
97 show_boot_progress (-13);
98 do_reset (cmdtp, flag, argc, argv);
102 * Now check if we have a multifile image
104 } else if (image_check_type (hdr, IH_TYPE_MULTI) && (len_ptr[1])) {
105 ulong tail = image_to_cpu (len_ptr[0]) % 4;
107 show_boot_progress (13);
109 /* skip kernel length and terminator */
110 data = (ulong) (&len_ptr[2]);
111 /* skip any additional image length fields */
112 for (i = 1; len_ptr[i]; ++i)
114 /* add kernel length, and align */
115 data += image_to_cpu (len_ptr[0]);
120 len = image_to_cpu (len_ptr[1]);
126 show_boot_progress (14);
133 printf ("No initrd\n");
139 initrd_end = initrd_start + len;
145 show_boot_progress (15);
148 printf ("## Transferring control to Linux (at address %08lx) ...\n",
152 theKernel (commandline);