]> git.sur5r.net Git - u-boot/blob - arch/x86/cpu/start.S
x86: Punt cold- and warm-boot flags
[u-boot] / arch / x86 / cpu / start.S
1 /*
2  *  U-boot - x86 Startup Code
3  *
4  * (C) Copyright 2008-2011
5  * Graeme Russ, <graeme.russ@gmail.com>
6  *
7  * (C) Copyright 2002
8  * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
9  *
10  * See file CREDITS for list of people who contributed to this
11  * project.
12  *
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.
17  *
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.
22  *
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,
26  * MA 02111-1307 USA
27  */
28
29 #include <config.h>
30 #include <version.h>
31 #include <asm/global_data.h>
32 #include <asm/processor-flags.h>
33
34 .section .text
35 .code32
36 .globl _start
37 .type _start, @function
38 .globl _x86boot_start
39 _x86boot_start:
40         /*
41          * This is the fail safe 32-bit bootstrap entry point. The
42          * following code is not executed from a cold-reset (actually, a
43          * lot of it is, but from real-mode after cold reset. It is
44          * repeated here to put the board into a state as close to cold
45          * reset as necessary)
46          */
47         cli
48         cld
49
50         /* Turn of cache (this might require a 486-class CPU) */
51         movl    %cr0, %eax
52         orl     $(X86_CR0_NW | X86_CR0_CD), %eax
53         movl    %eax, %cr0
54         wbinvd
55
56 _start:
57         /* This is the 32-bit cold-reset entry point */
58
59         /* Load the segement registes to match the gdt loaded in start16.S */
60         movl    $0x18, %eax
61         movw    %ax, %fs
62         movw    %ax, %ds
63         movw    %ax, %gs
64         movw    %ax, %es
65         movw    %ax, %ss
66
67         /* Clear the interrupt vectors */
68         lidt    blank_idt_ptr
69
70         /* Early platform init (setup gpio, etc ) */
71         jmp     early_board_init
72 .globl early_board_init_ret
73 early_board_init_ret:
74
75         /* Initialise Cache-As-RAM */
76         jmp     car_init
77 .globl car_init_ret
78 car_init_ret:
79         /*
80          * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
81          * or fully initialised SDRAM - we really don't care which)
82          * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
83          */
84         movl    $CONFIG_SYS_INIT_SP_ADDR, %esp
85
86         /* Set parameter to board_init_f() to boot flags */
87         xorl    %eax, %eax
88         movw    %bx, %ax
89
90         /* Enter, U-boot! */
91         call    board_init_f
92
93         /* indicate (lack of) progress */
94         movw    $0x85, %ax
95         jmp     die
96
97 .globl relocate_code
98 .type relocate_code, @function
99 relocate_code:
100         /*
101          * SDRAM has been initialised, U-Boot code has been copied into
102          * RAM, BSS has been cleared and relocation adjustments have been
103          * made. It is now time to jump into the in-RAM copy of U-Boot
104          *
105          * %eax = Address of top of stack
106          * %edx = Address of Global Data
107          * %ecx = Base address of in-RAM copy of U-Boot
108          */
109
110         /* Setup stack in RAM */
111         movl    %eax, %esp
112
113         /* Setup call address of in-RAM copy of board_init_r() */
114         movl    $board_init_r, %ebp
115         addl    (GD_RELOC_OFF * 4)(%edx), %ebp
116
117         /* Setup parameters to board_init_r() */
118         movl    %edx, %eax
119         movl    %ecx, %edx
120
121         /* Jump to in-RAM copy of board_init_r() */
122         call    *%ebp
123
124 die:    hlt
125         jmp     die
126         hlt
127
128 blank_idt_ptr:
129         .word   0               /* limit */
130         .long   0               /* base */