2002-11-18 00:14:45 +00:00
|
|
|
|
/*
|
2003-06-27 21:31:46 +00:00
|
|
|
|
* U-boot - i386 Startup Code
|
2002-11-18 00:14:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2002 Omicron Ceti AB, Daniel Engstr<EFBFBD>m <denaiel@omicron.se>
|
|
|
|
|
*
|
|
|
|
|
* 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>
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
.section .text
|
|
|
|
|
.code32
|
|
|
|
|
.globl _start
|
2003-06-27 21:31:46 +00:00
|
|
|
|
.type _start, @function
|
2002-11-18 00:14:45 +00:00
|
|
|
|
.globl _i386boot_start
|
|
|
|
|
_i386boot_start:
|
2003-06-27 21:31:46 +00:00
|
|
|
|
_start:
|
2008-05-20 14:00:29 +00:00
|
|
|
|
movl $0x18,%eax /* Load our segement registes, the
|
|
|
|
|
* gdt have already been loaded by start16.S */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw %ax,%fs
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movw %ax,%ds
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw %ax,%gs
|
|
|
|
|
movw %ax,%es
|
|
|
|
|
movw %ax,%ss
|
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/* We call a few functions in the board support package
|
|
|
|
|
* since we have no stack yet we'll have to use %ebp
|
|
|
|
|
* to store the return address */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/* Early platform init (setup gpio, etc ) */
|
|
|
|
|
mov $early_board_init_ret, %ebp
|
|
|
|
|
jmp early_board_init
|
|
|
|
|
early_board_init_ret:
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/* The __port80 entry-point should be usabe by now */
|
|
|
|
|
/* so we try to indicate progress */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $0x01, %ax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl $.progress0, %ebp
|
2008-09-29 13:03:14 +00:00
|
|
|
|
jmp show_boot_progress_asm
|
2003-06-27 21:31:46 +00:00
|
|
|
|
.progress0:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/* size memory */
|
|
|
|
|
mov $mem_init_ret, %ebp
|
2003-06-27 21:31:46 +00:00
|
|
|
|
jmp mem_init
|
2002-11-18 00:14:45 +00:00
|
|
|
|
mem_init_ret:
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
2009-11-24 09:04:21 +00:00
|
|
|
|
/* Check we have enough memory for stack */
|
|
|
|
|
movl $CONFIG_SYS_STACK_SIZE, %ecx
|
2003-06-27 21:31:46 +00:00
|
|
|
|
cmpl %ecx, %eax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
jae mem_ok
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/* indicate (lack of) progress */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $0x81, %ax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl $.progress0a, %ebp
|
2008-09-29 13:03:14 +00:00
|
|
|
|
jmp show_boot_progress_asm
|
2003-06-27 21:31:46 +00:00
|
|
|
|
.progress0a:
|
2008-05-20 14:00:29 +00:00
|
|
|
|
jmp die
|
2003-06-27 21:31:46 +00:00
|
|
|
|
mem_ok:
|
2009-11-24 09:04:21 +00:00
|
|
|
|
/* Set stack pointer to upper memory limit*/
|
|
|
|
|
movl %eax, %esp
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/* indicate progress */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $0x02, %ax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl $.progress1, %ebp
|
2008-09-29 13:03:14 +00:00
|
|
|
|
jmp show_boot_progress_asm
|
2003-06-27 21:31:46 +00:00
|
|
|
|
.progress1:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2009-11-24 09:04:21 +00:00
|
|
|
|
/* Test the stack */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
pushl $0
|
|
|
|
|
popl %eax
|
|
|
|
|
cmpl $0, %eax
|
|
|
|
|
jne no_stack
|
|
|
|
|
push $0x55aa55aa
|
|
|
|
|
popl %ebx
|
|
|
|
|
cmpl $0x55aa55aa, %ebx
|
|
|
|
|
je stack_ok
|
|
|
|
|
|
|
|
|
|
no_stack:
|
|
|
|
|
/* indicate (lack of) progress */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $0x82, %ax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl $.progress1a, %ebp
|
2008-09-29 13:03:14 +00:00
|
|
|
|
jmp show_boot_progress_asm
|
2003-06-27 21:31:46 +00:00
|
|
|
|
.progress1a:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
jmp die
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stack_ok:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
/* indicate progress */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $0x03, %ax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl $.progress2, %ebp
|
2008-09-29 13:03:14 +00:00
|
|
|
|
jmp show_boot_progress_asm
|
2003-06-27 21:31:46 +00:00
|
|
|
|
.progress2:
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
|
wbinvd
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2009-11-24 09:04:21 +00:00
|
|
|
|
/* Get upper memory limit */
|
|
|
|
|
movl %esp, %ecx
|
|
|
|
|
subl $CONFIG_SYS_STACK_SIZE, %ecx
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
2009-11-24 09:04:21 +00:00
|
|
|
|
/* Create a Stack Frame */
|
|
|
|
|
pushl %ebp
|
|
|
|
|
movl %esp, %ebp
|
|
|
|
|
|
|
|
|
|
/* stack_limit parameter */
|
|
|
|
|
pushl %ecx
|
|
|
|
|
call board_init_f /* Enter, U-boot! */
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
|
|
/* indicate (lack of) progress */
|
2003-06-27 21:31:46 +00:00
|
|
|
|
movw $0x85, %ax
|
2002-11-18 00:14:45 +00:00
|
|
|
|
movl $.progress4a, %ebp
|
2008-09-29 13:03:14 +00:00
|
|
|
|
jmp show_boot_progress_asm
|
2002-11-18 00:14:45 +00:00
|
|
|
|
.progress4a:
|
|
|
|
|
|
|
|
|
|
die: hlt
|
|
|
|
|
jmp die
|
2003-06-27 21:31:46 +00:00
|
|
|
|
hlt
|