1/*******************************************************************************
| 1/*- 2 * Copyright (c) 2006 M. Warner Losh. All rights reserved.
|
2 *
| 3 *
|
3 * Filename: main.c
| 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution.
|
4 *
| 12 *
|
5 * Basic entry points for top-level functions
| 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
6 *
| 23 *
|
7 * Revision information:
| 24 * This software is derived from software provided by kwikbyte without 25 * copyright as follows:
|
8 *
| 26 *
|
9 * 20AUG2004 kb_admin initial creation 10 * 12JAN2005 kb_admin cosmetic changes 11 * 29APR2005 kb_admin modified boot delay 12 * 13 * BEGIN_KBDD_BLOCK
| |
14 * No warranty, expressed or implied, is included with this software. It is 15 * provided "AS IS" and no warranty of any kind including statutory or aspects 16 * relating to merchantability or fitness for any purpose is provided. All 17 * intellectual property rights of others is maintained with the respective 18 * owners. This software is not copyrighted and is intended for reference 19 * only.
| 27 * No warranty, expressed or implied, is included with this software. It is 28 * provided "AS IS" and no warranty of any kind including statutory or aspects 29 * relating to merchantability or fitness for any purpose is provided. All 30 * intellectual property rights of others is maintained with the respective 31 * owners. This software is not copyrighted and is intended for reference 32 * only.
|
20 * END_BLOCK
| |
21 *
| 33 *
|
22 * $FreeBSD: head/sys/boot/arm/at91/bootspi/main.c 157873 2006-04-19 17:16:49Z imp $ 23 ******************************************************************************/
| 34 * $FreeBSD: head/sys/boot/arm/at91/bootspi/main.c 161370 2006-08-16 23:39:58Z imp $ 35 */
|
24 25#include "env_vars.h"
| 36 37#include "env_vars.h"
|
| 38#include "at91rm9200.h"
|
26#include "at91rm9200_lowlevel.h" 27#include "loader_prompt.h" 28#include "emac.h" 29#include "lib.h"
| 39#include "at91rm9200_lowlevel.h" 40#include "loader_prompt.h" 41#include "emac.h" 42#include "lib.h"
|
| 43#include "spi_flash.h"
|
30
| 44
|
31/* 32 * .KB_C_FN_DEFINITION_START 33 * int main(void) 34 * This global function waits at least one second, but not more than two 35 * seconds, for input from the serial port. If no response is recognized, 36 * it acts according to the parameters specified by the environment. For 37 * example, the function might boot an operating system. Do not return 38 * from this function. 39 * .KB_C_FN_DEFINITION_END 40 */
| |
41int 42main(void) 43{
| 45int 46main(void) 47{
|
44
| 48 printf("\r\nBoot\r\n"); 49 SPI_InitFlash();
|
45 EMAC_Init();
| 50 EMAC_Init();
|
46
| |
47 LoadBootCommands();
| 51 LoadBootCommands();
|
48 49 printf("\r\nSPI Boot loader.\r\nAutoboot...\r\n"); 50 51 if (getc(1) == -1)
| 52 if (getc(1) == -1) { 53 start_wdog(30);
|
52 ExecuteEnvironmentFunctions();
| 54 ExecuteEnvironmentFunctions();
|
53 54 Bootloader(0); 55
| 55 } 56 Bootloader(getc);
|
56 return (1); 57}
| 57 return (1); 58}
|