00001 /* 00002 *Copyright (c) 2000-2002 Viola Systems Ltd. 00003 *All rights reserved. 00004 * 00005 *Redistribution and use in source and binary forms, with or without 00006 *modification, are permitted provided that the following conditions 00007 *are met: 00008 * 00009 *1. Redistributions of source code must retain the above copyright 00010 *notice, this list of conditions and the following disclaimer. 00011 * 00012 *2. Redistributions in binary form must reproduce the above copyright 00013 *notice, this list of conditions and the following disclaimer in the 00014 *documentation and/or other materials provided with the distribution. 00015 * 00016 *3. The end-user documentation included with the redistribution, if 00017 *any, must include the following acknowledgment: 00018 * "This product includes software developed by Viola 00019 * Systems (http://www.violasystems.com/)." 00020 * 00021 *Alternately, this acknowledgment may appear in the software itself, 00022 *if and wherever such third-party acknowledgments normally appear. 00023 * 00024 *4. The names "OpenTCP" and "Viola Systems" must not be used to 00025 *endorse or promote products derived from this software without prior 00026 *written permission. For written permission, please contact 00027 *opentcp@opentcp.org. 00028 * 00029 *5. Products derived from this software may not be called "OpenTCP", 00030 *nor may "OpenTCP" appear in their name, without prior written 00031 *permission of the Viola Systems Ltd. 00032 * 00033 *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00034 *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00035 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00036 *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 00037 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00038 *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00039 *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00040 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00041 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00042 *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00043 *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00044 *==================================================================== 00045 * 00046 *OpenTCP is the unified open source TCP/IP stack available on a series 00047 *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>. 00048 * 00049 *For more information on how to network-enable your devices, or how to 00050 *obtain commercial technical support for OpenTCP, please see 00051 *<http://www.violasystems.com/>. 00052 */ 00053 00065 #ifndef INCLUDE_ETHERNET_H 00066 #define INCLUDE_ETHERNET_H 00067 00068 #include <inet/datatypes.h> 00069 00070 /* Symbolic constants */ 00071 00072 #define ETH_ADDRESS_LEN 6 00073 00074 /* Protocol Constants */ 00075 00076 #define ETH_HEADER_LEN 14 00077 #define ETH_CHIP_HEADER_LEN 4 00078 #define ETH_MTU 1500 00079 00080 #define PROTOCOL_IP 0x0800 00081 #define PROTOCOL_ARP 0x0806 00083 /* Page0 register offsets */ 00084 00085 #define CR 0x00 00086 #define PSTART 0x01 00087 #define PSTOP 0x02 00088 #define BOUNDARY 0x03 00091 #define TPSR 0x04 00092 #define TSR 0x04 00093 #define TBCR0 0x05 00094 #define TBCR1 0x06 00095 #define ISR 0x07 00096 #define RSAR0 0x08 00097 #define RSAR1 0x09 00098 #define RBCR0 0x0A 00099 #define RBCR1 0x0B 00100 #define RCR 0x0C 00101 #define TCR 0x0D 00102 #define DCR 0x0E 00103 #define IMR 0x0F 00105 /* Page 1 register offsets */ 00106 00107 #define PAR0 0x01 00108 #define PAR1 0x02 00109 #define PAR2 0x03 00110 #define PAR3 0x04 00111 #define PAR4 0x05 00112 #define PAR5 0x06 00113 #define CURR 0x07 00114 #define MAR0 0x08 00116 /* DMA Ports */ 00117 00118 #define IOPORT 0x10 00119 #define RESETPORT 0x1F 00120 00121 00122 /* Buffer addresses */ 00123 #define RXBUF_START 0x40 00124 #define RXBUF_END 0x4D 00125 #define ARP_BUFFER 0x5F 00126 #define ICMP_BUF 0x4D 00127 #define TCP_BUF 0x53 00128 #define UDP_BUF 0x59 00142 struct ethernet_frame 00143 { 00144 UINT8 destination[ETH_ADDRESS_LEN]; 00148 UINT8 source[ETH_ADDRESS_LEN]; 00152 UINT16 frame_size; 00155 UINT16 protocol; 00161 UINT16 buf_index; 00166 }; 00167 00168 /* API prototypes */ 00169 void outNE2000(UINT8, UINT8); 00170 void outNE2000again(UINT8); 00171 UINT8 inNE2000(UINT8); 00172 UINT8 inNE2000again(void); 00173 UINT8 NE2000CheckRxFrame(void); 00174 void NE2000DumpRxFrame(void); 00175 void NE2000Init(UINT8*); 00176 void NE2000CheckOverFlow(void); 00177 UINT8 NE2000ReceiveFrame(void); 00178 void InitTransmission(UINT8); 00179 void NE2000WriteEthernetHeader(struct ethernet_frame*); 00180 void NE2000DMAInit(UINT8); 00181 void NE2000DMAInit_position(UINT16); 00182 void NE2000SendFrame(UINT16); 00183 void NE2000EnterSleep(void); 00184 void NE2000ExitSleep(void); 00185 00186 00187 #endif 00188 00189