From 4a995edec1ac163d9326d143ffe2b47e7543407f Mon Sep 17 00:00:00 2001 From: Marian Balakowicz Date: Thu, 31 Jan 2008 13:20:06 +0100 Subject: [new uImage] Rename architecture specific bootm code files Implementation of the do_bootm_linux() and other bootm helper routines is architecture specific code. As such it resides in lib_ directories in files named _linux.c This patch renames those files to a more clear and accurate lib_/bootm.c form. List of the renamed files: lib_arm/armlinux.c -> lib_arm/bootm.c lib_avr32/avr32_linux.c -> lib_avr32/bootm.c lib_blackfin/bf533_linux.c -> lib_blackfin/bootm.c lib_i386/i386_linux.c -> lib_i386/bootm.c lib_m68k/m68k_linux.c -> lib_m68k/bootm.c lib_microblaze/microblaze_linux.c -> lib_microblaze/bootm.c lib_mips/mips_linux.c -> lib_mips/bootm.c lib_nios/nios_linux.c -> lib_nios/bootm.c lib_nios2/nios_linux.c -> lib_nios2/bootm.c lib_ppc/ppc_linux.c -> lib_ppc/bootm.c lib_sh/sh_linux.c -> lib_sh/bootm.c Signed-off-by: Marian Balakowicz --- lib_arm/Makefile | 2 +- lib_arm/armlinux.c | 384 -------------------------- lib_arm/bootm.c | 384 ++++++++++++++++++++++++++ lib_avr32/Makefile | 2 +- lib_avr32/avr32_linux.c | 277 ------------------- lib_avr32/bootm.c | 277 +++++++++++++++++++ lib_blackfin/Makefile | 2 +- lib_blackfin/bf533_linux.c | 84 ------ lib_blackfin/bootm.c | 84 ++++++ lib_i386/Makefile | 2 +- lib_i386/bootm.c | 142 ++++++++++ lib_i386/i386_linux.c | 142 ---------- lib_m68k/Makefile | 2 +- lib_m68k/bootm.c | 279 +++++++++++++++++++ lib_m68k/m68k_linux.c | 279 ------------------- lib_microblaze/Makefile | 2 +- lib_microblaze/bootm.c | 138 ++++++++++ lib_microblaze/microblaze_linux.c | 138 ---------- lib_mips/Makefile | 2 +- lib_mips/bootm.c | 249 +++++++++++++++++ lib_mips/mips_linux.c | 249 ----------------- lib_nios/Makefile | 2 +- lib_nios/bootm.c | 34 +++ lib_nios/nios_linux.c | 34 --- lib_nios2/Makefile | 2 +- lib_nios2/bootm.c | 37 +++ lib_nios2/nios_linux.c | 37 --- lib_ppc/Makefile | 2 +- lib_ppc/bootm.c | 554 ++++++++++++++++++++++++++++++++++++++ lib_ppc/ppc_linux.c | 554 -------------------------------------- lib_sh/Makefile | 2 +- lib_sh/bootm.c | 74 +++++ lib_sh/sh_linux.c | 74 ----- 33 files changed, 2263 insertions(+), 2263 deletions(-) delete mode 100644 lib_arm/armlinux.c create mode 100644 lib_arm/bootm.c delete mode 100644 lib_avr32/avr32_linux.c create mode 100644 lib_avr32/bootm.c delete mode 100644 lib_blackfin/bf533_linux.c create mode 100644 lib_blackfin/bootm.c create mode 100644 lib_i386/bootm.c delete mode 100644 lib_i386/i386_linux.c create mode 100644 lib_m68k/bootm.c delete mode 100644 lib_m68k/m68k_linux.c create mode 100644 lib_microblaze/bootm.c delete mode 100644 lib_microblaze/microblaze_linux.c create mode 100644 lib_mips/bootm.c delete mode 100644 lib_mips/mips_linux.c create mode 100644 lib_nios/bootm.c delete mode 100644 lib_nios/nios_linux.c create mode 100644 lib_nios2/bootm.c delete mode 100644 lib_nios2/nios_linux.c create mode 100644 lib_ppc/bootm.c delete mode 100644 lib_ppc/ppc_linux.c create mode 100644 lib_sh/bootm.c delete mode 100644 lib_sh/sh_linux.c diff --git a/lib_arm/Makefile b/lib_arm/Makefile index 037c475f8..aa9bee75c 100644 --- a/lib_arm/Makefile +++ b/lib_arm/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = _ashldi3.o _ashrdi3.o _divsi3.o _modsi3.o _udivsi3.o _umodsi3.o -COBJS = armlinux.o board.o \ +COBJS = bootm.o board.o \ cache.o div0.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/lib_arm/armlinux.c b/lib_arm/armlinux.c deleted file mode 100644 index 4f9aae613..000000000 --- a/lib_arm/armlinux.c +++ /dev/null @@ -1,384 +0,0 @@ -/* - * (C) Copyright 2002 - * Sysgo Real-Time Solutions, GmbH - * Marius Groeger - * - * 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 -#include -#include -#include -#include -#ifdef CONFIG_HAS_DATAFLASH -#include -#endif - -DECLARE_GLOBAL_DATA_PTR; - -/*cmd_boot.c*/ -extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ - defined (CONFIG_CMDLINE_TAG) || \ - defined (CONFIG_INITRD_TAG) || \ - defined (CONFIG_SERIAL_TAG) || \ - defined (CONFIG_REVISION_TAG) || \ - defined (CONFIG_VFD) || \ - defined (CONFIG_LCD) -static void setup_start_tag (bd_t *bd); - -# ifdef CONFIG_SETUP_MEMORY_TAGS -static void setup_memory_tags (bd_t *bd); -# endif -static void setup_commandline_tag (bd_t *bd, char *commandline); - -#if 0 -static void setup_ramdisk_tag (bd_t *bd); -#endif -# ifdef CONFIG_INITRD_TAG -static void setup_initrd_tag (bd_t *bd, ulong initrd_start, - ulong initrd_end); -# endif -static void setup_end_tag (bd_t *bd); - -# if defined (CONFIG_VFD) || defined (CONFIG_LCD) -static void setup_videolfb_tag (gd_t *gd); -# endif - - -static struct tag *params; -#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ - -void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - ulong rd_addr; - ulong rd_data, rd_len = 0; - ulong initrd_start, initrd_end; - image_header_t *rd_hdr; - void (*theKernel)(int zero, int arch, uint params); - bd_t *bd = gd->bd; - -#ifdef CONFIG_CMDLINE_TAG - char *commandline = getenv ("bootargs"); -#endif - - theKernel = (void (*)(int, int, uint))image_get_ep (hdr); - - /* - * Check if there is an initrd image - */ - if (argc >= 3) { - show_boot_progress (9); - - rd_addr = simple_strtoul (argv[2], NULL, 16); - printf ("## Loading Ramdisk Image at %08lx ...\n", rd_addr); - - /* Copy header so we can blank CRC field for re-calculation */ -#ifdef CONFIG_HAS_DATAFLASH - if (addr_dataflash (rd_addr)) { - rd_hdr = (image_header_t *)CFG_LOAD_ADDR; - read_dataflash (rd_addr, image_get_header_size (), - (char *)rd_hdr); - } else -#endif - rd_hdr = (image_header_t *)rd_addr; - - if (!image_check_magic (rd_hdr)) { - printf ("Bad Magic Number\n"); - show_boot_progress (-10); - do_reset (cmdtp, flag, argc, argv); - } - - if (!image_check_hcrc (rd_hdr)) { - printf ("Bad Header Checksum\n"); - show_boot_progress (-11); - do_reset (cmdtp, flag, argc, argv); - } - - show_boot_progress (10); - - print_image_hdr (rd_hdr); - - rd_data = image_get_data (rd_hdr); - rd_len = image_get_data_size (rd_hdr); - -#ifdef CONFIG_HAS_DATAFLASH - if (addr_dataflash (rd_addr)) - read_dataflash (rd_addr + image_get_header_size (), - rd_len, (char *)rd_data); -#endif - - if (verify) { - printf (" Verifying Checksum ... "); - if (!image_get_dcrc (rd_hdr)) { - printf ("Bad Data CRC\n"); - show_boot_progress (-12); - do_reset (cmdtp, flag, argc, argv); - } - printf ("OK\n"); - } - - show_boot_progress (11); - - if (!image_check_os (rd_hdr, IH_OS_LINUX) || - !image_check_arch (rd_hdr, IH_ARCH_ARM) || - !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { - printf ("No Linux ARM Ramdisk Image\n"); - show_boot_progress (-13); - do_reset (cmdtp, flag, argc, argv); - } - -#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) - /* - *we need to copy the ramdisk to SRAM to let Linux boot - */ - memmove ((void *)image_get_load (rd_hdr), (uchar *)rd_data, rd_len); - rd_data = image_get_load (rd_hdr); -#endif /* CONFIG_B2 || CONFIG_EVB4510 */ - - /* - * Now check if we have a multifile image - */ - } else if (image_check_type (hdr, IH_TYPE_MULTI)) { - /* - * Get second entry data start address and len - */ - show_boot_progress (13); - image_multi_getimg (hdr, 1, &rd_data, &rd_len); - } else { - /* - * no initrd image - */ - show_boot_progress (14); - - rd_len = rd_data = 0; - } - -#ifdef DEBUG - if (!rd_data) { - printf ("No initrd\n"); - } -#endif - - if (rd_data) { - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - } else { - initrd_start = 0; - initrd_end = 0; - } - - show_boot_progress (15); - - debug ("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); - -#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ - defined (CONFIG_CMDLINE_TAG) || \ - defined (CONFIG_INITRD_TAG) || \ - defined (CONFIG_SERIAL_TAG) || \ - defined (CONFIG_REVISION_TAG) || \ - defined (CONFIG_LCD) || \ - defined (CONFIG_VFD) - setup_start_tag (bd); -#ifdef CONFIG_SERIAL_TAG - setup_serial_tag (¶ms); -#endif -#ifdef CONFIG_REVISION_TAG - setup_revision_tag (¶ms); -#endif -#ifdef CONFIG_SETUP_MEMORY_TAGS - setup_memory_tags (bd); -#endif -#ifdef CONFIG_CMDLINE_TAG - setup_commandline_tag (bd, commandline); -#endif -#ifdef CONFIG_INITRD_TAG - if (initrd_start && initrd_end) - setup_initrd_tag (bd, initrd_start, initrd_end); -#endif -#if defined (CONFIG_VFD) || defined (CONFIG_LCD) - setup_videolfb_tag ((gd_t *) gd); -#endif - setup_end_tag (bd); -#endif - - /* we assume that the kernel is in place */ - printf ("\nStarting kernel ...\n\n"); - -#ifdef CONFIG_USB_DEVICE - { - extern void udc_disconnect (void); - udc_disconnect (); - } -#endif - - cleanup_before_linux (); - - theKernel (0, bd->bi_arch_number, bd->bi_boot_params); -} - - -#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ - defined (CONFIG_CMDLINE_TAG) || \ - defined (CONFIG_INITRD_TAG) || \ - defined (CONFIG_SERIAL_TAG) || \ - defined (CONFIG_REVISION_TAG) || \ - defined (CONFIG_LCD) || \ - defined (CONFIG_VFD) -static void setup_start_tag (bd_t *bd) -{ - params = (struct tag *) bd->bi_boot_params; - - params->hdr.tag = ATAG_CORE; - params->hdr.size = tag_size (tag_core); - - params->u.core.flags = 0; - params->u.core.pagesize = 0; - params->u.core.rootdev = 0; - - params = tag_next (params); -} - - -#ifdef CONFIG_SETUP_MEMORY_TAGS -static void setup_memory_tags (bd_t *bd) -{ - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - params->hdr.tag = ATAG_MEM; - params->hdr.size = tag_size (tag_mem32); - - params->u.mem.start = bd->bi_dram[i].start; - params->u.mem.size = bd->bi_dram[i].size; - - params = tag_next (params); - } -} -#endif /* CONFIG_SETUP_MEMORY_TAGS */ - - -static void setup_commandline_tag (bd_t *bd, char *commandline) -{ - char *p; - - if (!commandline) - return; - - /* eat leading white space */ - for (p = commandline; *p == ' '; p++); - - /* skip non-existent command lines so the kernel will still - * use its default command line. - */ - if (*p == '\0') - return; - - params->hdr.tag = ATAG_CMDLINE; - params->hdr.size = - (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; - - strcpy (params->u.cmdline.cmdline, p); - - params = tag_next (params); -} - - -#ifdef CONFIG_INITRD_TAG -static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end) -{ - /* 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; - params->hdr.size = tag_size (tag_initrd); - - params->u.initrd.start = initrd_start; - params->u.initrd.size = initrd_end - initrd_start; - - params = tag_next (params); -} -#endif /* CONFIG_INITRD_TAG */ - - -#if defined (CONFIG_VFD) || defined (CONFIG_LCD) -extern ulong calc_fbsize (void); -static void setup_videolfb_tag (gd_t *gd) -{ - /* 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; - params->hdr.size = tag_size (tag_videolfb); - - params->u.videolfb.lfb_base = (u32) gd->fb_base; - /* Fb size is calculated according to parameters for our panel - */ - params->u.videolfb.lfb_size = calc_fbsize(); - - params = tag_next (params); -} -#endif /* CONFIG_VFD || CONFIG_LCD */ - -#ifdef CONFIG_SERIAL_TAG -void setup_serial_tag (struct tag **tmp) -{ - 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; - params->hdr.size = tag_size (tag_serialnr); - params->u.serialnr.low = serialnr.low; - params->u.serialnr.high= serialnr.high; - params = tag_next (params); - *tmp = params; -} -#endif - -#ifdef CONFIG_REVISION_TAG -void setup_revision_tag(struct tag **in_params) -{ - u32 rev = 0; - u32 get_board_rev(void); - - rev = get_board_rev(); - params->hdr.tag = ATAG_REVISION; - params->hdr.size = tag_size (tag_revision); - params->u.revision.rev = rev; - params = tag_next (params); -} -#endif /* CONFIG_REVISION_TAG */ - - -static void setup_end_tag (bd_t *bd) -{ - params->hdr.tag = ATAG_NONE; - params->hdr.size = 0; -} - -#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ diff --git a/lib_arm/bootm.c b/lib_arm/bootm.c new file mode 100644 index 000000000..4f9aae613 --- /dev/null +++ b/lib_arm/bootm.c @@ -0,0 +1,384 @@ +/* + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH + * Marius Groeger + * + * 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 +#include +#include +#include +#include +#ifdef CONFIG_HAS_DATAFLASH +#include +#endif + +DECLARE_GLOBAL_DATA_PTR; + +/*cmd_boot.c*/ +extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ + defined (CONFIG_CMDLINE_TAG) || \ + defined (CONFIG_INITRD_TAG) || \ + defined (CONFIG_SERIAL_TAG) || \ + defined (CONFIG_REVISION_TAG) || \ + defined (CONFIG_VFD) || \ + defined (CONFIG_LCD) +static void setup_start_tag (bd_t *bd); + +# ifdef CONFIG_SETUP_MEMORY_TAGS +static void setup_memory_tags (bd_t *bd); +# endif +static void setup_commandline_tag (bd_t *bd, char *commandline); + +#if 0 +static void setup_ramdisk_tag (bd_t *bd); +#endif +# ifdef CONFIG_INITRD_TAG +static void setup_initrd_tag (bd_t *bd, ulong initrd_start, + ulong initrd_end); +# endif +static void setup_end_tag (bd_t *bd); + +# if defined (CONFIG_VFD) || defined (CONFIG_LCD) +static void setup_videolfb_tag (gd_t *gd); +# endif + + +static struct tag *params; +#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ + +void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + ulong rd_addr; + ulong rd_data, rd_len = 0; + ulong initrd_start, initrd_end; + image_header_t *rd_hdr; + void (*theKernel)(int zero, int arch, uint params); + bd_t *bd = gd->bd; + +#ifdef CONFIG_CMDLINE_TAG + char *commandline = getenv ("bootargs"); +#endif + + theKernel = (void (*)(int, int, uint))image_get_ep (hdr); + + /* + * Check if there is an initrd image + */ + if (argc >= 3) { + show_boot_progress (9); + + rd_addr = simple_strtoul (argv[2], NULL, 16); + printf ("## Loading Ramdisk Image at %08lx ...\n", rd_addr); + + /* Copy header so we can blank CRC field for re-calculation */ +#ifdef CONFIG_HAS_DATAFLASH + if (addr_dataflash (rd_addr)) { + rd_hdr = (image_header_t *)CFG_LOAD_ADDR; + read_dataflash (rd_addr, image_get_header_size (), + (char *)rd_hdr); + } else +#endif + rd_hdr = (image_header_t *)rd_addr; + + if (!image_check_magic (rd_hdr)) { + printf ("Bad Magic Number\n"); + show_boot_progress (-10); + do_reset (cmdtp, flag, argc, argv); + } + + if (!image_check_hcrc (rd_hdr)) { + printf ("Bad Header Checksum\n"); + show_boot_progress (-11); + do_reset (cmdtp, flag, argc, argv); + } + + show_boot_progress (10); + + print_image_hdr (rd_hdr); + + rd_data = image_get_data (rd_hdr); + rd_len = image_get_data_size (rd_hdr); + +#ifdef CONFIG_HAS_DATAFLASH + if (addr_dataflash (rd_addr)) + read_dataflash (rd_addr + image_get_header_size (), + rd_len, (char *)rd_data); +#endif + + if (verify) { + printf (" Verifying Checksum ... "); + if (!image_get_dcrc (rd_hdr)) { + printf ("Bad Data CRC\n"); + show_boot_progress (-12); + do_reset (cmdtp, flag, argc, argv); + } + printf ("OK\n"); + } + + show_boot_progress (11); + + if (!image_check_os (rd_hdr, IH_OS_LINUX) || + !image_check_arch (rd_hdr, IH_ARCH_ARM) || + !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { + printf ("No Linux ARM Ramdisk Image\n"); + show_boot_progress (-13); + do_reset (cmdtp, flag, argc, argv); + } + +#if defined(CONFIG_B2) || defined(CONFIG_EVB4510) || defined(CONFIG_ARMADILLO) + /* + *we need to copy the ramdisk to SRAM to let Linux boot + */ + memmove ((void *)image_get_load (rd_hdr), (uchar *)rd_data, rd_len); + rd_data = image_get_load (rd_hdr); +#endif /* CONFIG_B2 || CONFIG_EVB4510 */ + + /* + * Now check if we have a multifile image + */ + } else if (image_check_type (hdr, IH_TYPE_MULTI)) { + /* + * Get second entry data start address and len + */ + show_boot_progress (13); + image_multi_getimg (hdr, 1, &rd_data, &rd_len); + } else { + /* + * no initrd image + */ + show_boot_progress (14); + + rd_len = rd_data = 0; + } + +#ifdef DEBUG + if (!rd_data) { + printf ("No initrd\n"); + } +#endif + + if (rd_data) { + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + } else { + initrd_start = 0; + initrd_end = 0; + } + + show_boot_progress (15); + + debug ("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); + +#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ + defined (CONFIG_CMDLINE_TAG) || \ + defined (CONFIG_INITRD_TAG) || \ + defined (CONFIG_SERIAL_TAG) || \ + defined (CONFIG_REVISION_TAG) || \ + defined (CONFIG_LCD) || \ + defined (CONFIG_VFD) + setup_start_tag (bd); +#ifdef CONFIG_SERIAL_TAG + setup_serial_tag (¶ms); +#endif +#ifdef CONFIG_REVISION_TAG + setup_revision_tag (¶ms); +#endif +#ifdef CONFIG_SETUP_MEMORY_TAGS + setup_memory_tags (bd); +#endif +#ifdef CONFIG_CMDLINE_TAG + setup_commandline_tag (bd, commandline); +#endif +#ifdef CONFIG_INITRD_TAG + if (initrd_start && initrd_end) + setup_initrd_tag (bd, initrd_start, initrd_end); +#endif +#if defined (CONFIG_VFD) || defined (CONFIG_LCD) + setup_videolfb_tag ((gd_t *) gd); +#endif + setup_end_tag (bd); +#endif + + /* we assume that the kernel is in place */ + printf ("\nStarting kernel ...\n\n"); + +#ifdef CONFIG_USB_DEVICE + { + extern void udc_disconnect (void); + udc_disconnect (); + } +#endif + + cleanup_before_linux (); + + theKernel (0, bd->bi_arch_number, bd->bi_boot_params); +} + + +#if defined (CONFIG_SETUP_MEMORY_TAGS) || \ + defined (CONFIG_CMDLINE_TAG) || \ + defined (CONFIG_INITRD_TAG) || \ + defined (CONFIG_SERIAL_TAG) || \ + defined (CONFIG_REVISION_TAG) || \ + defined (CONFIG_LCD) || \ + defined (CONFIG_VFD) +static void setup_start_tag (bd_t *bd) +{ + params = (struct tag *) bd->bi_boot_params; + + params->hdr.tag = ATAG_CORE; + params->hdr.size = tag_size (tag_core); + + params->u.core.flags = 0; + params->u.core.pagesize = 0; + params->u.core.rootdev = 0; + + params = tag_next (params); +} + + +#ifdef CONFIG_SETUP_MEMORY_TAGS +static void setup_memory_tags (bd_t *bd) +{ + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + params->hdr.tag = ATAG_MEM; + params->hdr.size = tag_size (tag_mem32); + + params->u.mem.start = bd->bi_dram[i].start; + params->u.mem.size = bd->bi_dram[i].size; + + params = tag_next (params); + } +} +#endif /* CONFIG_SETUP_MEMORY_TAGS */ + + +static void setup_commandline_tag (bd_t *bd, char *commandline) +{ + char *p; + + if (!commandline) + return; + + /* eat leading white space */ + for (p = commandline; *p == ' '; p++); + + /* skip non-existent command lines so the kernel will still + * use its default command line. + */ + if (*p == '\0') + return; + + params->hdr.tag = ATAG_CMDLINE; + params->hdr.size = + (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; + + strcpy (params->u.cmdline.cmdline, p); + + params = tag_next (params); +} + + +#ifdef CONFIG_INITRD_TAG +static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end) +{ + /* 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; + params->hdr.size = tag_size (tag_initrd); + + params->u.initrd.start = initrd_start; + params->u.initrd.size = initrd_end - initrd_start; + + params = tag_next (params); +} +#endif /* CONFIG_INITRD_TAG */ + + +#if defined (CONFIG_VFD) || defined (CONFIG_LCD) +extern ulong calc_fbsize (void); +static void setup_videolfb_tag (gd_t *gd) +{ + /* 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; + params->hdr.size = tag_size (tag_videolfb); + + params->u.videolfb.lfb_base = (u32) gd->fb_base; + /* Fb size is calculated according to parameters for our panel + */ + params->u.videolfb.lfb_size = calc_fbsize(); + + params = tag_next (params); +} +#endif /* CONFIG_VFD || CONFIG_LCD */ + +#ifdef CONFIG_SERIAL_TAG +void setup_serial_tag (struct tag **tmp) +{ + 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; + params->hdr.size = tag_size (tag_serialnr); + params->u.serialnr.low = serialnr.low; + params->u.serialnr.high= serialnr.high; + params = tag_next (params); + *tmp = params; +} +#endif + +#ifdef CONFIG_REVISION_TAG +void setup_revision_tag(struct tag **in_params) +{ + u32 rev = 0; + u32 get_board_rev(void); + + rev = get_board_rev(); + params->hdr.tag = ATAG_REVISION; + params->hdr.size = tag_size (tag_revision); + params->u.revision.rev = rev; + params = tag_next (params); +} +#endif /* CONFIG_REVISION_TAG */ + + +static void setup_end_tag (bd_t *bd) +{ + params->hdr.tag = ATAG_NONE; + params->hdr.size = 0; +} + +#endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ diff --git a/lib_avr32/Makefile b/lib_avr32/Makefile index bb2938fe5..ebe237b15 100644 --- a/lib_avr32/Makefile +++ b/lib_avr32/Makefile @@ -29,7 +29,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = memset.o -COBJS = board.o interrupts.o avr32_linux.o +COBJS = board.o interrupts.o bootm.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_avr32/avr32_linux.c b/lib_avr32/avr32_linux.c deleted file mode 100644 index 455590e37..000000000 --- a/lib_avr32/avr32_linux.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright (C) 2004-2006 Atmel Corporation - * - * 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 - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - -extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -/* CPU-specific hook to allow flushing of caches, etc. */ -extern void prepare_to_boot(void); - -static struct tag *setup_start_tag(struct tag *params) -{ - params->hdr.tag = ATAG_CORE; - params->hdr.size = tag_size(tag_core); - - params->u.core.flags = 0; - params->u.core.pagesize = 4096; - params->u.core.rootdev = 0; - - return tag_next(params); -} - -static struct tag *setup_memory_tags(struct tag *params) -{ - bd_t *bd = gd->bd; - int i; - - for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { - params->hdr.tag = ATAG_MEM; - params->hdr.size = tag_size(tag_mem_range); - - params->u.mem_range.addr = bd->bi_dram[i].start; - params->u.mem_range.size = bd->bi_dram[i].size; - - params = tag_next(params); - } - - return params; -} - -static struct tag *setup_commandline_tag(struct tag *params, char *cmdline) -{ - if (!cmdline) - return params; - - /* eat leading white space */ - while (*cmdline == ' ') cmdline++; - - /* - * Don't include tags for empty command lines; let the kernel - * use its default command line. - */ - if (*cmdline == '\0') - return params; - - params->hdr.tag = ATAG_CMDLINE; - params->hdr.size = - (sizeof (struct tag_header) + strlen(cmdline) + 1 + 3) >> 2; - strcpy(params->u.cmdline.cmdline, cmdline); - - return tag_next(params); -} - -static struct tag *setup_ramdisk_tag(struct tag *params, - unsigned long rd_start, - unsigned long rd_end) -{ - if (rd_start == rd_end) - return params; - - params->hdr.tag = ATAG_RDIMG; - params->hdr.size = tag_size(tag_mem_range); - - params->u.mem_range.addr = rd_start; - params->u.mem_range.size = rd_end - rd_start; - - return tag_next(params); -} - -static struct tag *setup_clock_tags(struct tag *params) -{ - params->hdr.tag = ATAG_CLOCK; - params->hdr.size = tag_size(tag_clock); - params->u.clock.clock_id = ACLOCK_BOOTCPU; - params->u.clock.clock_flags = 0; - params->u.clock.clock_hz = gd->cpu_hz; - -#ifdef CONFIG_AT32AP7000 - /* - * New kernels don't need this, but we should be backwards - * compatible for a while... - */ - params = tag_next(params); - - params->hdr.tag = ATAG_CLOCK; - params->hdr.size = tag_size(tag_clock); - params->u.clock.clock_id = ACLOCK_HSB; - params->u.clock.clock_flags = 0; - params->u.clock.clock_hz = get_hsb_clk_rate(); -#endif - - return tag_next(params); -} - -static struct tag *setup_ethernet_tag(struct tag *params, - char *addr, int index) -{ - char *s, *e; - int i; - - params->hdr.tag = ATAG_ETHERNET; - params->hdr.size = tag_size(tag_ethernet); - - params->u.ethernet.mac_index = index; - params->u.ethernet.mii_phy_addr = gd->bd->bi_phy_id[index]; - - s = addr; - for (i = 0; i < 6; i++) { - params->u.ethernet.hw_address[i] = simple_strtoul(s, &e, 16); - s = e + 1; - } - - return tag_next(params); -} - -static struct tag *setup_ethernet_tags(struct tag *params) -{ - char name[16] = "ethaddr"; - char *addr; - int i = 0; - - do { - addr = getenv(name); - if (addr) - params = setup_ethernet_tag(params, addr, i); - sprintf(name, "eth%daddr", ++i); - } while (i < 4); - - return params; -} - -static void setup_end_tag(struct tag *params) -{ - params->hdr.tag = ATAG_NONE; - params->hdr.size = 0; -} - -void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - ulong rd_data, rd_len = 0; - ulong initrd_start, initrd_end; - image_header_t *rd_hdr; - - void (*theKernel)(int magic, void *tagtable); - struct tag *params, *params_start; - char *commandline = getenv("bootargs"); - - theKernel = (void *)image_get_ep (hdr); - - /* - * Check if there is an initrd image - */ - if (argc >= 3) { - show_boot_progress (9); - - rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); - printf ("## Loading RAMDISK image at %08lx ...\n", rd_hdr); - - if (!image_check_magic (rd_hdr)) { - puts("Bad Magic Number\n"); - show_boot_progress (-10); - do_reset(cmdtp, flag, argc, argv); - } - - if (!image_check_hcrc (rd_hdr)) { - puts("Bad Header Checksum\n"); - show_boot_progress (-11); - do_reset(cmdtp, flag, argc, argv); - } - - show_boot_progress (10); - print_image_hdr (rd_hdr); - - if (verify) { - puts(" Verifying Checksum ... "); - if (!image_check_dcrc (rd_hdr)) { - puts("Bad Data CRC\n"); - show_boot_progress (-12); - do_reset(cmdtp, flag, argc, argv); - } - puts("OK\n"); - } - - show_boot_progress (11); - - if (!image_check_os (rd_hdr, IH_OS_LINUX) || - !image_check_arch (rd_hdr, IH_ARCH_AVR32) || - !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { - puts("Not a Linux/AVR32 RAMDISK image\n"); - show_boot_progress (-13); - do_reset(cmdtp, flag, argc, argv); - } - - rd_data = image_get_data (rd_hdr); - rd_len = image_get_data_size (rd_hdr); - - } else if (image_check_type (hdr, IH_TYPE_MULTI)) { - /* - * Get second entry data start address and len - */ - show_boot_progress (13); - image_multi_getimg (hdr, 1, &rd_data, &rd_len); - } else { - /* no initrd image */ - show_boot_progress (14); - rd_len = rd_data = 0; - } - - if (rd_data) { - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - } else { - initrd_start = 0; - initrd_end = 0; - } - - show_boot_progress (15); - - params = params_start = (struct tag *)gd->bd->bi_boot_params; - params = setup_start_tag(params); - params = setup_memory_tags(params); - if (initrd_start) { - params = setup_ramdisk_tag(params, - PHYSADDR(initrd_start), - PHYSADDR(initrd_end)); - } - params = setup_commandline_tag(params, commandline); - params = setup_clock_tags(params); - params = setup_ethernet_tags(params); - setup_end_tag(params); - - printf("\nStarting kernel at %p (params at %p)...\n\n", - theKernel, params_start); - - prepare_to_boot(); - - theKernel(ATAG_MAGIC, params_start); -} diff --git a/lib_avr32/bootm.c b/lib_avr32/bootm.c new file mode 100644 index 000000000..455590e37 --- /dev/null +++ b/lib_avr32/bootm.c @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2004-2006 Atmel Corporation + * + * 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 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +extern int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +/* CPU-specific hook to allow flushing of caches, etc. */ +extern void prepare_to_boot(void); + +static struct tag *setup_start_tag(struct tag *params) +{ + params->hdr.tag = ATAG_CORE; + params->hdr.size = tag_size(tag_core); + + params->u.core.flags = 0; + params->u.core.pagesize = 4096; + params->u.core.rootdev = 0; + + return tag_next(params); +} + +static struct tag *setup_memory_tags(struct tag *params) +{ + bd_t *bd = gd->bd; + int i; + + for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { + params->hdr.tag = ATAG_MEM; + params->hdr.size = tag_size(tag_mem_range); + + params->u.mem_range.addr = bd->bi_dram[i].start; + params->u.mem_range.size = bd->bi_dram[i].size; + + params = tag_next(params); + } + + return params; +} + +static struct tag *setup_commandline_tag(struct tag *params, char *cmdline) +{ + if (!cmdline) + return params; + + /* eat leading white space */ + while (*cmdline == ' ') cmdline++; + + /* + * Don't include tags for empty command lines; let the kernel + * use its default command line. + */ + if (*cmdline == '\0') + return params; + + params->hdr.tag = ATAG_CMDLINE; + params->hdr.size = + (sizeof (struct tag_header) + strlen(cmdline) + 1 + 3) >> 2; + strcpy(params->u.cmdline.cmdline, cmdline); + + return tag_next(params); +} + +static struct tag *setup_ramdisk_tag(struct tag *params, + unsigned long rd_start, + unsigned long rd_end) +{ + if (rd_start == rd_end) + return params; + + params->hdr.tag = ATAG_RDIMG; + params->hdr.size = tag_size(tag_mem_range); + + params->u.mem_range.addr = rd_start; + params->u.mem_range.size = rd_end - rd_start; + + return tag_next(params); +} + +static struct tag *setup_clock_tags(struct tag *params) +{ + params->hdr.tag = ATAG_CLOCK; + params->hdr.size = tag_size(tag_clock); + params->u.clock.clock_id = ACLOCK_BOOTCPU; + params->u.clock.clock_flags = 0; + params->u.clock.clock_hz = gd->cpu_hz; + +#ifdef CONFIG_AT32AP7000 + /* + * New kernels don't need this, but we should be backwards + * compatible for a while... + */ + params = tag_next(params); + + params->hdr.tag = ATAG_CLOCK; + params->hdr.size = tag_size(tag_clock); + params->u.clock.clock_id = ACLOCK_HSB; + params->u.clock.clock_flags = 0; + params->u.clock.clock_hz = get_hsb_clk_rate(); +#endif + + return tag_next(params); +} + +static struct tag *setup_ethernet_tag(struct tag *params, + char *addr, int index) +{ + char *s, *e; + int i; + + params->hdr.tag = ATAG_ETHERNET; + params->hdr.size = tag_size(tag_ethernet); + + params->u.ethernet.mac_index = index; + params->u.ethernet.mii_phy_addr = gd->bd->bi_phy_id[index]; + + s = addr; + for (i = 0; i < 6; i++) { + params->u.ethernet.hw_address[i] = simple_strtoul(s, &e, 16); + s = e + 1; + } + + return tag_next(params); +} + +static struct tag *setup_ethernet_tags(struct tag *params) +{ + char name[16] = "ethaddr"; + char *addr; + int i = 0; + + do { + addr = getenv(name); + if (addr) + params = setup_ethernet_tag(params, addr, i); + sprintf(name, "eth%daddr", ++i); + } while (i < 4); + + return params; +} + +static void setup_end_tag(struct tag *params) +{ + params->hdr.tag = ATAG_NONE; + params->hdr.size = 0; +} + +void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + ulong rd_data, rd_len = 0; + ulong initrd_start, initrd_end; + image_header_t *rd_hdr; + + void (*theKernel)(int magic, void *tagtable); + struct tag *params, *params_start; + char *commandline = getenv("bootargs"); + + theKernel = (void *)image_get_ep (hdr); + + /* + * Check if there is an initrd image + */ + if (argc >= 3) { + show_boot_progress (9); + + rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); + printf ("## Loading RAMDISK image at %08lx ...\n", rd_hdr); + + if (!image_check_magic (rd_hdr)) { + puts("Bad Magic Number\n"); + show_boot_progress (-10); + do_reset(cmdtp, flag, argc, argv); + } + + if (!image_check_hcrc (rd_hdr)) { + puts("Bad Header Checksum\n"); + show_boot_progress (-11); + do_reset(cmdtp, flag, argc, argv); + } + + show_boot_progress (10); + print_image_hdr (rd_hdr); + + if (verify) { + puts(" Verifying Checksum ... "); + if (!image_check_dcrc (rd_hdr)) { + puts("Bad Data CRC\n"); + show_boot_progress (-12); + do_reset(cmdtp, flag, argc, argv); + } + puts("OK\n"); + } + + show_boot_progress (11); + + if (!image_check_os (rd_hdr, IH_OS_LINUX) || + !image_check_arch (rd_hdr, IH_ARCH_AVR32) || + !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { + puts("Not a Linux/AVR32 RAMDISK image\n"); + show_boot_progress (-13); + do_reset(cmdtp, flag, argc, argv); + } + + rd_data = image_get_data (rd_hdr); + rd_len = image_get_data_size (rd_hdr); + + } else if (image_check_type (hdr, IH_TYPE_MULTI)) { + /* + * Get second entry data start address and len + */ + show_boot_progress (13); + image_multi_getimg (hdr, 1, &rd_data, &rd_len); + } else { + /* no initrd image */ + show_boot_progress (14); + rd_len = rd_data = 0; + } + + if (rd_data) { + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + } else { + initrd_start = 0; + initrd_end = 0; + } + + show_boot_progress (15); + + params = params_start = (struct tag *)gd->bd->bi_boot_params; + params = setup_start_tag(params); + params = setup_memory_tags(params); + if (initrd_start) { + params = setup_ramdisk_tag(params, + PHYSADDR(initrd_start), + PHYSADDR(initrd_end)); + } + params = setup_commandline_tag(params, commandline); + params = setup_clock_tags(params); + params = setup_ethernet_tags(params); + setup_end_tag(params); + + printf("\nStarting kernel at %p (params at %p)...\n\n", + theKernel, params_start); + + prepare_to_boot(); + + theKernel(ATAG_MAGIC, params_start); +} diff --git a/lib_blackfin/Makefile b/lib_blackfin/Makefile index a7aaef7a3..ac3fb2855 100644 --- a/lib_blackfin/Makefile +++ b/lib_blackfin/Makefile @@ -31,7 +31,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = memcpy.o memcmp.o memset.o memmove.o -COBJS = post.o tests.o board.o bf533_linux.o bf533_string.o cache.o muldi3.o +COBJS = post.o tests.o board.o bootm.o bf533_string.o cache.o muldi3.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_blackfin/bf533_linux.c b/lib_blackfin/bf533_linux.c deleted file mode 100644 index 6299415b1..000000000 --- a/lib_blackfin/bf533_linux.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * U-boot - bf533_linux.c - * - * Copyright (c) 2005-2007 Analog Devices Inc. - * - * (C) Copyright 2000-2004 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * 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., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -/* Dummy functions, currently not in Use */ - -#include -#include -#include -#include -#include - -#define LINUX_MAX_ENVS 256 -#define LINUX_MAX_ARGS 256 - -#define CMD_LINE_ADDR 0xFF900000 /* L1 scratchpad */ - -#ifdef SHARED_RESOURCES -extern void swap_to(int device_id); -#endif - -extern void flush_instruction_cache(void); -extern void flush_data_cache(void); -static char *make_command_line(void); - -void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - int (*appl) (char *cmdline); - char *cmdline; - -#ifdef SHARED_RESOURCES - swap_to(FLASH); -#endif - - appl = (int (*)(char *))image_get_ep (hdr); - printf("Starting Kernel at = %x\n", appl); - cmdline = make_command_line(); - if (icache_status()) { - flush_instruction_cache(); - icache_disable(); - } - if (dcache_status()) { - flush_data_cache(); - dcache_disable(); - } - (*appl) (cmdline); -} - -char *make_command_line(void) -{ - char *dest = (char *)CMD_LINE_ADDR; - char *bootargs; - - if ((bootargs = getenv("bootargs")) == NULL) - return NULL; - - strncpy(dest, bootargs, 0x1000); - dest[0xfff] = 0; - return dest; -} diff --git a/lib_blackfin/bootm.c b/lib_blackfin/bootm.c new file mode 100644 index 000000000..6299415b1 --- /dev/null +++ b/lib_blackfin/bootm.c @@ -0,0 +1,84 @@ +/* + * U-boot - bf533_linux.c + * + * Copyright (c) 2005-2007 Analog Devices Inc. + * + * (C) Copyright 2000-2004 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +/* Dummy functions, currently not in Use */ + +#include +#include +#include +#include +#include + +#define LINUX_MAX_ENVS 256 +#define LINUX_MAX_ARGS 256 + +#define CMD_LINE_ADDR 0xFF900000 /* L1 scratchpad */ + +#ifdef SHARED_RESOURCES +extern void swap_to(int device_id); +#endif + +extern void flush_instruction_cache(void); +extern void flush_data_cache(void); +static char *make_command_line(void); + +void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + int (*appl) (char *cmdline); + char *cmdline; + +#ifdef SHARED_RESOURCES + swap_to(FLASH); +#endif + + appl = (int (*)(char *))image_get_ep (hdr); + printf("Starting Kernel at = %x\n", appl); + cmdline = make_command_line(); + if (icache_status()) { + flush_instruction_cache(); + icache_disable(); + } + if (dcache_status()) { + flush_data_cache(); + dcache_disable(); + } + (*appl) (cmdline); +} + +char *make_command_line(void) +{ + char *dest = (char *)CMD_LINE_ADDR; + char *bootargs; + + if ((bootargs = getenv("bootargs")) == NULL) + return NULL; + + strncpy(dest, bootargs, 0x1000); + dest[0xfff] = 0; + return dest; +} diff --git a/lib_i386/Makefile b/lib_i386/Makefile index e344da515..ef0ba5467 100644 --- a/lib_i386/Makefile +++ b/lib_i386/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = bios.o bios_pci.o realmode_switch.o -COBJS = board.o bios_setup.o i386_linux.o zimage.o realmode.o \ +COBJS = board.o bios_setup.o bootm.o zimage.o realmode.o \ pci_type1.o pci.o video_bios.o video.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c new file mode 100644 index 000000000..27a2b0d9a --- /dev/null +++ b/lib_i386/bootm.c @@ -0,0 +1,142 @@ +/* + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH + * Marius Groeger + * + * 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 +#include +#include +#include +#include +#include + +/*cmd_boot.c*/ +extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + void *base_ptr; + + ulong os_data, os_len; + ulong rd_data, rd_len; + ulong initrd_start, initrd_end; + image_header_t *rd_hdr; + + /* + * Check if there is an initrd image + */ + if (argc >= 3) { + rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); + printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr); + + if (!image_check_magic (rd_hdr)) { + printf ("Bad Magic Number\n"); + do_reset (cmdtp, flag, argc, argv); + } + + if (!image_check_hcrc (rd_hdr)) { + printf ("Bad Header Checksum\n"); + do_reset (cmdtp, flag, argc, argv); + } + + print_image_hdr (rd_hdr); + + rd_data = image_get_data (rd_hdr); + rd_len = image_get_data_size (rd_hdr); + + if (verify) { + printf (" Verifying Checksum ... "); + if (!image_check_dcrc (rd_hdr)) { + printf ("Bad Data CRC\n"); + do_reset (cmdtp, flag, argc, argv); + } + printf ("OK\n"); + } + + 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)) { + printf ("No Linux i386 Ramdisk Image\n"); + do_reset (cmdtp, flag, argc, argv); + } + + /* + * Now check if we have a multifile image + */ + } 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); + } else { + /* + * no initrd image + */ + rd_data = rd_len = 0; + } + +#ifdef DEBUG + if (!rd_data) { + printf ("No initrd\n"); + } +#endif + + if (rd_data) { + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + printf (" Loading Ramdisk to %08lx, end %08lx ... ", + initrd_start, initrd_end); + memmove ((void *)initrd_start, (void *)rd_data, rd_len); + printf ("OK\n"); + } else { + initrd_start = 0; + initrd_end = 0; + } + + /* if multi-part image, we need to advance base ptr */ + 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); + } + + base_ptr = load_zimage ((void*)os_data, os_len, + initrd_start, rd_len, 0); + + if (NULL == base_ptr) { + printf ("## Kernel loading failed ...\n"); + do_reset(cmdtp, flag, argc, argv); + + } + +#ifdef DEBUG + printf ("## Transferring control to Linux (at address %08x) ...\n", + (u32)base_ptr); +#endif + + /* we assume that the kernel is in place */ + printf("\nStarting kernel ...\n\n"); + + boot_zimage(base_ptr); + +} diff --git a/lib_i386/i386_linux.c b/lib_i386/i386_linux.c deleted file mode 100644 index 27a2b0d9a..000000000 --- a/lib_i386/i386_linux.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * (C) Copyright 2002 - * Sysgo Real-Time Solutions, GmbH - * Marius Groeger - * - * 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 -#include -#include -#include -#include -#include - -/*cmd_boot.c*/ -extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - void *base_ptr; - - ulong os_data, os_len; - ulong rd_data, rd_len; - ulong initrd_start, initrd_end; - image_header_t *rd_hdr; - - /* - * Check if there is an initrd image - */ - if (argc >= 3) { - rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); - printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr); - - if (!image_check_magic (rd_hdr)) { - printf ("Bad Magic Number\n"); - do_reset (cmdtp, flag, argc, argv); - } - - if (!image_check_hcrc (rd_hdr)) { - printf ("Bad Header Checksum\n"); - do_reset (cmdtp, flag, argc, argv); - } - - print_image_hdr (rd_hdr); - - rd_data = image_get_data (rd_hdr); - rd_len = image_get_data_size (rd_hdr); - - if (verify) { - printf (" Verifying Checksum ... "); - if (!image_check_dcrc (rd_hdr)) { - printf ("Bad Data CRC\n"); - do_reset (cmdtp, flag, argc, argv); - } - printf ("OK\n"); - } - - 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)) { - printf ("No Linux i386 Ramdisk Image\n"); - do_reset (cmdtp, flag, argc, argv); - } - - /* - * Now check if we have a multifile image - */ - } 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); - } else { - /* - * no initrd image - */ - rd_data = rd_len = 0; - } - -#ifdef DEBUG - if (!rd_data) { - printf ("No initrd\n"); - } -#endif - - if (rd_data) { - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - printf (" Loading Ramdisk to %08lx, end %08lx ... ", - initrd_start, initrd_end); - memmove ((void *)initrd_start, (void *)rd_data, rd_len); - printf ("OK\n"); - } else { - initrd_start = 0; - initrd_end = 0; - } - - /* if multi-part image, we need to advance base ptr */ - 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); - } - - base_ptr = load_zimage ((void*)os_data, os_len, - initrd_start, rd_len, 0); - - if (NULL == base_ptr) { - printf ("## Kernel loading failed ...\n"); - do_reset(cmdtp, flag, argc, argv); - - } - -#ifdef DEBUG - printf ("## Transferring control to Linux (at address %08x) ...\n", - (u32)base_ptr); -#endif - - /* we assume that the kernel is in place */ - printf("\nStarting kernel ...\n\n"); - - boot_zimage(base_ptr); - -} diff --git a/lib_m68k/Makefile b/lib_m68k/Makefile index 03784fd84..d51522325 100644 --- a/lib_m68k/Makefile +++ b/lib_m68k/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = -COBJS = cache.o traps.o time.o interrupts.o board.o m68k_linux.o +COBJS = cache.o traps.o time.o interrupts.o board.o bootm.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_m68k/bootm.c b/lib_m68k/bootm.c new file mode 100644 index 000000000..b135556a9 --- /dev/null +++ b/lib_m68k/bootm.c @@ -0,0 +1,279 @@ +/* + * (C) Copyright 2003 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define PHYSADDR(x) x + +#define LINUX_MAX_ENVS 256 +#define LINUX_MAX_ARGS 256 + +#ifdef CONFIG_SHOW_BOOT_PROGRESS +# include +# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) +#else +# define SHOW_BOOT_PROGRESS(arg) +#endif + +int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, + int argc, char *argv[], + image_header_t *hdr, int verify) +{ + ulong sp; + + ulong rd_data, rd_len; + ulong initrd_high; + ulong initrd_start, initrd_end; + image_header_t *rd_hdr; + int initrd_copy_to_ram = 1; + + ulong cmd_start, cmd_end; + char *cmdline; + char *s; + bd_t *kbd; + void (*kernel) (bd_t *, ulong, ulong, ulong, ulong); + + if ((s = getenv("initrd_high")) != NULL) { + /* a value of "no" or a similar string will act like 0, + * turning the "load high" feature off. This is intentional. + */ + initrd_high = simple_strtoul(s, NULL, 16); + if (initrd_high == ~0) + initrd_copy_to_ram = 0; + } else { /* not set, no restrictions to load high */ + initrd_high = ~0; + } + +#ifdef CONFIG_LOGBUFFER + kbd = gd->bd; + /* Prevent initrd from overwriting logbuffer */ + if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) + initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; + debug("## Logbuffer at 0x%08lX ", kbd->bi_memsize - LOGBUFF_LEN); +#endif + + /* + * Booting a (Linux) kernel image + * + * Allocate space for command line and board info - the + * address should be as high as possible within the reach of + * the kernel (see CFG_BOOTMAPSZ settings), but in unused + * memory, which means far enough below the current stack + * pointer. + */ + asm("movel %%a7, %%d0\n" + "movel %%d0, %0\n": "=d"(sp): :"%d0"); + + debug("## Current stack ends at 0x%08lX ", sp); + + sp -= 2048; /* just to be sure */ + if (sp > CFG_BOOTMAPSZ) + sp = CFG_BOOTMAPSZ; + sp &= ~0xF; + + debug("=> set upper limit to 0x%08lX\n", sp); + + cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF); + kbd = (bd_t *) (((ulong) cmdline - sizeof(bd_t)) & ~0xF); + + if ((s = getenv("bootargs")) == NULL) + s = ""; + + strcpy(cmdline, s); + + cmd_start = (ulong) & cmdline[0]; + cmd_end = cmd_start + strlen(cmdline); + + *kbd = *(gd->bd); + +#ifdef DEBUG + printf("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end); + + do_bdinfo(NULL, 0, 0, NULL); +#endif + + if ((s = getenv("clocks_in_mhz")) != NULL) { + /* convert all clock information to MHz */ + kbd->bi_intfreq /= 1000000L; + kbd->bi_busfreq /= 1000000L; + } + + kernel = + (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr); + + /* + * Check if there is an initrd image + */ + + if (argc >= 3) { + debug("Not skipping initrd\n"); + SHOW_BOOT_PROGRESS(9); + + rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); + printf ("## Loading RAMDisk Image at %08lx ...\n", rd_hdr); + + if (!image_check_magic (rd_hdr)) { + puts("Bad Magic Number\n"); + SHOW_BOOT_PROGRESS(-10); + do_reset(cmdtp, flag, argc, argv); + } + + if (!image_check_hcrc (rd_hdr)) { + puts("Bad Header Checksum\n"); + SHOW_BOOT_PROGRESS(-11); + do_reset(cmdtp, flag, argc, argv); + } + + SHOW_BOOT_PROGRESS(10); + + print_image_hdr (rd_hdr); + + rd_data = image_get_data (rd_hdr); + rd_len = image_get_data_size (rd_hdr); + + if (verify) { + puts(" Verifying Checksum ... "); + if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) { + puts("Bad Data CRC\n"); + SHOW_BOOT_PROGRESS(-12); + do_reset(cmdtp, flag, argc, argv); + } + puts("OK\n"); + } + + SHOW_BOOT_PROGRESS(11); + + if (!image_check_os (rd_hdr, IH_OS_LINUX) || + !image_check_arch (rd_hdr, IH_ARCH_M68K) || + !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { + puts("No Linux ColdFire Ramdisk Image\n"); + SHOW_BOOT_PROGRESS(-13); + do_reset(cmdtp, flag, argc, argv); + } + + /* + * Now check if we have a multifile image + */ + } else if (image_check_type (hdr, IH_TYPE_MULTI)) { + /* + * Get second entry data start address and len + */ + SHOW_BOOT_PROGRESS (13); + image_multi_getimg (hdr, 1, &rd_data, &rd_len); + } else { + /* + * no initrd image + */ + SHOW_BOOT_PROGRESS(14); + + rd_len = rd_data = 0; + } + + if (!rd_data) { + debug("No initrd\n"); + } + + if (rd_data) { + if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + } else { + initrd_start = (ulong) kbd - rd_len; + initrd_start &= ~(4096 - 1); /* align on page */ + + if (initrd_high) { + ulong nsp; + + /* + * the inital ramdisk does not need to be within + * CFG_BOOTMAPSZ as it is not accessed until after + * the mm system is initialised. + * + * do the stack bottom calculation again and see if + * the initrd will fit just below the monitor stack + * bottom without overwriting the area allocated + * above for command line args and board info. + */ + asm("movel %%a7, %%d0\n" + "movel %%d0, %0\n": "=d"(nsp): :"%d0"); + + nsp -= 2048; /* just to be sure */ + nsp &= ~0xF; + + if (nsp > initrd_high) /* limit as specified */ + nsp = initrd_high; + + nsp -= rd_len; + nsp &= ~(4096 - 1); /* align on page */ + + if (nsp >= sp) + initrd_start = nsp; + } + + SHOW_BOOT_PROGRESS(12); + + debug + ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", + rd_data, rd_data + rd_len - 1, rd_len, rd_len); + + initrd_end = initrd_start + rd_len; + printf(" Loading Ramdisk to %08lx, end %08lx ... ", + initrd_start, initrd_end); + + memmove_wd((void *)initrd_start, + (void *)rd_data, rd_len, CHUNKSZ); + + puts("OK\n"); + } + } else { + initrd_start = 0; + initrd_end = 0; + } + + debug("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) kernel); + + SHOW_BOOT_PROGRESS(15); + + /* + * Linux Kernel Parameters (passing board info data): + * r3: ptr to board info data + * r4: initrd_start or 0 if no initrd + * r5: initrd_end - unused if r4 is 0 + * r6: Start of command line string + * r7: End of command line string + */ + (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); + /* does not return */ +} diff --git a/lib_m68k/m68k_linux.c b/lib_m68k/m68k_linux.c deleted file mode 100644 index b135556a9..000000000 --- a/lib_m68k/m68k_linux.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * (C) Copyright 2003 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * 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 - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - -#define PHYSADDR(x) x - -#define LINUX_MAX_ENVS 256 -#define LINUX_MAX_ARGS 256 - -#ifdef CONFIG_SHOW_BOOT_PROGRESS -# include -# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg) -#else -# define SHOW_BOOT_PROGRESS(arg) -#endif - -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, - int argc, char *argv[], - image_header_t *hdr, int verify) -{ - ulong sp; - - ulong rd_data, rd_len; - ulong initrd_high; - ulong initrd_start, initrd_end; - image_header_t *rd_hdr; - int initrd_copy_to_ram = 1; - - ulong cmd_start, cmd_end; - char *cmdline; - char *s; - bd_t *kbd; - void (*kernel) (bd_t *, ulong, ulong, ulong, ulong); - - if ((s = getenv("initrd_high")) != NULL) { - /* a value of "no" or a similar string will act like 0, - * turning the "load high" feature off. This is intentional. - */ - initrd_high = simple_strtoul(s, NULL, 16); - if (initrd_high == ~0) - initrd_copy_to_ram = 0; - } else { /* not set, no restrictions to load high */ - initrd_high = ~0; - } - -#ifdef CONFIG_LOGBUFFER - kbd = gd->bd; - /* Prevent initrd from overwriting logbuffer */ - if (initrd_high < (kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD)) - initrd_high = kbd->bi_memsize - LOGBUFF_LEN - LOGBUFF_OVERHEAD; - debug("## Logbuffer at 0x%08lX ", kbd->bi_memsize - LOGBUFF_LEN); -#endif - - /* - * Booting a (Linux) kernel image - * - * Allocate space for command line and board info - the - * address should be as high as possible within the reach of - * the kernel (see CFG_BOOTMAPSZ settings), but in unused - * memory, which means far enough below the current stack - * pointer. - */ - asm("movel %%a7, %%d0\n" - "movel %%d0, %0\n": "=d"(sp): :"%d0"); - - debug("## Current stack ends at 0x%08lX ", sp); - - sp -= 2048; /* just to be sure */ - if (sp > CFG_BOOTMAPSZ) - sp = CFG_BOOTMAPSZ; - sp &= ~0xF; - - debug("=> set upper limit to 0x%08lX\n", sp); - - cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF); - kbd = (bd_t *) (((ulong) cmdline - sizeof(bd_t)) & ~0xF); - - if ((s = getenv("bootargs")) == NULL) - s = ""; - - strcpy(cmdline, s); - - cmd_start = (ulong) & cmdline[0]; - cmd_end = cmd_start + strlen(cmdline); - - *kbd = *(gd->bd); - -#ifdef DEBUG - printf("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end); - - do_bdinfo(NULL, 0, 0, NULL); -#endif - - if ((s = getenv("clocks_in_mhz")) != NULL) { - /* convert all clock information to MHz */ - kbd->bi_intfreq /= 1000000L; - kbd->bi_busfreq /= 1000000L; - } - - kernel = - (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr); - - /* - * Check if there is an initrd image - */ - - if (argc >= 3) { - debug("Not skipping initrd\n"); - SHOW_BOOT_PROGRESS(9); - - rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); - printf ("## Loading RAMDisk Image at %08lx ...\n", rd_hdr); - - if (!image_check_magic (rd_hdr)) { - puts("Bad Magic Number\n"); - SHOW_BOOT_PROGRESS(-10); - do_reset(cmdtp, flag, argc, argv); - } - - if (!image_check_hcrc (rd_hdr)) { - puts("Bad Header Checksum\n"); - SHOW_BOOT_PROGRESS(-11); - do_reset(cmdtp, flag, argc, argv); - } - - SHOW_BOOT_PROGRESS(10); - - print_image_hdr (rd_hdr); - - rd_data = image_get_data (rd_hdr); - rd_len = image_get_data_size (rd_hdr); - - if (verify) { - puts(" Verifying Checksum ... "); - if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) { - puts("Bad Data CRC\n"); - SHOW_BOOT_PROGRESS(-12); - do_reset(cmdtp, flag, argc, argv); - } - puts("OK\n"); - } - - SHOW_BOOT_PROGRESS(11); - - if (!image_check_os (rd_hdr, IH_OS_LINUX) || - !image_check_arch (rd_hdr, IH_ARCH_M68K) || - !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { - puts("No Linux ColdFire Ramdisk Image\n"); - SHOW_BOOT_PROGRESS(-13); - do_reset(cmdtp, flag, argc, argv); - } - - /* - * Now check if we have a multifile image - */ - } else if (image_check_type (hdr, IH_TYPE_MULTI)) { - /* - * Get second entry data start address and len - */ - SHOW_BOOT_PROGRESS (13); - image_multi_getimg (hdr, 1, &rd_data, &rd_len); - } else { - /* - * no initrd image - */ - SHOW_BOOT_PROGRESS(14); - - rd_len = rd_data = 0; - } - - if (!rd_data) { - debug("No initrd\n"); - } - - if (rd_data) { - if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - } else { - initrd_start = (ulong) kbd - rd_len; - initrd_start &= ~(4096 - 1); /* align on page */ - - if (initrd_high) { - ulong nsp; - - /* - * the inital ramdisk does not need to be within - * CFG_BOOTMAPSZ as it is not accessed until after - * the mm system is initialised. - * - * do the stack bottom calculation again and see if - * the initrd will fit just below the monitor stack - * bottom without overwriting the area allocated - * above for command line args and board info. - */ - asm("movel %%a7, %%d0\n" - "movel %%d0, %0\n": "=d"(nsp): :"%d0"); - - nsp -= 2048; /* just to be sure */ - nsp &= ~0xF; - - if (nsp > initrd_high) /* limit as specified */ - nsp = initrd_high; - - nsp -= rd_len; - nsp &= ~(4096 - 1); /* align on page */ - - if (nsp >= sp) - initrd_start = nsp; - } - - SHOW_BOOT_PROGRESS(12); - - debug - ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - rd_data, rd_data + rd_len - 1, rd_len, rd_len); - - initrd_end = initrd_start + rd_len; - printf(" Loading Ramdisk to %08lx, end %08lx ... ", - initrd_start, initrd_end); - - memmove_wd((void *)initrd_start, - (void *)rd_data, rd_len, CHUNKSZ); - - puts("OK\n"); - } - } else { - initrd_start = 0; - initrd_end = 0; - } - - debug("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) kernel); - - SHOW_BOOT_PROGRESS(15); - - /* - * Linux Kernel Parameters (passing board info data): - * r3: ptr to board info data - * r4: initrd_start or 0 if no initrd - * r5: initrd_end - unused if r4 is 0 - * r6: Start of command line string - * r7: End of command line string - */ - (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); - /* does not return */ -} diff --git a/lib_microblaze/Makefile b/lib_microblaze/Makefile index 82b7beadb..9b317a2da 100644 --- a/lib_microblaze/Makefile +++ b/lib_microblaze/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = -COBJS = board.o microblaze_linux.o time.o cache.o +COBJS = board.o bootm.o time.o cache.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_microblaze/bootm.c b/lib_microblaze/bootm.c new file mode 100644 index 000000000..a4fce5a73 --- /dev/null +++ b/lib_microblaze/bootm.c @@ -0,0 +1,138 @@ +/* + * (C) Copyright 2007 Michal Simek + * (C) Copyright 2004 Atmark Techno, Inc. + * + * Michal SIMEK + * Yasushi SHOJI + * + * 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 + */ + +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +extern int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); + +void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + int i; + ulong checksum; + + ulong rd_data, rd_len; + ulong initrd_start, initrd_end; + image_header_t *rd_hdr; + + /* First parameter is mapped to $r5 for kernel boot args */ + void (*theKernel) (char *); + char *commandline = getenv ("bootargs"); + + theKernel = (void (*)(char *))image_get_ep (hdr); + + /* Check if there is an initrd image */ + if (argc >= 3) { + show_boot_progress (9); + + rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); + printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr); + + if (!image_check_magic (rd_hdr)) { + printf ("Bad Magic Number\n"); + show_boot_progress (-10); + do_reset (cmdtp, flag, argc, argv); + } + + if (!image_check_magic (rd_hdr)) { + printf ("Bad Header Checksum\n"); + show_boot_progress (-11); + do_reset (cmdtp, flag, argc, argv); + } + + show_boot_progress (10); + print_image_hdr (rd_hdr); + + rd_data = image_get_data (rd_hdr); + rd_en = image_get_data_size (rd_hdr); + + if (verify) { + printf (" Verifying Checksum ... "); + if (!image_check_dcrc (rd_hdr)) { + printf ("Bad Data CRC\n"); + show_boot_progress (-12); + do_reset (cmdtp, flag, argc, argv); + } + printf ("OK\n"); + } + + show_boot_progress (11); + + if (!image_check_os (rd_hdr, IH_OS_LINUX) || + !image_check_arch (rd_hdr, IH_ARCH_MICROBLAZE) || + !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { + printf ("No Linux Microblaze Ramdisk Image\n"); + show_boot_progress (-13); + do_reset (cmdtp, flag, argc, argv); + } + + /* + * Now check if we have a multifile image + */ + } else if (image_check_type (hdr, IH_TYPE_MULTI)) { + /* + * Get second entry data start address and len + */ + show_boot_progress (13); + image_multi_getimg (hdr, 1, &rd_data, &rd_len); + } else { + /* + * no initrd image + */ + show_boot_progress (14); + + rd_data = rd_len = 0; + } + +#ifdef DEBUG + if (!rd_data) { + printf ("No initrd\n"); + } +#endif + + if (rd_data) { + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + } else { + initrd_start = 0; + initrd_end = 0; + } + + show_boot_progress (15); + +#ifdef DEBUG + printf ("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); +#endif + + theKernel (commandline); +} diff --git a/lib_microblaze/microblaze_linux.c b/lib_microblaze/microblaze_linux.c deleted file mode 100644 index a4fce5a73..000000000 --- a/lib_microblaze/microblaze_linux.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * (C) Copyright 2007 Michal Simek - * (C) Copyright 2004 Atmark Techno, Inc. - * - * Michal SIMEK - * Yasushi SHOJI - * - * 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 - */ - -#include -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - -extern int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); - -void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - int i; - ulong checksum; - - ulong rd_data, rd_len; - ulong initrd_start, initrd_end; - image_header_t *rd_hdr; - - /* First parameter is mapped to $r5 for kernel boot args */ - void (*theKernel) (char *); - char *commandline = getenv ("bootargs"); - - theKernel = (void (*)(char *))image_get_ep (hdr); - - /* Check if there is an initrd image */ - if (argc >= 3) { - show_boot_progress (9); - - rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); - printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr); - - if (!image_check_magic (rd_hdr)) { - printf ("Bad Magic Number\n"); - show_boot_progress (-10); - do_reset (cmdtp, flag, argc, argv); - } - - if (!image_check_magic (rd_hdr)) { - printf ("Bad Header Checksum\n"); - show_boot_progress (-11); - do_reset (cmdtp, flag, argc, argv); - } - - show_boot_progress (10); - print_image_hdr (rd_hdr); - - rd_data = image_get_data (rd_hdr); - rd_en = image_get_data_size (rd_hdr); - - if (verify) { - printf (" Verifying Checksum ... "); - if (!image_check_dcrc (rd_hdr)) { - printf ("Bad Data CRC\n"); - show_boot_progress (-12); - do_reset (cmdtp, flag, argc, argv); - } - printf ("OK\n"); - } - - show_boot_progress (11); - - if (!image_check_os (rd_hdr, IH_OS_LINUX) || - !image_check_arch (rd_hdr, IH_ARCH_MICROBLAZE) || - !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { - printf ("No Linux Microblaze Ramdisk Image\n"); - show_boot_progress (-13); - do_reset (cmdtp, flag, argc, argv); - } - - /* - * Now check if we have a multifile image - */ - } else if (image_check_type (hdr, IH_TYPE_MULTI)) { - /* - * Get second entry data start address and len - */ - show_boot_progress (13); - image_multi_getimg (hdr, 1, &rd_data, &rd_len); - } else { - /* - * no initrd image - */ - show_boot_progress (14); - - rd_data = rd_len = 0; - } - -#ifdef DEBUG - if (!rd_data) { - printf ("No initrd\n"); - } -#endif - - if (rd_data) { - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - } else { - initrd_start = 0; - initrd_end = 0; - } - - show_boot_progress (15); - -#ifdef DEBUG - printf ("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); -#endif - - theKernel (commandline); -} diff --git a/lib_mips/Makefile b/lib_mips/Makefile index 3163f00e0..93cca7a23 100644 --- a/lib_mips/Makefile +++ b/lib_mips/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = -COBJS = board.o time.o mips_linux.o +COBJS = board.o time.o bootm.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_mips/bootm.c b/lib_mips/bootm.c new file mode 100644 index 000000000..7ea7571a8 --- /dev/null +++ b/lib_mips/bootm.c @@ -0,0 +1,249 @@ +/* + * (C) Copyright 2003 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 + * + */ + +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define LINUX_MAX_ENVS 256 +#define LINUX_MAX_ARGS 256 + +extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +static int linux_argc; +static char ** linux_argv; + +static char ** linux_env; +static char * linux_env_p; +static int linux_env_idx; + +static void linux_params_init (ulong start, char * commandline); +static void linux_env_set (char * env_name, char * env_val); + + +void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + ulong rd_data, rd_len; + ulong initrd_start, initrd_end; + image_header_t *rd_hdr; + + void (*theKernel) (int, char **, char **, int *); + char *commandline = getenv ("bootargs"); + char env_buf[12]; + + theKernel = + (void (*)(int, char **, char **, int *))image_get_ep (hdr); + + /* + * Check if there is an initrd image + */ + if (argc >= 3) { + show_boot_progress (9); + + rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); + printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr); + + if (!image_check_magic (rd_hdr)) { + printf ("Bad Magic Number\n"); + show_boot_progress (-10); + do_reset (cmdtp, flag, argc, argv); + } + + if (!image_check_hcrc (rd_hdr)) { + printf ("Bad Header Checksum\n"); + show_boot_progress (-11); + do_reset (cmdtp, flag, argc, argv); + } + + show_boot_progress (10); + print_image_hdr (rd_hdr); + + rd_data = image_get_data (rd_hdr); + rd_len = image_get_data_size (rd_hdr); + + if (verify) { + printf (" Verifying Checksum ... "); + if (!image_check_dcrc (rd_hdr)) { + printf ("Bad Data CRC\n"); + show_boot_progress (-12); + do_reset (cmdtp, flag, argc, argv); + } + printf ("OK\n"); + } + + show_boot_progress (11); + + if (!image_check_os (rd_hdr, IH_OS_LINUX) || + !image_check_arch (rd_hdr, IH_ARCH_MIPS) || + !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { + printf ("No Linux MIPS Ramdisk Image\n"); + show_boot_progress (-13); + do_reset (cmdtp, flag, argc, argv); + } + + /* + * Now check if we have a multifile image + */ + } else if (image_check_type (hdr, IH_TYPE_MULTI)) { + /* + * Get second entry data start address and len + */ + show_boot_progress (13); + image_multi_getimg (hdr, 1, &rd_data, &rd_len); + } else { + /* + * no initrd image + */ + show_boot_progress (14); + + rd_data = rd_len = 0; + } + +#ifdef DEBUG + if (!rd_data) { + printf ("No initrd\n"); + } +#endif + + if (rd_data) { + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + } else { + initrd_start = 0; + initrd_end = 0; + } + + show_boot_progress (15); + +#ifdef DEBUG + printf ("## Transferring control to Linux (at address %08lx) ...\n", + (ulong) theKernel); +#endif + + linux_params_init (UNCACHED_SDRAM (gd->bd->bi_boot_params), commandline); + +#ifdef CONFIG_MEMSIZE_IN_BYTES + sprintf (env_buf, "%lu", gd->ram_size); +#ifdef DEBUG + printf ("## Giving linux memsize in bytes, %lu\n", gd->ram_size); +#endif +#else + sprintf (env_buf, "%lu", gd->ram_size >> 20); +#ifdef DEBUG + printf ("## Giving linux memsize in MB, %lu\n", gd->ram_size >> 20); +#endif +#endif /* CONFIG_MEMSIZE_IN_BYTES */ + + linux_env_set ("memsize", env_buf); + + sprintf (env_buf, "0x%08X", (uint) UNCACHED_SDRAM (initrd_start)); + linux_env_set ("initrd_start", env_buf); + + sprintf (env_buf, "0x%X", (uint) (initrd_end - initrd_start)); + linux_env_set ("initrd_size", env_buf); + + sprintf (env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart)); + linux_env_set ("flash_start", env_buf); + + sprintf (env_buf, "0x%X", (uint) (gd->bd->bi_flashsize)); + linux_env_set ("flash_size", env_buf); + + /* we assume that the kernel is in place */ + printf ("\nStarting kernel ...\n\n"); + + theKernel (linux_argc, linux_argv, linux_env, 0); +} + +static void linux_params_init (ulong start, char *line) +{ + char *next, *quote, *argp; + + linux_argc = 1; + linux_argv = (char **) start; + linux_argv[0] = 0; + argp = (char *) (linux_argv + LINUX_MAX_ARGS); + + next = line; + + while (line && *line && linux_argc < LINUX_MAX_ARGS) { + quote = strchr (line, '"'); + next = strchr (line, ' '); + + while (next != NULL && quote != NULL && quote < next) { + /* we found a left quote before the next blank + * now we have to find the matching right quote + */ + next = strchr (quote + 1, '"'); + if (next != NULL) { + quote = strchr (next + 1, '"'); + next = strchr (next + 1, ' '); + } + } + + if (next == NULL) { + next = line + strlen (line); + } + + linux_argv[linux_argc] = argp; + memcpy (argp, line, next - line); + argp[next - line] = 0; + + argp += next - line + 1; + linux_argc++; + + if (*next) + next++; + + line = next; + } + + linux_env = (char **) (((ulong) argp + 15) & ~15); + linux_env[0] = 0; + linux_env_p = (char *) (linux_env + LINUX_MAX_ENVS); + linux_env_idx = 0; +} + +static void linux_env_set (char *env_name, char *env_val) +{ + if (linux_env_idx < LINUX_MAX_ENVS - 1) { + linux_env[linux_env_idx] = linux_env_p; + + strcpy (linux_env_p, env_name); + linux_env_p += strlen (env_name); + + strcpy (linux_env_p, "="); + linux_env_p += 1; + + strcpy (linux_env_p, env_val); + linux_env_p += strlen (env_val); + + linux_env_p++; + linux_env[++linux_env_idx] = 0; + } +} diff --git a/lib_mips/mips_linux.c b/lib_mips/mips_linux.c deleted file mode 100644 index 7ea7571a8..000000000 --- a/lib_mips/mips_linux.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * (C) Copyright 2003 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * 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 - * - */ - -#include -#include -#include -#include -#include -#include - -DECLARE_GLOBAL_DATA_PTR; - -#define LINUX_MAX_ENVS 256 -#define LINUX_MAX_ARGS 256 - -extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -static int linux_argc; -static char ** linux_argv; - -static char ** linux_env; -static char * linux_env_p; -static int linux_env_idx; - -static void linux_params_init (ulong start, char * commandline); -static void linux_env_set (char * env_name, char * env_val); - - -void do_bootm_linux (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - ulong rd_data, rd_len; - ulong initrd_start, initrd_end; - image_header_t *rd_hdr; - - void (*theKernel) (int, char **, char **, int *); - char *commandline = getenv ("bootargs"); - char env_buf[12]; - - theKernel = - (void (*)(int, char **, char **, int *))image_get_ep (hdr); - - /* - * Check if there is an initrd image - */ - if (argc >= 3) { - show_boot_progress (9); - - rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); - printf ("## Loading Ramdisk Image at %08lx ...\n", rd_hdr); - - if (!image_check_magic (rd_hdr)) { - printf ("Bad Magic Number\n"); - show_boot_progress (-10); - do_reset (cmdtp, flag, argc, argv); - } - - if (!image_check_hcrc (rd_hdr)) { - printf ("Bad Header Checksum\n"); - show_boot_progress (-11); - do_reset (cmdtp, flag, argc, argv); - } - - show_boot_progress (10); - print_image_hdr (rd_hdr); - - rd_data = image_get_data (rd_hdr); - rd_len = image_get_data_size (rd_hdr); - - if (verify) { - printf (" Verifying Checksum ... "); - if (!image_check_dcrc (rd_hdr)) { - printf ("Bad Data CRC\n"); - show_boot_progress (-12); - do_reset (cmdtp, flag, argc, argv); - } - printf ("OK\n"); - } - - show_boot_progress (11); - - if (!image_check_os (rd_hdr, IH_OS_LINUX) || - !image_check_arch (rd_hdr, IH_ARCH_MIPS) || - !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { - printf ("No Linux MIPS Ramdisk Image\n"); - show_boot_progress (-13); - do_reset (cmdtp, flag, argc, argv); - } - - /* - * Now check if we have a multifile image - */ - } else if (image_check_type (hdr, IH_TYPE_MULTI)) { - /* - * Get second entry data start address and len - */ - show_boot_progress (13); - image_multi_getimg (hdr, 1, &rd_data, &rd_len); - } else { - /* - * no initrd image - */ - show_boot_progress (14); - - rd_data = rd_len = 0; - } - -#ifdef DEBUG - if (!rd_data) { - printf ("No initrd\n"); - } -#endif - - if (rd_data) { - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - } else { - initrd_start = 0; - initrd_end = 0; - } - - show_boot_progress (15); - -#ifdef DEBUG - printf ("## Transferring control to Linux (at address %08lx) ...\n", - (ulong) theKernel); -#endif - - linux_params_init (UNCACHED_SDRAM (gd->bd->bi_boot_params), commandline); - -#ifdef CONFIG_MEMSIZE_IN_BYTES - sprintf (env_buf, "%lu", gd->ram_size); -#ifdef DEBUG - printf ("## Giving linux memsize in bytes, %lu\n", gd->ram_size); -#endif -#else - sprintf (env_buf, "%lu", gd->ram_size >> 20); -#ifdef DEBUG - printf ("## Giving linux memsize in MB, %lu\n", gd->ram_size >> 20); -#endif -#endif /* CONFIG_MEMSIZE_IN_BYTES */ - - linux_env_set ("memsize", env_buf); - - sprintf (env_buf, "0x%08X", (uint) UNCACHED_SDRAM (initrd_start)); - linux_env_set ("initrd_start", env_buf); - - sprintf (env_buf, "0x%X", (uint) (initrd_end - initrd_start)); - linux_env_set ("initrd_size", env_buf); - - sprintf (env_buf, "0x%08X", (uint) (gd->bd->bi_flashstart)); - linux_env_set ("flash_start", env_buf); - - sprintf (env_buf, "0x%X", (uint) (gd->bd->bi_flashsize)); - linux_env_set ("flash_size", env_buf); - - /* we assume that the kernel is in place */ - printf ("\nStarting kernel ...\n\n"); - - theKernel (linux_argc, linux_argv, linux_env, 0); -} - -static void linux_params_init (ulong start, char *line) -{ - char *next, *quote, *argp; - - linux_argc = 1; - linux_argv = (char **) start; - linux_argv[0] = 0; - argp = (char *) (linux_argv + LINUX_MAX_ARGS); - - next = line; - - while (line && *line && linux_argc < LINUX_MAX_ARGS) { - quote = strchr (line, '"'); - next = strchr (line, ' '); - - while (next != NULL && quote != NULL && quote < next) { - /* we found a left quote before the next blank - * now we have to find the matching right quote - */ - next = strchr (quote + 1, '"'); - if (next != NULL) { - quote = strchr (next + 1, '"'); - next = strchr (next + 1, ' '); - } - } - - if (next == NULL) { - next = line + strlen (line); - } - - linux_argv[linux_argc] = argp; - memcpy (argp, line, next - line); - argp[next - line] = 0; - - argp += next - line + 1; - linux_argc++; - - if (*next) - next++; - - line = next; - } - - linux_env = (char **) (((ulong) argp + 15) & ~15); - linux_env[0] = 0; - linux_env_p = (char *) (linux_env + LINUX_MAX_ENVS); - linux_env_idx = 0; -} - -static void linux_env_set (char *env_name, char *env_val) -{ - if (linux_env_idx < LINUX_MAX_ENVS - 1) { - linux_env[linux_env_idx] = linux_env_p; - - strcpy (linux_env_p, env_name); - linux_env_p += strlen (env_name); - - strcpy (linux_env_p, "="); - linux_env_p += 1; - - strcpy (linux_env_p, env_val); - linux_env_p += strlen (env_val); - - linux_env_p++; - linux_env[++linux_env_idx] = 0; - } -} diff --git a/lib_nios/Makefile b/lib_nios/Makefile index 7c9d62cf7..d8ae7bd26 100644 --- a/lib_nios/Makefile +++ b/lib_nios/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = -COBJS = board.o cache.o divmod.o nios_linux.o mult.o time.o +COBJS = board.o cache.o divmod.o bootm.o mult.o time.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_nios/bootm.c b/lib_nios/bootm.c new file mode 100644 index 000000000..55f7e3adc --- /dev/null +++ b/lib_nios/bootm.c @@ -0,0 +1,34 @@ +/* + * (C) Copyright 2003, Psyent Corporation + * Scott McNutt + * + * 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 + */ + +#include +#include + +/* FIXME: Once we find a stable version of uC-linux for nios + * we can get this working. ;-) + * + */ +void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + image__header_t *hdr, int verify) +{ +} diff --git a/lib_nios/nios_linux.c b/lib_nios/nios_linux.c deleted file mode 100644 index 55f7e3adc..000000000 --- a/lib_nios/nios_linux.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * (C) Copyright 2003, Psyent Corporation - * Scott McNutt - * - * 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 - */ - -#include -#include - -/* FIXME: Once we find a stable version of uC-linux for nios - * we can get this working. ;-) - * - */ -void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], - image__header_t *hdr, int verify) -{ -} diff --git a/lib_nios2/Makefile b/lib_nios2/Makefile index 1ff2f29bc..5f996d3bf 100644 --- a/lib_nios2/Makefile +++ b/lib_nios2/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = cache.o -COBJS = board.o divmod.o nios_linux.o mult.o time.o +COBJS = board.o divmod.o bootm.o mult.o time.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_nios2/bootm.c b/lib_nios2/bootm.c new file mode 100644 index 000000000..cb843246b --- /dev/null +++ b/lib_nios2/bootm.c @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2003, Psyent Corporation + * Scott McNutt + * + * 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 + */ + +#include +#include +#include + +void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + image_header_t *hdr, int verify) +{ + void (*kernel)(void) = (void (*)(void))image_get_ep (hdr); + + /* For now we assume the Microtronix linux ... which only + * needs to be called ;-) + */ + kernel (); +} diff --git a/lib_nios2/nios_linux.c b/lib_nios2/nios_linux.c deleted file mode 100644 index cb843246b..000000000 --- a/lib_nios2/nios_linux.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * (C) Copyright 2003, Psyent Corporation - * Scott McNutt - * - * 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 - */ - -#include -#include -#include - -void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], - image_header_t *hdr, int verify) -{ - void (*kernel)(void) = (void (*)(void))image_get_ep (hdr); - - /* For now we assume the Microtronix linux ... which only - * needs to be called ;-) - */ - kernel (); -} diff --git a/lib_ppc/Makefile b/lib_ppc/Makefile index 2aa015485..6845ed012 100644 --- a/lib_ppc/Makefile +++ b/lib_ppc/Makefile @@ -29,7 +29,7 @@ SOBJS = ppcstring.o ticks.o COBJS = board.o \ bat_rw.o cache.o extable.o kgdb.o time.o interrupts.o \ - ppc_linux.o + bootm.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_ppc/bootm.c b/lib_ppc/bootm.c new file mode 100644 index 000000000..391168787 --- /dev/null +++ b/lib_ppc/bootm.c @@ -0,0 +1,554 @@ +/* + * (C) Copyright 2008 Semihalf + * + * (C) Copyright 2000-2006 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 + */ + +#define DEBUG + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(CONFIG_OF_LIBFDT) +#include +#include +#include +#elif defined(CONFIG_OF_FLAT_TREE) +#include +#endif + +#ifdef CONFIG_LOGBUFFER +#include +#endif + +#ifdef CFG_INIT_RAM_LOCK +#include +#endif + +DECLARE_GLOBAL_DATA_PTR; + +extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); + +#if defined(CONFIG_CMD_BDI) +extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); +#endif + +void __attribute__((noinline)) +do_bootm_linux(cmd_tbl_t *cmdtp, int flag, + int argc, char *argv[], + image_header_t *hdr, + int verify) +{ + ulong initrd_high; + int initrd_copy_to_ram = 1; + ulong initrd_start, initrd_end; + ulong rd_data, rd_len; + image_header_t *rd_hdr; + + ulong cmd_start, cmd_end; + char *cmdline; + + ulong sp; + char *s; + bd_t *kbd; + void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); + +#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) + image_header_t *fdt_hdr; + char *of_flat_tree = NULL; + ulong of_data = 0; +#endif + + if ((s = getenv ("initrd_high")) != NULL) { + /* a value of "no" or a similar string will act like 0, + * turning the "load high" feature off. This is intentional. + */ + initrd_high = simple_strtoul(s, NULL, 16); + if (initrd_high == ~0) + initrd_copy_to_ram = 0; + } else { /* not set, no restrictions to load high */ + initrd_high = ~0; + } + +#ifdef CONFIG_LOGBUFFER + kbd=gd->bd; + /* Prevent initrd from overwriting logbuffer */ + if (initrd_high < (kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD)) + initrd_high = kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD; + debug ("## Logbuffer at 0x%08lX ", kbd->bi_memsize-LOGBUFF_LEN); +#endif + + /* + * Booting a (Linux) kernel image + * + * Allocate space for command line and board info - the + * address should be as high as possible within the reach of + * the kernel (see CFG_BOOTMAPSZ settings), but in unused + * memory, which means far enough below the current stack + * pointer. + */ + + asm( "mr %0,1": "=r"(sp) : ); + + debug ("## Current stack ends at 0x%08lX ", sp); + + sp -= 2048; /* just to be sure */ + if (sp > CFG_BOOTMAPSZ) + sp = CFG_BOOTMAPSZ; + sp &= ~0xF; + + debug ("=> set upper limit to 0x%08lX\n", sp); + + cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF); + kbd = (bd_t *)(((ulong)cmdline - sizeof(bd_t)) & ~0xF); + + if ((s = getenv("bootargs")) == NULL) + s = ""; + + strcpy (cmdline, s); + + cmd_start = (ulong)&cmdline[0]; + cmd_end = cmd_start + strlen(cmdline); + + *kbd = *(gd->bd); + +#ifdef DEBUG + printf ("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end); + +#if defined(CONFIG_CMD_BDI) + do_bdinfo (NULL, 0, 0, NULL); +#endif +#endif + + if ((s = getenv ("clocks_in_mhz")) != NULL) { + /* convert all clock information to MHz */ + kbd->bi_intfreq /= 1000000L; + kbd->bi_busfreq /= 1000000L; +#if defined(CONFIG_MPC8220) + kbd->bi_inpfreq /= 1000000L; + kbd->bi_pcifreq /= 1000000L; + kbd->bi_pevfreq /= 1000000L; + kbd->bi_flbfreq /= 1000000L; + kbd->bi_vcofreq /= 1000000L; +#endif +#if defined(CONFIG_CPM2) + kbd->bi_cpmfreq /= 1000000L; + kbd->bi_brgfreq /= 1000000L; + kbd->bi_sccfreq /= 1000000L; + kbd->bi_vco /= 1000000L; +#endif +#if defined(CONFIG_MPC5xxx) + kbd->bi_ipbfreq /= 1000000L; + kbd->bi_pcifreq /= 1000000L; +#endif /* CONFIG_MPC5xxx */ + } + + kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr); + + /* + * Check if there is an initrd image + */ + +#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) + /* Look for a '-' which indicates to ignore the ramdisk argument */ + if (argc >= 3 && strcmp(argv[2], "-") == 0) { + debug ("Skipping initrd\n"); + rd_len = rd_data = 0; + } + else +#endif + if (argc >= 3) { + debug ("Not skipping initrd\n"); + show_boot_progress (9); + + rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); + printf ("## Loading RAMDisk Image at %08lx ...\n", (ulong)rd_hdr); + + if (!image_check_magic (rd_hdr)) { + puts ("Bad Magic Number\n"); + show_boot_progress (-10); + do_reset (cmdtp, flag, argc, argv); + } + + if (!image_check_hcrc (rd_hdr)) { + puts ("Bad Header Checksum\n"); + show_boot_progress (-11); + do_reset (cmdtp, flag, argc, argv); + } + show_boot_progress (10); + + print_image_hdr (rd_hdr); + + if (verify) { + puts (" Verifying Checksum ... "); + + if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) { + puts ("Bad Data CRC\n"); + show_boot_progress (-12); + do_reset (cmdtp, flag, argc, argv); + } + puts ("OK\n"); + } + + show_boot_progress (11); + + if (!image_check_os (rd_hdr, IH_OS_LINUX) || + !image_check_arch (rd_hdr, IH_ARCH_PPC) || + !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { + puts ("No Linux PPC Ramdisk Image\n"); + show_boot_progress (-13); + do_reset (cmdtp, flag, argc, argv); + } + + rd_data = image_get_data (rd_hdr); + rd_len = image_get_data_size (rd_hdr); + + /* + * Now check if we have a multifile image + */ + } 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); + show_boot_progress (13); + } else { + /* + * No initrd image + */ + show_boot_progress (14); + + rd_len = rd_data = 0; + } + +#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) + if(argc > 3) { + of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); + fdt_hdr = (image_header_t *)of_flat_tree; +#if defined(CONFIG_OF_FLAT_TREE) + if (*((ulong *)(of_flat_tree)) == OF_DT_HEADER) { +#elif defined(CONFIG_OF_LIBFDT) + if (fdt_check_header (of_flat_tree) == 0) { +#endif +#ifndef CFG_NO_FLASH + if (addr2info((ulong)of_flat_tree) != NULL) + of_data = (ulong)of_flat_tree; +#endif + } else if (image_check_magic (fdt_hdr)) { + ulong image_start, image_end; + ulong load_start, load_end; + + printf ("## Flat Device Tree at %08lX\n", fdt_hdr); + print_image_hdr (fdt_hdr); + + image_start = (ulong)fdt_hdr; + image_end = image_get_image_end (fdt_hdr); + + load_start = image_get_load (fdt_hdr); + load_end = load_start + image_get_data_size (fdt_hdr); + + if ((load_start < image_end) && (load_end > image_start)) { + puts ("ERROR: fdt overwritten - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + + puts (" Verifying Checksum ... "); + if (!image_check_hcrc (fdt_hdr)) { + puts ("ERROR: fdt header checksum invalid - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + + if (!image_check_dcrc (fdt_hdr)) { + puts ("ERROR: fdt checksum invalid - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + puts ("OK\n"); + + if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) { + puts ("ERROR: uImage is not a fdt - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + if (image_get_comp (fdt_hdr) != IH_COMP_NONE) { + puts ("ERROR: uImage is compressed - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } +#if defined(CONFIG_OF_FLAT_TREE) + if (*((ulong *)(of_flat_tree + image_get_header_size ())) != OF_DT_HEADER) { +#elif defined(CONFIG_OF_LIBFDT) + if (fdt_check_header (of_flat_tree + image_get_header_size ()) != 0) { +#endif + puts ("ERROR: uImage data is not a fdt - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + + memmove ((void *)image_get_load (fdt_hdr), + (void *)(of_flat_tree + image_get_header_size ()), + image_get_data_size (fdt_hdr)); + + of_flat_tree = (char *)image_get_load (fdt_hdr); + } else { + puts ("Did not find a flat Flat Device Tree.\n" + "Must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + printf (" Booting using the fdt at 0x%x\n", + of_flat_tree); + } else if (image_check_type (hdr, IH_TYPE_MULTI)) { + ulong fdt_data, fdt_len; + + image_multi_getimg (hdr, 2, &fdt_data, &fdt_len); + if (fdt_len) { + + of_flat_tree = (char *)fdt_data; + +#ifndef CFG_NO_FLASH + /* move the blob if it is in flash (set of_data to !null) */ + if (addr2info ((ulong)of_flat_tree) != NULL) + of_data = (ulong)of_flat_tree; +#endif + +#if defined(CONFIG_OF_FLAT_TREE) + if (*((ulong *)(of_flat_tree)) != OF_DT_HEADER) { +#elif defined(CONFIG_OF_LIBFDT) + if (fdt_check_header (of_flat_tree) != 0) { +#endif + puts ("ERROR: image is not a fdt - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + +#if defined(CONFIG_OF_FLAT_TREE) + if (((struct boot_param_header *)of_flat_tree)->totalsize != fdt_len) { +#elif defined(CONFIG_OF_LIBFDT) + if (be32_to_cpu (fdt_totalsize (of_flat_tree)) != fdt_len) { +#endif + puts ("ERROR: fdt size != image size - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + } + } +#endif + if (!rd_data) { + debug ("No initrd\n"); + } + + if (rd_data) { + if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ + initrd_start = rd_data; + initrd_end = initrd_start + rd_len; + } else { + initrd_start = (ulong)kbd - rd_len; + initrd_start &= ~(4096 - 1); /* align on page */ + + if (initrd_high) { + ulong nsp; + + /* + * the inital ramdisk does not need to be within + * CFG_BOOTMAPSZ as it is not accessed until after + * the mm system is initialised. + * + * do the stack bottom calculation again and see if + * the initrd will fit just below the monitor stack + * bottom without overwriting the area allocated + * above for command line args and board info. + */ + asm( "mr %0,1": "=r"(nsp) : ); + nsp -= 2048; /* just to be sure */ + nsp &= ~0xF; + if (nsp > initrd_high) /* limit as specified */ + nsp = initrd_high; + nsp -= rd_len; + nsp &= ~(4096 - 1); /* align on page */ + if (nsp >= sp) + initrd_start = nsp; + } + + show_boot_progress (12); + + debug ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", + rd_data, rd_data + rd_len - 1, rd_len, rd_len); + + initrd_end = initrd_start + rd_len; + printf (" Loading Ramdisk to %08lx, end %08lx ... ", + initrd_start, initrd_end); + + memmove_wd((void *)initrd_start, + (void *)rd_data, rd_len, CHUNKSZ); + + puts ("OK\n"); + } + } else { + initrd_start = 0; + initrd_end = 0; + } + +#if defined(CONFIG_OF_LIBFDT) + +#ifdef CFG_BOOTMAPSZ + /* + * The blob must be within CFG_BOOTMAPSZ, + * so we flag it to be copied if it is not. + */ + if (of_flat_tree >= (char *)CFG_BOOTMAPSZ) + of_data = (ulong)of_flat_tree; +#endif + + /* move of_flat_tree if needed */ + if (of_data) { + int err; + ulong of_start, of_len; + + of_len = be32_to_cpu(fdt_totalsize(of_data)); + + /* position on a 4K boundary before the kbd */ + of_start = (ulong)kbd - of_len; + of_start &= ~(4096 - 1); /* align on page */ + debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", + of_data, of_data + of_len - 1, of_len, of_len); + + of_flat_tree = (char *)of_start; + printf (" Loading Device Tree to %08lx, end %08lx ... ", + of_start, of_start + of_len - 1); + err = fdt_open_into((void *)of_data, (void *)of_start, of_len); + if (err != 0) { + puts ("ERROR: fdt move failed - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } + puts ("OK\n"); + } + /* + * Add the chosen node if it doesn't exist, add the env and bd_t + * if the user wants it (the logic is in the subroutines). + */ + if (of_flat_tree) { + if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) { + puts ("ERROR: /chosen node create failed - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } +#ifdef CONFIG_OF_HAS_UBOOT_ENV + if (fdt_env(of_flat_tree) < 0) { + puts ("ERROR: /u-boot-env node create failed - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } +#endif +#ifdef CONFIG_OF_HAS_BD_T + if (fdt_bd_t(of_flat_tree) < 0) { + puts ("ERROR: /bd_t node create failed - " + "must RESET the board to recover.\n"); + do_reset (cmdtp, flag, argc, argv); + } +#endif +#ifdef CONFIG_OF_BOARD_SETUP + /* Call the board-specific fixup routine */ + ft_board_setup(of_flat_tree, gd->bd); +#endif + } + +#elif defined(CONFIG_OF_FLAT_TREE) + +#ifdef CFG_BOOTMAPSZ + /* + * The blob must be within CFG_BOOTMAPSZ, + * so we flag it to be copied if it is not. + */ + if (of_flat_tree >= (char *)CFG_BOOTMAPSZ) + of_data = (ulong)of_flat_tree; +#endif + + /* move of_flat_tree if needed */ + if (of_data) { + ulong of_start, of_len; + of_len = ((struct boot_param_header *)of_data)->totalsize; + + /* provide extra 8k pad */ + of_start = (ulong)kbd - of_len - 8192; + of_start &= ~(4096 - 1); /* align on page */ + debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", + of_data, of_data + of_len - 1, of_len, of_len); + + of_flat_tree = (char *)of_start; + printf (" Loading Device Tree to %08lx, end %08lx ... ", + of_start, of_start + of_len - 1); + memmove ((void *)of_start, (void *)of_data, of_len); + puts ("OK\n"); + } + /* + * Create the /chosen node and modify the blob with board specific + * values as needed. + */ + ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); + /* ft_dump_blob(of_flat_tree); */ + +#endif /* #if defined(CONFIG_OF_LIBFDT) #elif defined(CONFIG_OF_FLAT_TREE) */ + + debug ("## Transferring control to Linux (at address %08lx) ...\n", + (ulong)kernel); + + show_boot_progress (15); + +#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) + unlock_ram_in_cache(); +#endif + +#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) + if (of_flat_tree) { /* device tree; boot new style */ + /* + * Linux Kernel Parameters (passing device tree): + * r3: pointer to the fdt, followed by the board info data + * r4: physical pointer to the kernel itself + * r5: NULL + * r6: NULL + * r7: NULL + */ + (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0); + /* does not return */ + } +#endif + /* + * Linux Kernel Parameters (passing board info data): + * r3: ptr to board info data + * r4: initrd_start or 0 if no initrd + * r5: initrd_end - unused if r4 is 0 + * r6: Start of command line string + * r7: End of command line string + */ + (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); + /* does not return */ +} diff --git a/lib_ppc/ppc_linux.c b/lib_ppc/ppc_linux.c deleted file mode 100644 index 391168787..000000000 --- a/lib_ppc/ppc_linux.c +++ /dev/null @@ -1,554 +0,0 @@ -/* - * (C) Copyright 2008 Semihalf - * - * (C) Copyright 2000-2006 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * 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 - */ - -#define DEBUG - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_OF_LIBFDT) -#include -#include -#include -#elif defined(CONFIG_OF_FLAT_TREE) -#include -#endif - -#ifdef CONFIG_LOGBUFFER -#include -#endif - -#ifdef CFG_INIT_RAM_LOCK -#include -#endif - -DECLARE_GLOBAL_DATA_PTR; - -extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); - -#if defined(CONFIG_CMD_BDI) -extern int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); -#endif - -void __attribute__((noinline)) -do_bootm_linux(cmd_tbl_t *cmdtp, int flag, - int argc, char *argv[], - image_header_t *hdr, - int verify) -{ - ulong initrd_high; - int initrd_copy_to_ram = 1; - ulong initrd_start, initrd_end; - ulong rd_data, rd_len; - image_header_t *rd_hdr; - - ulong cmd_start, cmd_end; - char *cmdline; - - ulong sp; - char *s; - bd_t *kbd; - void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); - -#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) - image_header_t *fdt_hdr; - char *of_flat_tree = NULL; - ulong of_data = 0; -#endif - - if ((s = getenv ("initrd_high")) != NULL) { - /* a value of "no" or a similar string will act like 0, - * turning the "load high" feature off. This is intentional. - */ - initrd_high = simple_strtoul(s, NULL, 16); - if (initrd_high == ~0) - initrd_copy_to_ram = 0; - } else { /* not set, no restrictions to load high */ - initrd_high = ~0; - } - -#ifdef CONFIG_LOGBUFFER - kbd=gd->bd; - /* Prevent initrd from overwriting logbuffer */ - if (initrd_high < (kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD)) - initrd_high = kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD; - debug ("## Logbuffer at 0x%08lX ", kbd->bi_memsize-LOGBUFF_LEN); -#endif - - /* - * Booting a (Linux) kernel image - * - * Allocate space for command line and board info - the - * address should be as high as possible within the reach of - * the kernel (see CFG_BOOTMAPSZ settings), but in unused - * memory, which means far enough below the current stack - * pointer. - */ - - asm( "mr %0,1": "=r"(sp) : ); - - debug ("## Current stack ends at 0x%08lX ", sp); - - sp -= 2048; /* just to be sure */ - if (sp > CFG_BOOTMAPSZ) - sp = CFG_BOOTMAPSZ; - sp &= ~0xF; - - debug ("=> set upper limit to 0x%08lX\n", sp); - - cmdline = (char *)((sp - CFG_BARGSIZE) & ~0xF); - kbd = (bd_t *)(((ulong)cmdline - sizeof(bd_t)) & ~0xF); - - if ((s = getenv("bootargs")) == NULL) - s = ""; - - strcpy (cmdline, s); - - cmd_start = (ulong)&cmdline[0]; - cmd_end = cmd_start + strlen(cmdline); - - *kbd = *(gd->bd); - -#ifdef DEBUG - printf ("## cmdline at 0x%08lX ... 0x%08lX\n", cmd_start, cmd_end); - -#if defined(CONFIG_CMD_BDI) - do_bdinfo (NULL, 0, 0, NULL); -#endif -#endif - - if ((s = getenv ("clocks_in_mhz")) != NULL) { - /* convert all clock information to MHz */ - kbd->bi_intfreq /= 1000000L; - kbd->bi_busfreq /= 1000000L; -#if defined(CONFIG_MPC8220) - kbd->bi_inpfreq /= 1000000L; - kbd->bi_pcifreq /= 1000000L; - kbd->bi_pevfreq /= 1000000L; - kbd->bi_flbfreq /= 1000000L; - kbd->bi_vcofreq /= 1000000L; -#endif -#if defined(CONFIG_CPM2) - kbd->bi_cpmfreq /= 1000000L; - kbd->bi_brgfreq /= 1000000L; - kbd->bi_sccfreq /= 1000000L; - kbd->bi_vco /= 1000000L; -#endif -#if defined(CONFIG_MPC5xxx) - kbd->bi_ipbfreq /= 1000000L; - kbd->bi_pcifreq /= 1000000L; -#endif /* CONFIG_MPC5xxx */ - } - - kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr); - - /* - * Check if there is an initrd image - */ - -#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) - /* Look for a '-' which indicates to ignore the ramdisk argument */ - if (argc >= 3 && strcmp(argv[2], "-") == 0) { - debug ("Skipping initrd\n"); - rd_len = rd_data = 0; - } - else -#endif - if (argc >= 3) { - debug ("Not skipping initrd\n"); - show_boot_progress (9); - - rd_hdr = (image_header_t *)simple_strtoul (argv[2], NULL, 16); - printf ("## Loading RAMDisk Image at %08lx ...\n", (ulong)rd_hdr); - - if (!image_check_magic (rd_hdr)) { - puts ("Bad Magic Number\n"); - show_boot_progress (-10); - do_reset (cmdtp, flag, argc, argv); - } - - if (!image_check_hcrc (rd_hdr)) { - puts ("Bad Header Checksum\n"); - show_boot_progress (-11); - do_reset (cmdtp, flag, argc, argv); - } - show_boot_progress (10); - - print_image_hdr (rd_hdr); - - if (verify) { - puts (" Verifying Checksum ... "); - - if (!image_check_dcrc_wd (rd_hdr, CHUNKSZ)) { - puts ("Bad Data CRC\n"); - show_boot_progress (-12); - do_reset (cmdtp, flag, argc, argv); - } - puts ("OK\n"); - } - - show_boot_progress (11); - - if (!image_check_os (rd_hdr, IH_OS_LINUX) || - !image_check_arch (rd_hdr, IH_ARCH_PPC) || - !image_check_type (rd_hdr, IH_TYPE_RAMDISK)) { - puts ("No Linux PPC Ramdisk Image\n"); - show_boot_progress (-13); - do_reset (cmdtp, flag, argc, argv); - } - - rd_data = image_get_data (rd_hdr); - rd_len = image_get_data_size (rd_hdr); - - /* - * Now check if we have a multifile image - */ - } 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); - show_boot_progress (13); - } else { - /* - * No initrd image - */ - show_boot_progress (14); - - rd_len = rd_data = 0; - } - -#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) - if(argc > 3) { - of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); - fdt_hdr = (image_header_t *)of_flat_tree; -#if defined(CONFIG_OF_FLAT_TREE) - if (*((ulong *)(of_flat_tree)) == OF_DT_HEADER) { -#elif defined(CONFIG_OF_LIBFDT) - if (fdt_check_header (of_flat_tree) == 0) { -#endif -#ifndef CFG_NO_FLASH - if (addr2info((ulong)of_flat_tree) != NULL) - of_data = (ulong)of_flat_tree; -#endif - } else if (image_check_magic (fdt_hdr)) { - ulong image_start, image_end; - ulong load_start, load_end; - - printf ("## Flat Device Tree at %08lX\n", fdt_hdr); - print_image_hdr (fdt_hdr); - - image_start = (ulong)fdt_hdr; - image_end = image_get_image_end (fdt_hdr); - - load_start = image_get_load (fdt_hdr); - load_end = load_start + image_get_data_size (fdt_hdr); - - if ((load_start < image_end) && (load_end > image_start)) { - puts ("ERROR: fdt overwritten - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - - puts (" Verifying Checksum ... "); - if (!image_check_hcrc (fdt_hdr)) { - puts ("ERROR: fdt header checksum invalid - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - - if (!image_check_dcrc (fdt_hdr)) { - puts ("ERROR: fdt checksum invalid - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - puts ("OK\n"); - - if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) { - puts ("ERROR: uImage is not a fdt - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - if (image_get_comp (fdt_hdr) != IH_COMP_NONE) { - puts ("ERROR: uImage is compressed - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } -#if defined(CONFIG_OF_FLAT_TREE) - if (*((ulong *)(of_flat_tree + image_get_header_size ())) != OF_DT_HEADER) { -#elif defined(CONFIG_OF_LIBFDT) - if (fdt_check_header (of_flat_tree + image_get_header_size ()) != 0) { -#endif - puts ("ERROR: uImage data is not a fdt - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - - memmove ((void *)image_get_load (fdt_hdr), - (void *)(of_flat_tree + image_get_header_size ()), - image_get_data_size (fdt_hdr)); - - of_flat_tree = (char *)image_get_load (fdt_hdr); - } else { - puts ("Did not find a flat Flat Device Tree.\n" - "Must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - printf (" Booting using the fdt at 0x%x\n", - of_flat_tree); - } else if (image_check_type (hdr, IH_TYPE_MULTI)) { - ulong fdt_data, fdt_len; - - image_multi_getimg (hdr, 2, &fdt_data, &fdt_len); - if (fdt_len) { - - of_flat_tree = (char *)fdt_data; - -#ifndef CFG_NO_FLASH - /* move the blob if it is in flash (set of_data to !null) */ - if (addr2info ((ulong)of_flat_tree) != NULL) - of_data = (ulong)of_flat_tree; -#endif - -#if defined(CONFIG_OF_FLAT_TREE) - if (*((ulong *)(of_flat_tree)) != OF_DT_HEADER) { -#elif defined(CONFIG_OF_LIBFDT) - if (fdt_check_header (of_flat_tree) != 0) { -#endif - puts ("ERROR: image is not a fdt - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - -#if defined(CONFIG_OF_FLAT_TREE) - if (((struct boot_param_header *)of_flat_tree)->totalsize != fdt_len) { -#elif defined(CONFIG_OF_LIBFDT) - if (be32_to_cpu (fdt_totalsize (of_flat_tree)) != fdt_len) { -#endif - puts ("ERROR: fdt size != image size - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - } - } -#endif - if (!rd_data) { - debug ("No initrd\n"); - } - - if (rd_data) { - if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ - initrd_start = rd_data; - initrd_end = initrd_start + rd_len; - } else { - initrd_start = (ulong)kbd - rd_len; - initrd_start &= ~(4096 - 1); /* align on page */ - - if (initrd_high) { - ulong nsp; - - /* - * the inital ramdisk does not need to be within - * CFG_BOOTMAPSZ as it is not accessed until after - * the mm system is initialised. - * - * do the stack bottom calculation again and see if - * the initrd will fit just below the monitor stack - * bottom without overwriting the area allocated - * above for command line args and board info. - */ - asm( "mr %0,1": "=r"(nsp) : ); - nsp -= 2048; /* just to be sure */ - nsp &= ~0xF; - if (nsp > initrd_high) /* limit as specified */ - nsp = initrd_high; - nsp -= rd_len; - nsp &= ~(4096 - 1); /* align on page */ - if (nsp >= sp) - initrd_start = nsp; - } - - show_boot_progress (12); - - debug ("## initrd at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - rd_data, rd_data + rd_len - 1, rd_len, rd_len); - - initrd_end = initrd_start + rd_len; - printf (" Loading Ramdisk to %08lx, end %08lx ... ", - initrd_start, initrd_end); - - memmove_wd((void *)initrd_start, - (void *)rd_data, rd_len, CHUNKSZ); - - puts ("OK\n"); - } - } else { - initrd_start = 0; - initrd_end = 0; - } - -#if defined(CONFIG_OF_LIBFDT) - -#ifdef CFG_BOOTMAPSZ - /* - * The blob must be within CFG_BOOTMAPSZ, - * so we flag it to be copied if it is not. - */ - if (of_flat_tree >= (char *)CFG_BOOTMAPSZ) - of_data = (ulong)of_flat_tree; -#endif - - /* move of_flat_tree if needed */ - if (of_data) { - int err; - ulong of_start, of_len; - - of_len = be32_to_cpu(fdt_totalsize(of_data)); - - /* position on a 4K boundary before the kbd */ - of_start = (ulong)kbd - of_len; - of_start &= ~(4096 - 1); /* align on page */ - debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - of_data, of_data + of_len - 1, of_len, of_len); - - of_flat_tree = (char *)of_start; - printf (" Loading Device Tree to %08lx, end %08lx ... ", - of_start, of_start + of_len - 1); - err = fdt_open_into((void *)of_data, (void *)of_start, of_len); - if (err != 0) { - puts ("ERROR: fdt move failed - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } - puts ("OK\n"); - } - /* - * Add the chosen node if it doesn't exist, add the env and bd_t - * if the user wants it (the logic is in the subroutines). - */ - if (of_flat_tree) { - if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) { - puts ("ERROR: /chosen node create failed - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } -#ifdef CONFIG_OF_HAS_UBOOT_ENV - if (fdt_env(of_flat_tree) < 0) { - puts ("ERROR: /u-boot-env node create failed - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } -#endif -#ifdef CONFIG_OF_HAS_BD_T - if (fdt_bd_t(of_flat_tree) < 0) { - puts ("ERROR: /bd_t node create failed - " - "must RESET the board to recover.\n"); - do_reset (cmdtp, flag, argc, argv); - } -#endif -#ifdef CONFIG_OF_BOARD_SETUP - /* Call the board-specific fixup routine */ - ft_board_setup(of_flat_tree, gd->bd); -#endif - } - -#elif defined(CONFIG_OF_FLAT_TREE) - -#ifdef CFG_BOOTMAPSZ - /* - * The blob must be within CFG_BOOTMAPSZ, - * so we flag it to be copied if it is not. - */ - if (of_flat_tree >= (char *)CFG_BOOTMAPSZ) - of_data = (ulong)of_flat_tree; -#endif - - /* move of_flat_tree if needed */ - if (of_data) { - ulong of_start, of_len; - of_len = ((struct boot_param_header *)of_data)->totalsize; - - /* provide extra 8k pad */ - of_start = (ulong)kbd - of_len - 8192; - of_start &= ~(4096 - 1); /* align on page */ - debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - of_data, of_data + of_len - 1, of_len, of_len); - - of_flat_tree = (char *)of_start; - printf (" Loading Device Tree to %08lx, end %08lx ... ", - of_start, of_start + of_len - 1); - memmove ((void *)of_start, (void *)of_data, of_len); - puts ("OK\n"); - } - /* - * Create the /chosen node and modify the blob with board specific - * values as needed. - */ - ft_setup(of_flat_tree, kbd, initrd_start, initrd_end); - /* ft_dump_blob(of_flat_tree); */ - -#endif /* #if defined(CONFIG_OF_LIBFDT) #elif defined(CONFIG_OF_FLAT_TREE) */ - - debug ("## Transferring control to Linux (at address %08lx) ...\n", - (ulong)kernel); - - show_boot_progress (15); - -#if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) - unlock_ram_in_cache(); -#endif - -#if defined(CONFIG_OF_FLAT_TREE) || defined(CONFIG_OF_LIBFDT) - if (of_flat_tree) { /* device tree; boot new style */ - /* - * Linux Kernel Parameters (passing device tree): - * r3: pointer to the fdt, followed by the board info data - * r4: physical pointer to the kernel itself - * r5: NULL - * r6: NULL - * r7: NULL - */ - (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0); - /* does not return */ - } -#endif - /* - * Linux Kernel Parameters (passing board info data): - * r3: ptr to board info data - * r4: initrd_start or 0 if no initrd - * r5: initrd_end - unused if r4 is 0 - * r6: Start of command line string - * r7: End of command line string - */ - (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); - /* does not return */ -} diff --git a/lib_sh/Makefile b/lib_sh/Makefile index cf127a826..edb03d008 100644 --- a/lib_sh/Makefile +++ b/lib_sh/Makefile @@ -24,7 +24,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = -COBJS = board.o sh_linux.o # time.o +COBJS = board.o bootm.o # time.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) diff --git a/lib_sh/bootm.c b/lib_sh/bootm.c new file mode 100644 index 000000000..14b6815cd --- /dev/null +++ b/lib_sh/bootm.c @@ -0,0 +1,74 @@ +/* + * (C) Copyright 2003 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * 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 + * + */ + +#include +#include +#include + +extern image_header_t header; /* common/cmd_bootm.c */ + +/* The SH kernel reads arguments from the empty zero page at location + * 0 at the start of SDRAM. The following are copied from + * arch/sh/kernel/setup.c and may require tweaking if the kernel sources + * change. + */ +#define PARAM ((unsigned char *)CFG_SDRAM_BASE + 0x1000) + +#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) +#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004)) +#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008)) +#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c)) +#define INITRD_START (*(unsigned long *) (PARAM+0x010)) +#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014)) +/* ... */ +#define COMMAND_LINE ((char *) (PARAM+0x100)) + +#define RAMDISK_IMAGE_START_MASK 0x07FF + +#ifdef CFG_DEBUG +static void hexdump (unsigned char *buf, int len) +{ + int i; + + for (i = 0; i < len; i++) { + if ((i % 16) == 0) + printf ("%s%08x: ", i ? "\n" : "", (unsigned int) &buf[i]); + printf ("%02x ", buf[i]); + } + printf ("\n"); +} +#endif + +void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], + ulong addr, ulong *len_ptr, int verify) +{ + image_header_t *hdr = &header; + char *bootargs = getenv("bootargs"); + void (*kernel) (void) = (void (*)(void)) ntohl (hdr->ih_ep); + + /* Setup parameters */ + memset(PARAM, 0, 0x1000); /* Clear zero page */ + strcpy(COMMAND_LINE, bootargs); + + kernel(); +} diff --git a/lib_sh/sh_linux.c b/lib_sh/sh_linux.c deleted file mode 100644 index 14b6815cd..000000000 --- a/lib_sh/sh_linux.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * (C) Copyright 2003 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * 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 - * - */ - -#include -#include -#include - -extern image_header_t header; /* common/cmd_bootm.c */ - -/* The SH kernel reads arguments from the empty zero page at location - * 0 at the start of SDRAM. The following are copied from - * arch/sh/kernel/setup.c and may require tweaking if the kernel sources - * change. - */ -#define PARAM ((unsigned char *)CFG_SDRAM_BASE + 0x1000) - -#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) -#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004)) -#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008)) -#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c)) -#define INITRD_START (*(unsigned long *) (PARAM+0x010)) -#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014)) -/* ... */ -#define COMMAND_LINE ((char *) (PARAM+0x100)) - -#define RAMDISK_IMAGE_START_MASK 0x07FF - -#ifdef CFG_DEBUG -static void hexdump (unsigned char *buf, int len) -{ - int i; - - for (i = 0; i < len; i++) { - if ((i % 16) == 0) - printf ("%s%08x: ", i ? "\n" : "", (unsigned int) &buf[i]); - printf ("%02x ", buf[i]); - } - printf ("\n"); -} -#endif - -void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[], - ulong addr, ulong *len_ptr, int verify) -{ - image_header_t *hdr = &header; - char *bootargs = getenv("bootargs"); - void (*kernel) (void) = (void (*)(void)) ntohl (hdr->ih_ep); - - /* Setup parameters */ - memset(PARAM, 0, 0x1000); /* Clear zero page */ - strcpy(COMMAND_LINE, bootargs); - - kernel(); -} -- cgit v1.2.3