
#ifndef __egret_h
#define __egret_h

#ifndef __sys_types_h
#if defined(__MPW_C__)
# include "/:usr:include:sys:types.h"
#else
# include <sys/types.h>
#endif
#endif

typedef struct egretPBrec {
	uchar_t		pbCmdType;
	uchar_t		pbCmd;
	uchar_t		pbParam[4];
	ushort_t	pbByteCnt;
	uchar_t *	pbBufPtr;
	uchar_t		pbFlags;
	uchar_t		pad;
	short		pbResult;
	void		(*pbCompletion)();
} egretPBrec_t, *egretPB_t;

typedef struct egretResprec {
	uchar_t		resplength;
	uchar_t		resptype;
	uchar_t		respflags;
	uchar_t		respcmd;
	uchar_t		respdata[8];
} egretResprec_t, *egretResp_t;

/* packet types */
#define SPECIALPKT	0xff
#define ADBPKT		0x0
#define PSUEDOPKT	0x1
#define ERRORPKT	0x2
#define TICKPKT		0x3
#define	PWRMSGPKT	0x4	/* Power Supply Message Transaction */
#define	INITPWRDWNVEC	0xfe	/* Eclipse Init Powerdown Message Vector. */ 

/* commands */
#define NOPCMD		0
#define APOLL		1	/* start/stop autopoll */
#define RD6805ADDR	2	/* read 6805 address */
#define RDTIME		3	/* read real time clock psuedo command */
#define RDROMSIZE	4	/* get rom size command */
#define RDROMBASE	5	/* get rom base address */
#define RDROMHEADER	6	/* get rom header address */
#define RDPRAM		7	/* read parameter ram */
#define WR6805ADDR	8	/* write 6805 address */
#define WRTIME		9	/* write time command */
#define PWRDOWN		0xa	/* powerdown command */
#define WRPWRUPTIME	0xb	/* set powerup time */
#define WRPRAM		0xc	/* write parameter ram */
#define MONORESET	0xd	/* monostable reset */
#define WRDFAC		0xe	/* write DFAC */
#define EGRETDIAGS	0xf	/* run egret diagnostics */
#define RDCTLPANEL	0x10	/* sense control panel enable */
#define	BATSSWPSNS	0x10	/* Battery Swap Sense */
#define RESETEGRET	0x11	/* Egret cold start command */
#define ENDISVPP	0x12	/* ELSIE enable/disable VPP */
#define	SETIPLLVL	0x12	/* Set IPL Level */
#define ENDISFILES	0x13	/* ELSIE enable/disable file server flag */
#define SETAUTOPOLL	0x14	/* set autopoll rate */
#define RDPRAMSIZE	0x15	/* get parameter ram size */
#define RDAUTORATE	0x16	/* get autopoll rate */
#define WRBUSDELAY	0x17	/* set bus delay constant */
#define RDBUSDELAY	0x18	/* get bus delay constant */
#define WRDEVLIST	0x19	/* set ADB device list */
#define RDDEVLIST	0x1a	/* get ADB device list */
#define WR1SECMODE	0x1b	/* set 1 second interrupt mode */
#define ENDISKBDNMI	0x1c	/* enable/disable keyboard NMI */
#define ENDISPARSE	0x1d	/* enable/disable post parse R2 A2 */
#define WRHANGTOUT	0x1e	/* set hang threshold */
#define RDHANGTOUT	0x1f	/* get hang threshold */
#define	WRDFACSTR	0x20	/* Set Default DFAC String */
#define	ENDISPWRMSG	0x21	/* Enable/Disable Power Supply Messages */

/* VIA definitions for egret flow control */
#define XCVR_SESSION	0x8	/* ADBu session */
#define VIA_FULL	0x10	/* VIA full indicator */
#define SYS_SESSION	0x20	/* system session */

/* VIA ACR definitions */
#define SRDIR_OUT	0x10	/* 0 = input, 1 = output */

/* defines for egret_status */
#define EGRET_BUSY	0x1	/* currently busy with a packet */
#define EGRET_OPENDATA	0x2	/* open ended read response */
#define EGRET_BADPKT	0x4	/* error packet in progress */

/* flag bits in the ADB Status byte returned from the ADB processor */

#define EGSRQ		0x1	/* SRQ asserted */
#define EGTIMEOUT	0x2	/* active device did not have data avail */
#define EGSRQERROR	0x4	/* device asserted excessive SRQ period */
#define EGBUSERROR	0x8	/* timing error in bit cell was detected */
#define EGAUTOPOLL	0x40	/* data is from an auto poll */
#define EGRESPONSE	0x80	; bit 7, 1=Response packett in process


/* misc equates */
#define INVPSUEDO	0x202	/* invalid psuedo packet */
#define INVPKT		0x201	/* invalid packet type */
#define MAXRETRIES	0x100	/* 256 retries to communicate with egret */
#define MAXTOUT		0x7fff	/* timeout waiting for VIA IRQ from egret */

/* Key-switch positions. */
#define KEYSW_OFF	0	/* 'Off' position */
#define KEYSW_SECURE	1	/* 'Secure' position */
#define KEYSW_ON	2	/* 'On' position */

#define KEYSW_BIT	0x01	/* 'Keyswitch bit' */
#define POWER_OFF_BIT	0x04	/* 'Keyswitch bit' */
#endif /* __egret_h */
