xref: /rk3399_rockchip-uboot/arch/x86/cpu/start.S (revision f48dd6fc6cc9fdf15408e98132dc5575a31026cf)
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.h>
33#include <asm/processor-flags.h>
34#include <generated/asm-offsets.h>
35
36.section .text
37.code32
38.globl _start
39.type _start, @function
40.globl _x86boot_start
41_x86boot_start:
42	/*
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
47	 * reset as necessary)
48	 */
49	cli
50	cld
51
52	/* Turn off cache (this might require a 486-class CPU) */
53	movl	%cr0, %eax
54	orl	$(X86_CR0_NW | X86_CR0_CD), %eax
55	movl	%eax, %cr0
56	wbinvd
57
58_start:
59	/* This is the 32-bit cold-reset entry point */
60
61	/* Load the segement registes to match the gdt loaded in start16.S */
62	movl	$(X86_GDT_ENTRY_32BIT_DS * X86_GDT_ENTRY_SIZE), %eax
63	movw	%ax, %fs
64	movw	%ax, %ds
65	movw	%ax, %gs
66	movw	%ax, %es
67	movw	%ax, %ss
68
69	/* Clear the interrupt vectors */
70	lidt	blank_idt_ptr
71
72	/* Early platform init (setup gpio, etc ) */
73	jmp	early_board_init
74.globl early_board_init_ret
75early_board_init_ret:
76
77	/* Initialise Cache-As-RAM */
78	jmp	car_init
79.globl car_init_ret
80car_init_ret:
81	/*
82	 * We now have CONFIG_SYS_CAR_SIZE bytes of Cache-As-RAM (or SRAM,
83	 * or fully initialised SDRAM - we really don't care which)
84	 * starting at CONFIG_SYS_CAR_ADDR to be used as a temporary stack
85	 */
86	movl	$CONFIG_SYS_INIT_SP_ADDR, %esp
87
88	/* Set parameter to board_init_f() to boot flags */
89	xorl	%eax, %eax
90	movw	%bx, %ax
91
92	/* Enter, U-boot! */
93	call	board_init_f
94
95	/* indicate (lack of) progress */
96	movw	$0x85, %ax
97	jmp	die
98
99.globl board_init_f_r_trampoline
100.type board_init_f_r_trampoline, @function
101board_init_f_r_trampoline:
102	/*
103	 * SDRAM has been initialised, U-Boot code has been copied into
104	 * RAM, BSS has been cleared and relocation adjustments have been
105	 * made. It is now time to jump into the in-RAM copy of U-Boot
106	 *
107	 * %eax = Address of top of new stack
108	 */
109
110	/* Setup stack in RAM */
111	movl	%eax, %esp
112
113	/* Re-enter U-Boot by calling board_init_f_r */
114	call	board_init_f_r
115
116die:
117	hlt
118	jmp	die
119	hlt
120
121blank_idt_ptr:
122	.word	0		/* limit */
123	.long	0		/* base */
124
125	.p2align	2	/* force 4-byte alignment */
126
127multiboot_header:
128	/* magic */
129	.long	0x1BADB002
130	/* flags */
131	.long	(1 << 16)
132	/* checksum */
133	.long	-0x1BADB002 - (1 << 16)
134	/* header addr */
135	.long	multiboot_header - _x86boot_start + CONFIG_SYS_TEXT_BASE
136	/* load addr */
137	.long	CONFIG_SYS_TEXT_BASE
138	/* load end addr */
139	.long	0
140	/* bss end addr */
141	.long	0
142	/* entry addr */
143	.long	CONFIG_SYS_TEXT_BASE
144