/* $Id: hps.diag.h,v 2.3 91/10/11 15:59:51 jt Exp $ */
/****************************************************************/
/*						hps.diag.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.									*/
/****************************************************************/

/*
 * HPS-6816 Diagnostics Application Package Header File
 *
 * This header file contains definitions required by host programs
 * to communicate with the HPS Diagnostic Application.
 *
 * Precede with:
 *	#include "hps.types.h"
 *	#include "hps.iocb.h"
 *	#include "hps.net.h"
 */

/*
 * Unique upper byte for queue IDs, task IDs, etc.
 */
#define DIAG_ID	240

/*
 * Diagnostic Application Task Parameters:
 */
#define DIAG_TID	(DIAG_ID + 1)		/* Diagnostic task ID		*/
#define DIAG_PRI	200					/* Diagnostic priority		*/
#define DNET_TID	(DIAG_ID + 2)		/* Network service task ID	*/
#ifdef STEPUP1
#define DNET_PRI	156				/* Network service priority	*/
#else
#define DNET_PRI	201				/* Network service priority	*/
#endif

/*
 * VRTX queue IDs:
 */
#define DIAG_IOCBQ	(DIAG_ID + 3)
#define DIAG_DEV	0xFF			/* Diagnostic Application major #	*/

#define DIAG_NETQ	(DIAG_ID + 4)
#define DIAG_SKT	0xFF			/* Network socket for diag.		*/


/* Diagnostic Application Package Minor Device Numbers */
#define DLB_DEV		00	/* DMA Loopback						*/
#define RLB_DEV		10	/* Remote Station Loopback			*/
#define CP_DEV		11	/* Network Configuration Poll		*/
#define RLG_DEV		30	/* Return remote log table			*/
#define RLGC_DEV	31	/* Return and clear remote log table*/
#define RRESET_DEV	32	/* Remote Reset						*/
#define RPEEK_DEV	33	/* Read remote memory				*/
#define PRF_DEV		34	/* REM4 profile commands			*/

/*
 * Diagnostic Application Package command modifiers 
 */
#define	PRF_CLEAR		1
#define	PRF_REMOTE		2
#define	PRF_LOCAL		3
#define	SET_THRESHOLD	4
#define	GET_THRESHOLD	5

#define RPEEK_SIZE	128	/* Block size returned by rpeek function	*/

/* Diagnostic application definitions (remote) */
#define DIAGRSKT	5		/* Diagnostic application's socket		*/
#define DIAGRID		3		/* its task ID							*/
#define NETW_RID	1		/* Network manager's task ID (for post) */
#define RESET_SKT	0xcc 	/* Socket ID for reset request			*/


#define US		0x80	/* Flags this station in configuration poll */
#define D_OPEN	0x80
#define D_WRITE	0x01

/*
 * REM4 data is passed in the following structure from the host adaptor
 *  to the host.
 */
typedef struct
{
	bit32	success_count;
	bit32	max_packet_size;
	bit32	smallest_packet_nOK;
	bit32	full_packets_sent;
	bit32	partial_packets_sent;
	bit32	packet_size;			/* Size of network packets, 502 or 504	*/
} PRF_DATA;

/*
 * Diagnostic Application Header
 *
 * This structure augments the standard Network Header information
 * for the Diagnostic Application.
 */
typedef struct
{
	char		min_dev;		/* Minor device # selects diagnostic func.	*/
	char		type;			/* Packet type (below)						*/
	union						/* Additional type-specific info			*/
	{
		char		err_no;		/* Error number (below)			*/
		short		length;
		long		offset;
	} dun;
	char		cd;				/* Connection descriptor					*/
	long	    *mbox;			/* Sender's mailbox address					*/
} DAH;

/* "type" codes */
#define	T_FIELD	0xC0
#define	REQUEST	0x40
#define	CONFIRM	0x80
#define	ERROR	0xC0


typedef struct
{
	SBH	a_sbh;
	DAH	dah;
} DAHB;



/*
 * The Network Manager gives the Diagnostic Application a
 * pointer to the first system buffer header, from which the
 * rest of this information can be extracted.
 */
typedef struct
{
	SBH	*sbh;	/* first system buffer header */
	QEH	*qeh;	/* queue element header (first data buffer) */
	DAH	*dah;	/* diagnostic application header (second data buffer) */
} DIAG_MSG;


/*
 * This structure is the Diagnostic Application's IOCB.  The address
 * of one of these may be passed to the HPS controller throught the
 * HPS raw device driver.
 */
typedef struct
{
	IOCBHDR	hdr;			/* Standard HPS raw header			*/
	bit16	command;		/* open, close, read, write, ioctl	*/
	bit16	cmd_modifier;	/* For ioctl functions				*/
	bit16	station;		/* Remote station address, when req.*/
	bit16	connection;		/* Connection descriptor			*/
} DIAG_IOCB;


/*
 * A station returns one of these structures in response to a
 * "Network Configuration Poll" request.
 */
typedef struct
{
	bit8		c_model;		/* Device model code					*/
	char		c_fwrev[3];		/* Firmware revision (3 ascii chars.)	*/
	bit8		c_pad[12];		/* Reserved for expansion				*/
} NW_CONF;

/* Offset to start of RAM on cluster controller */

#define RRAM_BASE   0x40000

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

typedef struct
{
	/* NULL-terminated ASCII strings: */
	bit8		model[16];		/* Model number					*/
	bit8		fw_rev[24];		/* Firmware revision level		*/
	bit8		hw_rev[24];		/* hardware revision level		*/

	/* Other board information: */
	bit8		dev_type;		/* Device type code				*/
	bit8		stat_id;		/* Station network address		*/
} RINFO;

/****************************************************************/
/* 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 RL_TICKS	0	/* Real-time clock ticks				*/
#define RL_IDLE		1	/* Idle task's counter					*/
#define RL_NOMEM	2	/* Times memory not available			*/
#define RL_PANIC	3	/* Non-fatal panics						*/
#define RL_SENT		4	/* Network packets successfully sent	*/
#define RL_RECEIVED	5	/* Network packets received				*/
#define RL_NORESP	6	/* No response transmit errors			*/
#define RL_BADRESP	7	/* Bad response transmit errors			*/
#define RL_OFFLINE	8	/* Local transmit errors				*/
#define RL_RECONF	9	/* Network reconfigurations				*/

#define RL_ROMSIZE	10	/* ROM size, in bytes					*/
#define RL_CHECKSUM	11	/* ROM checksum							*/
#define RL_RAMEND	12	/* ending address of RAM				*/ 
#define RL_CHANSTAT	13	/* status of serial channel				*/

/*
 * MODIFICATION HISTORY:
 *
 * $Log:	hps.diag.h,v $
 * Revision 1.1.2.1  92/06/24  13:53:21  marker
 * Branch RISCOS_5_01_2_FIXES off of trunk.
 * 
 * Revision 2.3  91/10/11  15:59:51  jt
 * Added REM4 performance related items
 * 
 * Revision 2.2  91/01/10  20:41:55  dave
 * Update header.
 * COSMETIC
 * 
 */
