⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipport.h

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 H
📖 第 1 页 / 共 2 页
字号:

#ifndef USE_RESOURCE_LOCKS
void ENTER_CRIT_SECTION(void * p);
void EXIT_CRIT_SECTION(void * p);

/* if we're using CRIT_SECTION, undefine RESOURCE_LOCK macros */
#define LOCK_NET_RESOURCE(res)
#define UNLOCK_NET_RESOURCE(res)

#else /* USE_RESOURCE_LOCKS */

/* the LOCK_NET_RESOURCE macros. These can be used when CRIT_SECTION
 * is not practical, as in some serious Real-time systems.
 */
extern void LOCK_NET_RESOURCE(void * res);
extern void UNLOCK_NET_RESOURCE(void * res);

/* #define resource IDs */

extern void * net_task_sem_ptr;   /* actually a pointer to semaphore */

/* ...and undefine CRIT_SECTION macros */
/* (yaxon del) */
/*#define ENTER_CRIT_SECTION(p)*/
/*#define EXIT_CRIT_SECTION(p)*/

/* (yaxon add) */
#undef ENTER_CRIT_SECTION
#undef EXIT_CRIT_SECTION
extern void ENTER_CRIT_SECTION(void * p);
extern void EXIT_CRIT_SECTION(void * p);
/* (yaxon add) */

#endif /* USE_RESOURCE_LOCKS */

#define YIELD tk_yield

#ifdef INICHE_TASKS     /* InterNiche multitasking system */
#include "tk_ntask.h"
void  tk_idle_hook(void);      /* System idle stuff. */

#define TCPWAKE_ALREADY 1  /* use per-port sleep, wakeup */
#define tcp_sleep(ev)   tk_ev_block(ev)
#define tcp_wakeup(ev)  tk_ev_wake(ev)

#endif   /* INICHE_TASKS */

extern char * pre_task_setup(void);
extern char * post_task_setup(void);


/* set up memory device as SNDS300 dram area */
#ifdef VFS_FILES
#define MEMDEV_BASE 0x01000000
#define MEMDEV_SIZE 0x00200000
#endif /* VFS_FILES */

/* number of entries in IP routing table */
#define RT_TABS   16

/* override ETHHDR_SIZE to introduce padding so that ARP, IP headers
 * will be aligned on a four-byte boundary
 */
#define ETHHDR_SIZE     16

/* Set ETHHDR_BIAS to allow our ethernet device to place ethernet headers 2 bytes
 * into the packet nb_buff area. This allows us to receive contiguous packets and
 * also have the IP header 32 bit aligned in emmory
 */
#define ETHHDR_BIAS     2


/* InterNiche stack generic error codes: generally full success is 0;
 * definite errors are negative numbers, and indeterminate conditions
 * are positive numbers. These may be changed if they conflict with
 * defines in the target system. They apply to the NetPort IP stack,
 * the IPX logic, and the portable SNMP Agent. If you have to change
 * these values, be sure to recompile ALL NetPort sources.
 */

#define SUCCESS            0   /* whatever the call was, it worked. */

/* programming errors */
#define ENP_PARAM        -10  /* bad parameter */
#define ENP_LOGIC        -11  /* sequence of events that shouldn't happen */

/* system errors */
#define ENP_NOMEM        -20  /* malloc or calloc failed */
#define ENP_NOBUFFER     -21  /* ran out of free packets */
#define ENP_RESOURCE     -22  /* ran out of other queue-able resource */
#define SEND_DROPPED     ENP_RESOURCE   /* full queue or similar lack of resource */
#define ENP_BAD_STATE    -23  /* TCP layer error */
#define ENP_TIMEOUT      -24  /* TCP layer error */
#define ENP_NOFILE       -25  /* expected file was missing */
#define ENP_FILEIO       -26  /* file IO error */

/* net errors */
#define ENP_SENDERR      -30  /* send to net failed at low layer */
#define ENP_NOARPREP     -31  /* no ARP for a given host */
#define ENP_BAD_HEADER   -32  /* bad header at upper layer (for upcalls) */
#define ENP_NO_ROUTE     -33  /* can't find a reasonable next IP hop */
#define ENP_NO_IFACE     -34  /* can't find a reasonable interface */
#define ENP_HARDWARE     -35  /* detected hardware failure */

/* conditions that are not really fatal OR success: */
#define ENP_SEND_PENDING   1  /* packet queued pending an ARP reply */
#define ENP_NOT_MINE       2  /* packet was not of interest (upcall reply) */
#define ARP_WAITING      ENP_SEND_PENDING /* ARP holding pkt, waiting for response from fhost */

/* A portable macro to check whether a ptr is within a certain range.
 * In an environment where selectors are important, this macro will
 * be altered to reflect that.
 */
 
#define IN_RANGE(p1, len1, p2) \
   (((p1) <= (p2)) && (((p1) + (len1)) > (p2)))

/* define the various IP stack block and buffer allocation routines */

char *   npalloc(unsigned size);
void     npfree(void * ptr);

/* (yaxon del) */
/* special un-cached buffer allocator for Samsung ARM ship */
/*char *   snds_alloc(unsigned size);*/
/*void     snds_free(void * ptr);*/

