]> git.sur5r.net Git - u-boot/blobdiff - arch/x86/lib/zimage.c
kbuild: move asm-offsets.c from SoC directory to arch/$(ARCH)/lib
[u-boot] / arch / x86 / lib / zimage.c
index 0cbb57101bb1d07fee818adcb59b990e01cfd66c..1dab3cc78878dcea322d1685f0df0ed388f7a70c 100644 (file)
@@ -3,23 +3,7 @@
  * (C) Copyright 2002
  * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
  *
- * 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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
 #include <asm/io.h>
 #include <asm/ptrace.h>
 #include <asm/zimage.h>
-#include <asm/realmode.h>
 #include <asm/byteorder.h>
 #include <asm/bootparam.h>
+#ifdef CONFIG_SYS_COREBOOT
+#include <asm/arch/timestamp.h>
+#endif
+#include <linux/compiler.h>
 
 /*
  * Memory lay-out:
@@ -171,16 +158,9 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
        else
                *load_address = (void *)ZIMAGE_LOAD_ADDR;
 
-#if defined CONFIG_ZBOOT_32
        printf("Building boot_params at 0x%8.8lx\n", (ulong)setup_base);
        memset(setup_base, 0, sizeof(*setup_base));
        setup_base->hdr = params->hdr;
-#else
-       /* load setup */
-       printf("Moving Real-Mode Code to 0x%8.8lx (%d bytes)\n",
-              (ulong)setup_base, setup_size);
-       memmove(setup_base, image, setup_size);
-#endif
 
        if (bootproto >= 0x0204)
                kernel_size = hdr->syssize * 16;
@@ -237,10 +217,8 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
        struct setup_header *hdr = &setup_base->hdr;
        int bootproto = get_boot_protocol(hdr);
 
-#if defined CONFIG_ZBOOT_32
        setup_base->e820_entries = install_e820_map(
                ARRAY_SIZE(setup_base->e820_map), setup_base->e820_map);
-#endif
 
        if (bootproto == 0x0100) {
                setup_base->screen_info.cl_magic = COMMAND_LINE_MAGIC;
@@ -279,11 +257,30 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
        return 0;
 }
 
+/*
+ * Implement a weak default function for boards that optionally
+ * need to clean up the system before jumping to the kernel.
+ */
+__weak void board_final_cleanup(void)
+{
+}
+
 void boot_zimage(void *setup_base, void *load_address)
 {
+       debug("## Transferring control to Linux (at address %08x) ...\n",
+             (u32)setup_base);
+
+       bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
+#ifdef CONFIG_BOOTSTAGE_REPORT
+       bootstage_report();
+#endif
+       board_final_cleanup();
+
        printf("\nStarting kernel ...\n\n");
 
-#if defined CONFIG_ZBOOT_32
+#ifdef CONFIG_SYS_COREBOOT
+       timestamp_add_now(TS_U_BOOT_START_KERNEL);
+#endif
        /*
         * Set %ebx, %ebp, and %edi to 0, %esi to point to the boot_params
         * structure, and then jump to the kernel. We assume that %cs is
@@ -292,26 +289,21 @@ void boot_zimage(void *setup_base, void *load_address)
         * itself in arch/i386/cpu/cpu.c.
         */
        __asm__ __volatile__ (
-       "movl $0, %%ebp         \n"
-       "cli                    \n"
-       "jmp %[kernel_entry]    \n"
+       "movl $0, %%ebp\n"
+       "cli\n"
+       "jmp *%[kernel_entry]\n"
        :: [kernel_entry]"a"(load_address),
           [boot_params] "S"(setup_base),
           "b"(0), "D"(0)
        :  "%ebp"
        );
-#else
-       struct pt_regs regs;
-
-       memset(&regs, 0, sizeof(struct pt_regs));
-       regs.xds = (u32)setup_base >> 4;
-       regs.xes = regs.xds;
-       regs.xss = regs.xds;
-       regs.esp = 0x9000;
-       regs.eflags = 0;
-       enter_realmode(((u32)setup_base + SETUP_START_OFFSET) >> 4, 0,
-                      &regs, &regs);
-#endif
+}
+
+void setup_pcat_compatibility(void)
+       __attribute__((weak, alias("__setup_pcat_compatibility")));
+
+void __setup_pcat_compatibility(void)
+{
 }
 
 int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
@@ -321,6 +313,8 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        void *load_address;
        char *s;
        ulong bzImage_size = 0;
+       ulong initrd_addr = 0;
+       ulong initrd_size = 0;
 
        disable_interrupts();
 
@@ -337,9 +331,15 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
        if (s)
                bzImage_addr = (void *)simple_strtoul(s, NULL, 16);
 
-       if (argc >= 3)
+       if (argc >= 3) {
                /* argv[2] holds the size of the bzImage */
                bzImage_size = simple_strtoul(argv[2], NULL, 16);
+       }
+
+       if (argc >= 4)
+               initrd_addr = simple_strtoul(argv[3], NULL, 16);
+       if (argc >= 5)
+               initrd_size = simple_strtoul(argv[4], NULL, 16);
 
        /* Lets look for */
        base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address);
@@ -349,15 +349,11 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
                return -1;
        }
        if (setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
-                       0, 0, 0)) {
+                       0, initrd_addr, initrd_size)) {
                printf("Setting up boot parameters failed ...\n");
                return -1;
        }
 
-       printf("## Transferring control to Linux "
-              "(at address %08x) ...\n",
-              (u32)base_ptr);
-
        /* we assume that the kernel is in place */
        boot_zimage(base_ptr, load_address);
        /* does not return */
@@ -366,7 +362,14 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 }
 
 U_BOOT_CMD(
-       zboot, 2, 0,    do_zboot,
+       zboot, 5, 0,    do_zboot,
        "Boot bzImage",
-       ""
+       "[addr] [size] [initrd addr] [initrd size]\n"
+       "      addr -        The optional starting address of the bzimage.\n"
+       "                    If not set it defaults to the environment\n"
+       "                    variable \"fileaddr\".\n"
+       "      size -        The optional size of the bzimage. Defaults to\n"
+       "                    zero.\n"
+       "      initrd addr - The address of the initrd image to use, if any.\n"
+       "      initrd size - The size of the initrd image to use, if any.\n"
 );