/* $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: scsi_adapter.h 1.3 89/08/07 $"

/*
 * Standard SCSI adapter definitions and structures.
 */

#ifndef _SYS_SCSI_ADAPTER_H_

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

/*
 * Return values of a SCSI probe function to the
 * adapter specific probe setup routine.  
 */
#define SPROBE_ONELUN  	2	/* Embedded SCSI device found */
#define SPROBE_FOUND   	1	/* Probed successfully otherwise */
#define SPROBE_NOTARGET  	-1	/* No such target adapter */
#define SPROBE_NOLUN   	-2	/* No such logical unit */
#define SPROBE_NOTFOUND  	0	/* Unsuccessful for any other reason */

/*
 * This record is filled in by the device driver.
 * and passed to the SCSI adapter code to execute 
 * a SCSI command.  
 * 
 * The address of the 'scmd' field should be passed to 
 * SCSI library functions, which will fill in its fields.
 */
struct scsi_adapter_cmd {
	scsicmd_t scmd;			/* Generic SCSI command information */
	ulong dlen;			/* #bytes of data the adapter xfers */
	paddr_t data;			/* Physical address of data to xfer */
	paddr_t iov;			/* Physical address of indirect address
					 * table, if applicable */
	paddr_t sense;  		/* Physical address of request-sense
					 * buffer, for check conditions. */
	unchar slen;			/* Byte length of sense */
};

typedef struct scsi_adapter_cmd scac_t;

/*
 * The following record adds fields necessary for SCSI support to 
 * the autoconfiguration generic device description.  As such, it 
 * is necessary to include 'sys/autoconf.h' along with this file.
 * 
 * The SCSI specific fields of this structure 'ident' and
 * 'adapt' are reserved specifically for the use of SCSI 
 * adapter specific code and should not be changed by device 
 * drivers.  The SCSI specific fields of this structure 
 * 'polled_cmd', 'start_cmd', and 'alloc' are the addresses of the 
 * adapter specific versions of the interfaces 'xxx_scsi_polled_cmd',
 * 'xxx_scsi_start_cmd', and 'xxx_alloc'.  They will be filled in by 
 * the adapter specific code for this device and may be referenced by 
 * the device driver.  They were placed here since the bus structures,
 * etc., did not have a standardized, obvious place for them.  Consider 
 * them, along with the 'struct *gen_device' portion of the record to 
 * be read-only.
 *
 * The 'ident' field is set by the adapter specific code to 
 * contain a value that identifies this device uniquely to it.
 * The field 'adapt' addresses resources, if any, that the 
 * adapter specific code allocated so that it may perform its 
 * generic SCSI services for this device.  The adapter specific 
 * module will provide its own definition of the structure 
 * addressed by 'adapt' and, therefore, may use them in any 
 * manner it pleases.  The system's configuration and adapter 
 * specific code will not 'touch' driver dependent additions to 
 * this structure.
 *
 * Each SCSI device driver must define its own DEV_device 
 * structure (where DEV is the device prefix for its driver) 
 * begining with this structure. This enables autoconfig and 
 * SCSI bus configuration to put things they need to know 
 * about the device in a known location for efficient reference.  
 * The local definition of struct DEV_device may append other 
 * information to this definition for the device driver's own use.
 * For example the mythical xxx-driver might declare:
 *		struct xxx_device {
 *			scsidev_t gen;
 *			int xxx_state;
 *			int xxx_flags;
 *			lock_t xxx_lock;
 *		};
 */
struct gen_scsi_device {
	struct gen_device gen;  	/* Generic device description */
	ulong ident;			/* Adapter specific i.d. of device */
	int (*polled_cmd)();		/* Adapter specific scsi_polled_cmd
					 * interface for this device */
	ulong (*start_cmd)();		/* Adapter specific scsi_start_cmd
					 * interface for this device */
	caddr_t (*alloc)();		/* Adapter specific allocation function
					 * to ensure data alignment. */
	caddr_t adapt; 			/* Adapter specific info for device */
};

typedef struct gen_scsi_device scsidev_t;

#define _SYS_SCSI_ADAPTER_H_
#endif  /*_SYS_SCSI_ADAPTER_H_*/
