root/drivers/scsi/BusLogic.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. BusLogic_AcquireHostAdapterLock
  2. BusLogic_ReleaseHostAdapterLock
  3. BusLogic_AcquireHostAdapterLockID
  4. BusLogic_ReleaseHostAdapterLockID
  5. BusLogic_WriteControlRegister
  6. BusLogic_ReadStatusRegister
  7. BusLogic_WriteCommandParameterRegister
  8. BusLogic_ReadDataInRegister
  9. BusLogic_ReadInterruptRegister
  10. BusLogic_ReadGeometryRegister
  11. BusLogic_StartMailboxCommand
  12. BusLogic_Delay

   1 /*
   2 
   3   Linux Driver for BusLogic MultiMaster SCSI Host Adapters
   4 
   5   Copyright 1995 by Leonard N. Zubkoff <lnz@dandelion.com>
   6 
   7   This program is free software; you may redistribute and/or modify it under
   8   the terms of the GNU General Public License Version 2 as published by the
   9   Free Software Foundation, provided that none of the source code or runtime
  10   copyright notices are removed or modified.
  11 
  12   This program is distributed in the hope that it will be useful, but
  13   WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
  14   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15   for complete details.
  16 
  17   The author respectfully requests that any modifications to this software be
  18   sent directly to him for evaluation and testing.
  19 
  20   Special thanks to Wayne Yen and Alex Win of BusLogic, whose advice has been
  21   invaluable, to David Gentzel, for writing the original Linux BusLogic driver,
  22   and to Paul Gortmaker, for being such a dedicated test site.
  23 
  24 */
  25 
  26 
  27 /*
  28   Define types for some of the structures that interface with the rest
  29   of the Linux Kernel and SCSI Subsystem.
  30 */
  31 
  32 typedef struct pt_regs Registers_T;
  33 typedef Scsi_Host_Template SCSI_Host_Template_T;
  34 typedef struct Scsi_Host SCSI_Host_T;
  35 typedef struct scsi_device SCSI_Device_T;
  36 typedef struct scsi_disk SCSI_Disk_T;
  37 typedef struct scsi_cmnd SCSI_Command_T;
  38 typedef struct scatterlist SCSI_ScatterList_T;
  39 typedef kdev_t KernelDevice_T;
  40 
  41 
  42 /*
  43   Define prototypes for the BusLogic Driver Interface Functions.
  44 */
  45 
  46 const char *BusLogic_DriverInfo(SCSI_Host_T *);
  47 int BusLogic_DetectHostAdapter(SCSI_Host_Template_T *);
  48 int BusLogic_ReleaseHostAdapter(SCSI_Host_T *);
  49 int BusLogic_QueueCommand(SCSI_Command_T *,
  50                           void (*CompletionRoutine)(SCSI_Command_T *));
  51 int BusLogic_AbortCommand(SCSI_Command_T *);
  52 int BusLogic_ResetCommand(SCSI_Command_T *, unsigned int);
  53 int BusLogic_BIOSDiskParameters(SCSI_Disk_T *, KernelDevice_T, int *);
  54 
  55 
  56 /*
  57   Define the BusLogic SCSI Host Template structure.
  58 */
  59 
  60 #define BUSLOGIC                                                         \
  61   { NULL,                               /* Next                      */  \
  62     NULL,                               /* Usage Count Pointer       */  \
  63     NULL,                               /* /proc Directory Entry     */  \
  64     NULL,                               /* /proc Info Function       */  \
  65     "BusLogic",                         /* Driver Name               */  \
  66     BusLogic_DetectHostAdapter,         /* Detect Host Adapter       */  \
  67     BusLogic_ReleaseHostAdapter,        /* Release Host Adapter      */  \
  68     BusLogic_DriverInfo,                /* Driver Info Function      */  \
  69     NULL,                               /* Command Function          */  \
  70     BusLogic_QueueCommand,              /* Queue Command Function    */  \
  71     BusLogic_AbortCommand,              /* Abort Command Function    */  \
  72     BusLogic_ResetCommand,              /* Reset Command Function    */  \
  73     NULL,                               /* Slave Attach Function     */  \
  74     BusLogic_BIOSDiskParameters,        /* Disk BIOS Parameters      */  \
  75     0,                                  /* Can Queue                 */  \
  76     0,                                  /* This ID                   */  \
  77     0,                                  /* Scatter/Gather Table Size */  \
  78     0,                                  /* SCSI Commands per LUN     */  \
  79     0,                                  /* Present                   */  \
  80     1,                                  /* Default Unchecked ISA DMA */  \
  81     ENABLE_CLUSTERING }                 /* Enable Clustering         */
  82 
  83 
  84 /*
  85   BusLogic_DriverVersion protects the private portion of this file.
  86 */
  87 
  88 #ifdef BusLogic_DriverVersion
  89 
  90 
  91 /*
  92   Define the maximum number of BusLogic Host Adapters that are supported.
  93 */
  94 
  95 #define BusLogic_MaxHostAdapters                10
  96 
  97 
  98 /*
  99   Define the maximum number of I/O Addresses that may be probed.
 100 */
 101 
 102 #define BusLogic_IO_MaxProbeAddresses           16
 103 
 104 
 105 /*
 106   Define the maximum number of Target Devices supported by this driver.
 107 */
 108 
 109 #define BusLogic_MaxTargetDevices               16
 110 
 111 
 112 /*
 113   Define the maximum number of Scatter/Gather Segments used by this driver.
 114   For optimal performance, it is important that this limit be at least as
 115   large as the maximum single request generated by the I/O Subsystem.
 116 */
 117 
 118 #define BusLogic_ScatterGatherLimit             128
 119 
 120 
 121 /*
 122   Define the maximum and default Queue Depth to allow for Target Devices
 123   depending on whether or not they support Tagged Queuing and whether or not
 124   ISA Bounce Buffers are required.
 125 */
 126 
 127 #define BusLogic_MaxTaggedQueueDepth            31
 128 #define BusLogic_TaggedQueueDepth_BB            2
 129 #define BusLogic_UntaggedQueueDepth             3
 130 
 131 
 132 /*
 133   Define the default amount of time in seconds to wait between a Host Adapter
 134   Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands.
 135   Some SCSI devices get confused if they receive SCSI commands too soon after
 136   a SCSI Bus Reset.
 137 */
 138 
 139 #define BusLogic_DefaultBusSettleTime           2
 140 
 141 
 142 /*
 143   Define the possible Local Options.
 144 */
 145 
 146 #define BusLogic_InhibitTargetInquiry           1
 147 
 148 
 149 /*
 150   Define the possible Global Options.
 151 */
 152 
 153 #define BusLogic_TraceProbe                     1
 154 #define BusLogic_TraceHardReset                 2
 155 #define BusLogic_TraceConfiguration             4
 156 #define BusLogic_TraceErrors                    8
 157 #define BusLogic_TraceQueueDepths               16
 158 
 159 
 160 /*
 161   Define the possible Error Recovery Strategy Options.
 162 */
 163 
 164 #define BusLogic_ErrorRecovery_Default          0
 165 #define BusLogic_ErrorRecovery_HardReset        1
 166 #define BusLogic_ErrorRecovery_BusDeviceReset   2
 167 #define BusLogic_ErrorRecovery_None             3
 168 
 169 static char
 170   *BusLogic_ErrorRecoveryStrategyNames[] =
 171     { "Default", "Hard Reset", "Bus Device Reset", "None" },
 172   *BusLogic_ErrorRecoveryStrategyLetters[] =
 173     { "D", "H", "B", "N" };
 174 
 175 
 176 /*
 177   Define a boolean data type.
 178 */
 179 
 180 #define false 0
 181 #define true  1
 182 typedef unsigned char boolean;
 183 
 184 
 185 /*
 186   Define the BusLogic SCSI Host Adapter I/O Register Offsets.
 187 */
 188 
 189 #define BusLogic_IO_PortCount                   4       /* I/O Registers */
 190 #define BusLogic_ControlRegister                0       /* WO register */
 191 #define BusLogic_StatusRegister                 0       /* RO register */
 192 #define BusLogic_CommandParameterRegister       1       /* WO register */
 193 #define BusLogic_DataInRegister                 1       /* RO register */
 194 #define BusLogic_InterruptRegister              2       /* RO register */
 195 #define BusLogic_GeometryRegister               3       /* RO, undocumented */
 196 
 197 
 198 /*
 199   Define the bits in the write-only Control Register.
 200 */
 201 
 202 #define BusLogic_ReservedCR                     0x0F
 203 #define BusLogic_SCSIBusReset                   0x10
 204 #define BusLogic_InterruptReset                 0x20
 205 #define BusLogic_SoftReset                      0x40
 206 #define BusLogic_HardReset                      0x80
 207 
 208 
 209 /*
 210   Define the bits in the read-only Status Register.
 211 */
 212 
 213 #define BusLogic_CommandInvalid                 0x01
 214 #define BusLogic_ReservedSR                     0x02
 215 #define BusLogic_DataInRegisterReady            0x04
 216 #define BusLogic_CommandParameterRegisterBusy   0x08
 217 #define BusLogic_HostAdapterReady               0x10
 218 #define BusLogic_InitializationRequired         0x20
 219 #define BusLogic_DiagnosticFailure              0x40
 220 #define BusLogic_DiagnosticActive               0x80
 221 
 222 
 223 /*
 224   Define the bits in the read-only Interrupt Register.
 225 */
 226 
 227 #define BusLogic_IncomingMailboxLoaded          0x01
 228 #define BusLogic_OutgoingMailboxAvailable       0x02
 229 #define BusLogic_CommandComplete                0x04
 230 #define BusLogic_SCSIResetState                 0x08
 231 #define BusLogic_ReservedIR                     0x70
 232 #define BusLogic_InterruptValid                 0x80
 233 
 234 
 235 /*
 236   Define the bits in the undocumented read-only Geometry Register.
 237 */
 238 
 239 #define BusLogic_Drive0Geometry                 0x03
 240 #define BusLogic_Drive1Geometry                 0x0C
 241 #define BusLogic_ReservedGR                     0x70
 242 #define BusLogic_ExtendedTranslationEnabled     0x80
 243 
 244 
 245 /*
 246   Define the BusLogic SCSI Host Adapter Command Register Operation Codes.
 247 */
 248 
 249 typedef enum
 250 {
 251   BusLogic_TestCommandCompleteInterrupt =       0x00,   /* documented */
 252   BusLogic_InitializeMailbox =                  0x01,   /* documented */
 253   BusLogic_ExecuteMailboxCommand =              0x02,   /* documented */
 254   BusLogic_ExecuteBIOSCommand =                 0x03,   /* documented */
 255   BusLogic_InquireBoardID =                     0x04,   /* documented */
 256   BusLogic_EnableOutgoingMailboxAvailableInt =  0x05,   /* documented */
 257   BusLogic_SetSCSISelectionTimeout =            0x06,   /* documented */
 258   BusLogic_SetPreemptTimeOnBus =                0x07,   /* documented */
 259   BusLogic_SetTimeOffBus =                      0x08,   /* ISA Bus only */
 260   BusLogic_SetBusTransferRate =                 0x09,   /* ISA Bus only */
 261   BusLogic_InquireInstalledDevicesID0to7 =      0x0A,   /* documented */
 262   BusLogic_InquireConfiguration =               0x0B,   /* documented */
 263   BusLogic_SetTargetMode =                      0x0C,   /* now undocumented */
 264   BusLogic_InquireSetupInformation =            0x0D,   /* documented */
 265   BusLogic_WriteAdapterLocalRAM =               0x1A,   /* documented */
 266   BusLogic_ReadAdapterLocalRAM =                0x1B,   /* documented */
 267   BusLogic_WriteBusMasterChipFIFO =             0x1C,   /* documented */
 268   BusLogic_ReadBusMasterChipFIFO =              0x1D,   /* documented */
 269   BusLogic_EchoCommandData =                    0x1F,   /* documented */
 270   BusLogic_HostAdapterDiagnostic =              0x20,   /* documented */
 271   BusLogic_SetAdapterOptions =                  0x21,   /* documented */
 272   BusLogic_InquireInstalledDevicesID8to15 =     0x23,   /* Wide only */
 273   BusLogic_InquireDevices =                     0x24,   /* "W" and "C" only */
 274   BusLogic_InitializeExtendedMailbox =          0x81,   /* documented */
 275   BusLogic_InquireFirmwareVersion3rdDigit =     0x84,   /* undocumented */
 276   BusLogic_InquireFirmwareVersionLetter =       0x85,   /* undocumented */
 277   BusLogic_InquireGenericIOPortInformation =    0x86,   /* PCI only */
 278   BusLogic_InquireBoardModelNumber       =      0x8B,   /* undocumented */
 279   BusLogic_InquireSynchronousPeriod =           0x8C,   /* undocumented */
 280   BusLogic_InquireExtendedSetupInformation =    0x8D,   /* documented */
 281   BusLogic_EnableStrictRoundRobinMode =         0x8F,   /* documented */
 282   BusLogic_FetchHostAdapterLocalRAM =           0x91,   /* undocumented */
 283   BusLogic_ModifyIOAddress =                    0x95,   /* PCI only */
 284   BusLogic_EnableWideModeCCB =                  0x96    /* Wide only */
 285 }
 286 BusLogic_OperationCode_T;
 287 
 288 
 289 /*
 290   Define the Inquire Board ID reply structure.
 291 */
 292 
 293 typedef struct BusLogic_BoardID
 294 {
 295   unsigned char BoardType;                              /* Byte 0 */
 296   unsigned char CustomFeatures;                         /* Byte 1 */
 297   unsigned char FirmwareVersion1stDigit;                /* Byte 2 */
 298   unsigned char FirmwareVersion2ndDigit;                /* Byte 3 */
 299 }
 300 BusLogic_BoardID_T;
 301 
 302 
 303 /*
 304   Define the Inquire Installed Devices ID 0 to 7 and Inquire Installed
 305   Devices ID 8 to 15 reply type.  For each Target Device, a byte is returned
 306   where bit 0 set indicates that Logical Unit 0 exists, bit 1 set indicates
 307   that Logical Unit 1 exists, and so on.
 308 */
 309 
 310 typedef unsigned char BusLogic_InstalledDevices8_T[8];
 311 
 312 
 313 /*
 314   Define the Inquire Devices reply type.  Inquire Devices only tests Logical
 315   Unit 0 of each Target Device unlike Inquire Installed Devices which tests
 316   Logical Units 0 - 7.  Two bytes are returned, where bit 0 set indicates
 317   that Target Device 0 exists, and so on.
 318 */
 319 
 320 typedef unsigned short BusLogic_InstalledDevices_T;
 321 
 322 
 323 /*
 324   Define the Inquire Configuration reply structure.
 325 */
 326 
 327 typedef struct BusLogic_Configuration
 328 {
 329   unsigned char :5;                                     /* Byte 0 Bits 0-4 */
 330   boolean DMA_Channel5:1;                               /* Byte 0 Bit 5 */
 331   boolean DMA_Channel6:1;                               /* Byte 0 Bit 6 */
 332   boolean DMA_Channel7:1;                               /* Byte 0 Bit 7 */
 333   boolean IRQ_Channel9:1;                               /* Byte 1 Bit 0 */
 334   boolean IRQ_Channel10:1;                              /* Byte 1 Bit 1 */
 335   boolean IRQ_Channel11:1;                              /* Byte 1 Bit 2 */
 336   boolean IRQ_Channel12:1;                              /* Byte 1 Bit 3 */
 337   unsigned char :1;                                     /* Byte 1 Bit 4 */
 338   boolean IRQ_Channel14:1;                              /* Byte 1 Bit 5 */
 339   boolean IRQ_Channel15:1;                              /* Byte 1 Bit 6 */
 340   unsigned char :1;                                     /* Byte 1 Bit 7 */
 341   unsigned char HostAdapterID:4;                        /* Byte 2 Bits 0-3 */
 342   unsigned char :4;                                     /* Byte 2 Bits 4-7 */
 343 }
 344 BusLogic_Configuration_T;
 345 
 346 
 347 /*
 348   Define the Inquire Setup Information reply structure.
 349 */
 350 
 351 typedef struct BusLogic_SynchronousValue
 352 {
 353   unsigned char Offset:4;                               /* Bits 0-3 */
 354   unsigned char TransferPeriod:3;                       /* Bits 4-6 */
 355   boolean Synchronous:1;                                /* Bit 7 */
 356 }
 357 BusLogic_SynchronousValue_T;
 358 
 359 typedef BusLogic_SynchronousValue_T
 360   BusLogic_SynchronousValues8_T[8];
 361 
 362 typedef BusLogic_SynchronousValue_T
 363   BusLogic_SynchronousValues_T[BusLogic_MaxTargetDevices];
 364 
 365 typedef struct BusLogic_SetupInformation
 366 {
 367   boolean SynchronousInitiationEnabled:1;               /* Byte 0 Bit 0 */
 368   boolean ParityCheckEnabled:1;                         /* Byte 0 Bit 1 */
 369   unsigned char :6;                                     /* Byte 0 Bits 2-7 */
 370   unsigned char BusTransferRate;                        /* Byte 1 */
 371   unsigned char PreemptTimeOnBus;                       /* Byte 2 */
 372   unsigned char TimeOffBus;                             /* Byte 3 */
 373   unsigned char MailboxCount;                           /* Byte 4 */
 374   unsigned char MailboxAddress[3];                      /* Bytes 5-7 */
 375   BusLogic_SynchronousValues8_T SynchronousValuesID0to7; /* Bytes 8-15 */
 376   unsigned char DisconnectPermittedID0to7;              /* Byte 16 */
 377   unsigned char Signature;                              /* Byte 17 */
 378   unsigned char CharacterD;                             /* Byte 18 */
 379   unsigned char BusLetter;                              /* Byte 19 */
 380   unsigned char :8;                                     /* Byte 20 */
 381   unsigned char :8;                                     /* Byte 21 */
 382   BusLogic_SynchronousValues8_T SynchronousValuesID8to15; /* Bytes 22-29 */
 383   unsigned char DisconnectPermittedID8to15;             /* Byte 30 */
 384 }
 385 BusLogic_SetupInformation_T;
 386 
 387 
 388 /*
 389   Define the Initialize Extended Mailbox request structure.
 390 */
 391 
 392 typedef struct BusLogic_ExtendedMailboxRequest
 393 {
 394   unsigned char MailboxCount;                           /* Byte 0 */
 395   void *BaseMailboxAddress __attribute__ ((packed));    /* Bytes 1-4 */
 396 }
 397 BusLogic_ExtendedMailboxRequest_T;
 398 
 399 
 400 /*
 401   Define the Inquire Firmware Version 3rd Digit reply type.
 402 */
 403 
 404 typedef unsigned char BusLogic_FirmwareVersion3rdDigit_T;
 405 
 406 
 407 /*
 408   Define the Inquire Firmware Version Letter reply type.
 409 */
 410 
 411 typedef unsigned char BusLogic_FirmwareVersionLetter_T;
 412 
 413 
 414 /*
 415   Define the Inquire Generic I/O Port Information reply type.
 416 */
 417 
 418 typedef struct BusLogic_GenericIOPortInformation
 419 {
 420   unsigned char ISACompatibleIOPort;                    /* Byte 0 */
 421   unsigned char PCIAssignedIRQChannel;                  /* Byte 1 */
 422   boolean LowByteTerminated:1;                          /* Byte 2 Bit 0 */
 423   boolean HighByteTerminated:1;                         /* Byte 2 Bit 1 */
 424   unsigned char :2;                                     /* Byte 2 Bits 2-3 */
 425   boolean JP1:1;                                        /* Byte 2 Bit 4 */
 426   boolean JP2:1;                                        /* Byte 2 Bit 5 */
 427   boolean JP3:1;                                        /* Byte 2 Bit 6 */
 428   boolean Valid:1;                                      /* Byte 2 Bit 7 */
 429   unsigned char :8;                                     /* Byte 3 */
 430 }
 431 BusLogic_GenericIOPortInformation_T;
 432 
 433 
 434 /*
 435   Define the Inquire Board Model Number reply type.
 436 */
 437 
 438 typedef unsigned char BusLogic_BoardModelNumber_T[5];
 439 
 440 
 441 /*
 442   Define the Inquire Synchronous Period reply type.  For each Target Device,
 443   a byte is returned which represents the Synchronous Transfer Period in units
 444   of 10 nanoseconds.
 445 */
 446 
 447 typedef unsigned char BusLogic_SynchronousPeriod_T[BusLogic_MaxTargetDevices];
 448 
 449 
 450 /*
 451   Define the Inquire Extended Setup Information reply structure.
 452 */
 453 
 454 typedef struct BusLogic_ExtendedSetupInformation
 455 {
 456   unsigned char BusType;                                /* Byte 0 */
 457   unsigned char BIOS_Address;                           /* Byte 1 */
 458   unsigned short ScatterGatherLimit;                    /* Bytes 2-3 */
 459   unsigned char MailboxCount;                           /* Byte 4 */
 460   void *BaseMailboxAddress __attribute__ ((packed));    /* Bytes 5-8 */
 461   struct { unsigned char :6;                            /* Byte 9 Bits 0-5 */
 462            boolean LevelSensitiveInterrupts:1;          /* Byte 9 Bit 6 */
 463            unsigned char :1; } Misc;                    /* Byte 9 Bit 7 */
 464   unsigned char FirmwareRevision[3];                    /* Bytes 10-12 */
 465   boolean HostWideSCSI:1;                               /* Byte 13 Bit 0 */
 466   boolean HostDifferentialSCSI:1;                       /* Byte 13 Bit 1 */
 467   boolean HostAutomaticConfiguration:1;                 /* Byte 13 Bit 2 */
 468   boolean HostUltraSCSI:1;                              /* Byte 13 Bit 3 */
 469   unsigned char :4;                                     /* Byte 13 Bits 4-7 */
 470 }
 471 BusLogic_ExtendedSetupInformation_T;
 472 
 473 
 474 /*
 475   Define the Enable Strict Round Robin Mode request type.
 476 */
 477 
 478 #define BusLogic_AggressiveRoundRobinMode       0x00
 479 #define BusLogic_StrictRoundRobinMode           0x01
 480 
 481 typedef unsigned char BusLogic_RoundRobinModeRequest_T;
 482 
 483 
 484 /*
 485   Define the Fetch Host Adapter Local RAM request type.
 486 */
 487 
 488 #define BusLogic_BIOS_BaseOffset                0
 489 #define BusLogic_AutoSCSI_BaseOffset            64
 490 
 491 typedef struct BusLogic_FetchHostAdapterLocalRAMRequest
 492 {
 493   unsigned char ByteOffset;                             /* Byte 0 */
 494   unsigned char ByteCount;                              /* Byte 1 */
 495 }
 496 BusLogic_FetchHostAdapterLocalRAMRequest_T;
 497 
 498 
 499 /*
 500   Define the Host Adapter Local RAM Auto SCSI Byte 15 reply structure.
 501 */
 502 
 503 typedef struct BusLogic_AutoSCSIByte15
 504 {
 505   unsigned char LowByteTerminated:1;                    /* Bit 0 */
 506   unsigned char :1;                                     /* Bit 1 */
 507   unsigned char HighByteTerminated:1;                   /* Bit 2 */
 508   unsigned char :5;                                     /* Bits 3-7 */
 509 }
 510 BusLogic_AutoSCSIByte15_T;
 511 
 512 
 513 /*
 514   Define the Host Adapter Local RAM Auto SCSI Byte 45 reply structure.
 515 */
 516 
 517 typedef struct BusLogic_AutoSCSIByte45
 518 {
 519   unsigned char ForceBusDeviceScanningOrder:1;          /* Bit 0 */
 520   unsigned char :7;                                     /* Bits 1-7 */
 521 }
 522 BusLogic_AutoSCSIByte45_T;
 523 
 524 
 525 /*
 526   Define the Modify I/O Address request type.  On PCI Host Adapters, the
 527   Modify I/O Address command allows modification of the ISA compatible I/O
 528   Address that the Host Adapter responds to; it does not affect the PCI
 529   compliant I/O Address assigned at system initialization.
 530 */
 531 
 532 #define BusLogic_ModifyIO_330                   0x00
 533 #define BusLogic_ModifyIO_334                   0x01
 534 #define BusLogic_ModifyIO_230                   0x02
 535 #define BusLogic_ModifyIO_234                   0x03
 536 #define BusLogic_ModifyIO_130                   0x04
 537 #define BusLogic_ModifyIO_134                   0x05
 538 #define BusLogic_ModifyIO_Disable               0x06
 539 #define BusLogic_ModifyIO_Disable2              0x07
 540 
 541 typedef unsigned char BusLogic_ModifyIOAddressRequest_T;
 542 
 543 
 544 /*
 545   Define the Enable Wide Mode SCSI CCB request type.  Wide Mode CCBs are
 546   necessary to support more than 8 Logical Units per Target Device.
 547 */
 548 
 549 #define BusLogic_NormalModeCCB                  0x00
 550 #define BusLogic_WideModeCCB                    0x01
 551 
 552 typedef unsigned char BusLogic_WideModeCCBRequest_T;
 553 
 554 
 555 /*
 556   Define the Requested Reply Length type used by the Inquire Setup Information,
 557   Inquire Board Model Number, Inquire Synchronous Period, and Inquire Extended
 558   Setup Information commands.
 559 */
 560 
 561 typedef unsigned char BusLogic_RequestedReplyLength_T;
 562 
 563 
 564 /*
 565   Define a Lock data structure.  Until a true symmetric multiprocessing kernel
 566   with fine grained locking is available, acquiring the lock is implemented as
 567   saving the processor flags and disabling interrupts, and releasing the lock
 568   restores the saved processor flags.
 569 */
 570 
 571 typedef unsigned long BusLogic_Lock_T;
 572 
 573 
 574 /*
 575   Define the Outgoing Mailbox Action Codes.
 576 */
 577 
 578 typedef enum
 579 {
 580   BusLogic_OutgoingMailboxFree =                0,
 581   BusLogic_MailboxStartCommand =                1,
 582   BusLogic_MailboxAbortCommand =                2
 583 }
 584 BusLogic_ActionCode_T;
 585 
 586 
 587 /*
 588   Define the Incoming Mailbox Completion Codes.
 589 */
 590 
 591 typedef enum
 592 {
 593   BusLogic_IncomingMailboxFree =                0,
 594   BusLogic_CommandCompletedWithoutError =       1,
 595   BusLogic_CommandAbortedAtHostRequest =        2,
 596   BusLogic_AbortedCommandNotFound =             3,
 597   BusLogic_CommandCompletedWithError =          4
 598 }
 599 BusLogic_CompletionCode_T;
 600 
 601 
 602 /*
 603   Define the Command Control Block (CCB) Opcodes.
 604 */
 605 
 606 typedef enum
 607 {
 608   BusLogic_InitiatorCCB =                       0x00,
 609   BusLogic_TargetCCB =                          0x01,
 610   BusLogic_InitiatorCCB_ScatterGather =         0x02,
 611   BusLogic_InitiatorCCB_ResidualDataLength =    0x03,
 612   BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04,
 613   BusLogic_BusDeviceReset =                     0x81
 614 }
 615 BusLogic_CCB_Opcode_T;
 616 
 617 
 618 /*
 619   Define the CCB Data Direction Codes.
 620 */
 621 
 622 typedef enum
 623 {
 624   BusLogic_UncheckedDataTransfer =              0x00,
 625   BusLogic_DataInLengthChecked =                0x01,
 626   BusLogic_DataOutLengthChecked =               0x02,
 627   BusLogic_NoDataTransfer =                     0x03
 628 }
 629 BusLogic_DataDirection_T;
 630 
 631 
 632 /*
 633   Define the Host Adapter Status Codes.
 634 */
 635 
 636 typedef enum
 637 {
 638   BusLogic_CommandCompletedNormally =           0x00,
 639   BusLogic_LinkedCommandCompleted =             0x0A,
 640   BusLogic_LinkedCommandCompletedWithFlag =     0x0B,
 641   BusLogic_SCSISelectionTimeout =               0x11,
 642   BusLogic_DataOverUnderRun =                   0x12,
 643   BusLogic_UnexpectedBusFree =                  0x13,
 644   BusLogic_InvalidBusPhaseRequested =           0x14,
 645   BusLogic_InvalidOutgoingMailboxActionCode =   0x15,
 646   BusLogic_InvalidCommandOperationCode =        0x16,
 647   BusLogic_LinkedCCBhasInvalidLUN =             0x17,
 648   BusLogic_InvalidCommandParameter =            0x1A,
 649   BusLogic_AutoRequestSenseFailed =             0x1B,
 650   BusLogic_TaggedQueuingMessageRejected =       0x1C,
 651   BusLogic_UnsupportedMessageReceived =         0x1D,
 652   BusLogic_HostAdapterHardwareFailed =          0x20,
 653   BusLogic_TargetFailedResponseToATN =          0x21,
 654   BusLogic_HostAdapterAssertedRST =             0x22,
 655   BusLogic_OtherDeviceAssertedRST =             0x23,
 656   BusLogic_TargetDeviceReconnectedImproperly =  0x24,
 657   BusLogic_HostAdapterAssertedBusDeviceReset =  0x25,
 658   BusLogic_AbortQueueGenerated =                0x26,
 659   BusLogic_HostAdapterSoftwareError =           0x27,
 660   BusLogic_HostAdapterHardwareTimeoutError =    0x30,
 661   BusLogic_SCSIParityErrorDetected =            0x34
 662 }
 663 BusLogic_HostAdapterStatus_T;
 664 
 665 
 666 /*
 667   Define the SCSI Target Device Status Codes.
 668 */
 669 
 670 typedef enum
 671 {
 672   BusLogic_OperationGood =                      0x00,
 673   BusLogic_CheckCondition =                     0x02,
 674   BusLogic_DeviceBusy =                         0x08
 675 }
 676 BusLogic_TargetDeviceStatus_T;
 677 
 678 
 679 /*
 680   Define the Queue Tag Codes.
 681 */
 682 
 683 typedef enum
 684 {
 685   BusLogic_SimpleQueueTag =                     0x00,
 686   BusLogic_HeadOfQueueTag =                     0x01,
 687   BusLogic_OrderedQueueTag =                    0x02,
 688   BusLogic_ReservedQT =                         0x03
 689 }
 690 BusLogic_QueueTag_T;
 691 
 692 
 693 /*
 694   Define the SCSI Command Descriptor Block (CDB).
 695 */
 696 
 697 #define BusLogic_CDB_MaxLength                  12
 698 
 699 typedef unsigned char SCSI_CDB_T[BusLogic_CDB_MaxLength];
 700 
 701 
 702 /*
 703   Define the SCSI Sense Data.
 704 */
 705 
 706 #define BusLogic_SenseDataMaxLength             255
 707 
 708 typedef unsigned char SCSI_SenseData_T[BusLogic_SenseDataMaxLength];
 709 
 710 
 711 /*
 712   Define the Scatter/Gather Segment structure required by the Host Adapter
 713   Firmware Interface.
 714 */
 715 
 716 typedef struct BusLogic_ScatterGatherSegment
 717 {
 718   unsigned long SegmentByteCount;                       /* Bytes 0-3 */
 719   void *SegmentDataPointer;                             /* Bytes 4-7 */
 720 }
 721 BusLogic_ScatterGatherSegment_T;
 722 
 723 
 724 /*
 725   Define the 32 Bit Mode Command Control Block (CCB) structure.  The first 40
 726   bytes are defined by the Host Adapter Firmware Interface.  The remaining
 727   components are defined by the Linux BusLogic Driver.  Wide Mode CCBs differ
 728   from standard 32 Bit Mode CCBs only in having the TagEnable and QueueTag
 729   fields moved from byte 17 to byte 1, and the Logical Unit field in byte 17
 730   expanded to 6 bits; unfortunately, using a union of structs containing
 731   enumeration type bitfields to provide both definitions leads to packing
 732   problems, so the following definition is used which requires setting
 733   TagEnable to Logical Unit bit 5 in Wide Mode CCBs.
 734 */
 735 
 736 typedef struct BusLogic_CCB
 737 {
 738   /*
 739     BusLogic Host Adapter Firmware Portion.
 740   */
 741   BusLogic_CCB_Opcode_T Opcode:8;                       /* Byte 0 */
 742   unsigned char :3;                                     /* Byte 1 Bits 0-2 */
 743   BusLogic_DataDirection_T DataDirection:2;             /* Byte 1 Bits 3-4 */
 744   boolean WideModeTagEnable:1;                          /* Byte 1 Bit 5 */
 745   BusLogic_QueueTag_T WideModeQueueTag:2;               /* Byte 1 Bits 6-7 */
 746   unsigned char CDB_Length;                             /* Byte 2 */
 747   unsigned char SenseDataLength;                        /* Byte 3 */
 748   unsigned long DataLength;                             /* Bytes 4-7 */
 749   void *DataPointer;                                    /* Bytes 8-11 */
 750   unsigned char :8;                                     /* Byte 12 */
 751   unsigned char :8;                                     /* Byte 13 */
 752   BusLogic_HostAdapterStatus_T HostAdapterStatus:8;     /* Byte 14 */
 753   BusLogic_TargetDeviceStatus_T TargetDeviceStatus:8;   /* Byte 15 */
 754   unsigned char TargetID;                               /* Byte 16 */
 755   unsigned char LogicalUnit:5;                          /* Byte 17 Bits 0-4 */
 756   boolean TagEnable:1;                                  /* Byte 17 Bit 5 */
 757   BusLogic_QueueTag_T QueueTag:2;                       /* Byte 17 Bits 6-7 */
 758   SCSI_CDB_T CDB;                                       /* Bytes 18-29 */
 759   unsigned char :8;                                     /* Byte 30 */
 760   unsigned char :8;                                     /* Byte 31 */
 761   unsigned long :32;                                    /* Bytes 32-35 */
 762   SCSI_SenseData_T *SenseDataPointer;                   /* Bytes 36-39 */
 763   /*
 764     BusLogic Linux Driver Portion.
 765   */
 766   struct BusLogic_HostAdapter *HostAdapter;
 767   SCSI_Command_T *Command;
 768   enum { BusLogic_CCB_Free =        0,
 769          BusLogic_CCB_Active =      1,
 770          BusLogic_CCB_Completed =   2,
 771          BusLogic_CCB_Reset =       3 } Status;
 772   BusLogic_CompletionCode_T MailboxCompletionCode;
 773   unsigned int SerialNumber;
 774   struct BusLogic_CCB *Next;
 775   struct BusLogic_CCB *NextAll;
 776   BusLogic_ScatterGatherSegment_T
 777     ScatterGatherList[BusLogic_ScatterGatherLimit];
 778 }
 779 BusLogic_CCB_T;
 780 
 781 
 782 /*
 783   Define the 32 Bit Mode Outgoing Mailbox structure.
 784 */
 785 
 786 typedef struct BusLogic_OutgoingMailbox
 787 {
 788   BusLogic_CCB_T *CCB;                                  /* Bytes 0-3 */
 789   unsigned long :24;                                    /* Byte 4 */
 790   BusLogic_ActionCode_T ActionCode:8;                   /* Bytes 5-7 */
 791 }
 792 BusLogic_OutgoingMailbox_T;
 793 
 794 
 795 /*
 796   Define the 32 Bit Mode Incoming Mailbox structure.
 797 */
 798 
 799 typedef struct BusLogic_IncomingMailbox
 800 {
 801   BusLogic_CCB_T *CCB;                                  /* Bytes 0-3 */
 802   BusLogic_HostAdapterStatus_T HostAdapterStatus:8;     /* Byte 4 */
 803   BusLogic_TargetDeviceStatus_T TargetDeviceStatus:8;   /* Byte 5 */
 804   unsigned char :8;                                     /* Byte 6 */
 805   BusLogic_CompletionCode_T CompletionCode:8;           /* Byte 7 */
 806 }
 807 BusLogic_IncomingMailbox_T;
 808 
 809 
 810 /*
 811   Define the possible Bus Types.
 812 */
 813 
 814 typedef enum
 815 {
 816   BusLogic_Unknown_Bus =                        0,
 817   BusLogic_ISA_Bus =                            1,
 818   BusLogic_MCA_Bus =                            2,
 819   BusLogic_EISA_Bus =                           3,
 820   BusLogic_VESA_Bus =                           4,
 821   BusLogic_PCI_Bus =                            5
 822 }
 823 BusLogic_BusType_T;
 824 
 825 static char
 826   *BusLogic_BusNames[] =
 827     { "Unknown", "ISA", "MCA", "EISA", "VESA", "PCI" };
 828 
 829 
 830 /*
 831   Define the Linux BusLogic Driver Command Line Entry structure.
 832 */
 833 
 834 typedef struct BusLogic_CommandLineEntry
 835 {
 836   unsigned short IO_Address;
 837   unsigned short TaggedQueueDepth;
 838   unsigned short BusSettleTime;
 839   unsigned short LocalOptions;
 840   unsigned short TaggedQueuingPermitted;
 841   unsigned short TaggedQueuingPermittedMask;
 842   unsigned char ErrorRecoveryStrategy[BusLogic_MaxTargetDevices];
 843 }
 844 BusLogic_CommandLineEntry_T;
 845 
 846 
 847 /*
 848   Define the Linux BusLogic Driver Host Adapter structure.
 849 */
 850 
 851 typedef struct BusLogic_HostAdapter
 852 {
 853   SCSI_Host_T *SCSI_Host;
 854   unsigned char HostNumber;
 855   unsigned char ModelName[9];
 856   unsigned char FirmwareVersion[6];
 857   unsigned char BoardName[18];
 858   unsigned char InterruptLabel[62];
 859   unsigned short IO_Address;
 860   unsigned char IRQ_Channel;
 861   unsigned char DMA_Channel;
 862   unsigned char SCSI_ID;
 863   BusLogic_BusType_T BusType:3;
 864   boolean IRQ_ChannelAcquired:1;
 865   boolean DMA_ChannelAcquired:1;
 866   boolean SynchronousInitiation:1;
 867   boolean ParityChecking:1;
 868   boolean ExtendedTranslation:1;
 869   boolean LevelSensitiveInterrupts:1;
 870   boolean HostWideSCSI:1;
 871   boolean HostDifferentialSCSI:1;
 872   boolean HostAutomaticConfiguration:1;
 873   boolean HostUltraSCSI:1;
 874   boolean TerminationInfoValid:1;
 875   boolean LowByteTerminated:1;
 876   boolean HighByteTerminated:1;
 877   boolean BounceBuffersRequired:1;
 878   boolean StrictRoundRobinModeSupported:1;
 879   boolean HostAdapterResetRequested:1;
 880   volatile boolean HostAdapterCommandCompleted:1;
 881   unsigned short HostAdapterScatterGatherLimit;
 882   unsigned short DriverScatterGatherLimit;
 883   unsigned short MaxTargetDevices;
 884   unsigned short MaxLogicalUnits;
 885   unsigned short MailboxCount;
 886   unsigned short InitialCCBs;
 887   unsigned short IncrementalCCBs;
 888   unsigned short TotalQueueDepth;
 889   unsigned short TaggedQueueDepth;
 890   unsigned short UntaggedQueueDepth;
 891   unsigned short BusSettleTime;
 892   unsigned short LocalOptions;
 893   unsigned short DisconnectPermitted;
 894   unsigned short TaggedQueuingPermitted;
 895   unsigned long BIOS_Address;
 896   BusLogic_InstalledDevices_T InstalledDevices;
 897   BusLogic_SynchronousValues_T SynchronousValues;
 898   BusLogic_SynchronousPeriod_T SynchronousPeriod;
 899   BusLogic_CommandLineEntry_T *CommandLineEntry;
 900   struct BusLogic_HostAdapter *Next;
 901   BusLogic_CCB_T *All_CCBs;
 902   BusLogic_CCB_T *Free_CCBs;
 903   BusLogic_CCB_T *BusDeviceResetPendingCCB[BusLogic_MaxTargetDevices];
 904   unsigned char ErrorRecoveryStrategy[BusLogic_MaxTargetDevices];
 905   unsigned char TaggedQueuingActive[BusLogic_MaxTargetDevices];
 906   unsigned char CommandSuccessfulFlag[BusLogic_MaxTargetDevices];
 907   unsigned char ActiveCommandCount[BusLogic_MaxTargetDevices];
 908   unsigned long TotalCommandCount[BusLogic_MaxTargetDevices];
 909   unsigned long LastSequencePoint[BusLogic_MaxTargetDevices];
 910   unsigned long LastResetTime[BusLogic_MaxTargetDevices];
 911   BusLogic_OutgoingMailbox_T *FirstOutgoingMailbox;
 912   BusLogic_OutgoingMailbox_T *LastOutgoingMailbox;
 913   BusLogic_OutgoingMailbox_T *NextOutgoingMailbox;
 914   BusLogic_IncomingMailbox_T *FirstIncomingMailbox;
 915   BusLogic_IncomingMailbox_T *LastIncomingMailbox;
 916   BusLogic_IncomingMailbox_T *NextIncomingMailbox;
 917 }
 918 BusLogic_HostAdapter_T;
 919 
 920 
 921 /*
 922   Define a structure for the BIOS Disk Parameters.
 923 */
 924 
 925 typedef struct BIOS_DiskParameters
 926 {
 927   int Heads;
 928   int Sectors;
 929   int Cylinders;
 930 }
 931 BIOS_DiskParameters_T;
 932 
 933 
 934 /*
 935   BusLogic_AcquireHostAdapterLock acquires exclusive access to Host Adapter.
 936 */
 937 
 938 static inline
 939 void BusLogic_AcquireHostAdapterLock(BusLogic_HostAdapter_T *HostAdapter,
     /* [previous][next][first][last][top][bottom][index][help] */
 940                                      BusLogic_Lock_T *Lock)
 941 {
 942   save_flags(*Lock);
 943   cli();
 944 }
 945 
 946 
 947 /*
 948   BusLogic_ReleaseHostAdapterLock releases exclusive access to Host Adapter.
 949 */
 950 
 951 static inline
 952 void BusLogic_ReleaseHostAdapterLock(BusLogic_HostAdapter_T *HostAdapter,
     /* [previous][next][first][last][top][bottom][index][help] */
 953                                      BusLogic_Lock_T *Lock)
 954 {
 955   restore_flags(*Lock);
 956 }
 957 
 958 
 959 /*
 960   BusLogic_AcquireHostAdapterLockID acquires exclusive access to Host Adapter,
 961   but is only called when interrupts are disabled.
 962 */
 963 
 964 static inline
 965 void BusLogic_AcquireHostAdapterLockID(BusLogic_HostAdapter_T *HostAdapter,
     /* [previous][next][first][last][top][bottom][index][help] */
 966                                        BusLogic_Lock_T *Lock)
 967 {
 968 }
 969 
 970 
 971 /*
 972   BusLogic_ReleaseHostAdapterLockID releases exclusive access to Host Adapter,
 973   but is only called when interrupts are disabled.
 974 */
 975 
 976 static inline
 977 void BusLogic_ReleaseHostAdapterLockID(BusLogic_HostAdapter_T *HostAdapter,
     /* [previous][next][first][last][top][bottom][index][help] */
 978                                        BusLogic_Lock_T *Lock)
 979 {
 980 }
 981 
 982 
 983 /*
 984   Define functions to provide an abstraction for reading and writing the
 985   Host Adapter I/O Registers.
 986 */
 987 
 988 static inline
 989 void BusLogic_WriteControlRegister(BusLogic_HostAdapter_T *HostAdapter,
     /* [previous][next][first][last][top][bottom][index][help] */
 990                                    unsigned char Value)
 991 {
 992   outb(Value, HostAdapter->IO_Address + BusLogic_ControlRegister);
 993 }
 994 
 995 static inline
 996 unsigned char BusLogic_ReadStatusRegister(BusLogic_HostAdapter_T *HostAdapter)
     /* [previous][next][first][last][top][bottom][index][help] */
 997 {
 998   return inb(HostAdapter->IO_Address + BusLogic_StatusRegister);
 999 }
