1 /* 2 * Copyright (c) 1992 Regents of the University of California. 3 * 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 7.1 (Berkeley) 01/07/92 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 }; 25 26 /* 27 * This structure describes controllers directly connected to CPU 28 * and is partially initialized in "ioconf.c" by the 'config' program. 29 */ 30 struct pmax_ctlr { 31 struct driver *pmax_driver; /* controller driver routines */ 32 int pmax_unit; /* controller number */ 33 char *pmax_addr; /* address of controller */ 34 int pmax_flags; /* flags */ 35 36 int pmax_alive; /* true if init routine succeeded */ 37 }; 38 39 /* 40 * This structure describes devices connected to a SCSI interface 41 * and is partially initialized in "ioconf.c" by the 'config' program. 42 */ 43 struct scsi_device { 44 struct driver *sd_driver; /* SCSI device driver routines */ 45 struct driver *sd_cdriver; /* SCSI interface driver routines */ 46 int sd_unit; /* device unit number */ 47 int sd_ctlr; /* SCSI interface number */ 48 int sd_drive; /* SCSI address number */ 49 int sd_slave; /* LUN if device has multiple units */ 50 int sd_dk; /* used for disk statistics */ 51 int sd_flags; /* flags */ 52 53 int sd_alive; /* true if init routine succeeded */ 54 }; 55 56 /* Define special unit types used by the config program */ 57 #define QUES -1 /* -1 means '?' */ 58 #define UNKNOWN -2 /* -2 means not set yet */ 59 60 /* 61 * This structure contains information that a SCSI interface controller 62 * needs to execute a SCSI command. 63 */ 64 typedef struct ScsiCmd { 65 struct scsi_device *sd; /* device requesting the command */ 66 int unit; /* unit number passed to device done routine */ 67 int flags; /* control flags for this command (see below) */ 68 int buflen; /* length of the data buffer in bytes */ 69 char *buf; /* pointer to data buffer for this command */ 70 int cmdlen; /* length of data in cmdbuf */ 71 u_char *cmd; /* buffer for the SCSI command */ 72 } ScsiCmd; 73 74 /* 75 * Define flags for controlling the SCSI command. 76 * 77 * SCSICMD_DATA_TO_DEVICE 78 * TRUE -> data is to be transferred to the device. 79 * FALSE -> data is to be transferred from the device. 80 * meaningless if buflen is 0. 81 * SCSICMD_USE_SYNC 82 * Attempt to negotiate for a synchronous data transfer. 83 */ 84 #define SCSICMD_DATA_TO_DEVICE 0x01 85 #define SCSICMD_USE_SYNC 0x02 86 87 #ifdef KERNEL 88 extern struct pmax_ctlr pmax_cinit[]; 89 extern struct scsi_device scsi_dinit[]; 90 #endif 91