2008-03-28 08:47:00 +00:00
|
|
|
/* SPARC code for booting linux 2.6
|
|
|
|
*
|
|
|
|
* (C) Copyright 2007
|
|
|
|
* Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2008-03-28 08:47:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/cache.h>
|
2008-11-10 12:46:20 +00:00
|
|
|
#include <image.h>
|
2008-03-28 08:47:00 +00:00
|
|
|
|
|
|
|
#define PRINT_KERNEL_HEADER
|
|
|
|
|
|
|
|
extern image_header_t header;
|
|
|
|
extern void srmmu_init_cpu(unsigned int entry);
|
|
|
|
extern void prepare_bootargs(char *bootargs);
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_UHCI
|
2012-09-25 22:14:34 +00:00
|
|
|
extern int usb_lowlevel_stop(int index);
|
2008-03-28 08:47:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* sparc kernel argument (the ROM vector) */
|
|
|
|
struct linux_romvec *kernel_arg_promvec;
|
|
|
|
|
|
|
|
/* page szie is 4k */
|
|
|
|
#define PAGE_SIZE 0x1000
|
|
|
|
#define RAMDISK_IMAGE_START_MASK 0x07FF
|
|
|
|
#define RAMDISK_PROMPT_FLAG 0x8000
|
|
|
|
#define RAMDISK_LOAD_FLAG 0x4000
|
|
|
|
struct __attribute__ ((packed)) {
|
|
|
|
char traptable[PAGE_SIZE];
|
|
|
|
char swapper_pg_dir[PAGE_SIZE];
|
|
|
|
char pg0[PAGE_SIZE];
|
|
|
|
char pg1[PAGE_SIZE];
|
|
|
|
char pg2[PAGE_SIZE];
|
|
|
|
char pg3[PAGE_SIZE];
|
|
|
|
char empty_bad_page[PAGE_SIZE];
|
|
|
|
char empty_bad_page_table[PAGE_SIZE];
|
|
|
|
char empty_zero_page[PAGE_SIZE];
|
|
|
|
unsigned char hdr[4]; /* ascii "HdrS" */
|
|
|
|
/* 00.02.06.0b is for Linux kernel 2.6.11 */
|
|
|
|
unsigned char linuxver_mega_major;
|
|
|
|
unsigned char linuxver_major;
|
|
|
|
unsigned char linuxver_minor;
|
|
|
|
unsigned char linuxver_revision;
|
|
|
|
/* header version 0x0203 */
|
|
|
|
unsigned short hdr_ver;
|
|
|
|
union __attribute__ ((packed)) {
|
|
|
|
struct __attribute__ ((packed)) {
|
|
|
|
unsigned short root_flags;
|
|
|
|
unsigned short root_dev;
|
|
|
|
unsigned short ram_flags;
|
|
|
|
unsigned int sparc_ramdisk_image;
|
|
|
|
unsigned int sparc_ramdisk_size;
|
|
|
|
unsigned int reboot_command;
|
|
|
|
unsigned int resv[3];
|
|
|
|
unsigned int end;
|
|
|
|
} ver_0203;
|
|
|
|
} hdr_input;
|
|
|
|
} *linux_hdr;
|
|
|
|
|
|
|
|
/* temporary initrd image holder */
|
|
|
|
image_header_t ihdr;
|
|
|
|
|
2008-10-17 02:52:08 +00:00
|
|
|
void arch_lmb_reserve(struct lmb *lmb)
|
|
|
|
{
|
|
|
|
/* Reserve the space used by PROM and stack. This is done
|
|
|
|
* to avoid that the RAM image is copied over stack or
|
|
|
|
* PROM.
|
|
|
|
*/
|
|
|
|
lmb_reserve(lmb, CONFIG_SYS_RELOC_MONITOR_BASE, CONFIG_SYS_RAM_END);
|
|
|
|
}
|
|
|
|
|
2008-03-28 08:47:00 +00:00
|
|
|
/* boot the linux kernel */
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t * images)
|
2008-03-28 08:47:00 +00:00
|
|
|
{
|
|
|
|
char *bootargs;
|
2008-08-15 13:24:37 +00:00
|
|
|
ulong rd_len;
|
2008-03-28 08:47:00 +00:00
|
|
|
void (*kernel) (struct linux_romvec *, void *);
|
|
|
|
int ret;
|
|
|
|
|
2013-07-02 11:57:44 +00:00
|
|
|
/*
|
|
|
|
* allow the PREP bootm subcommand, it is required for bootm to work
|
|
|
|
*/
|
|
|
|
if (flag & BOOTM_STATE_OS_PREP)
|
|
|
|
return 0;
|
|
|
|
|
bootm: Add subcommands
Add the ability to break the steps of the bootm command into several
subcommands: start, loados, ramdisk, fdt, bdt, cmdline, prep, go.
This allows us to do things like manipulate device trees before
they are passed to a booting kernel or setup memory for a secondary
core in multicore situations.
Not all OS types support all subcommands (currently only start, loados,
ramdisk, fdt, and go are supported).
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-10-21 22:25:45 +00:00
|
|
|
if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
|
|
|
|
return 1;
|
|
|
|
|
2008-03-28 08:47:00 +00:00
|
|
|
/* Get virtual address of kernel start */
|
2008-08-15 13:24:41 +00:00
|
|
|
linux_hdr = (void *)images->os.load;
|
2008-03-28 08:47:00 +00:00
|
|
|
|
|
|
|
/* */
|
2008-08-15 13:24:36 +00:00
|
|
|
kernel = (void (*)(struct linux_romvec *, void *))images->ep;
|
2008-03-28 08:47:00 +00:00
|
|
|
|
|
|
|
/* check for a SPARC kernel */
|
|
|
|
if ((linux_hdr->hdr[0] != 'H') ||
|
|
|
|
(linux_hdr->hdr[1] != 'd') ||
|
|
|
|
(linux_hdr->hdr[2] != 'r') || (linux_hdr->hdr[3] != 'S')) {
|
|
|
|
puts("Error reading header of SPARC Linux kernel, aborting\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#ifdef PRINT_KERNEL_HEADER
|
|
|
|
printf("## Found SPARC Linux kernel %d.%d.%d ...\n",
|
|
|
|
linux_hdr->linuxver_major,
|
|
|
|
linux_hdr->linuxver_minor, linux_hdr->linuxver_revision);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_UHCI
|
|
|
|
usb_lowlevel_stop();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* set basic boot params in kernel header now that it has been
|
|
|
|
* extracted and is writeable.
|
|
|
|
*/
|
|
|
|
|
2013-05-08 08:06:06 +00:00
|
|
|
ret = image_setup_linux(images);
|
|
|
|
if (ret) {
|
|
|
|
puts("### Failed to relocate RAM disk\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2008-03-28 08:47:00 +00:00
|
|
|
/* Calc length of RAM disk, if zero no ramdisk available */
|
2008-08-15 13:24:37 +00:00
|
|
|
rd_len = images->rd_end - images->rd_start;
|
2008-03-28 08:47:00 +00:00
|
|
|
|
|
|
|
if (rd_len) {
|
|
|
|
/* Update SPARC kernel header so that Linux knows
|
|
|
|
* what is going on and where to find RAM disk.
|
|
|
|
*
|
|
|
|
* Set INITRD Image address relative to RAM Start
|
|
|
|
*/
|
|
|
|
linux_hdr->hdr_input.ver_0203.sparc_ramdisk_image =
|
2013-05-08 08:06:06 +00:00
|
|
|
images->initrd_start - CONFIG_SYS_RAM_BASE;
|
2008-03-28 08:47:00 +00:00
|
|
|
linux_hdr->hdr_input.ver_0203.sparc_ramdisk_size = rd_len;
|
|
|
|
/* Clear READ ONLY flag if set to non-zero */
|
|
|
|
linux_hdr->hdr_input.ver_0203.root_flags = 1;
|
|
|
|
/* Set root device to: Root_RAM0 */
|
|
|
|
linux_hdr->hdr_input.ver_0203.root_dev = 0x100;
|
|
|
|
linux_hdr->hdr_input.ver_0203.ram_flags = 0;
|
|
|
|
} else {
|
|
|
|
/* NOT using RAMDISK image, overwriting kernel defaults */
|
|
|
|
linux_hdr->hdr_input.ver_0203.sparc_ramdisk_image = 0;
|
|
|
|
linux_hdr->hdr_input.ver_0203.sparc_ramdisk_size = 0;
|
|
|
|
/* Leave to kernel defaults
|
|
|
|
linux_hdr->hdr_input.ver_0203.root_flags = 1;
|
|
|
|
linux_hdr->hdr_input.ver_0203.root_dev = 0;
|
|
|
|
linux_hdr->hdr_input.ver_0203.ram_flags = 0;
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy bootargs from bootargs variable to kernel readable area */
|
|
|
|
bootargs = getenv("bootargs");
|
|
|
|
prepare_bootargs(bootargs);
|
|
|
|
|
|
|
|
/* turn on mmu & setup context table & page table for process 0 (kernel) */
|
|
|
|
srmmu_init_cpu((unsigned int)kernel);
|
|
|
|
|
|
|
|
/* Enter SPARC Linux kernel
|
|
|
|
* From now on the only code in u-boot that will be
|
|
|
|
* executed is the PROM code.
|
|
|
|
*/
|
2008-11-10 12:46:20 +00:00
|
|
|
kernel(kernel_arg_promvec, (void *)images->ep);
|
2008-03-28 08:47:00 +00:00
|
|
|
|
|
|
|
/* It will never come to this... */
|
|
|
|
while (1) ;
|
|
|
|
|
|
|
|
error:
|
2008-08-15 13:24:45 +00:00
|
|
|
return 1;
|
2008-03-28 08:47:00 +00:00
|
|
|
}
|