2007-07-05 16:01:14 +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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
#include <boot.h>
|
2007-07-05 16:01:14 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2007-07-05 16:01:27 +00:00
|
|
|
#include <driver.h>
|
2007-11-28 08:03:27 +00:00
|
|
|
#include <environment.h>
|
2007-07-05 16:01:14 +00:00
|
|
|
#include <image.h>
|
|
|
|
#include <zlib.h>
|
2007-11-28 08:03:27 +00:00
|
|
|
|
2007-07-05 16:01:14 +00:00
|
|
|
#include <asm/byteorder.h>
|
2007-11-28 08:03:27 +00:00
|
|
|
#include <asm/global_data.h>
|
2007-07-05 19:41:37 +00:00
|
|
|
#include <asm/setup.h>
|
2007-07-16 08:29:57 +00:00
|
|
|
#include <asm/u-boot-arm.h>
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
static struct tag *params;
|
|
|
|
|
2007-07-05 16:01:14 +00:00
|
|
|
#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
|
|
|
|
defined (CONFIG_CMDLINE_TAG) || \
|
|
|
|
defined (CONFIG_INITRD_TAG) || \
|
|
|
|
defined (CONFIG_SERIAL_TAG) || \
|
|
|
|
defined (CONFIG_REVISION_TAG) || \
|
2007-11-28 08:03:27 +00:00
|
|
|
defined (CONFIG_LCD) || \
|
|
|
|
defined (CONFIG_VFD)
|
|
|
|
static void __setup_start_tag(void);
|
|
|
|
static void __setup_end_tag(void);
|
|
|
|
#define setup_start_tag __setup_start_tag
|
|
|
|
#define setup_end_tag __setup_end_tag
|
|
|
|
#else
|
|
|
|
#define setup_start_tag() do {} while(0)
|
|
|
|
#define setup_end_tag() do {} while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_CMDLINE_TAG
|
|
|
|
static void __setup_commandline_tag(const char *commandline);
|
|
|
|
#define setup_commandline_tag __setup_commandline_tag
|
|
|
|
#else
|
|
|
|
#define setup_commandline_tag(a) do {} while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_SETUP_MEMORY_TAGS
|
|
|
|
static void __setup_memory_tags(void);
|
|
|
|
#define setup_memory_tags __setup_memory_tags
|
|
|
|
#else
|
|
|
|
#define setup_memory_tags() do {} while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#ifdef CONFIG_INITRD_TAG
|
|
|
|
static void __setup_initrd_tag(ulong initrd_start, ulong initrd_end);
|
|
|
|
#define setup_initrd_tag __setup_initrd_tag
|
|
|
|
#else
|
|
|
|
#define setup_initrd_tag(a,b) do {} while(0)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern ulong calc_fbsize(void);
|
|
|
|
#if defined (CONFIG_VFD) || defined (CONFIG_LCD)
|
|
|
|
static void __setup_videolfb_tag(gd_t *gd);
|
|
|
|
#define setup_videolfb_tag __setup_videolfb_tag
|
|
|
|
#else
|
|
|
|
#define setup_videolfb_tag(a) do {} while(0)
|
|
|
|
#endif
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
#ifdef CONFIG_REVISION_TAG
|
|
|
|
static void __setup_revision_tag(struct tag **in_params);
|
|
|
|
#define setup_revision_tag __setup_revision_tag
|
|
|
|
#else
|
|
|
|
#define setup_revision_tag(a) do {} while(0)
|
|
|
|
#endif
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
#ifdef CONFIG_SERIAL_TAG
|
|
|
|
void __setup_serial_tag(struct tag **tmp);
|
|
|
|
#define setup_serial tag __setup_serial_tag
|
|
|
|
#else
|
|
|
|
#define setup_serial_tag(a) do {} while(0)
|
|
|
|
#endif
|
2007-07-05 16:01:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SHOW_BOOT_PROGRESS
|
|
|
|
# include <status_led.h>
|
|
|
|
# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
|
|
|
|
#else
|
|
|
|
# define SHOW_BOOT_PROGRESS(arg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
int
|
|
|
|
do_bootm_linux(struct image_handle *os_handle, struct image_handle *initrd)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
|
|
|
void (*theKernel)(int zero, int arch, uint params);
|
2007-07-15 12:02:53 +00:00
|
|
|
image_header_t *os_header = &os_handle->header;
|
2007-07-05 16:01:58 +00:00
|
|
|
const char *commandline = getenv ("bootargs");
|
2007-11-28 08:03:27 +00:00
|
|
|
|
2007-07-05 16:02:11 +00:00
|
|
|
if (os_header->ih_type == IH_TYPE_MULTI) {
|
|
|
|
printf("Multifile images not handled at the moment\n");
|
|
|
|
return -1;
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
2007-07-15 12:02:53 +00:00
|
|
|
|
|
|
|
printf("commandline: %s\n", commandline);
|
|
|
|
|
2007-07-05 16:02:11 +00:00
|
|
|
theKernel = (void (*)(int, int, uint))ntohl((unsigned long)(os_header->ih_ep));
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
/* FIXME: replace by pr_debug */
|
2007-07-05 16:01:14 +00:00
|
|
|
debug ("## Transferring control to Linux (at address %08lx) ...\n",
|
|
|
|
(ulong) theKernel);
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
setup_start_tag();
|
|
|
|
setup_serial_tag(¶ms);
|
|
|
|
setup_revision_tag(¶ms);
|
|
|
|
setup_memory_tags();
|
|
|
|
setup_commandline_tag(commandline);
|
|
|
|
#if 0
|
|
|
|
if (initrd_start && initrd_end)
|
|
|
|
setup_initrd_tag (initrd_start, initrd_end);
|
2007-07-05 16:01:14 +00:00
|
|
|
#endif
|
2007-11-28 08:03:27 +00:00
|
|
|
setup_videolfb_tag((gd_t *) gd);
|
|
|
|
setup_end_tag();
|
|
|
|
|
2007-07-15 12:02:53 +00:00
|
|
|
if (relocate_image(os_handle, (void *)ntohl(os_header->ih_load)))
|
2007-07-05 16:02:11 +00:00
|
|
|
return -1;
|
2007-07-05 16:01:14 +00:00
|
|
|
|
|
|
|
/* we assume that the kernel is in place */
|
|
|
|
printf ("\nStarting kernel ...\n\n");
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_DEVICE
|
|
|
|
{
|
2007-11-28 08:03:27 +00:00
|
|
|
extern void udc_disconnect(void);
|
|
|
|
udc_disconnect();
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
cleanup_before_linux();
|
2007-07-05 16:01:24 +00:00
|
|
|
theKernel (0, CONFIG_ARCH_NUMBER, CONFIG_BOOT_PARAMS);
|
2007-11-28 08:03:27 +00:00
|
|
|
|
2007-07-05 16:02:11 +00:00
|
|
|
return -1;
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
void
|
|
|
|
__setup_start_tag(void)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
2007-11-28 08:03:27 +00:00
|
|
|
params = (struct tag *)CONFIG_BOOT_PARAMS;
|
2007-07-05 16:01:14 +00:00
|
|
|
|
|
|
|
params->hdr.tag = ATAG_CORE;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->hdr.size = tag_size(tag_core);
|
2007-07-05 16:01:14 +00:00
|
|
|
|
|
|
|
params->u.core.flags = 0;
|
|
|
|
params->u.core.pagesize = 0;
|
|
|
|
params->u.core.rootdev = 0;
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
params = tag_next(params);
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
void
|
|
|
|
__setup_memory_tags(void)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
2007-07-05 16:01:27 +00:00
|
|
|
struct device_d *dev = NULL;
|
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
list_for_each_entry(dev, &device_list, list) {
|
|
|
|
if (dev->type == DEVICE_TYPE_DRAM) {
|
|
|
|
params->hdr.tag = ATAG_MEM;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->hdr.size = tag_size(tag_mem32);
|
2007-07-05 16:01:27 +00:00
|
|
|
|
2007-10-11 18:20:36 +00:00
|
|
|
params->u.mem.start = dev->map_base;
|
|
|
|
params->u.mem.size = dev->size;
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
params = tag_next(params);
|
2007-10-11 18:20:36 +00:00
|
|
|
}
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
void
|
|
|
|
__setup_commandline_tag(const char *commandline)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
2007-07-05 16:01:58 +00:00
|
|
|
const char *p;
|
2007-07-05 16:01:14 +00:00
|
|
|
|
|
|
|
if (!commandline)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* eat leading white space */
|
2007-11-28 08:03:27 +00:00
|
|
|
for (p = commandline; *p == ' '; p++) ;
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
/*
|
|
|
|
* skip non-existent command lines so the kernel will still
|
2007-07-05 16:01:14 +00:00
|
|
|
* use its default command line.
|
|
|
|
*/
|
|
|
|
if (*p == '\0')
|
|
|
|
return;
|
|
|
|
|
|
|
|
params->hdr.tag = ATAG_CMDLINE;
|
|
|
|
params->hdr.size =
|
2007-11-28 08:03:27 +00:00
|
|
|
(sizeof (struct tag_header) + strlen(p) + 1 + 4) >> 2;
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
strcpy(params->u.cmdline.cmdline, p);
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
params = tag_next(params);
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
void
|
|
|
|
__setup_initrd_tag(ulong initrd_start, ulong initrd_end)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
|
|
|
/* an ATAG_INITRD node tells the kernel where the compressed
|
|
|
|
* ramdisk can be found. ATAG_RDIMG is a better name, actually.
|
|
|
|
*/
|
|
|
|
params->hdr.tag = ATAG_INITRD2;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->hdr.size = tag_size(tag_initrd);
|
2007-07-05 16:01:14 +00:00
|
|
|
|
|
|
|
params->u.initrd.start = initrd_start;
|
|
|
|
params->u.initrd.size = initrd_end - initrd_start;
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
params = tag_next(params);
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
#if 0 /* FIXME: doesn't compile */
|
|
|
|
void
|
|
|
|
__setup_videolfb_tag(gd_t *gd)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
|
|
|
/* An ATAG_VIDEOLFB node tells the kernel where and how large
|
|
|
|
* the framebuffer for video was allocated (among other things).
|
|
|
|
* Note that a _physical_ address is passed !
|
|
|
|
*
|
|
|
|
* We only use it to pass the address and size, the other entries
|
|
|
|
* in the tag_videolfb are not of interest.
|
|
|
|
*/
|
|
|
|
params->hdr.tag = ATAG_VIDEOLFB;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->hdr.size = tag_size(tag_videolfb);
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
params->u.videolfb.lfb_base = (u32)gd->fb_base;
|
|
|
|
/* Fb size is calculated according to parameters for our panel */
|
2007-07-05 16:01:14 +00:00
|
|
|
params->u.videolfb.lfb_size = calc_fbsize();
|
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
params = tag_next(params);
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
2007-11-28 08:03:27 +00:00
|
|
|
#endif
|
|
|
|
#if 0 /* FIXME: doesn't compile */
|
|
|
|
void
|
|
|
|
__setup_serial_tag(struct tag **tmp)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
|
|
|
struct tag *params = *tmp;
|
|
|
|
struct tag_serialnr serialnr;
|
|
|
|
void get_board_serial(struct tag_serialnr *serialnr);
|
|
|
|
|
|
|
|
get_board_serial(&serialnr);
|
|
|
|
params->hdr.tag = ATAG_SERIAL;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->hdr.size = tag_size(tag_serialnr);
|
2007-07-05 16:01:14 +00:00
|
|
|
params->u.serialnr.low = serialnr.low;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->u.serialnr.high = serialnr.high;
|
|
|
|
params = tag_next(params);
|
2007-07-05 16:01:14 +00:00
|
|
|
*tmp = params;
|
|
|
|
}
|
|
|
|
#endif
|
2007-11-28 08:03:27 +00:00
|
|
|
#if 0 /* FIXME: doesn't compile */
|
|
|
|
void
|
|
|
|
__setup_revision_tag(struct tag **in_params)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
|
|
|
u32 rev = 0;
|
|
|
|
u32 get_board_rev(void);
|
|
|
|
|
|
|
|
rev = get_board_rev();
|
|
|
|
params->hdr.tag = ATAG_REVISION;
|
2007-11-28 08:03:27 +00:00
|
|
|
params->hdr.size = tag_size(tag_revision);
|
2007-07-05 16:01:14 +00:00
|
|
|
params->u.revision.rev = rev;
|
2007-11-28 08:03:27 +00:00
|
|
|
params = tag_next(params);
|
2007-07-05 16:01:14 +00:00
|
|
|
}
|
2007-11-28 08:03:27 +00:00
|
|
|
#endif
|
2007-07-05 16:01:14 +00:00
|
|
|
|
2007-11-28 08:03:27 +00:00
|
|
|
void
|
|
|
|
__setup_end_tag (void)
|
2007-07-05 16:01:14 +00:00
|
|
|
{
|
|
|
|
params->hdr.tag = ATAG_NONE;
|
|
|
|
params->hdr.size = 0;
|
|
|
|
}
|
|
|
|
|