X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=arch%2Fx86%2Flib%2Fzimage.c;h=1b33c771391f49ffe82864ff1582bdfd07e5e97d;hb=fc4f5cccd87abf4c72b13f64b49719fde9107cad;hp=4e9e1f77e5ac35bda83ff2fe8b23c0e9970c9859;hpb=9f024f62e4604274a23213dcee30016092e32e7b;p=u-boot diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index 4e9e1f77e5..1b33c77139 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -3,23 +3,7 @@ * (C) Copyright 2002 * Daniel Engström, Omicron Ceti AB, * - * 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+ */ /* @@ -34,12 +18,15 @@ #include #include #include +#include #include #ifdef CONFIG_SYS_COREBOOT #include #endif #include +DECLARE_GLOBAL_DATA_PTR; + /* * Memory lay-out: * @@ -55,16 +42,6 @@ #define COMMAND_LINE_SIZE 2048 -unsigned generic_install_e820_map(unsigned max_entries, - struct e820entry *entries) -{ - return 0; -} - -unsigned install_e820_map(unsigned max_entries, - struct e820entry *entries) - __attribute__((weak, alias("generic_install_e820_map"))); - static void build_command_line(char *command_line, int auto_boot) { char *env_command_line; @@ -118,7 +95,7 @@ static int get_boot_protocol(struct setup_header *hdr) } struct boot_params *load_zimage(char *image, unsigned long kernel_size, - void **load_address) + ulong *load_addressp) { struct boot_params *setup_base; int setup_size; @@ -170,9 +147,9 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, /* Determine load address */ if (big_image) - *load_address = (void *)BZIMAGE_LOAD_ADDR; + *load_addressp = BZIMAGE_LOAD_ADDR; else - *load_address = (void *)ZIMAGE_LOAD_ADDR; + *load_addressp = ZIMAGE_LOAD_ADDR; printf("Building boot_params at 0x%8.8lx\n", (ulong)setup_base); memset(setup_base, 0, sizeof(*setup_base)); @@ -219,10 +196,10 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, return 0; } - printf("Loading %s at address %p (%ld bytes)\n", - big_image ? "bzImage" : "zImage", *load_address, kernel_size); + printf("Loading %s at address %lx (%ld bytes)\n", + big_image ? "bzImage" : "zImage", *load_addressp, kernel_size); - memmove(*load_address, image + setup_size, kernel_size); + memmove((void *)*load_addressp, image + setup_size, kernel_size); return setup_base; } @@ -258,54 +235,24 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot, hdr->loadflags |= HEAP_FLAG; } - if (bootproto >= 0x0202) { - hdr->cmd_line_ptr = (uintptr_t)cmd_line; - } else if (bootproto >= 0x0200) { - setup_base->screen_info.cl_magic = COMMAND_LINE_MAGIC; - setup_base->screen_info.cl_offset = - (uintptr_t)cmd_line - (uintptr_t)setup_base; + if (cmd_line) { + if (bootproto >= 0x0202) { + hdr->cmd_line_ptr = (uintptr_t)cmd_line; + } else if (bootproto >= 0x0200) { + setup_base->screen_info.cl_magic = COMMAND_LINE_MAGIC; + setup_base->screen_info.cl_offset = + (uintptr_t)cmd_line - (uintptr_t)setup_base; - hdr->setup_move_size = 0x9100; - } - - /* build command line at COMMAND_LINE_OFFSET */ - build_command_line(cmd_line, 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) -{ -} + hdr->setup_move_size = 0x9100; + } -void boot_zimage(void *setup_base, void *load_address) -{ - board_final_cleanup(); + /* build command line at COMMAND_LINE_OFFSET */ + build_command_line(cmd_line, auto_boot); + } - printf("\nStarting kernel ...\n\n"); + setup_video(&setup_base->screen_info); -#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 - * 0x10, 4GB flat, and read/execute, and the data segments are 0x18, - * 4GB flat, and read/write. U-boot is setting them up that way for - * itself in arch/i386/cpu/cpu.c. - */ - __asm__ __volatile__ ( - "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" - ); + return 0; } void setup_pcat_compatibility(void) @@ -319,7 +266,7 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { struct boot_params *base_ptr; void *bzImage_addr = NULL; - void *load_address; + ulong load_address; char *s; ulong bzImage_size = 0; ulong initrd_addr = 0; @@ -354,24 +301,17 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) base_ptr = load_zimage(bzImage_addr, bzImage_size, &load_address); if (!base_ptr) { - printf("## Kernel loading failed ...\n"); + puts("## Kernel loading failed ...\n"); return -1; } if (setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET, 0, initrd_addr, initrd_size)) { - printf("Setting up boot parameters failed ...\n"); + puts("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 */ - - return -1; + return boot_linux_kernel((ulong)base_ptr, load_address, false); } U_BOOT_CMD(