/* $Source: /usr/local/kcs/sys.ROSE_800/h/RCS/3bdkcom.h,v $
 * $Revision: 1.2.106.1 $	$Author: root $
 * $State: Exp $   	$Locker: CRT $
 * $Date: 97/07/07 17:33:00 $
 */
/*
 *	@(#)3bdkcom.h	2.7 DKHOST 87/03/20
 *
 *	COMMKIT(TM) Software - Datakit(R) VCS Interface Release 2.0 V1
 *			Copyright 1984 AT&T
 *			All Rights Reserved
 *
 *	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
 *     The copyright notice above does not evidence any actual
 *          or intended publication of such source code.
 */
/**********************************************************************/
/*                                                                    */
/* Version 1.08 of the HP Datakit Common Header File                  */
/*                                                                    */
/**********************************************************************/
#define ERRORCNT (long *)0x30080 /*error counts*/
/*
 * ERRORCNT: 0=bad blocks,1=INITREQ recvd,2=invalid ECHO/REJ/ACK,3=ENQ sent
 *           4=retrans,5=ENQ limit(hung),6=ENQ limit(dead),7=REJ recvd
 *           8=open channels,9=BFIFO parity err,10=CHECK sent
 */
#define ERRORNUM 11 /*number of separate entries in ERRORCNT*/
#define PACKETSIZE 17
#define MOREDATA 1
/*
 * Command queue (cmdq) codes
 */
#define C_OPEN	   0x0001  /* open: chan,0,0,0,0 */
#define C_SEND     0x0002  /* send: chan,len,cntl,0,addr */
#define C_RCVB     0x0003  /* recv: chan,len,0,mode,addr */
#define C_CLOSE    0x0004  /* close: chan,0,0,0,0 */
#define C_CMD      0x0006  /* cmd: chan,0,cmd,0,0 */
#define C_SEXP     0x0008  /* send express: chan,(byte2<<8)|byte1,0,0,0 */
#define C_SCNTL    0x000f  /* send control: chan,0,cntl,0,0 */
#define C_DGN      0x0010  /* diagnose: phase,0,type,0, addr */
#define C_ILOOP    0x007f  /* internal loop: 0,0,0,0,0 (for debug only) */
#define C_ELOOP    0x007e  /* external loop: 0,0,0,0,0 (for debug only) */
/*
 * Sub-command codes (C_CMD)
 */
#define OFLUSH     0x02    /* flush output: chan,0,OFLUSH,0,0 */
#define SINT       0x03    /* interrupt on/off: 0,0,SINT,int,0 */
#define CHTIME     0x04    /* set timeout: chan,time,CHTIME,0,0 (time in ms) */
#define RSLOT      0x06    /* read slot number: 0,0,RSLOT,0,0 */
#define DKRES      0x07    /* reset DATAKIT: 0,0,DKRES,0,0 */
#define BLKSZ      0x09    /* set block size: chan,blksz,BLKSZ,0,0 */
#define RRAM       0x0a    /* read NICPU RAM: NIaddr,len,RRAM,chan,3Baddr */
#define WRAM       0x0b    /* write NICPU RAM: NIaddr,len,WRAM,chan,3Baddr */
/*
 * Response queue (resq) codes
 */
#define DKR_SEND     0x0014  /* send: chan,0,0,0,0 */
#define DKR_RCVB     0x0015  /* recv: chan,residue len,cntl,mode,0 */
#define DKR_REXP     0x0016  /* recv express: chan,(byte2<<8)|byte1,0,0,0 */
#define DKR_RCNTL    0x0017  /* recv cntl: chan,0,cntl,0,0 */
#define DKR_ERR      0x0018  /* error: chan,code,0,0,0 */
#define DKR_INDONE   0x001c  /* init done: 0,code,0,0,0 (fail if code != 0) */
#define DKR_OPEN     0x001d  /* open: chan,0,0,0,0 */
#define DKR_DGN	     0x001e  /* diagnose: 0,0,0,0,0 */
#define DKR_CPMUP    0x001f  /* cpm is up: 0,0,0,0,0 */
#define DKR_RSLOT    0x0032  /* read slot number: 0,slot,data1,data2,0 */
#define DKR_RRAM     0x0033  /* read NICPU RAM: chan,0,0,0,0 */
#define DKR_WRAM     0x0034  /* write NICPU RAM: chan,0,0,0,0 */
/*
 * C_RCVB modes
 */
#define CBLOCK     0x20    /* block mode, return on message boundary */
#define CTIME      0x40    /* time mode, return on timeout */
/*
 * DKR_SEND modes
 */
#define SNORM      0x00    /* normal response, all data ECHOed */
#define SDEAD      0x04    /* receiver dead, timed out with no ENQ reply */
/*
 * DKR_RCVB modes (and event list codes)
 */
#define SFULL      0x01    /* buffer full (length satisfied) */
#define SCNTL      0x02    /* control char received */
#define SABORT     0x08    /* receive aborted, used for DKR_SEND also */
#define SBLOCK     0x20    /* block boundary */
#define STIME      0x40    /* time limit expired */
#define SBOTM      0x80    /* end of BOTM block (event list code only) */
/*
 * SINT values
 */