1000 
1001 static inline
1002 void BusLogic_WriteCommandParameterRegister(BusLogic_HostAdapter_T *HostAdapter,
     /* [previous][next][first][last][top][bottom][index][help] */
1003                                             unsigned char Value)
1004 {
1005   outb(Value, HostAdapter->IO_Address + BusLogic_CommandParameterRegister);
1006 }
1007 
1008 static inline
1009 unsigned char BusLogic_ReadDataInRegister(BusLogic_HostAdapter_T *HostAdapter)
     /* [previous][next][first][last][top][bottom][index][help] */
1010 {
1011   return inb(HostAdapter->IO_Address + BusLogic_DataInRegister);
1012 }
1013 
1014 static inline
1015 unsigned char BusLogic_ReadInterruptRegister(BusLogic_HostAdapter_T
     /* [previous][next][first][last][top][bottom][index][help] */
1016                                              *HostAdapter)
1017 {
1018   return inb(HostAdapter->IO_Address + BusLogic_InterruptRegister);
1019 }
1020 
1021 static inline
1022 unsigned char BusLogic_ReadGeometryRegister(BusLogic_HostAdapter_T *HostAdapter)
     /* [previous][next][first][last][top][bottom][index][help] */
1023 {
1024   return inb(HostAdapter->IO_Address + BusLogic_GeometryRegister);
1025 }
1026 
1027 
1028 /*
1029   BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which
1030   notifies the Host Adapter that an entry has been made in an Outgoing
1031   Mailbox.
1032 */
1033 
1034 static inline
1035 void BusLogic_StartMailboxCommand(BusLogic_HostAdapter_T *HostAdapter)
     /* [previous][next][first][last][top][bottom][index][help] */
1036 {
1037   BusLogic_WriteCommandParameterRegister(HostAdapter,
1038                                          BusLogic_ExecuteMailboxCommand);
1039 }
1040 
1041 
1042 /*
1043   BusLogic_Delay waits for Seconds to elapse.
1044 */
1045 
1046 static inline void BusLogic_Delay(int Seconds)
     /* [previous][next][first][last][top][bottom][index][help] */
1047 {
1048   unsigned long TimeoutJiffies = jiffies + Seconds * HZ;
1049   unsigned long ProcessorFlags;
1050   save_flags(ProcessorFlags);
1051   sti();
1052   while (jiffies < TimeoutJiffies) ;
1053   restore_flags(ProcessorFlags);
1054 }
1055 
1056 
1057 /*
1058   Define prototypes for the forward referenced BusLogic Driver
1059   Internal Functions.
1060 */
1061 
1062 static void BusLogic_InterruptHandler(int, void *, Registers_T *);
1063 static int BusLogic_ResetHostAdapter(BusLogic_HostAdapter_T *,
1064                                      SCSI_Command_T *,
1065                                      unsigned int);
1066 
1067 
1068 #endif /* BusLogic_DriverVersion */

/* [previous][next][first][last][top][bottom][index][help] */