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