#define SOFF       0x01    /* don't interrupt on transmit responses */
#define ROFF       0x02    /* don't interrupt on receive responses */
/*
 * Error codes
 */
#define INV_CMD    0x0081  /*invalid command*/
#define DUP_SEND   0x0082  /*duplicate send command*/
#define CL_SEND    0x0084  /*send to closed channel*/
#define SOFT_ERR   0x8088  /*software error (fatal)*/
#define FIFO_OVFL  0x8089  /*FIFO overflow (fatal)*/
#define DK_HUNG    0x808b  /*DATAKIT down, "tbusy hung" (fatal)*/
#define DK_DOWN    0x808c  /*DATAKIT down, no "receiver ready" (fatal)*/
#define FATAL      0x8000  /*fatal error mask*/

/*
 *	state flags for "dkactive"
 */
#define	DKFAULT		(short)0x8000	/* interface error, access denied */
#define	DKNOINIT	(short)0xc000	/* no interface re-init (+DKFAULT) */
#define	DKRESET		(short)0x8002	/* interface has been reset */
#define	DKPWR		(short)0x8004	/* power failure (no re-init) */
#define	DKDGNSET	(short)0x8008	/* diagnostic mode active */
#define	DKDGNACT	(short)0x8010	/* diagnostic request active */
#define	DKDGNDON	(short)0x8020	/* diagnostic request complete */
#define	DKDGNRES	(short)0x8040	/* diagnostic results returned */
#define	DKCPMERR	(short)0x8080	/* CPM comm. problem (no re-init) */
#define	DKINITERR	(short)0x8100	/* firmware initialization error */

/**********************************************************************/
/*                                                                    */
/* Structure Definitions                                              */
/*                                                                    */
/**********************************************************************/
struct tcmdq { /* command/response queue entry */
     unsigned short qtype,qchan,qlen;
     unsigned char qcntl,qmode;
     long qaddr;
};
struct tcb { /* command/response queue control block */
     struct tcmdq *qstart;
     long qunload,qload;
     long qsize;
};
struct tdkseg {
#if	defined(__u3b__) || defined(hpux)
     unsigned int dkxdma[256]; /* DMAC extended job table */
#endif
     struct tcb cmdqcb;
     struct tcb resqcb;
     long numchan,inittime,xmittime,enqretry,window;
     int dkbuffer[128];
};


/*
 * Version structure and define
 */
struct version {
	unsigned short date;
	unsigned short version;
};

#define VERSION ((struct version *)0x31c98)


/*
 * Datakit on-line diagnostic defines
 */

struct dkdgnreslt { /* diagnostic result save area */
	unsigned long d_rslt;
	unsigned long d_rd1;
	unsigned long d_rd2;
	unsigned long fftest;
	unsigned long phn;
	unsigned long tblsz;
	unsigned long devchan;
};

#define OFFLINE 0x0
#define ONLINE 0x00020002
#define PARTL_ON 0x3b203b20
#define PARTL_OF 0x203b203b
#define DGNCMP   0x3334L	/* diagnostic completed		*/
#define	PHASECNT 0x19		/* number of phases		*/

#ifndef BD_ATP
/* Result Status */
#define BD_ATP   0x21523b05L	/* board completed ATP		*/
#define BD_STF   0xdead3b05L	/* board completed STF		*/
#define BD_ABT   0xbdab3b05L	/* board aborted		*/
#define BD_SDSTF 0xface3b05L    /* subdevice STF                */
#define	BD_MED	 0xacbaddcaL	/* media failure		*/
#define BD_NPE   0x00003b05L    /* board completed NPE          */
#define BD_NTR   0xfeedbeefL    /* board completed NTR          */
#endif

#ifndef ABT
/* The following defines are used by the diagnostic control	*/
/* programs to indicate abnormal termination of diagnostic	*/
/* execution.							*/

#define NMOK             0	/* Success - Found Unit in EDT	      */
#define ABT             -1	/* Diagnostics Aborted - Failure      */
#define R_DFAIL         -2	/* Diagnostic reset via SIT Failed    */
#define INVLDCMP        -3	/* Currently Unused		      */
#define INVRSLTC        -4	/* Invalid Return Results for a board */
#define INVLDCICRQ      -5	/* Invalid Request from a CIC Board   */
#define CNTMVCMD        -6	/* Couldn't move command to CIC Board */
#define ILLGLPH         -7	/* Invalid Phase Specification	      */
#define D_HASHFAIL      -8	/* Failing Hashsum reading ROM        */
#define NOUNIT          -9	/* CC Diagnostics - not CC in EDT     */
#define INVLDREQ       -10	/* Invalid Diagnostic Request	      */
#define INVPHRC        -11	/* Invalid Phase Return Code (CC)     */
#define INVLDEQID      -12	/* Invalid Equipment ID		      */
#define DLD_ERROR      -13	/* Error in downloading from a board  */
#endif
