/* $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: wd.h 1.15 90/01/19 $"

#ifndef	_SYS_WD_H_

/*
 * wd.h
 *      SCSI disk driver for SSM definitions
 */

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

#ifndef NCBPERSCSI
#include "sys/ssm_scsi.h"
#endif /* NCBPERSCSI */

/*
 * wd disk driver macros
 */
#define WD_LEVEL_SHIFT	0x01		/* divide by #cb's to get info index */
#define WD_LEVEL_CB	0x01		/* cb index */
#define WD_RSENSE(cb)	((struct scrsense *) (cb)->sh.cb_sense)

#define WD_PRINT_CB	1

/*
 * Locking levels
 */
#define	WDSPL		SPL5		/* level to lock wd_lock at */

/*
 * Information structure for a SCSI disk on a SSM. There is one per
 * channel (LUN).
 */
typedef struct {
	int	wd_alive;		/* is device alive? */ 
	int	wd_nopen;		/* open count */
	struct	cb_desc *wd_cbdp;	/* description command blocks I own */
	int	wd_iovcount;		/* number of iovects per cb */
	int	wd_flags;		/* local state flags */
	unchar	wd_devno;		/* logical SCSI_DEVNO(targ, lun) */
	unchar	wd_ctlr;		/* SSM controller number */
	int	wd_inuse;		/* number of cbs I think are in use */
	daddr_t wd_capacity;		/* full capacity of disk */
	int	wd_retrys;		/* number of times to retry xfer */
	struct	disk_stats *wd_dstats;	/* statistics */
	struct	buf wd_bufh;		/* header for sorted queue */
	struct  buf wd_rbufh;		/* raw buffer for ioctls */
	lock_t 	wd_lock;		/* mutex access to this structure */
} wd_t;

/*
 * Defines for info struct state flags
 */
#define WD_IS_ALIVE	0x01		/* board passed probing */
#define WD_BAD		0x02		/* drive has died */
#define WD_REZERO	0x04		/* rezeroing drive */
#define WD_SENSE	0x08		/* getting request sense info */
#define WD_EXCLUSIVE	0x10		/* disk in exclusive access mode */

/*
 * Configuration structures.
 */
struct wd_bconf {
	int	bc_iovects;		/* number of iat's per cb */
};

struct wd_driveconf {
	char	dc_vendor[8];		/* from inquiry info */
	char	dc_product[16];		/* from inquiry info */
	uint	dc_capacity;		/* from READC */	
	uint	dc_blockscyl;		/* number of addressable blocks/cyl */
};

#define	WD_DIAG_CYLS	0x02		/* Number of cylinders reserved */

/*
 * SCSI disk sizes
 */
#define WD_MAX_XFER		256	/* SCSI xfer size limit, in blocks */

#define	_SYS_WD_H_
#endif	/* _SYS_WD_H_ */
