/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

#ident	"$Header: ssm.h 1.14 90/07/25 $"

#ifndef	_SYS_SSM_H_

/*
 * ssm.h
 *      Systems Services Module (SSM) definitions
 */

/* $Log:	ssm.h,v $
 */

/*
 * This structure contains a single interrupt 
 * level/vector pair for an SSM VME bus as well 
 * as a pointer to the next such structure.
 */
struct ssm_vme_int {
	unchar 			level;
	long 			vector;
	struct ssm_vme_int 	*next;
};

/*
 * One of these exists per active SSM.
 */
struct ssm_desc {
	struct ctlr_desc *ssm_cd;    	/* descriptor for this SSM */
	struct cons_cb	*ssm_cons_cbs;	/* Base console command block for SSM */
	struct print_cb *ssm_prnt_cbs;	/* Base printer command block for SSM */
	struct ssm_misc	*ssm_mc;	/* Low level message block for SSM */
	unchar 		ssm_vmedevs;	/* # devices alive on the VME bus */
	ushort		ssm_s2v_map;	/* next available s2v map */
	ushort		ssm_v2s_map[4]; /* next map in mapset */
	struct ssm_vme_int *ssm_vints;	  /* interrupt vectors in use */
};

#define ssm_diag_flags  ssm_cd->cd_diag_flag
#define ssm_target_no   ssm_cd->cd_ssm_host_num
#define ssm_is_cons     ssm_cd->cd_ssm_cons
#define ssm_version     ssm_cd->cd_sc_version
#define ssm_slicaddr    ssm_cd->cd_slic
#define ssm_biff_type   ssm_cd->cd_ssm_biff_type
#define ssm_biff_flags  ssm_cd->cd_ssm_biff_flags


/*
 * SSM_vec is located in ssm.c.  It is a bit vector containing a
 * bit for each SSM for which configuration is attempted, i.e.,
 * bit 0 corresponds to ssm0.  The bit is set that SSM is alive
 * and clear otherwise.  The following macro tests the bit
 * setting for the specified SSM.
 */
#define SSM_EXISTS(index)	(SSM_vec & (1 << (index)))

#define SSM_VME_EXISTS(index)   (SSM_desc[index].ssm_cd->cd_ssm_biff_type == \
				CFG_SSM_BTYPE_VBIF)


#define SSM_WDT_TIMEOUT 4	/* SSM Watchdog timer timeout values in secs */
				/* Watchdog timer reset every 1/2 second */


/*
 * Memory allignment definitions for the SSM.
 * Data structures transferred by the SSM CPU 
 * cannot cross a megabyte boundary and should
 * be 16 byte aligned.  DMA transfers are most
 * efficient when located upon 16 byte boundaries.
 */
#define	SSM_ALIGN_BASE	16		/* Align host/SSM shared data 
					 * structures to 16-byte boundary */
#define	SSM_ALIGN_XFER	16		/* Align xfers to 16-byte boundary */
#define	SSM_BAD_BOUND	(1 << 20)	/* Xfer can't cross meg. boundary */

#ifdef INKERNEL
/* 
 * Global definitions associated with the SSM.
 */
extern int NSSM;			/* Number of SSMs that are alive */
extern struct ssm_desc *SSM_desc;	/* Array of SSM descriptors. */
extern int ssm_max_idx;			/* Max config index # for an SSM */
extern uint SSM_vec;			/* Bit-vector of existing SSM's */
extern struct ssm_desc *SSM_cons;	/* SSM descriptor of console board. */

/* Interfaces from ssm_misc.c */
extern struct cons_cb *init_ssm_cons();
extern struct print_cb *init_ssm_prnt();

#ifdef DEBUG
extern int ssm_debug;			/* Debug information level */
#endif /* DEBUG */

#endif /* INKERNEL */

#define	_SYS_SSM_H_
#endif	/* _SYS_SSM_H_ */
