/* $Id: hps.net.h,v 2.2 91/01/10 20:42:35 dave Exp $ */
/****************************************************************/
/*						 hps.net.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.									*/
/****************************************************************/
/*																*/
/*	Network management and network interface definitions.		*/
/*																*/
/****************************************************************/

/*
 * Precede with:
 *	#include "hps.types.h"
 *	#include "hps.onb.h"
 */

/* Post Network Queue Elements to this queue for transmission:	*/
#define NETW_QID	0x000A

/* Network Manager's task info: */
#define NETW_PRI	0x000F			/* priority	*/
#define NETW_TID	0x000C			/* task ID */

/* Network Interface task's info: */
#define NIF_ID		208				/* unique upper byte for ID's */
#define NIF_TID		(NIF_ID + 1)	/* network interface task ID */
#define NNET_TID	(NIF_ID + 2)	/* network service task ID */
#define NIF_IOCBQ	(NIF_ID + 3)	/* queue ID for host requests */
#define NIF_NETQ	(NIF_ID + 4)	/* queue ID for network messages */
#define NIF_PRI		172				/* network interface task priority */
#ifdef STEPUP1
/* WARNING: see also hps.nif.h */
#define NNET_PRI	160				/* network service task priority */
#else
#define NNET_PRI	173				/* network service task priority */
#endif
#define NIF_SKT		0xdf			/* network interface socket ID */
#define NIF_DEV		0xfb			/* net interface task's major device # */



/****************************************************************/
/* Queue Element Header -										*/
/* The data portion of the first buffer in a Network Queue 		*/
/* Element holds one of these.  The QEH contains network and	*/
/* data link layer information.									*/
/****************************************************************/

typedef struct
{
	bit8	code;				/* Request code	*/
	bit8	status;				/* Completion status */
	bit16	length;				/* Total data length */
	bit8	saddr;				/* Source station address */
	bit8	ssocket;			/* Source socket number */
	bit8	station;			/* Destination station address */
	bit8	dsocket;			/* Destination socket number */
	bit32   *mbox;				/* Address of mailbox */
	bit32	msg;				/* Message to post to mbox */
	bit16	sqid;				/* Sender's Queue ID (Task ID on remote) */
} QEH;

/* Values for "code" */
#define NET_XMIT	1			/* Transmit a packet over the network */
#define NET_RCV		2			/* Message received on network */
#define NET_CTRL	3			/* Control message from network manager	*/
/* #define	NET_PRIXMIT	4 -- defined in hps.net_onb.h */
#define MARK_MSG	5			/* Mark Message faked by the TCS */

/* Values for "status" (filled in by Network Manager) */
#define XMTDONE		0			/* Good transmit completion	*/
#define BRDCAST		1			/* Good completion of broadcast transmission */
#define NORESP		2			/* No response from destination	*/
#define BADRESP		4			/* Bad response (NAK) from destination */
#define OFFLINE		8			/* Transmit failed--no token received */

/* Values for "status" field of NET_CTRL messages: */
#define RECONF		1			/* Network reconfiguration occurred	*/
#define XRECONF		2			/* Excessive network reconfigurations */
#define NCFSC		3			/* Network configuration state change */

/* Network Configuration Table entry definition */

typedef struct
{
	char	state;				/* state (see definitions below) */
	char	host_id;			/* host ID (host adapters only) */
	short	poll_id;			/* poll ID */
	char	dev_type;			/* device type code (see defs in hps.diag.h) */
	char	fw_rev[3];			/* three ASCII characters */
} NCFT;

/* State values in Network Configuration Table */

#define OFFLN		0			/* offline */
#define PRIMIDLE	1			/* primitive idle (not being downloaded) */
#define PCNCT		2			/* primitive connected (downloading) */
#define NORML		3			/* normal (on line)	*/
#define DISCNCT		4			/* station considers poller offline */
#define MINE		5			/* set in this station's entry */
#define PRIMIDLEFP	6			/* primitive idle w/ failed port(s) */
#define OFRDY		8			/* about to go offline */
#define ONTENT		9			/* about to go online */

/* Active Station Table entry definition */

typedef struct
{
	bit8	net_addr;			/* network address */
	char	state;				/* state (see definitions above) */
	char	host_id;			/* host ID (host adapters only) */
	char	dev_type;			/* device type code (see defs in hps.diag.h) */
	char	fw_rev[4];			/* firmware rev (3 ASCII chars, null term'd) */
} AST;

/* IOCB format for request to Network Interface Task */

#ifdef HPS_ALIGN
	typedef struct
	{
		IOCBHDR	hdr;				/* standard IOCB header */
		char	command;			/* open, close, read */
		char	connection;		/* connection descriptor(assigned on open) */
		bit16	res;
	} NIF_IOCB;
#else
typedef struct
{
	IOCBHDR	hdr;				/* standard IOCB header */
	char	command;			/* open, close, read */
	char	connection;			/* connection descriptor (assigned on open) */
} NIF_IOCB;
#endif

/*
 * Minor device numbers for host requests to network interface task
 */

#define NET_STNTFY	1	/* Toggles "state change" interrupt on and off */
#define NET_AST		2	/* Returns active station table */
#define NET_SETID	3	/* Sets host ID */

/*
 * Message format passed by network manager to tasks with state change
 * notification.  The first buffer of the message includes a system
 * buffer header, with next pointing to the second buffer, if any, and
 * length set to the length of the queue element header, which follows.
 * The code field of the qeh indicates control message type.  The status
 * field indicates net config state change notification.  The length
 * field indicates the total number of data bytes in the message (which
 * may include more than one data buffer).  No other fields of the qeh
 * are used.  Following the qeh is an array of 2-byte entries--network
 * address followed by current state.
 */

typedef struct
{
	SBH	sbh;		/* system buffer header */
	QEH	qeh;		/* queue element header */
} NIF_MSG;

/*
 * MODIFICATION HISTORY:
 *
 * $Log:	hps.net.h,v $
 * Revision 1.1.2.1  92/06/24  13:53:25  marker
 * Branch RISCOS_5_01_2_FIXES off of trunk.
 * 
 * Revision 2.2  91/01/10  20:42:35  dave
 * Update header.
 * COSMETIC
 * 
 */
