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