/* $Id: hps.ioctl.h,v 2.8 91/10/31 15:32:20 annette Exp $ */
/* ex:set ts=4 sw=4: */
/****************************************************************/
/*						 hps.ioctl.h							*/
/****************************************************************/
/*																*/
/*                 Confidential Information                     */
/*      Limited Distribution to Authorized Persons Only         */
/*     Created 1986 and Protected as an Unpublished Work        */
/*          Under the U.S. Copyright Act of 1976.               */
/*         Copyright (c) 1986, Systech Corporation          	*/
/*                  All Rights Reserved                         */
/*																*/
/*	THIS SOFTWARE IS LICENSED BY AND IS THE	CONFIDENTIAL AND 	*/
/*	PROPRIETARY PROPERTY OF SYSTECH COMPUTER CORPORATION AND 	*/
/*	MAY NOT, WITHOUT THE PRIOR WRITTEN CONSENT OF SYSTECH 		*/
/*	COMPUTER CORPORATION, BE REPRODUCED, USED OR DISCLOSED 		*/
/*	EXCEPT IN ACCORDANCE WITH A SYSTECH COMPUTER CORPORATION 	*/
/*	SOFTWARE LICENSE AGREEMENT.									*/
/****************************************************************/
/*																*/
/* Precede with:												*/
/*	#include "hps.types.h"										*/
/*	#include "hps.iocb.h"										*/
/*																*/
/****************************************************************/

/* Download IOCB format; the HPS loader recognizes this IOCB.	*/

#ifdef HPS_ALIGN
	typedef struct
	{
		IOCBHDR	header;			/* IOCB header							*/
		bit16	command;		/* OPEN, CLOSE, READ, WRITE, IOCTL		*/
		bit16	cmd_modifier;	/* For ioctls							*/
		HPS_LONG	hpsadr;		/* Physical HPS on-board memory address	*/
		bit16	priority;		/* For CREATE ioctl: VRTX task priority	*/
		bit16	tid;			/* For CREATE ioctl: VRTX task ID		*/
		bit16	mode;			/* For CREATE ioctl: VRTX task mode		*/
		bit16	res;
	} LOADER_IOCB;
#else
	typedef struct
	{
		IOCBHDR	header;			/* IOCB header							*/
		bit16	command;		/* OPEN, CLOSE, READ, WRITE, IOCTL		*/
		bit16	cmd_modifier;	/* For ioctls							*/
		HPS_LONG	hpsadr;		/* Physical HPS on-board memory address	*/
		bit16	priority;		/* For CREATE ioctl: VRTX task priority	*/
		bit16	tid;			/* For CREATE ioctl: VRTX task ID		*/
		bit16	mode;			/* For CREATE ioctl: VRTX task mode		*/
	} LOADER_IOCB;
#endif

/*
 * Download file header format
 */

typedef struct
{
	bit32	start;
	bit32	end;
	bit32	vt_start;
	bit32	vt_len;
	bit32	tt_start;
	bit32	tt_len;
	bit32	boot_start;
	bit32	v_ws;
	bit32	v_ws_size;
	bit16	v_us_size;
	bit16	t_count;
	bit16	b_pri;
	bit16	b_id;
} DNL_HDR;



/****************************************************************/
/* IOCB command values.  Also used by on-board diagnostics.		*/ 
/* LSEEK is not recognized by the controller as a command from 	*/
/* the host-- only by the remote as a command from the 			*/
/* controller.													*/
/****************************************************************/

#define OPEN		1
#define CLOSE		2
#define READ		3
#define WRITE		4
#define IOCTL		5
#define LSEEK		6


/* Also ioctl() requests for the raw driver.					*/

#define RAW_DEVNAME	"/dev/rhp0"	/* Pathname for raw device		*/

#define RESET_HPS	1		/* Reset HPS controller hardware		*/
#define DO_IOCB		2		/* Pass an IOCB to the HPS				*/
#define NOTIFY_ACT	3		/* Notify on station active				*/
#define SET_DEBUG	4		/* change the message printing level	*/
#define DO_DNA_IOCB	5		/* Pass a DNA IOCB to the HPS       	*/
#define DO_CONFIG	6		/* Set up system configuration			*/
#define GET_RVER	9		/* get raw driver version info          */
#define GET_TVER	10		/* get tty driver version info          */
#define GET_VVER	11 		/* get vtio driver version info         */
#define BIOC		('B'<<8)
#define TCSETDCE	(BIOC|16) /* set port to be a DCE port          */
#define TCSETDTE	(BIOC|17) /* set port to be a DTE port          */
#define TCGETTYPE	(BIOC|18) /* get the current DCE/DTE setting    */


/* IOCB command modifier values for the EPROM-resident loader		*/

#define INIT		1	/* Re-initializes VRTX					*/
#define CREATE		2	/* Starts-up a task						*/
#define LOG			3	/* Return log table						*/
#define LOGCLR		4	/* Return and clear log table			*/
#define SET_AML		5	/* Set address-modifier lines			*/
#define GET_ADDRS	6	/* Get on-board system addresses		*/


