2002-11-18 00:14:45 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
|
|
|
* Marius Groeger <mgroeger@sysgo.de>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <image.h>
|
|
|
|
#include <zlib.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <asm/zimage.h>
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*cmd_boot.c*/
|
|
|
|
extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
2008-01-08 17:12:17 +00:00
|
|
|
image_header_t *hdr, int verify)
|
2002-11-18 00:14:45 +00:00
|
|
|
{
|
2002-11-21 23:11:29 +00:00
|
|
|
void *base_ptr;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
ulong os_data, os_len;
|
|
|
|
ulong rd_data, rd_len;
|
2002-11-18 00:14:45 +00:00
|
|
|
ulong initrd_start, initrd_end;
|
2008-01-08 17:12:17 +00:00
|
|
|
image_header_t *rd_hdr;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/*
|
|
|
|
* Check if there is an initrd image
|
|
|
|
*/
|
|
|
|
if (argc >= 3) {
|
2008-01-08 17:12:17 +00:00
|
|
|
rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16);
|
|
|
|
printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
if (!image_check_magic (rd_hdr)) {
|
2002-11-18 00:14:45 +00:00
|
|
|
printf ("Bad Magic Number\n");
|
|
|
|
do_reset (cmdtp, flag, argc, argv);
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
if (!image_check_hcrc (rd_hdr)) {
|
2002-11-18 00:14:45 +00:00
|
|
|
printf ("Bad Header Checksum\n");
|
|
|
|
do_reset (cmdtp, flag, argc, argv);
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
print_image_hdr (rd_hdr);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
rd_data = image_get_data (rd_hdr);
|
|
|
|
rd_len = image_get_data_size (rd_hdr);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
if (verify) {
|
|
|
|
printf (" Verifying Checksum ... ");
|
2008-01-08 17:12:17 +00:00
|
|
|
if (!image_check_dcrc (rd_hdr)) {
|
2002-11-18 00:14:45 +00:00
|
|
|
printf ("Bad Data CRC\n");
|
|
|
|
do_reset (cmdtp, flag, argc, argv);
|
|
|
|
}
|
|
|
|
printf ("OK\n");
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
if (!image_check_os (rd_hdr, IH_OS_LINUX) ||
|
|
|
|
!image_check_arch (rd_hdr, IH_ARCH_I386) ||
|
|
|
|
!image_check_type (rd_hdr, IH_TYPE_RAMDISK)) {
|
2002-11-18 00:14:45 +00:00
|
|
|
printf ("No Linux i386 Ramdisk Image\n");
|
|
|
|
do_reset (cmdtp, flag, argc, argv);
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/*
|
|
|
|
* Now check if we have a multifile image
|
|
|
|
*/
|
2008-01-08 17:12:17 +00:00
|
|
|
} else if (image_check_type (hdr, IH_TYPE_MULTI)) {
|
|
|
|
/*
|
|
|
|
* Get second entry data start address and len
|
|
|
|
*/
|
|
|
|
image_multi_getimg (hdr, 1, &rd_data, &rd_len);
|
2002-11-18 00:14:45 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* no initrd image
|
|
|
|
*/
|
2008-01-08 17:12:17 +00:00
|
|
|
rd_data = rd_len = 0;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
#ifdef DEBUG
|
2008-01-08 17:12:17 +00:00
|
|
|
if (!rd_data) {
|
2002-11-18 00:14:45 +00:00
|
|
|
printf ("No initrd\n");
|
|
|
|
}
|
|
|
|
#endif
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
if (rd_data) {
|
|
|
|
initrd_start = rd_data;
|
|
|
|
initrd_end = initrd_start + rd_len;
|
2002-11-18 00:14:45 +00:00
|
|
|
printf (" Loading Ramdisk to %08lx, end %08lx ... ",
|
|
|
|
initrd_start, initrd_end);
|
2008-01-08 17:12:17 +00:00
|
|
|
memmove ((void *)initrd_start, (void *)rd_data, rd_len);
|
2002-11-18 00:14:45 +00:00
|
|
|
printf ("OK\n");
|
|
|
|
} else {
|
|
|
|
initrd_start = 0;
|
|
|
|
initrd_end = 0;
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2006-07-21 09:30:18 +00:00
|
|
|
/* if multi-part image, we need to advance base ptr */
|
2008-01-08 17:12:17 +00:00
|
|
|
if (image_check_type (hdr, IH_TYPE_MULTI)) {
|
|
|
|
image_multi_getimg (hdr, 0, &os_data, &os_len);
|
|
|
|
} else {
|
|
|
|
os_data = image_get_data (hdr);
|
|
|
|
os_len = image_get_data_size (hdr);
|
2006-07-21 09:30:18 +00:00
|
|
|
}
|
|
|
|
|
2008-01-08 17:12:17 +00:00
|
|
|
base_ptr = load_zimage ((void*)os_data, os_len,
|
|
|
|
initrd_start, rd_len, 0);
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
if (NULL == base_ptr) {
|
|
|
|
printf ("## Kernel loading failed ...\n");
|
|
|
|
do_reset(cmdtp, flag, argc, argv);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf ("## Transferring control to Linux (at address %08x) ...\n",
|
|
|
|
(u32)base_ptr);
|
|
|
|
#endif
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* we assume that the kernel is in place */
|
|
|
|
printf("\nStarting kernel ...\n\n");
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
boot_zimage(base_ptr);
|
2002-11-18 00:14:45 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
}
|