152130Smckusick /* 2*63205Sbostic * Copyright (c) 1992, 1993 3*63205Sbostic * The Regents of the University of California. All rights reserved. 452130Smckusick * 552130Smckusick * This code is derived from software contributed to Berkeley by 652130Smckusick * Ralph Campbell. 752130Smckusick * 852130Smckusick * %sccs.include.redist.c% 952130Smckusick * 10*63205Sbostic * @(#)device.h 8.1 (Berkeley) 06/10/93 1152130Smckusick */ 1252130Smckusick 1352130Smckusick /* 1452130Smckusick * This structure is used to encapsulate the routines for a device driver. 1552130Smckusick * This allows an "object oriented" approach so a controller device driver 1652130Smckusick * can support multiple attached devices or a device can be attached to 1752130Smckusick * different types of controllers. 1852130Smckusick */ 1952130Smckusick struct driver { 2052130Smckusick char *d_name; /* device driver name (e.g., "rz") */ 2152130Smckusick int (*d_init)(); /* routine to probe & initialize device */ 2252130Smckusick void (*d_start)(); /* routine to start operation */ 2352130Smckusick void (*d_done)(); /* routine to call when operation complete */ 2452694Sralph void (*d_intr)(); /* routine to call when interrupt is seen */ 2552130Smckusick }; 2652130Smckusick 2752130Smckusick /* 2852130Smckusick * This structure describes controllers directly connected to CPU 2952130Smckusick * and is partially initialized in "ioconf.c" by the 'config' program. 3052130Smckusick */ 3152130Smckusick struct pmax_ctlr { 3252130Smckusick struct driver *pmax_driver; /* controller driver routines */ 3352130Smckusick int pmax_unit; /* controller number */ 3452130Smckusick char *pmax_addr; /* address of controller */ 3552694Sralph int pmax_pri; /* interrupt priority */ 3652130Smckusick int pmax_flags; /* flags */ 3752130Smckusick 3852130Smckusick int pmax_alive; /* true if init routine succeeded */ 3952130Smckusick }; 4052130Smckusick 4152130Smckusick /* 4252130Smckusick * This structure describes devices connected to a SCSI interface 4352130Smckusick * and is partially initialized in "ioconf.c" by the 'config' program. 4452130Smckusick */ 4552130Smckusick struct scsi_device { 4652130Smckusick struct driver *sd_driver; /* SCSI device driver routines */ 4752130Smckusick struct driver *sd_cdriver; /* SCSI interface driver routines */ 4852130Smckusick int sd_unit; /* device unit number */ 4952130Smckusick int sd_ctlr; /* SCSI interface number */ 5052130Smckusick int sd_drive; /* SCSI address number */ 5152130Smckusick int sd_slave; /* LUN if device has multiple units */ 5252130Smckusick int sd_dk; /* used for disk statistics */ 5352130Smckusick int sd_flags; /* flags */ 5452130Smckusick 5552130Smckusick int sd_alive; /* true if init routine succeeded */ 5652130Smckusick }; 5752130Smckusick 5852130Smckusick /* Define special unit types used by the config program */ 5952130Smckusick #define QUES -1 /* -1 means '?' */ 6052130Smckusick #define UNKNOWN -2 /* -2 means not set yet */ 6152130Smckusick 6252130Smckusick /* 6352130Smckusick * This structure contains information that a SCSI interface controller 6452130Smckusick * needs to execute a SCSI command. 6552130Smckusick */ 6652130Smckusick typedef struct ScsiCmd { 6752130Smckusick struct scsi_device *sd; /* device requesting the command */ 6852130Smckusick int unit; /* unit number passed to device done routine */ 6952130Smckusick int flags; /* control flags for this command (see below) */ 7052130Smckusick int buflen; /* length of the data buffer in bytes */ 7152130Smckusick char *buf; /* pointer to data buffer for this command */ 7252130Smckusick int cmdlen; /* length of data in cmdbuf */ 7352130Smckusick u_char *cmd; /* buffer for the SCSI command */ 7452130Smckusick } ScsiCmd; 7552130Smckusick 7652130Smckusick /* 7752130Smckusick * Define flags for controlling the SCSI command. 7852130Smckusick * 7952130Smckusick * SCSICMD_DATA_TO_DEVICE 8052130Smckusick * TRUE -> data is to be transferred to the device. 8152130Smckusick * FALSE -> data is to be transferred from the device. 8252130Smckusick * meaningless if buflen is 0. 8352130Smckusick * SCSICMD_USE_SYNC 8452130Smckusick * Attempt to negotiate for a synchronous data transfer. 8552130Smckusick */ 8652130Smckusick #define SCSICMD_DATA_TO_DEVICE 0x01 8752130Smckusick #define SCSICMD_USE_SYNC 0x02 8852130Smckusick 8952130Smckusick #ifdef KERNEL 9052130Smckusick extern struct pmax_ctlr pmax_cinit[]; 9152130Smckusick extern struct scsi_device scsi_dinit[]; 9252130Smckusick #endif 93