#define RT_ALLOC(size)     npalloc(size)  /* route block alloc */
#define RT_FREE(ptr)       npfree(ptr)
#define NB_ALLOC(size)     npalloc(size)  /* netbuf structure alloc */
#define NB_FREE(ptr)       npfree(ptr)
#define BB_ALLOC(size)     npalloc(size)  /* Big packet buffer alloc */
#define BB_FREE(ptr)       npfree(ptr)
#define LB_ALLOC(size)     npalloc(size)  /* Little packet buffer alloc */
#define LB_FREE(ptr)       npfree(ptr)
/* (yaxon modify) */
/*#define BB_ALLOC(size)     snds_alloc(size)   Big packet buffer alloc */
/*#define BB_FREE(ptr)       snds_free(ptr)*/
/*#define LB_ALLOC(size)     snds_alloc(size)   Little packet buffer alloc */
/*#define LB_FREE(ptr)       snds_free(ptr)*/
#define UC_ALLOC(size)     npalloc(size)  /* UDP connection block alloc */
#define UC_FREE(ptr)       npfree(ptr)
#define TK_ALLOC(size)     npalloc(size)  /* task control block */
#define TK_FREE(ptr)       npfree(ptr)
#define STK_ALLOC(size)    npalloc(size)  /* task stack */
#define STK_FREE(ptr)      npfree(ptr)
#define PMTU_ALLOC(size)   npalloc(size)  /* path MTU cache */
#define PMTU_FREE(ptr)     npfree(ptr)

#ifdef DYNAMIC_IFACES
#define NET_ALLOC(size)    npalloc(size)  /* struct net */
#define NET_FREE(ptr)      npfree(ptr)
#define IFM_ALLOC(size)    npalloc(size)  /* struct IfMib */
#define IFM_FREE(ptr)      npfree(ptr)
#endif   /* DYNAMIC_IFACES */

/* map memory routines to standard lib */
#define MEMCPY(dst,src,size)  memcpy((void *)(dst),(void *)(src),(size))
#define MEMMOVE(dst,src,size) memmove((void *)(dst),(void *)(src),(size))
#define MEMSET(ptr,val,size)  memset((void *)(ptr),(val),(size))
#define MEMCMP(p1,p2,size)    memcmp((void *)(p1),(void *)(p2),(size))

/*extern void dtrap( void );*/ /* (yaxon modify) */
extern void dtrap(char *);

/*
 * Structure packing is achieved using NO_CC_PACKING
 */

#define NO_CC_PACKING   1

#define START_PACKED_STRUCT(sname)    struct sname {
#define END_PACKED_STRUCT(sname)      };



/* UART driver header */
/* #define UART_INCLUDE "../snds300/uart.h" */ /* (yaxon del) */

#ifdef NATIVE_PRINTF
/*
 * Use native printf from the C library for debug output.
 */
#define dprintf  printf
#define dputchar putchar
#else
/*
** Use UART driver for debug output
*/
#ifdef putchar
#undef putchar
#endif
#define putchar dputchar
#define printf  dprintf
#ifndef _IN_TTYIO_
#if DEBUG_PRINTF
void dprintf( char *, ... );
#else
#define dprintf
#endif
#endif
#if DEBUG_PRINTF
void dputchar( int );
#else
#define dputchar
#endif
#endif


#include "zprint.h"
/* Send startup errors to the right place */
#define initmsg  dprintf

/* net stats printf with redirectable device: */
extern int ns_printf( void * pio, char * format, ... );
extern int sprintf_t(char * buf, const char *   fmt, ...);



#define COMMSIZE       64    /* max bytes in community string */

#define DELAY_REPLY	1    /* process incoming packets in background loop */

#define INETNET		0    /* index into nets[] for internet iface */
#define LOCALNET	1    /* index into nets[] for local net iface */

int   prep_ppp(int);    /* in ..\ppp\sys_np.c */
int   prep_ifaces(int firstIface);   /* set up interfaces */


#define   LITTLE_ENDIAN 1234
#define   BIG_ENDIAN    4321
/*
#ifdef ENDIAN_BIG
#define   BYTE_ORDER    BIG_ENDIAN
#elif  ENDIAN_LITTLE
#define   BYTE_ORDER    LITTLE_ENDIAN
#else
#error - no byte order defined
#endif
*/
#ifdef ENDIAN_BIG
#define   BYTE_ORDER    BIG_ENDIAN
#endif

#ifdef ENDIAN_LITTLE
#define   BYTE_ORDER    LITTLE_ENDIAN
#endif

/* some maximum packet buffer numbers */
#define MAXBIGPKTS   100
#define MAXLILPKTS   100
#define MAXPACKETS (MAXLILPKTS+MAXBIGPKTS)


#define MAX_NVSTRING   128       /* MAX length of a nparms string */

/* macros to get rid of "unused argument" warnings. With compilers that
 * can suppress these warnings, define this to nothing.
 */
/*#define USE_ARG(x)  (x++)*/ /* (yaxon modify) */
/*#define USE_VOID(x)*/       /* (yaxon modify) */
#define USE_ARG(x)  (x++)
#define USE_VOID(x) (x = x) 

/* macro to remap "FAR" keyword to nothing -- FAR pointers are just
 * plain pointers on ARM targets
 */
#define FAR


#include "string.h"   /* from C lib, for memmove(), et al */
#include "in_utils.h"   /* from C lib, for memmove(), et al */


#endif /* _IPPORT_H_ */

/* end of file ipport.h */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -