/*
 * Monitor's Ethernet support definitions
 */

/*
 * Data structures defining the ethernet support data
 */

#define SAVECOUNT   4


struct ether_data {
	/*
	 * communication parameters
	 */

	char	eaddr[6];	/* our ethernet address */
	char	host_eaddr[6];	/* host's ethernet address */
	unsigned long ipaddr;	/* our IP address */
	unsigned long host_ipaddr;
				/* connected host's IP address */
	unsigned short monport;	/* monitor port #, at the host */
	unsigned short hostport;/* host port number */
	struct	epacket packet; /* the packet data */
	int	connected;	/* connected flag */
	
	/*
	 * protocol data
	 */

	char	framechar;	/* last frame character */
	char    reply_framechar;/* reply frame character */
	struct	concmd	con;	/* connection parameters */
	unsigned short seq_num;	/* sequence number of last packet */
	unsigned char  reply_seqno[4];

	/*
	 * monitor keeps last two messages
	 * if length of messages from monitor to debugger will
	 * grow byeond 512 bytes, the constants below MUST change
	 */

	int	savemsg;	/* message save flag */
	int	savemsg_len;	/* length of last message */
	char	savemsg_buff[512];
				/* saved message for retransmit */
	int	prevmsg_len[SAVECOUNT];	/* previous message */
	char	prevmsg_buff[SAVECOUNT] [512]; /* previous message buffer */
	int	save_num;
	
	/*
	 * driver stuff
	 */

	int	retry;		/* number of xmit retries */
	int	fail_transmit;	/* failed transmission indicator */
	int	overwrite_error;
	unsigned char	nxtpkt;		/* next packet pointer */
};

extern struct ether_data evars;	/* value set in monitor */

/* 
 * Some debugging goodies
 */

#ifdef DEBUG
#define	PUTCHAR(c)	putchar(c)
#define PUTSTR(s)	putstr(s)
#define PUTSTRN(s,n)	putstrn(s,n)
#define PUTNUM(n)	putnum(n)
#else
#define PUTCHAR(c)
#define PUTSTR(s)
#define PUTSTRN(s,n)
#define PUTNUM(n)
#endif

#define MAGIC_PORT 0xFFFF	/* Port number for initial connection */
#define STX	2		/* Protocol B character */
#define TRUE	1
#define FALSE	0

/*
 * Development board dependant constants
 */
#if (BOARD == CG16)
#   define RETRYCNT  40000	/* count up to 1.5 sec */
#endif
#if (BOARD == SHARK_CCA)
#   define RETRYCNT  70000	/* count up to 1.5 sec */
#endif
#if (BOARD == LX32 || BOARD == BARACUDA_CCA)
#   define RETRYCNT  160000	/* count up to 1.5 sec */
#endif
#define RESENDCNT 4	/* max resend count for '*' */
			/* don't change easily */

/*
 * Some commonly used external routines
 */

extern unsigned short hs2net();	/* host to network short */
extern unsigned short net2hs();	/* net to host short */
extern long hl2net();	/* host to network long */
extern long net2hl();	/* net to host long */
extern long cksum();	/* 1s comp. of 16 bit 2s comp. sum */
