main.c revision 302408
1233294Sstas/*-
255682Smarkm * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
355682Smarkm *
455682Smarkm * Redistribution and use in source and binary forms, with or without
5178825Sdfr * modification, are permitted provided that the following conditions
655682Smarkm * are met:
755682Smarkm * 1. Redistributions of source code must retain the above copyright
855682Smarkm *    notice, this list of conditions and the following disclaimer.
955682Smarkm * 2. Redistributions in binary form must reproduce the above copyright
1055682Smarkm *    notice, this list of conditions and the following disclaimer in the
1155682Smarkm *    documentation and/or other materials provided with the distribution.
1255682Smarkm *
1355682Smarkm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1455682Smarkm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1555682Smarkm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1655682Smarkm * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1755682Smarkm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1855682Smarkm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1955682Smarkm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2055682Smarkm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2155682Smarkm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2255682Smarkm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2355682Smarkm *
2455682Smarkm * This software is derived from software provided by kwikbyte without
25178825Sdfr * copyright as follows:
26178825Sdfr *
2755682Smarkm * No warranty, expressed or implied, is included with this software.  It is
2855682Smarkm * provided "AS IS" and no warranty of any kind including statutory or aspects
2955682Smarkm * relating to merchantability or fitness for any purpose is provided.  All
30233294Sstas * intellectual property rights of others is maintained with the respective
3155682Smarkm * owners.  This software is not copyrighted and is intended for reference
3255682Smarkm * only.
3355682Smarkm *
3455682Smarkm * $FreeBSD: stable/11/sys/boot/arm/at91/bootspi/main.c 269111 2014-07-26 03:33:19Z ian $
3555682Smarkm */
3655682Smarkm
3755682Smarkm#include "env_vars.h"
3855682Smarkm#include "at91rm9200.h"
3955682Smarkm#include "at91rm9200_lowlevel.h"
4055682Smarkm#include "loader_prompt.h"
41233294Sstas#include "emac.h"
4255682Smarkm#include "lib.h"
4355682Smarkm#include "spi_flash.h"
4455682Smarkm#include "ee.h"
4555682Smarkm
4690926Snectarint main(void);
4755682Smarkm
4855682Smarkmint
4990926Snectarmain(void)
5055682Smarkm{
51178825Sdfr	printf("\nBoot\n");
5290926Snectar	EEInit();
53178825Sdfr	SPI_InitFlash();
54233294Sstas#ifdef TSC_FPGA
55	fpga_load();
56#endif
57	EMAC_Init();
58	LoadBootCommands();
59	if (getc(1) == -1) {
60		start_wdog(30);
61		ExecuteEnvironmentFunctions();
62	}
63	Bootloader(getc);
64	return (1);
65}
66