00001 /*
00002 * Copyright (C) 2002 by egnite Software GmbH. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions
00006 * are met:
00007 *
00008 * 1. Redistributions of source code must retain the above copyright
00009 * notice, this list of conditions and the following disclaimer.
00010 * 2. Redistributions in binary form must reproduce the above copyright
00011 * notice, this list of conditions and the following disclaimer in the
00012 * documentation and/or other materials provided with the distribution.
00013 * 3. All advertising materials mentioning features or use of this
00014 * software must display the following acknowledgement:
00015 *
00016 * This product includes software developed by egnite Software GmbH
00017 * and its contributors.
00018 *
00019 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00020 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00023 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030 * SUCH DAMAGE.
00031 *
00032 * For additional information see http://www.ethernut.de/
00033 *
00034 */
00035
00036 /*
00037 * $Log: eboot.c,v $
00038 * Revision 1.1 2002/08/01 17:34:30 harald
00039 * First check in
00040 *
00041 */
00042
00043 #include <pgmspace.h>
00044
00045 #include "ether.h"
00046 #include "dhcp.h"
00047 #include "tftp.h"
00048 #include "eboot.h"
00049
00050 BOOTFRAME sframe;
00051 BOOTFRAME rframe;
00052 u_long netmask;
00053 u_long broadcast;
00054 u_long gateway;
00055 u_long dns;
00056 u_long sid;
00057 u_long local_ip;
00058 u_long server_ip;
00059 u_char bootfile[128];
00060
00061 /*!
00062 * \addtogroup xgEBoot
00063 */
00064 /*@{*/
00065
00066 /*!
00067 * \brief Boot loader entry.
00068 *
00069 * This boot loader is very special. It is completely self
00070 * contained, which means that it runs without any library.
00071 * This entry point must be linked first and will be located
00072 * at byte address 0x1F000 in the program flash ROM.
00073 *
00074 * \return Never, but jumps at absolute address 0 when done.
00075 */
00076 int main(void)
00077 {
00078 u_char *bp;
00079 u_long pp;
00080
00081 /*
00082 * We are without runtime library, so we have
00083 * to initialize everything.
00084 */
00085 asm volatile("clr r1");
00086 asm volatile("cli");
00087 for(bp = (u_char *)0x100; bp < (u_char *)0x1000; bp++)
00088 *bp = 0xFF;
00089
00090 /*
00091 * Initialize the data segment.
00092 */
00093 pp = (u_long)&__data_load_start;
00094 for(bp = &__data_start; bp < &__data_end; bp++) {
00095 *bp = _ELPM(pp);
00096 pp++;
00097 }
00098
00099 /*
00100 * Clear bss.
00101 */
00102 for(bp = &__bss_start; bp < &__bss_end; bp++)
00103 *bp = 0;
00104
00105 /*
00106 * Initialize the network interface controller hardware.
00107 */
00108 NicInit();
00109
00110 /*
00111 * DHCP query and TFTP download.
00112 */
00113 if(DhcpQuery() == 0 && bootfile[0])
00114 TftpRecv();
00115
00116 /*
00117 * Will jump to the application.
00118 */
00119 asm volatile("jmp 0");
00120 for(;;);
00121 return 0;
00122 }
00123
00124 /*@}*/