/*
 *	Used in downloading configuration
 */
typedef struct
{
	union
	{
		struct
		{
			bit16  cboard;			/* Board Number					*/
			bit16  cstation;			/* Station address for channel	*/
			bit16  cnumber;			/* Port number, within station	*/
			bit16  cflags;			/* Flags ports as parallel or serial */
		} config;
		bit16 data_len;
	} d1;
} DNL_CONF;

#define	c_cboard		d1.config.cboard
#define	c_cstation		d1.config.cstation
#define	c_cnumber		d1.config.cnumber
#define	c_cflags		d1.config.cflags


/*****************************************************************/
/* This structure holds static information about the controller.	*/
/* One of these structures resides at the beginning of the log	*/
/* table.												*/
/*****************************************************************/

typedef struct
{
	/* NULL-terminated ASCII strings: */
	bit8		i_model[16];	/* Model name; e.g. "HPS-6860."		*/
	bit8		i_pn[24];		/* Firmware p/n;					*/
	bit8		i_assy[24];	/* Board assembly rev. number			*/

	/* Other board information: */
	bit8	i_type;		/* Device type code */
	bit8	i_id;		/* Station ID		*/
	bit8	i_options;	/* Option switches	*/
	bit8	i_size;		/* Size, in bytes, of remainder of table	*/
} INFO;

/*****************************************************************/
/* The system keeps log information in an array of long 		*/
/* integers. The #defines here establish the indexes into the	*/
/* array, and the array size.  The array of longs follows the	*/
/* structure defined above.								*/
/*****************************************************************/

#define L_TICKS	0	/* Real-time clock ticks				*/
#define L_IDLE		1	/* Idle task's counter				*/

#define L_GDATA	2	/* No. of bytes IEEE --> On-board		*/
#define L_PDATA	3	/* No. of bytes On-board --> IEEE		*/
#define L_XACKTO	4	/* No. of DMA XACK timeouts			*/
#define L_CBRQTO	5	/* No. of DMA CBRQ timeouts			*/
#define L_BREQTO	6	/* No. of DMA Bus Request Timeouts		*/

#define L_IOCBS	7	/* No. of IOCBs completed			*/
#define L_NOMEM	8	/* Times memory not available			*/
#define L_RQFULL	9	/* Times Response Queue found full		*/
#define L_NQFULL	10	/* Times Network Queue found full		*/
#define L_PANIC	11	/* Non-fatal panics					*/

#define L_SENT		12	/* Network packets successfully sent	*/
#define L_RECEIVED	13	/* Network packets received			*/
#define L_NORESP	14	/* No response transmit errors		*/
#define L_BADRESP	15	/* Bad response transmit errors		*/
#define L_OFFLINE	16	/* Local transmit errors				*/
#define L_RECONF	17	/* Network reconfigurations			*/

#define L_MAXTXQ	22	/* Maximum length reached by network TX queue */
#define L_CHANSTAT	28	/* status of serial channels on 6830/32	*/
#define L_ROMSIZE	29	/* ROM size, in bytes				*/
#define L_CHECKSUM	30	/* ROM checksum					*/
#define L_RAMSIZE	31	/* RAM size, in bytes				*/
#define L_HZ		32	/* real-time clock speed				*/

/*
 * MODIFICATION HISTORY:
 *
 * $Log:	hps.ioctl.h,v $
 * Revision 1.1.2.1  92/06/24  13:53:24  marker
 * Branch RISCOS_5_01_2_FIXES off of trunk.
 * 
 * Revision 2.8  91/10/31  15:32:20  annette
 * Changed SIOC to BIOC using 'B' instead of 'S'.  SIOC based commands 
 * conflicted with commands defined in SCO.
 * SPR=742
 * Changed the definitions of cboard, cstation, cnumber and cflags from
 * bit8 to bit16 in the DNL_CONF structure to accomodate download config.
 * bit switches to indicate serial printers.
 * INTERNAL
 * 
 * Revision 2.7  91/10/23  10:24:02  annette
 * Moved DNL_CONF definition from systemv/hpsdrconf.h to here.
 * INTERNAL
 * 
 * Revision 2.6  91/10/11  08:46:16  eric
 * Fixed log entry for revision 2.5
 * INTERNAL
 * 
 * Revision 2.5  91/10/11  08:40:29  eric
 * Added definition for L_MAXTXQ = 22.  This should match the offset (in
 * bit32s) of the ext_maxtxq field in the NTX_EXT structure.
 * Also added the ex mode line in the file header.
 * ENHANCEMENT
 * 
 * Revision 2.4  91/09/13  12:43:48  don
 * Changed the definition TIOC to SIOC using 'S' instead of 'T'.
 * This is used in the private hty IOCTLs (also in this file).
 * The TIOC based commands conflicted with commands defined in AIX.
 * SPR=742
 * 
 * Revision 2.3  91/09/03  16:46:44  annette
 * Added DO_CONFIG definition for downloadable configuration.
 * ENHANCEMENT
 * 
 * Revision 2.2  91/01/10  20:42:27  dave
 * Update header.
 * COSMETIC
 * 
 */
