1*52130Smckusick /* 2*52130Smckusick * Copyright (c) 1992 Regents of the University of California. 3*52130Smckusick * All rights reserved. 4*52130Smckusick * 5*52130Smckusick * This code is derived from software contributed to Berkeley by 6*52130Smckusick * Ralph Campbell. 7*52130Smckusick * 8*52130Smckusick * %sccs.include.redist.c% 9*52130Smckusick * 10*52130Smckusick * @(#)device.h 7.1 (Berkeley) 01/07/92 11*52130Smckusick */ 12*52130Smckusick 13*52130Smckusick /* 14*52130Smckusick * This structure is used to encapsulate the routines for a device driver. 15*52130Smckusick * This allows an "object oriented" approach so a controller device driver 16*52130Smckusick * can support multiple attached devices or a device can be attached to 17*52130Smckusick * different types of controllers. 18*52130Smckusick */ 19*52130Smckusick struct driver { 20*52130Smckusick char *d_name; /* device driver name (e.g., "rz") */ 21*52130Smckusick int (*d_init)(); /* routine to probe & initialize device */ 22*52130Smckusick void (*d_start)(); /* routine to start operation */ 23*52130Smckusick void (*d_done)(); /* routine to call when operation complete */ 24*52130Smckusick }; 25*52130Smckusick 26*52130Smckusick /* 27*52130Smckusick * This structure describes controllers directly connected to CPU 28*52130Smckusick * and is partially initialized in "ioconf.c" by the 'config' program. 29*52130Smckusick */ 30*52130Smckusick struct pmax_ctlr { 31*52130Smckusick struct driver *pmax_driver; /* controller driver routines */ 32*52130Smckusick int pmax_unit; /* controller number */ 33*52130Smckusick char *pmax_addr; /* address of controller */ 34*52130Smckusick int pmax_flags; /* flags */ 35*52130Smckusick 36*52130Smckusick int pmax_alive; /* true if init routine succeeded */ 37*52130Smckusick }; 38*52130Smckusick 39*52130Smckusick /* 40*52130Smckusick * This structure describes devices connected to a SCSI interface 41*52130Smckusick * and is partially initialized in "ioconf.c" by the 'config' program. 42*52130Smckusick */ 43*52130Smckusick struct scsi_device { 44*52130Smckusick struct driver *sd_driver; /* SCSI device driver routines */ 45*52130Smckusick struct driver *sd_cdriver; /* SCSI interface driver routines */ 46*52130Smckusick int sd_unit; /* device unit number */ 47*52130Smckusick int sd_ctlr; /* SCSI interface number */ 48*52130Smckusick int sd_drive; /* SCSI address number */ 49*52130Smckusick int sd_slave; /* LUN if device has multiple units */ 50*52130Smckusick int sd_dk; /* used for disk statistics */ 51*52130Smckusick int sd_flags; /* flags */ 52*52130Smckusick 53*52130Smckusick int sd_alive; /* true if init routine succeeded */ 54*52130Smckusick }; 55*52130Smckusick 56*52130Smckusick /* Define special unit types used by the config program */ 57*52130Smckusick #define QUES -1 /* -1 means '?' */ 58*52130Smckusick #define UNKNOWN -2 /* -2 means not set yet */ 59*52130Smckusick 60*52130Smckusick /* 61*52130Smckusick * This structure contains information that a SCSI interface controller 62*52130Smckusick * needs to execute a SCSI command. 63*52130Smckusick */ 64*52130Smckusick typedef struct ScsiCmd { 65*52130Smckusick struct scsi_device *sd; /* device requesting the command */ 66*52130Smckusick int unit; /* unit number passed to device done routine */ 67*52130Smckusick int flags; /* control flags for this command (see below) */ 68*52130Smckusick int buflen; /* length of the data buffer in bytes */ 69*52130Smckusick char *buf; /* pointer to data buffer for this command */ 70*52130Smckusick int cmdlen; /* length of data in cmdbuf */ 71*52130Smckusick u_char *cmd; /* buffer for the SCSI command */ 72*52130Smckusick } ScsiCmd; 73*52130Smckusick 74*52130Smckusick /* 75*52130Smckusick * Define flags for controlling the SCSI command. 76*52130Smckusick * 77*52130Smckusick * SCSICMD_DATA_TO_DEVICE 78*52130Smckusick * TRUE -> data is to be transferred to the device. 79*52130Smckusick * FALSE -> data is to be transferred from the device. 80*52130Smckusick * meaningless if buflen is 0. 81*52130Smckusick * SCSICMD_USE_SYNC 82*52130Smckusick * Attempt to negotiate for a synchronous data transfer. 83*52130Smckusick */ 84*52130Smckusick #define SCSICMD_DATA_TO_DEVICE 0x01 85*52130Smckusick #define SCSICMD_USE_SYNC 0x02 86*52130Smckusick 87*52130Smckusick #ifdef KERNEL 88*52130Smckusick extern struct pmax_ctlr pmax_cinit[]; 89*52130Smckusick extern struct scsi_device scsi_dinit[]; 90*52130Smckusick #endif 91