summaryrefslogtreecommitdiffstats
path: root/lib_i386
diff options
context:
space:
mode:
Diffstat (limited to 'lib_i386')
-rw-r--r--lib_i386/Makefile23
-rw-r--r--lib_i386/bootm.c107
-rw-r--r--lib_i386/i386_linux.c179
-rw-r--r--lib_i386/zimage.c50
4 files changed, 123 insertions, 236 deletions
diff --git a/lib_i386/Makefile b/lib_i386/Makefile
index e344da5157..4cc29f432a 100644
--- a/lib_i386/Makefile
+++ b/lib_i386/Makefile
@@ -25,13 +25,22 @@ include $(TOPDIR)/config.mk
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 \
- pci_type1.o pci.o video_bios.o video.o
-
-SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
+SOBJS-y += bios.o
+SOBJS-y += bios_pci.o
+SOBJS-y += realmode_switch.o
+
+COBJS-y += bios_setup.o
+COBJS-y += board.o
+COBJS-y += bootm.o
+COBJS-y += pci.o
+COBJS-y += pci_type1.o
+COBJS-y += realmode.o
+COBJS-y += video_bios.o
+COBJS-y += video.o
+COBJS-y += zimage.o
+
+SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
diff --git a/lib_i386/bootm.c b/lib_i386/bootm.c
new file mode 100644
index 0000000000..107ebaaa67
--- /dev/null
+++ b/lib_i386/bootm.c
@@ -0,0 +1,107 @@
+/*
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <image.h>
+#include <zlib.h>
+#include <asm/byteorder.h>
+#include <asm/zimage.h>
+
+/*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[],
+ bootm_headers_t *images)
+{
+ void *base_ptr;
+ ulong os_data, os_len;
+ ulong initrd_start, initrd_end;
+ ulong ep;
+ image_header_t *hdr;
+ int ret;
+#if defined(CONFIG_FIT)
+ const void *data;
+ size_t len;
+#endif
+
+ ret = boot_get_ramdisk (argc, argv, images, IH_ARCH_I386,
+ &initrd_start, &initrd_end);
+ if (ret)
+ goto error;
+
+ if (images->legacy_hdr_valid) {
+ hdr = images->legacy_hdr_os;
+ if (image_check_type (hdr, IH_TYPE_MULTI)) {
+ /* if multi-part image, we need to get first subimage */
+ image_multi_getimg (hdr, 0, &os_data, &os_len);
+ } else {
+ /* otherwise get image data */
+ os_data = image_get_data (hdr);
+ os_len = image_get_data_size (hdr);
+ }
+#if defined(CONFIG_FIT)
+ } else if (images->fit_uname_os) {
+ ret = fit_image_get_data (images->fit_hdr_os,
+ images->fit_noffset_os, &data, &len);
+ if (ret) {
+ puts ("Can't get image data/size!\n");
+ goto error;
+ }
+ os_data = (ulong)data;
+ os_len = (ulong)len;
+#endif
+ } else {
+ puts ("Could not find kernel image!\n");
+ goto error;
+ }
+
+ base_ptr = load_zimage ((void*)os_data, os_len,
+ initrd_start, initrd_end - initrd_start, 0);
+
+ if (NULL == base_ptr) {
+ printf ("## Kernel loading failed ...\n");
+ goto error;
+
+ }
+
+ if (!images->autostart)
+ return ;
+
+#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);
+ /* does not return */
+ return;
+
+error:
+ if (images->autostart)
+ do_reset (cmdtp, flag, argc, argv);
+ return;
+}
diff --git a/lib_i386/i386_linux.c b/lib_i386/i386_linux.c
deleted file mode 100644
index b4a6f5a3cd..0000000000
--- a/lib_i386/i386_linux.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-
-#include <common.h>
-#include <command.h>
-#include <image.h>
-#include <zlib.h>
-#include <asm/byteorder.h>
-#include <asm/zimage.h>
-
-/*cmd_boot.c*/
-extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
-
-extern image_header_t header; /* from cmd_bootm.c */
-
-
-image_header_t *fake_header(image_header_t *hdr, void *ptr, int size)
-{
- /* try each supported image type in order */
- if (NULL != fake_zimage_header(hdr, ptr, size)) {
- return hdr;
- }
-
- return NULL;
-}
-
-
-void do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
- ulong addr, ulong *len_ptr, int verify)
-{
- void *base_ptr;
-
- ulong len = 0, checksum;
- ulong initrd_start, initrd_end;
- ulong data;
- image_header_t *hdr = &header;
-
- /*
- * Check if there is an initrd image
- */
- if (argc >= 3) {
- addr = simple_strtoul(argv[2], NULL, 16);
-
- printf ("## Loading Ramdisk Image at %08lx ...\n", addr);
-
- /* Copy header so we can blank CRC field for re-calculation */
- memcpy (&header, (char *)addr, sizeof(image_header_t));
-
- if (ntohl(hdr->ih_magic) != IH_MAGIC) {
- printf ("Bad Magic Number\n");
- do_reset (cmdtp, flag, argc, argv);
- }
-
- data = (ulong)&header;
- len = sizeof(image_header_t);
-
- checksum = ntohl(hdr->ih_hcrc);
- hdr->ih_hcrc = 0;
-
- if (crc32 (0, (char *)data, len) != checksum) {
- printf ("Bad Header Checksum\n");
- do_reset (cmdtp, flag, argc, argv);
- }
-
- print_image_hdr (hdr);
-
- data = addr + sizeof(image_header_t);
- len = ntohl(hdr->ih_size);
-
- if (verify) {
- ulong csum = 0;
-
- printf (" Verifying Checksum ... ");
- csum = crc32 (0, (char *)data, len);
- if (csum != ntohl(hdr->ih_dcrc)) {
- printf ("Bad Data CRC\n");
- do_reset (cmdtp, flag, argc, argv);
- }
- printf ("OK\n");
- }
-
- if ((hdr->ih_os != IH_OS_LINUX) ||
- (hdr->ih_arch != IH_CPU_I386) ||
- (hdr->ih_type != 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 ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
- ulong tail = ntohl(len_ptr[0]) % 4;
- int i;
-
- /* skip kernel length and terminator */
- data = (ulong)(&len_ptr[2]);
- /* skip any additional image length fields */
- for (i=1; len_ptr[i]; ++i)
- data += 4;
- /* add kernel length, and align */
- data += ntohl(len_ptr[0]);
- if (tail) {
- data += 4 - tail;
- }
-
- len = ntohl(len_ptr[1]);
-
- } else {
- /*
- * no initrd image
- */
- data = 0;
- }
-
-#ifdef DEBUG
- if (!data) {
- printf ("No initrd\n");
- }
-#endif
-
- if (data) {
- initrd_start = data;
- initrd_end = initrd_start + len;
- printf (" Loading Ramdisk to %08lx, end %08lx ... ",
- initrd_start, initrd_end);
- memmove ((void *)initrd_start, (void *)data, len);
- printf ("OK\n");
- } else {
- initrd_start = 0;
- initrd_end = 0;
- }
-
- /* if multi-part image, we need to advance base ptr */
- if ((hdr->ih_type==IH_TYPE_MULTI) && (len_ptr[1])) {
- int i;
- for (i=0, addr+=sizeof(int); len_ptr[i++]; addr+=sizeof(int));
- }
-
- base_ptr = load_zimage((void*)addr + sizeof(image_header_t), ntohl(hdr->ih_size),
- initrd_start, initrd_end-initrd_start, 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/zimage.c b/lib_i386/zimage.c
index 3510f2fd64..c3b4e597aa 100644
--- a/lib_i386/zimage.c
+++ b/lib_i386/zimage.c
@@ -212,7 +212,6 @@ void *load_zimage(char *image, unsigned long kernel_size,
return setup_base;
}
-
void boot_zimage(void *setup_base)
{
struct pt_regs regs;
@@ -224,52 +223,3 @@ void boot_zimage(void *setup_base)
regs.eflags = 0;
enter_realmode(((u32)setup_base+SETUP_START_OFFSET)>>4, 0, &regs, &regs);
}
-
-
-image_header_t *fake_zimage_header(image_header_t *hdr, void *ptr, int size)
-{
- /* There is no way to know the size of a zImage ... *
- * so we assume that 2MB will be enough for now */
-#define ZIMAGE_SIZE 0x200000
-
- /* load a 1MB, the loaded will have to be moved to its final
- * position again later... */
-#define ZIMAGE_LOAD 0x100000
-
- ulong checksum;
-
- if (KERNEL_MAGIC != *(u16*)(ptr + BOOT_FLAG_OFF)) {
- /* not a zImage or bzImage */
- return NULL;
- }
-
- if (-1 == size) {
- size = ZIMAGE_SIZE;
- }
-#if 0
- checksum = crc32 (0, ptr, size);
-#else
- checksum = 0;
-#endif
- memset(hdr, 0, sizeof(image_header_t));
-
- /* Build new header */
- hdr->ih_magic = htonl(IH_MAGIC);
- hdr->ih_time = 0;
- hdr->ih_size = htonl(size);
- hdr->ih_load = htonl(ZIMAGE_LOAD);
- hdr->ih_ep = 0;
- hdr->ih_dcrc = htonl(checksum);
- hdr->ih_os = IH_OS_LINUX;
- hdr->ih_arch = IH_CPU_I386;
- hdr->ih_type = IH_TYPE_KERNEL;
- hdr->ih_comp = IH_COMP_NONE;
-
- strncpy((char *)hdr->ih_name, "(none)", IH_NMLEN);
-
- checksum = crc32(0,(const char *)hdr,sizeof(image_header_t));
-
- hdr->ih_hcrc = htonl(checksum);
-
- return hdr;
-}
OpenPOWER on IntegriCloud