2002-11-18 09:14:45 +09:00
|
|
|
/*
|
2011-04-13 18:43:28 +09:00
|
|
|
* U-boot - x86 Startup Code
|
2002-11-18 09:14:45 +09:00
|
|
|
*
|
2011-04-13 18:43:26 +09:00
|
|
|
* (C) Copyright 2008-2011
|
|
|
|
* Graeme Russ, <graeme.russ@gmail.com>
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002
|
2011-08-05 01:45:45 +09:00
|
|
|
* Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
|
2002-11-18 09:14:45 +09:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <version.h>
|
2010-10-07 18:03:29 +09:00
|
|
|
#include <asm/global_data.h>
|
2011-02-12 13:11:32 +09:00
|
|
|
#include <asm/processor-flags.h>
|
2002-11-18 09:14:45 +09:00
|
|
|
|
|
|
|
.section .text
|
|
|
|
.code32
|
|
|
|
.globl _start
|
2003-06-28 06:31:46 +09:00
|
|
|
.type _start, @function
|
2011-04-13 18:43:28 +09:00
|
|
|
.globl _x86boot_start
|
|
|
|
_x86boot_start:
|
2010-04-23 23:05:42 +09:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
cli
|
|
|
|
cld
|
|
|
|
|
|
|
|
/* Turn of cache (this might require a 486-class CPU) */
|
|
|
|
movl %cr0, %eax
|
2011-02-12 13:11:32 +09:00
|
|
|
orl $(X86_CR0_NW | X86_CR0_CD), %eax
|
2010-04-23 23:05:42 +09:00
|
|
|
movl %eax, %cr0
|
|
|
|
wbinvd
|
|
|
|
|
|
|
|
/* Tell 32-bit code it is being entered from an in-RAM copy */
|
2010-10-07 18:03:30 +09:00
|
|
|
movw $GD_FLG_WARM_BOOT, %bx
|
2003-06-28 06:31:46 +09:00
|
|
|
_start:
|
2010-04-23 23:05:42 +09:00
|
|
|
/* This is the 32-bit cold-reset entry point */
|
|
|
|
|
2011-04-13 18:43:26 +09:00
|
|
|
/* Load the segement registes to match the gdt loaded in start16.S */
|
|
|
|
movl $0x18, %eax
|
2010-10-07 18:03:21 +09:00
|
|
|
movw %ax, %fs
|
|
|
|
movw %ax, %ds
|
|
|
|
movw %ax, %gs
|
|
|
|
movw %ax, %es
|
|
|
|
movw %ax, %ss
|
2003-06-28 06:31:46 +09:00
|
|
|
|
2011-07-22 13:01:30 +09:00
|
|
|
/* Clear the interrupt vectors */
|
2010-04-23 23:05:42 +09:00
|
|
|
lidt blank_idt_ptr
|
|
|
|
|
2002-11-18 09:14:45 +09:00
|
|
|
/* Early platform init (setup gpio, etc ) */
|
|
|
|
jmp early_board_init
|
2010-10-07 18:03:27 +09:00
|
|
|
.globl early_board_init_ret
|
2002-11-18 09:14:45 +09:00
|
|
|
early_board_init_ret:
|
2003-06-28 06:31:46 +09:00
|
|
|
|
2011-02-12 13:11:52 +09:00
|
|
|
/* Initialise Cache-As-RAM */
|
|
|
|
jmp car_init
|
|
|
|
.globl car_init_ret
|
|
|
|
car_init_ret:
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
movl $CONFIG_SYS_INIT_SP_ADDR, %esp
|
2010-04-23 23:05:41 +09:00
|
|
|
|
2011-02-12 13:11:54 +09:00
|
|
|
/* Set parameter to board_init_f() to boot flags */
|
2011-04-13 18:43:26 +09:00
|
|
|
xorl %eax, %eax
|
|
|
|
movw %bx, %ax
|
2010-10-07 18:03:29 +09:00
|
|
|
|
2011-04-13 18:43:26 +09:00
|
|
|
/* Enter, U-boot! */
|
|
|
|
call board_init_f
|
2002-11-18 09:14:45 +09:00
|
|
|
|
|
|
|
/* indicate (lack of) progress */
|
2003-06-28 06:31:46 +09:00
|
|
|
movw $0x85, %ax
|
2011-02-12 13:11:58 +09:00
|
|
|
jmp die
|
|
|
|
|
|
|
|
.globl relocate_code
|
|
|
|
.type relocate_code, @function
|
|
|
|
relocate_code:
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Setup stack in RAM */
|
|
|
|
movl %eax, %esp
|
|
|
|
|
|
|
|
/* Setup call address of in-RAM copy of board_init_r() */
|
|
|
|
movl $board_init_r, %ebp
|
2011-02-12 13:12:05 +09:00
|
|
|
addl (GD_RELOC_OFF * 4)(%edx), %ebp
|
2011-02-12 13:11:58 +09:00
|
|
|
|
|
|
|
/* Setup parameters to board_init_r() */
|
|
|
|
movl %edx, %eax
|
|
|
|
movl %ecx, %edx
|
|
|
|
|
|
|
|
/* Jump to in-RAM copy of board_init_r() */
|
|
|
|
call *%ebp
|
|
|
|
|
2002-11-18 09:14:45 +09:00
|
|
|
die: hlt
|
|
|
|
jmp die
|
2003-06-28 06:31:46 +09:00
|
|
|
hlt
|
2010-04-23 23:05:42 +09:00
|
|
|
|
|
|
|
blank_idt_ptr:
|
|
|
|
.word 0 /* limit */
|
|
|
|
.long 0 /* base */
|