root/drivers/scsi/BusLogic.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. BusLogic_LockHostAdapter
  2. BusLogic_UnlockHostAdapter
  3. BusLogic_LockHostAdapterID
  4. BusLogic_UnlockHostAdapterID
  5. BusLogic_WriteControlRegister
  6. BusLogic_ReadStatusRegister
  7. BusLogic_WriteCommandParameterRegister
  8. BusLogic_ReadDataInRegister
  9. BusLogic_ReadInterruptRegister
  10. BusLogic_ReadGeometryRegister
  11. BusLogic_StartMailboxScan
  12. BusLogic_Delay

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

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