main.c revision 163597
1238384Sjkim/*-
2238384Sjkim * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
3238384Sjkim *
4238384Sjkim * Redistribution and use in source and binary forms, with or without
5246769Sjkim * modification, are permitted provided that the following conditions
6238384Sjkim * are met:
7238384Sjkim * 1. Redistributions of source code must retain the above copyright
8238384Sjkim *    notice, this list of conditions and the following disclaimer.
9238384Sjkim * 2. Redistributions in binary form must reproduce the above copyright
10238384Sjkim *    notice, this list of conditions and the following disclaimer in the
11246769Sjkim *    documentation and/or other materials provided with the distribution.
12246769Sjkim *
13238384Sjkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14238384Sjkim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15238384Sjkim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16238384Sjkim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17238384Sjkim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18246769Sjkim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19238384Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20238384Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21246769Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22238384Sjkim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23238384Sjkim *
24238384Sjkim * This software is derived from software provided by kwikbyte without
25238384Sjkim * copyright as follows:
26238384Sjkim *
27238384Sjkim * No warranty, expressed or implied, is included with this software.  It is
28238384Sjkim * provided "AS IS" and no warranty of any kind including statutory or aspects
29238384Sjkim * relating to merchantability or fitness for any purpose is provided.  All
30238384Sjkim * intellectual property rights of others is maintained with the respective
31238384Sjkim * owners.  This software is not copyrighted and is intended for reference
32238384Sjkim * only.
33238384Sjkim *
34238384Sjkim * $FreeBSD: head/sys/boot/arm/at91/bootspi/main.c 163597 2006-10-21 22:44:26Z imp $
35238384Sjkim */
36238384Sjkim
37238384Sjkim#include "env_vars.h"
38238384Sjkim#include "at91rm9200.h"
39246769Sjkim#include "at91rm9200_lowlevel.h"
40238384Sjkim#include "loader_prompt.h"
41238384Sjkim#include "emac.h"
42238384Sjkim#include "lib.h"
43246769Sjkim#include "spi_flash.h"
44238384Sjkim#include "ee.h"
45238384Sjkim
46238384Sjkimint
47238384Sjkimmain(void)
48246769Sjkim{
49238384Sjkim	printf("\nBoot\n");
50238384Sjkim	EEInit();
51238384Sjkim	SPI_InitFlash();
52238384Sjkim#ifdef TSC_FPGA
53238384Sjkim	fpga_load();
54238384Sjkim#endif
55238384Sjkim	EMAC_Init();
56238384Sjkim	LoadBootCommands();
57238384Sjkim	if (getc(1) == -1) {
58238384Sjkim		start_wdog(30);
59238384Sjkim		ExecuteEnvironmentFunctions();
60238384Sjkim	}
61238384Sjkim	Bootloader(getc);
62238384Sjkim	return (1);
63238384Sjkim}
64238384Sjkim