2 * U-boot - x86 Startup Code
4 * (C) Copyright 2008-2011
5 * Graeme Russ, <graeme.russ@gmail.com>
8 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/global_data.h>
32 #include <asm/processor.h>
33 #include <asm/processor-flags.h>
34 #include <generated/generic-asm-offsets.h>
39 .type _start, @function
43 * This is the fail safe 32-bit bootstrap entry point. The
44 * following code is not executed from a cold-reset (actually, a
45 * lot of it is, but from real-mode after cold reset. It is
46 * repeated here to put the board into a state as close to cold
52 /* Turn off cache (this might require a 486-class CPU) */
54 orl $(X86_CR0_NW | X86_CR0_CD), %eax
58 /* Tell 32-bit code it is being entered from an in-RAM copy */
59 movw $GD_FLG_WARM_BOOT, %bx
63 * This is the 32-bit cold-reset entry point. Initialize %bx to 0
64 * in case we're preceeded by some sort of boot stub.
66 movw $GD_FLG_COLD_BOOT, %bx
69 /* Load the segement registes to match the gdt loaded in start16.S */
70 movl $(X86_GDT_ENTRY_32BIT_DS * X86_GDT_ENTRY_SIZE), %eax
77 /* Clear the interrupt vectors */
80 /* Early platform init (setup gpio, etc ) */
82 .globl early_board_init_ret
85 /* Initialise Cache-As-RAM */
90 * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
91 * or fully initialised SDRAM - we really don't care which)
92 * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
95 /* Stack grows down from top of CAR */
96 movl $(CONFIG_SYS_CAR_ADDR + CONFIG_SYS_CAR_SIZE), %esp
98 /* Reserve space on stack for global data */
99 subl $GENERATED_GBL_DATA_SIZE, %esp
101 /* Align global data to 16-byte boundary */
102 andl $0xfffffff0, %esp
104 /* Setup first parameter to setup_gdt */
107 /* Reserve space for global descriptor table */
108 subl $X86_GDT_SIZE, %esp
110 /* Align temporary global descriptor table to 16-byte boundary */
111 andl $0xfffffff0, %esp
113 /* Set second parameter to setup_gdt */
116 /* Setup global descriptor table so gd->xyz works */
119 /* Set parameter to board_init_f() to boot flags */
126 /* indicate (lack of) progress */
130 .globl board_init_f_r_trampoline
131 .type board_init_f_r_trampoline, @function
132 board_init_f_r_trampoline:
134 * SDRAM has been initialised, U-Boot code has been copied into
135 * RAM, BSS has been cleared and relocation adjustments have been
136 * made. It is now time to jump into the in-RAM copy of U-Boot
138 * %eax = Address of top of new stack
141 /* Stack grows down from top of SDRAM */
144 /* Reserve space on stack for global data */
145 subl $GENERATED_GBL_DATA_SIZE, %esp
147 /* Align global data to 16-byte boundary */
148 andl $0xfffffff0, %esp
150 /* Setup first parameter to memcpy (and setup_gdt) */
153 /* Setup second parameter to memcpy */
156 /* Set third parameter to memcpy */
157 movl $GENERATED_GBL_DATA_SIZE, %ecx
159 /* Copy global data from CAR to SDRAM stack */
162 /* Reserve space for global descriptor table */
163 subl $X86_GDT_SIZE, %esp
165 /* Align global descriptor table to 16-byte boundary */
166 andl $0xfffffff0, %esp
168 /* Set second parameter to setup_gdt */
171 /* Setup global descriptor table so gd->xyz works */
174 /* Re-enter U-Boot by calling board_init_f_r */
186 .p2align 2 /* force 4-byte alignment */
194 .long -0x1BADB002 - (1 << 16)
196 .long multiboot_header - _x86boot_start + CONFIG_SYS_TEXT_BASE
198 .long CONFIG_SYS_TEXT_BASE
204 .long CONFIG_SYS_TEXT_BASE