2002-11-18 00:14:45 +00:00
|
|
|
/*
|
2011-12-05 12:09:23 +00:00
|
|
|
* Copyright (c) 2011 The Chromium OS Authors.
|
2002-11-18 00:14:45 +00:00
|
|
|
* (C) Copyright 2002
|
2011-08-04 16:45:45 +00:00
|
|
|
* Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
2002-11-18 00:14:45 +00:00
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2011-04-13 09:43:26 +00:00
|
|
|
* Linux x86 zImage and bzImage loading
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
|
|
|
* based on the procdure described in
|
2002-11-18 00:14:45 +00:00
|
|
|
* linux/Documentation/i386/boot.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#include <asm/zimage.h>
|
|
|
|
#include <asm/realmode.h>
|
|
|
|
#include <asm/byteorder.h>
|
2010-04-23 14:05:49 +00:00
|
|
|
#include <asm/bootparam.h>
|
2012-10-23 18:04:34 +00:00
|
|
|
#ifdef CONFIG_SYS_COREBOOT
|
|
|
|
#include <asm/arch/timestamp.h>
|
|
|
|
#endif
|
2012-10-23 18:04:37 +00:00
|
|
|
#include <linux/compiler.h>
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory lay-out:
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
2002-11-18 00:14:45 +00:00
|
|
|
* relative to setup_base (which is 0x90000 currently)
|
2003-06-27 21:31:46 +00:00
|
|
|
*
|
|
|
|
* 0x0000-0x7FFF Real mode kernel
|
2002-11-18 00:14:45 +00:00
|
|
|
* 0x8000-0x8FFF Stack and heap
|
|
|
|
* 0x9000-0x90FF Kernel command line
|
|
|
|
*/
|
2011-11-08 02:33:15 +00:00
|
|
|
#define DEFAULT_SETUP_BASE 0x90000
|
|
|
|
#define COMMAND_LINE_OFFSET 0x9000
|
|
|
|
#define HEAP_END_OFFSET 0x8e00
|
2002-11-18 00:14:45 +00:00
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
#define COMMAND_LINE_SIZE 2048
|
2002-11-18 00:14:45 +00:00
|
|
|
|
2011-12-05 12:09:24 +00:00
|
|
|
unsigned generic_install_e820_map(unsigned max_entries,
|
|
|
|
struct e820entry *entries)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned install_e820_map(unsigned max_entries,
|
|
|
|
struct e820entry *entries)
|
|
|
|
__attribute__((weak, alias("generic_install_e820_map")));
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
static void build_command_line(char *command_line, int auto_boot)
|
|
|
|
{
|
|
|
|
char *env_command_line;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
command_line[0] = '\0';
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
env_command_line = getenv("bootargs");
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* set console= argument if we use a serial console */
|
2011-11-08 02:33:15 +00:00
|
|
|
if (!strstr(env_command_line, "console=")) {
|
|
|
|
if (!strcmp(getenv("stdout"), "serial")) {
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* We seem to use serial console */
|
2003-06-27 21:31:46 +00:00
|
|
|
sprintf(command_line, "console=ttyS0,%s ",
|
2011-11-08 02:33:15 +00:00
|
|
|
getenv("baudrate"));
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
if (auto_boot)
|
2002-11-18 00:14:45 +00:00
|
|
|
strcat(command_line, "auto ");
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
if (env_command_line)
|
2002-11-18 00:14:45 +00:00
|
|
|
strcat(command_line, env_command_line);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
printf("Kernel command line: \"%s\"\n", command_line);
|
|
|
|
}
|
|
|
|
|
2011-12-05 12:09:26 +00:00
|
|
|
static int kernel_magic_ok(struct setup_header *hdr)
|
2002-11-18 00:14:45 +00:00
|
|
|
{
|
2010-04-23 14:05:49 +00:00
|
|
|
if (KERNEL_MAGIC != hdr->boot_flag) {
|
2011-12-05 12:09:23 +00:00
|
|
|
printf("Error: Invalid Boot Flag "
|
|
|
|
"(found 0x%04x, expected 0x%04x)\n",
|
|
|
|
hdr->boot_flag, KERNEL_MAGIC);
|
2002-11-18 00:14:45 +00:00
|
|
|
return 0;
|
2010-04-23 14:05:49 +00:00
|
|
|
} else {
|
|
|
|
printf("Valid Boot Flag\n");
|
2011-12-05 12:09:26 +00:00
|
|
|
return 1;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2011-12-05 12:09:26 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-12-05 12:09:26 +00:00
|
|
|
static int get_boot_protocol(struct setup_header *hdr)
|
|
|
|
{
|
|
|
|
if (hdr->header == KERNEL_V2_MAGIC) {
|
2010-04-23 14:05:49 +00:00
|
|
|
printf("Magic signature found\n");
|
2011-12-05 12:09:26 +00:00
|
|
|
return hdr->version;
|
2002-11-18 00:14:45 +00:00
|
|
|
} else {
|
|
|
|
/* Very old kernel */
|
2010-04-23 14:05:49 +00:00
|
|
|
printf("Magic signature not found\n");
|
2011-12-05 12:09:26 +00:00
|
|
|
return 0x0100;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2011-12-05 12:09:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct boot_params *load_zimage(char *image, unsigned long kernel_size,
|
|
|
|
void **load_address)
|
|
|
|
{
|
|
|
|
struct boot_params *setup_base;
|
|
|
|
int setup_size;
|
|
|
|
int bootproto;
|
|
|
|
int big_image;
|
|
|
|
|
|
|
|
struct boot_params *params = (struct boot_params *)image;
|
|
|
|
struct setup_header *hdr = ¶ms->hdr;
|
|
|
|
|
|
|
|
/* base address for real-mode segment */
|
|
|
|
setup_base = (struct boot_params *)DEFAULT_SETUP_BASE;
|
|
|
|
|
|
|
|
if (!kernel_magic_ok(hdr))
|
|
|
|
return 0;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* determine size of setup */
|
2010-04-23 14:05:49 +00:00
|
|
|
if (0 == hdr->setup_sects) {
|
|
|
|
printf("Setup Sectors = 0 (defaulting to 4)\n");
|
2002-11-18 00:14:45 +00:00
|
|
|
setup_size = 5 * 512;
|
|
|
|
} else {
|
2010-04-23 14:05:49 +00:00
|
|
|
setup_size = (hdr->setup_sects + 1) * 512;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2010-04-23 14:05:49 +00:00
|
|
|
printf("Setup Size = 0x%8.8lx\n", (ulong)setup_size);
|
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
if (setup_size > SETUP_MAX_SIZE)
|
2002-11-18 00:14:45 +00:00
|
|
|
printf("Error: Setup is too large (%d bytes)\n", setup_size);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-12-05 12:09:26 +00:00
|
|
|
/* determine boot protocol version */
|
|
|
|
bootproto = get_boot_protocol(hdr);
|
|
|
|
|
|
|
|
printf("Using boot protocol version %x.%02x\n",
|
|
|
|
(bootproto & 0xff00) >> 8, bootproto & 0xff);
|
|
|
|
|
|
|
|
if (bootproto >= 0x0200) {
|
|
|
|
if (hdr->setup_sects >= 15) {
|
|
|
|
printf("Linux kernel version %s\n",
|
|
|
|
(char *)params +
|
|
|
|
hdr->kernel_version + 0x200);
|
|
|
|
} else {
|
|
|
|
printf("Setup Sectors < 15 - "
|
|
|
|
"Cannot print kernel version.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* Determine image type */
|
2011-11-08 02:33:15 +00:00
|
|
|
big_image = (bootproto >= 0x0200) &&
|
|
|
|
(hdr->loadflags & BIG_KERNEL_FLAG);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2010-04-23 14:05:49 +00:00
|
|
|
/* Determine load address */
|
2011-12-05 12:09:23 +00:00
|
|
|
if (big_image)
|
2011-12-05 12:09:24 +00:00
|
|
|
*load_address = (void *)BZIMAGE_LOAD_ADDR;
|
2011-12-05 12:09:23 +00:00
|
|
|
else
|
2011-12-05 12:09:24 +00:00
|
|
|
*load_address = (void *)ZIMAGE_LOAD_ADDR;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2012-11-29 16:23:41 +00:00
|
|
|
#if (defined CONFIG_ZBOOT_32 || defined CONFIG_X86_NO_REAL_MODE)
|
2011-12-05 12:09:24 +00:00
|
|
|
printf("Building boot_params at 0x%8.8lx\n", (ulong)setup_base);
|
|
|
|
memset(setup_base, 0, sizeof(*setup_base));
|
|
|
|
setup_base->hdr = params->hdr;
|
|
|
|
#else
|
2002-11-18 00:14:45 +00:00
|
|
|
/* load setup */
|
2011-11-08 02:33:15 +00:00
|
|
|
printf("Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n",
|
|
|
|
(ulong)setup_base, setup_size);
|
2002-11-18 00:14:45 +00:00
|
|
|
memmove(setup_base, image, setup_size);
|
2011-12-05 12:09:24 +00:00
|
|
|
#endif
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-12-05 12:09:26 +00:00
|
|
|
if (bootproto >= 0x0204)
|
|
|
|
kernel_size = hdr->syssize * 16;
|
|
|
|
else
|
|
|
|
kernel_size -= setup_size;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
|
|
if (bootproto == 0x0100) {
|
2011-11-08 02:33:15 +00:00
|
|
|
/*
|
|
|
|
* A very old kernel MUST have its real-mode code
|
|
|
|
* loaded at 0x90000
|
|
|
|
*/
|
2002-11-18 00:14:45 +00:00
|
|
|
if ((u32)setup_base != 0x90000) {
|
|
|
|
/* Copy the real-mode kernel */
|
2011-11-08 02:33:15 +00:00
|
|
|
memmove((void *)0x90000, setup_base, setup_size);
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* Copy the command line */
|
2011-11-08 02:33:15 +00:00
|
|
|
memmove((void *)0x99000,
|
2011-12-05 12:09:23 +00:00
|
|
|
(u8 *)setup_base + COMMAND_LINE_OFFSET,
|
2011-11-08 02:33:15 +00:00
|
|
|
COMMAND_LINE_SIZE);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
/* Relocated */
|
2011-12-05 12:09:23 +00:00
|
|
|
setup_base = (struct boot_params *)0x90000;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* It is recommended to clear memory up to the 32K mark */
|
2011-12-05 12:09:23 +00:00
|
|
|
memset((u8 *)0x90000 + setup_size, 0,
|
|
|
|
SETUP_MAX_SIZE - setup_size);
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-12-05 12:09:26 +00:00
|
|
|
if (big_image) {
|
|
|
|
if (kernel_size > BZIMAGE_MAX_SIZE) {
|
|
|
|
printf("Error: bzImage kernel too big! "
|
|
|
|
"(size: %ld, max: %d)\n",
|
|
|
|
kernel_size, BZIMAGE_MAX_SIZE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else if ((kernel_size) > ZIMAGE_MAX_SIZE) {
|
|
|
|
printf("Error: zImage kernel too big! (size: %ld, max: %d)\n",
|
|
|
|
kernel_size, ZIMAGE_MAX_SIZE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Loading %s at address %p (%ld bytes)\n",
|
|
|
|
big_image ? "bzImage" : "zImage", *load_address, kernel_size);
|
|
|
|
|
|
|
|
memmove(*load_address, image + setup_size, kernel_size);
|
|
|
|
|
|
|
|
return setup_base;
|
|
|
|
}
|
|
|
|
|
|
|
|
int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
|
|
|
|
unsigned long initrd_addr, unsigned long initrd_size)
|
|
|
|
{
|
|
|
|
struct setup_header *hdr = &setup_base->hdr;
|
|
|
|
int bootproto = get_boot_protocol(hdr);
|
|
|
|
|
2012-11-29 16:23:41 +00:00
|
|
|
#if (defined CONFIG_ZBOOT_32 || defined CONFIG_X86_NO_REAL_MODE)
|
2011-12-05 12:09:26 +00:00
|
|
|
setup_base->e820_entries = install_e820_map(
|
|
|
|
ARRAY_SIZE(setup_base->e820_map), setup_base->e820_map);
|
|
|
|
#endif
|
2010-04-23 14:05:49 +00:00
|
|
|
|
2011-12-05 12:09:26 +00:00
|
|
|
if (bootproto == 0x0100) {
|
|
|
|
setup_base->screen_info.cl_magic = COMMAND_LINE_MAGIC;
|
|
|
|
setup_base->screen_info.cl_offset = COMMAND_LINE_OFFSET;
|
|
|
|
}
|
2002-11-18 00:14:45 +00:00
|
|
|
if (bootproto >= 0x0200) {
|
2010-04-23 14:05:49 +00:00
|
|
|
hdr->type_of_loader = 8;
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
if (initrd_addr) {
|
2011-12-05 12:09:23 +00:00
|
|
|
printf("Initial RAM disk at linear address "
|
|
|
|
"0x%08lx, size %ld bytes\n",
|
2002-11-18 00:14:45 +00:00
|
|
|
initrd_addr, initrd_size);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2010-04-23 14:05:49 +00:00
|
|
|
hdr->ramdisk_image = initrd_addr;
|
|
|
|
hdr->ramdisk_size = initrd_size;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
if (bootproto >= 0x0201) {
|
2010-04-23 14:05:49 +00:00
|
|
|
hdr->heap_end_ptr = HEAP_END_OFFSET;
|
|
|
|
hdr->loadflags |= HEAP_FLAG;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
if (bootproto >= 0x0202) {
|
2011-12-05 12:09:26 +00:00
|
|
|
hdr->cmd_line_ptr = (uintptr_t)cmd_line;
|
2002-11-18 00:14:45 +00:00
|
|
|
} else if (bootproto >= 0x0200) {
|
2011-12-05 12:09:23 +00:00
|
|
|
setup_base->screen_info.cl_magic = COMMAND_LINE_MAGIC;
|
2011-12-05 12:09:26 +00:00
|
|
|
setup_base->screen_info.cl_offset =
|
|
|
|
(uintptr_t)cmd_line - (uintptr_t)setup_base;
|
2010-04-23 14:05:49 +00:00
|
|
|
|
|
|
|
hdr->setup_move_size = 0x9100;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* build command line at COMMAND_LINE_OFFSET */
|
2011-12-05 12:09:26 +00:00
|
|
|
build_command_line(cmd_line, auto_boot);
|
|
|
|
return 0;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
2012-10-23 18:04:37 +00:00
|
|
|
/*
|
|
|
|
* Implement a weak default function for boards that optionally
|
|
|
|
* need to clean up the system before jumping to the kernel.
|
|
|
|
*/
|
|
|
|
__weak void board_final_cleanup(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-12-05 12:09:24 +00:00
|
|
|
void boot_zimage(void *setup_base, void *load_address)
|
2002-11-18 00:14:45 +00:00
|
|
|
{
|
2012-10-23 18:04:37 +00:00
|
|
|
board_final_cleanup();
|
|
|
|
|
2011-12-05 12:09:24 +00:00
|
|
|
printf("\nStarting kernel ...\n\n");
|
|
|
|
|
2012-10-23 18:04:34 +00:00
|
|
|
#ifdef CONFIG_SYS_COREBOOT
|
|
|
|
timestamp_add_now(TS_U_BOOT_START_KERNEL);
|
|
|
|
#endif
|
2011-12-05 12:09:24 +00:00
|
|
|
#if defined CONFIG_ZBOOT_32
|
|
|
|
/*
|
|
|
|
* Set %ebx, %ebp, and %edi to 0, %esi to point to the boot_params
|
|
|
|
* structure, and then jump to the kernel. We assume that %cs is
|
|
|
|
* 0x10, 4GB flat, and read/execute, and the data segments are 0x18,
|
|
|
|
* 4GB flat, and read/write. U-boot is setting them up that way for
|
|
|
|
* itself in arch/i386/cpu/cpu.c.
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"movl $0, %%ebp \n"
|
|
|
|
"cli \n"
|
|
|
|
"jmp %[kernel_entry] \n"
|
|
|
|
:: [kernel_entry]"a"(load_address),
|
|
|
|
[boot_params] "S"(setup_base),
|
|
|
|
"b"(0), "D"(0)
|
|
|
|
: "%ebp"
|
|
|
|
);
|
|
|
|
#else
|
2002-11-18 00:14:45 +00:00
|
|
|
struct pt_regs regs;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
memset(®s, 0, sizeof(struct pt_regs));
|
|
|
|
regs.xds = (u32)setup_base >> 4;
|
2010-04-23 14:05:49 +00:00
|
|
|
regs.xes = regs.xds;
|
|
|
|
regs.xss = regs.xds;
|
2003-05-31 18:35:21 +00:00
|
|
|
regs.esp = 0x9000;
|
2002-11-18 00:14:45 +00:00
|
|
|
regs.eflags = 0;
|
2011-12-05 12:09:23 +00:00
|
|
|
enter_realmode(((u32)setup_base + SETUP_START_OFFSET) >> 4, 0,
|
|
|
|
®s, ®s);
|
2011-12-05 12:09:24 +00:00
|
|
|
#endif
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2010-04-23 14:05:49 +00:00
|
|
|
|
2011-12-22 23:20:55 +00:00
|
|
|
void setup_pcat_compatibility(void)
|
|
|
|
__attribute__((weak, alias("__setup_pcat_compatibility")));
|
|
|
|
|
|
|
|
void __setup_pcat_compatibility(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
2010-04-23 14:05:49 +00:00
|
|
|
{
|
2011-12-05 12:09:26 +00:00
|
|
|
struct boot_params *base_ptr;
|
2010-10-07 09:03:19 +00:00
|
|
|
void *bzImage_addr = NULL;
|
2011-12-05 12:09:24 +00:00
|
|
|
void *load_address;
|
2010-10-07 09:03:19 +00:00
|
|
|
char *s;
|
2010-04-23 14:05:49 +00:00
|
|
|
ulong bzImage_size = 0;
|
2011-12-05 12:09:27 +00:00
|
|
|
ulong initrd_addr = 0;
|
|
|
|
ulong initrd_size = 0;
|
2010-04-23 14:05:49 +00:00
|
|
|
|
|
|
|
disable_interrupts();
|
|
|
|
|
|
|
|
/* Setup board for maximum PC/AT Compatibility */
|
|
|
|
setup_pcat_compatibility();
|
|
|
|
|
2011-12-05 12:09:23 +00:00
|
|
|
if (argc >= 2) {
|
2010-10-07 09:03:19 +00:00
|
|
|
/* argv[1] holds the address of the bzImage */
|
|
|
|
s = argv[1];
|
2011-12-05 12:09:23 +00:00
|
|
|
} else {
|
2010-10-07 09:03:19 +00:00
|
|
|
s = getenv("fileaddr");
|
2011-12-05 12:09:23 +00:00
|
|
|
}
|
2010-10-07 09:03:19 +00:00
|
|
|
|
|
|
|
if (s)
|
|
|
|
bzImage_addr = (void *)simple_strtoul(s, NULL, 16);
|
2010-04-23 14:05:49 +00:00
|
|
|
|
2011-12-05 12:09:27 +00:00
|
|
|
if (argc >= 3) {
|
2010-10-07 09:03:19 +00:00
|
|
|
/* argv[2] holds the size of the bzImage */
|
2010-04-23 14:05:49 +00:00
|
|
|
bzImage_size = simple_strtoul(argv[2], NULL, 16);
|
2011-12-05 12:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (argc >= 4)
|
|
|
|
initrd_addr = simple_strtoul(argv[3], NULL, 16);
|
|
|
|
if (argc >= 5)
|
|
|
|
initrd_size = simple_strtoul(argv[4], NULL, 16);
|
2010-04-23 14:05:49 +00:00
|
|
|
|
2011-12-05 12:09:23 +00:00
|
|
|
/* Lets look for */
|
2011-12-05 12:09:26 +00:00
|
|
|
base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address);
|
2010-04-23 14:05:49 +00:00
|
|
|
|
2011-11-08 02:33:15 +00:00
|
|
|
if (!base_ptr) {
|
|
|
|
printf("## Kernel loading failed ...\n");
|
2011-12-05 12:09:26 +00:00
|
|
|
return -1;
|
2010-04-23 14:05:49 +00:00
|
|
|
}
|
2011-12-05 12:09:26 +00:00
|
|
|
if (setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
|
2011-12-05 12:09:27 +00:00
|
|
|
0, initrd_addr, initrd_size)) {
|
2011-12-05 12:09:26 +00:00
|
|
|
printf("Setting up boot parameters failed ...\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("## Transferring control to Linux "
|
|
|
|
"(at address %08x) ...\n",
|
|
|
|
(u32)base_ptr);
|
|
|
|
|
|
|
|
/* we assume that the kernel is in place */
|
|
|
|
boot_zimage(base_ptr, load_address);
|
|
|
|
/* does not return */
|
2010-04-23 14:05:49 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(
|
2011-12-05 12:09:27 +00:00
|
|
|
zboot, 5, 0, do_zboot,
|
2010-04-23 14:05:49 +00:00
|
|
|
"Boot bzImage",
|
2011-12-05 12:09:27 +00:00
|
|
|
"[addr] [size] [initrd addr] [initrd size]\n"
|
|
|
|
" addr - The optional starting address of the bzimage.\n"
|
|
|
|
" If not set it defaults to the environment\n"
|
|
|
|
" variable \"fileaddr\".\n"
|
|
|
|
" size - The optional size of the bzimage. Defaults to\n"
|
|
|
|
" zero.\n"
|
|
|
|
" initrd addr - The address of the initrd image to use, if any.\n"
|
|
|
|
" initrd size - The size of the initrd image to use, if any.\n"
|
2010-04-23 14:05:49 +00:00
|
|
|
);
|