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 00064 #ifndef SYSTEM_H_INCLUDE 00065 #define SYSTEM_H_INCLUDE 00066 00067 #include <inet/datatypes.h> 00068 #include <inet/globalvariables.h> 00075 #define OPENTCP_VERSION "1.0.4" 00076 00077 /* Boolean values*/ 00078 #define TRUE 1 00079 #define FALSE 0 00091 #define NETWORK_TX_BUFFER_SIZE 1024 00092 00100 struct netif{ 00119 LWORD localip; 00120 00128 BYTE localHW[6]; 00129 00136 LWORD defgw; 00137 00145 LWORD netmask; 00146 }; 00147 00148 /* System variable definitions */ 00149 00150 #define MASTER_MS_CLOCK base_timer 00151 #define TXBUF net_buf 00153 /* System macros */ 00154 00163 #define RESET_SYSTEM() while(1) /* Let the watchdog bite */ 00164 00176 #define OS_EnterCritical __DI 00177 00189 #define OS_ExitCritical __EI 00190 00210 #define RECEIVE_NETWORK_B() inNE2000again() 00211 00220 #define RECEIVE_NETWORK_BUF(c,d) inNE2000againbuf(c,d) 00221 00240 #define SEND_NETWORK_B(c) outNE2000again(c) 00241 00248 #define SEND_NETWORK_BUF(c,d) outNE2000againbuf(c,d) 00249 00262 #define NETWORK_CHECK_IF_RECEIVED() NE2000ReceiveFrame() 00263 00270 #define NETWORK_RECEIVE_INITIALIZE(c) NE2000DMAInit_position(c) 00271 00279 #define NETWORK_RECEIVE_END() NE2000DumpRxFrame() 00280 00288 #define NETWORK_COMPLETE_SEND(c) NE2000SendFrame(c) 00289 00296 #define NETWORK_SEND_INITIALIZE(c) InitTransmission(c) 00297 00306 #define NETWORK_ADD_DATALINK(c) NE2000WriteEthernetHeader(c) 00307 00308 00309 /* System functions */ 00310 00311 extern void kick_WD(void); 00312 extern void wait(INT16); 00313 extern void enter_power_save(void); 00314 extern void exit_power_save(void); 00315 extern INT16 strlen(UINT8*, UINT16); 00316 extern INT16 bufsearch(UINT8*, UINT16, UINT8*); 00317 extern UINT16 hextoascii(UINT8); 00318 extern void itoa(UINT16, UINT8*); 00319 extern void ltoa(UINT32, UINT8*); 00320 extern INT16 atoi(UINT8*, UINT8); 00321 extern UINT8 asciitohex(UINT8); 00322 extern UINT8 isnumeric(UINT8); 00323 extern void mputs(UINT8*); 00324 void mputhex(UINT8 ); 00325 extern UINT32 random(void); 00326 extern void dummy(void); 00327 00328 /* External functions */ 00329 00330 extern void init(void); 00331 00332 00333 #endif 00334 00335 00336 00337 00338