/* $Id: hps.if.h,v 2.2 91/01/10 20:42:04 dave Exp $ */
/****************************************************************/
/* 						hps.if.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.									*/
/****************************************************************/
/*																*/
/* This file defines the hardware interface to the HPS-6816.	*/
/*																*/
/* Precede with:												*/
/*	#include "hps.types.h"										*/
/*																*/
/* Structure of the I/O block--									*/
/*																*/
/* Exactly one of these exists on each HPS board in the system.	*/
/* These structures appear in I/O space, or memory space, 		*/
/* depending on the hardware configuration.  In the dual-port 	*/
/* RAM configuration, this structure resides at the base of 	*/
/* dual-port RAM. The union, "un," holds two structures.  		*/
/* Structure "st" is used only during self-test to execute the 	*/
/* "primative functions" tests. Structure "n" is used at all 	*/
/* other times.													*/
/*																*/
/****************************************************************/

#ifdef EISA
#define st_in		n_iocb		/* Self-test input			*/
#define st_out		n_msg		/* Self-test output			*/
#define st_optr		in_cnt		/* Self-test DMA pointer	*/
#define st_olen		in_buff[2]	/* Self-test DMA length		*/
#endif

struct HPS6816
{
#ifdef EISA
	bit8	io_pad0[0x100];	/* Unused slot I/O space					*/
	bit8	io_pad1[0x300];	/* General I/O space alias					*/

	bit8	sm_pad2[2];		/* Unused HPS shared memory					*/
	bit8	host_code;		/* Interrupt type code						*/
	bit8	sm_pad3[1];		/* Unused HPS shared memory					*/
	bit32	n_iocb;			/* IOCB pointer								*/
	bit32	n_msg;			/* Return message from HPS					*/
	bit8	in_cnt;			/* VTIO input byte count					*/
	bit8	out_cnt;		/* VTIO output byte count					*/
	bit8	in_buff[8];		/* VTIO input buffer						*/
	bit8	out_buff[8];	/* VTIO output buffer						*/
	bit8	sm_pad4[2];		/* Unused HPS shared memory					*/
	bit8	DREQ_bits[32];	/* Chan enable bits to send data to HPS		*/
	bit8	read_bits[32];	/* Chan enable bits for multi-channel reads	*/
	bit8	sm_pad5[32];	/* Unused HPS shared memory					*/
	bit8	sm_pad6[128];	/* Unused HPS shared memory					*/

	bit8	io_pad7[0x300];	/* General I/O space alias					*/
	bit8	io_pad8[0x100];	/* Unused slot I/O space					*/
	bit8	io_pad9[0x300];	/* General I/O space alias					*/

	bit8	bm_pad10[0x80];	/* Unused slot I/O space					*/
	bit8	hps_pid[4];		/* Product ID								*/
	bit8	bm_pad11[4];	/* Non-BMIC registers						*/
	bit8	host_conf;		/* Global Configuration						*/
	bit8	host_enab;		/* System Interrupt Enable/Control			*/
	bit8	bm_pad12[2];	/* Unused semaphore registers				*/
	bit8	hps_mask;		/* Local Doorbell Enable					*/
	bit8	hps_flag;		/* Local Doorbell Interrupt/Status			*/
	bit8	host_mask;		/* EISA System Doorbell Enable				*/
	bit8	host_flag;		/* EISA System Doorbell Interrupt/Status	*/
	bit8	st_dtm;			/* mbox0: Value on DTM display				*/
	bit8	st_opts;		/* mbox1: Self-test options					*/
	bit8	bm_pad13[14];	/* mbox2-15: Unused							*/
	bit8	bm_pad14[16];	/* BMIC Reseved								*/
	bit8	bm_pad15[0x50];	/* Unused slot I/O space					*/

	bit8	io_pad16[0x300];/* General I/O space alias					*/
#else
	bit8	host_flag;		/* HPS writes to interrupt host	*/
	bit8	hps_flag;		/* Host writes to interrupt HPS	*/
	bit8	host_code;		/* HPS writes to indicate results	*/
	bit8	hps_mode;		/* Host writes to set modes		*/

	union
	{
		struct /* Set up this way during Self-test */
		{
			bit32	test_ptr;	/* For DMA test			*/
			bit16	hps_out;	/* For data and ...			*/
			bit16	hps_in;	/* ... interrupt tests		*/
		} st;

		struct /* Set up this way during normal operation */
		{
#ifdef HPS_THIRTYTWO
			bit32	iocb_ptr;	/* Address of next IOCB		*/
			bit32	message;	/* Response message			*/
#else
			bit16	iocb_ptrh;	/* next IOCB (high word)*/
			bit16	iocb_ptrl;	/* next IOCB (low word)	*/
			bit16	messageh;	/* response (high word)	*/
			bit16	messagel;	/* response (low word)	*/
#endif
		} n;
	} un;

	union
	{
		struct /* For intial verif of byte/word order agreement */
		{
			bit8	chars[4];		/* Host writes "abcd"         */
			bit16	words[2];		/* Host writes 0x1122, 0x3344 */
			bit32	a_long;			/* Host writes 0x12345678     */
			bit8	st_dtm;			/* HPS writes for DTM tests 30, 41, 42 */
			bit8	reserved1[7];
		} order;

		struct /* VRTX/Tracer I/O area */
		{
			bit8	input_count;	/* Host writes input chr cnt */
			bit8	output_count;	/* HPS writes output chr cnt */
			bit8	inp_buf[8];		/* upto 8 input characters   */
			bit8	out_buf[8];		/* upto 8 output characters  */
			bit8 reserved[2];
		} vtio;
	} un1;
	bit8 DREQ_bits[32];	/* Asynch application data request flag bits */
	bit8 read_bits[32];	/* Asynch application read request flag bits */
	bit8 reserve2[32];	/* Reserved */
#endif
};

#ifndef EISA
/* Shorthand union access: */
#define st_ptr		un.st.test_ptr
#define st_out		un.st.hps_out
#define st_in		un.st.hps_in

#ifdef HPS_THIRTYTWO
#define n_iocb		un.n.iocb_ptr
#define n_msg		un.n.message
#else
#define n_iocbh		un.n.iocb_ptrh
#define n_iocbl		un.n.iocb_ptrl
#define n_msgh		un.n.messageh
#define n_msgl		un.n.messagel
#endif

#define in_cnt		un1.vtio.input_count
#define out_cnt		un1.vtio.output_count
#define in_buff		un1.vtio.inp_buf
#define out_buff	un1.vtio.out_buf
#endif

/* Flag byte bits: */
#define INTR		0x01		/* Hardware interrupt		*/
#define HDWR_RESET	0x02		/* Hardware Reset			*/
#define SBUSY		0x10		/* Software busy			*/

/* Mode bits: */
#define DP_IOCB	0x01			/* IOCBs located in dual-port RAM	*/
#define DP_DATA	0x02			/* Data located in dual-port RAM	*/


/* Result codes: */
#define IOCB_DONE	1
#define DAV			2
#define DREQ		3
#define ASYNCH		4
#define IOCB_ERROR	5
#define NON_FATAL	6
#define APPL_ERROR	7
#define SYST_ERROR	8
#define NETFIG_CHG	9

#define MORE_SPACE	0x80000000

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