X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=arch%2Fx86%2Fcpu%2Fstart.S;h=e94ddc45ddb78475eefa3e306b9f352d1f378755;hb=f0c7d9c74642ccd6c76993b721b0fb87aab685fa;hp=6027f54186bf711088a02256263715ae75776e58;hpb=109ad143f8f2a948dc6628f55dbb6a8905087bfe;p=u-boot diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index 6027f54186..e94ddc45dd 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -1,5 +1,5 @@ /* - * U-boot - x86 Startup Code + * U-Boot - x86 Startup Code * * (C) Copyright 2008-2011 * Graeme Russ, @@ -7,30 +7,15 @@ * (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+ */ #include -#include #include +#include #include #include +#include #include .section .text @@ -40,11 +25,11 @@ .globl _x86boot_start _x86boot_start: /* - * This is the fail safe 32-bit bootstrap entry point. The - * following code is not executed from a cold-reset (actually, a - * lot of it is, but from real-mode after cold reset. It is - * repeated here to put the board into a state as close to cold - * reset as necessary) + * This is the fail-safe 32-bit bootstrap entry point. + * + * This code is used when booting from another boot loader like + * coreboot or EFI. So we repeat some of the same init found in + * start16. */ cli cld @@ -55,10 +40,35 @@ _x86boot_start: movl %eax, %cr0 wbinvd + /* Tell 32-bit code it is being entered from an in-RAM copy */ + movl $GD_FLG_WARM_BOOT, %ebx + + /* + * Zero the BIST (Built-In Self Test) value since we don't have it. + * It must be 0 or the previous loader would have reported an error. + */ + movl $0, %ebp + + jmp 1f + + /* Add a way for tools to discover the _start entry point */ + .align 4 + .long 0x12345678 _start: - /* This is the 32-bit cold-reset entry point */ + /* + * This is the 32-bit cold-reset entry point, coming from start16. + * Set %ebx to GD_FLG_COLD_BOOT to indicate this. + */ + movl $GD_FLG_COLD_BOOT, %ebx + + /* Save BIST */ + movl %eax, %ebp +1: + + /* Save table pointer */ + movl %ecx, %esi - /* Load the segement registes to match the gdt loaded in start16.S */ + /* Load the segement registers to match the GDT loaded in start16.S */ movl $(X86_GDT_ENTRY_32BIT_DS * X86_GDT_ENTRY_SIZE), %eax movw %ax, %fs movw %ax, %ds @@ -69,59 +79,111 @@ _start: /* Clear the interrupt vectors */ lidt blank_idt_ptr - /* Early platform init (setup gpio, etc ) */ + /* + * Critical early platform init - generally not used, we prefer init + * to happen later when we have a console, in case something goes + * wrong. + */ jmp early_board_init .globl early_board_init_ret early_board_init_ret: + post_code(POST_START) /* Initialise Cache-As-RAM */ jmp car_init .globl car_init_ret car_init_ret: +#ifndef CONFIG_HAVE_FSP /* * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM, * or fully initialised SDRAM - we really don't care which) * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack + * and early malloc() area. The MRC requires some space at the top. + * + * Stack grows down from top of CAR. We have: + * + * top-> CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE + * MRC area + * global_data with x86 global descriptor table + * early malloc area + * stack + * bottom-> CONFIG_SYS_CAR_ADDR + */ + movl $(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE - 4), %esp +#ifdef CONFIG_DCACHE_RAM_MRC_VAR_SIZE + subl $CONFIG_DCACHE_RAM_MRC_VAR_SIZE, %esp +#endif +#else + /* + * When we get here after car_init(), esp points to a temporary stack + * and esi holds the HOB list address returned by the FSP. */ - movl $CONFIG_SYS_INIT_SP_ADDR, %esp +#endif + /* Set up global data */ + mov %esp, %eax + call board_init_f_mem + mov %eax, %esp + + /* + * Debug UART is available here although it may not be plumbed out + * to pins depending on the board. To use it: + * + * call debug_uart_init + * mov $'a', %eax + * call printch + */ + + /* Get address of global_data */ + mov %fs:0, %edx +#ifdef CONFIG_HAVE_FSP + /* Store the HOB list if we have one */ + test %esi, %esi + jz skip_hob + movl %esi, GD_HOB_LIST(%edx) + +skip_hob: +#else + /* Store table pointer */ + movl %esi, GD_TABLE(%edx) +#endif + /* Store BIST */ + movl %ebp, GD_BIST(%edx) /* Set parameter to board_init_f() to boot flags */ + post_code(POST_START_DONE) xorl %eax, %eax - movw %bx, %ax - /* Enter, U-boot! */ + /* Enter, U-Boot! */ call board_init_f /* indicate (lack of) progress */ movw $0x85, %ax jmp die -.globl relocate_code -.type relocate_code, @function -relocate_code: +.globl board_init_f_r_trampoline +.type board_init_f_r_trampoline, @function +board_init_f_r_trampoline: /* * SDRAM has been initialised, U-Boot code has been copied into * RAM, BSS has been cleared and relocation adjustments have been * made. It is now time to jump into the in-RAM copy of U-Boot * - * %eax = Address of top of stack - * %edx = Address of Global Data - * %ecx = Base address of in-RAM copy of U-Boot + * %eax = Address of top of new stack */ - /* Setup stack in RAM */ + /* Stack grows down from top of SDRAM */ movl %eax, %esp - /* Setup call address of in-RAM copy of board_init_r() */ - movl $board_init_r, %ebp - addl (GENERATED_GD_RELOC_OFF)(%edx), %ebp - - /* Setup parameters to board_init_r() */ - movl %edx, %eax - movl %ecx, %edx + /* See if we need to disable CAR */ +.weak car_uninit + movl $car_uninit, %eax + cmpl $0, %eax + jz 1f - /* Jump to in-RAM copy of board_init_r() */ - call *%ebp + call car_uninit +1: + /* Re-enter U-Boot by calling board_init_f_r() */ + call board_init_f_r die: hlt @@ -134,9 +196,10 @@ blank_idt_ptr: .p2align 2 /* force 4-byte alignment */ + /* Add a multiboot header so U-Boot can be loaded by GRUB2 */ multiboot_header: /* magic */ - .long 0x1BADB002 + .long 0x1badb002 /* flags */ .long (1 << 16) /* checksum */