Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > DoxygenBusLogic958.h
Go to the documentation of this file.
00001 /* 00002 * vmscsi-- Miniport driver for the Buslogic BT 958 SCSI Controller 00003 * under Windows 2000/XP/Server 2003 00004 * 00005 * Based in parts on the buslogic driver for the same device 00006 * available with the GNU Linux Operating System. 00007 * 00008 * This program is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License 00010 * as published by the Free Software Foundation; either version 2 00011 * of the License, or (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License along 00019 * with this program; if not, write to the Free Software Foundation, Inc., 00020 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 */ 00022 00023 //_________________________________________________________________________________________ 00024 // 00025 // File description :The header file the driver for BusLogic-958 SCSI Host adapter card. 00026 // The technical refernece for this driver is at : 00027 // 00028 // Author: Namita Lal, Sirish Raghuram ( Calsoft Pvt Ltd) 00029 // Date: 10th June 2002 00030 // Status: Released 00031 // Revision History: Changed queue depth to 191 - June 2002 00032 // 00033 //_________________________________________________________________________________________ 00034 00035 // Prototype for functions 00036 00037 #pragma once 00038 00039 #include <ntddk.h> 00040 #include <srb.h> 00041 #include <scsi.h> 00042 #include <ntddscsi.h> 00043 #include <scsiwmi.h> 00044 //#include <ntos/kefuncs.h> 00045 00046 00047 //#include "miniport.h" 00048 //#include "scsi.h" 00049 //#include "scsiwmi.h" 00050 //_________________________________________________________________________________________ 00051 // #defines 00052 //_________________________________________________________________________________________ 00053 00054 // Debug levels 00055 #define ERROR 1 00056 #define WARNING 2 00057 #define TRACE 3 00058 #define INFO 4 00059 00060 // Max transfer size 00061 #define MAX_TRANSFER_SIZE 64 * 1024 00062 // flag to turn on Scatter gather support 00063 #define SG_SUPPORT 1 00064 // flag to turn on tagged command queuing 00065 #define TAG_QUEUING 1 00066 00067 #define BUSLOGIC_MAXIMUM_TAGS 128 00068 00069 // Define the maximum, maximum automatic, minimum automatic, and default Queue 00070 // Depth to allow for Target Devices depending on whether or not they support 00071 // Tagged Queuing and whether or not ISA Bounce Buffers are required. 00072 #define BusLogic_MaxTaggedQueueDepth 128 00073 00074 // Define the default amount of time in seconds to wait between a Host Adapter 00075 // Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands. 00076 // Some SCSI devices get confused if they receive SCSI commands too soon after 00077 // a SCSI Bus Reset. 00078 #define BusLogic_DefaultBusSettleTime 2 00079 00080 // Define the maximum number of Target Devices supported by this driver. 00081 #define BusLogic_MaxTargetDevices 16 00082 00083 // Define the maximum number of Logical unit supported/Target Devices supported by this driver. 00084 #define BusLogic_MaxLogicalUnits 32 00085 00086 // Define the maximum number of Mailboxes that should be used for MultiMaster 00087 // Host Adapters. This number is chosen to be larger than the maximum Host 00088 // Adapter Queue Depth and small enough so that the Host Adapter structure 00089 // does not cross an allocation block size boundary. 00090 #define BusLogic_MaxMailboxes 211 00091 00092 // Define the Fetch Host Adapter Local RAM request type. 00093 #define BusLogic_BIOS_BaseOffset 0 00094 #define BusLogic_AutoSCSI_BaseOffset 64 00095 00096 // Define the SCSI Command Descriptor Block (CDB). 00097 #define BusLogic_CDB_MaxLength 12 00098 00099 // Define the maximum number of Scatter/Gather Segments used by this driver. 00100 // For optimal performance, it is important that this limit be at least as 00101 // large as the largest single request generated by the I/O Subsystem. 00102 #define BusLogic_ScatterGatherLimit 128 00103 #define MAX_SG_LIMIT BusLogic_ScatterGatherLimit 00104 00105 #define BusLogic_AggressiveRoundRobinMode 0 00106 #define BusLogic_StrictRoundRobinMode 1 00107 00108 // Define the Codes for byte 3 (Request sense allocation length) of the CCB structure. 00109 #define BusLogic_Allocate14Bytes 0x00 00110 #define BusLogic_DisableAutoReqSense 0x01 00111 //_________________________________________________________________________________________ 00112 00113 00114 //_________________________________________________________________________________________ 00115 // typedef 00116 //_________________________________________________________________________________________ 00117 typedef enum 00118 { 00119 BusLogic_TestCommandCompleteInterrupt = 0x00, 00120 BusLogic_InitializeMailbox = 0x01, 00121 BusLogic_ExecuteMailboxCommand = 0x02, 00122 BusLogic_ExecuteBIOSCommand = 0x03, 00123 BusLogic_InquireBoardID = 0x04, 00124 BusLogic_EnableOutgoingMailboxAvailableInt = 0x05, 00125 BusLogic_SetSCSISelectionTimeout = 0x06, 00126 BusLogic_SetPreemptTimeOnBus = 0x07, 00127 BusLogic_SetTimeOffBus = 0x08, 00128 BusLogic_SetBusTransferRate = 0x09, 00129 BusLogic_InquireInstalledDevicesID0to7 =0x0A, 00130 BusLogic_InquireConfiguration = 0x0B, 00131 BusLogic_EnableTargetMode = 0x0C, 00132 BusLogic_InquireSetupInformation = 0x0D, 00133 BusLogic_WriteAdapterLocalRAM = 0x1A, 00134 BusLogic_ReadAdapterLocalRAM = 0x1B, 00135 BusLogic_WriteBusMasterChipFIFO = 0x1C, 00136 BusLogic_ReadBusMasterChipFIFO = 0x1D, 00137 BusLogic_EchoCommandData = 0x1F, 00138 BusLogic_HostAdapterDiagnostic = 0x20, 00139 BusLogic_SetAdapterOptions = 0x21, 00140 BusLogic_InquireInstalledDevicesID8to15 = 0x23, 00141 BusLogic_InquireTargetDevices = 0x24, 00142 BusLogic_DisableHostAdapterInterrupt = 0x25, 00143 BusLogic_InitializeExtendedMailbox = 0x81, 00144 BusLogic_ExecuteSCSICommand = 0x83, 00145 BusLogic_InquireFirmwareVersion3rdDigit = 0x84, 00146 BusLogic_InquireFirmwareVersionLetter = 0x85, 00147 BusLogic_InquirePCIHostAdapterInformation = 0x86, 00148 BusLogic_InquireHostAdapterModelNumber =0x8B, 00149 BusLogic_InquireSynchronousPeriod = 0x8C, 00150 BusLogic_InquireExtendedSetupInformation = 0x8D, 00151 BusLogic_EnableStrictRoundRobinMode = 0x8F, 00152 BusLogic_StoreHostAdapterLocalRAM = 0x90, 00153 BusLogic_FetchHostAdapterLocalRAM = 0x91, 00154 BusLogic_StoreLocalDataInEEPROM = 0x92, 00155 BusLogic_UploadAutoSCSICode = 0x94, 00156 BusLogic_ModifyIOAddress = 0x95, 00157 BusLogic_SetCCBFormat = 0x96, 00158 BusLogic_WriteInquiryBuffer = 0x9A, 00159 BusLogic_ReadInquiryBuffer = 0x9B, 00160 BusLogic_FlashROMUploadDownload = 0xA7, 00161 BusLogic_ReadSCAMData = 0xA8, 00162 BusLogic_WriteSCAMData = 0xA9 00163 }BusLogic_OperationCode_T; 00164 00165 00166 // Define the Requested Reply Length type used by the Inquire Setup Information, 00167 // Inquire Host Adapter Model Number, Inquire Synchronous Period, and Inquire 00168 // Extended Setup Information commands. 00169 typedef UCHAR BusLogic_RequestedReplyLength_T; 00170 00171 // Define a 32 bit Bus Address data type. 00172 typedef unsigned int BusLogic_BusAddress_T; 00173 00174 // Define the Inquire Host Adapter Model Number reply type. 00175 typedef UCHAR BusLogic_HostAdapterModelNumber_T[5]; 00176 00177 // Define the Inquire Firmware Version 3rd Digit reply type. 00178 typedef UCHAR BusLogic_FirmwareVersion3rdDigit_T; 00179 00180 // Define the Inquire Firmware Version Letter reply type. 00181 typedef UCHAR BusLogic_FirmwareVersionLetter_T; 00182 00183 // Define a 32 bit Byte Count data type. 00184 typedef unsigned int BusLogic_ByteCount_T; 00185 00186 typedef struct BusLogic_FetchHostAdapterLocalRAMRequest 00187 { 00188 UCHAR ByteOffset; // Byte 0 00189 UCHAR ByteCount; // Byte 1 00190 } 00191 BusLogic_FetchHostAdapterLocalRAMRequest_T; 00192 00193 // Define the Inquire PCI Host Adapter Information reply type. The ISA 00194 // Compatible I/O Port values are defined here and are also used with 00195 // the Modify I/O Address command. 00196 typedef enum BusLogic_ISACompatibleIOPort 00197 { 00198 BusLogic_IO_330 = 0, 00199 BusLogic_IO_334 = 1, 00200 BusLogic_IO_230 = 2, 00201 BusLogic_IO_234 = 3, 00202 BusLogic_IO_130 = 4, 00203 BusLogic_IO_134 = 5, 00204 BusLogic_IO_Disable = 6, 00205 BusLogic_IO_Disable2 = 7 00206 } 00207 BusLogic_ISACompatibleIOPort_T; 00208 00209 #pragma pack (1) 00210 typedef struct BusLogic_PCIHostAdapterInformation 00211 { 00212 UCHAR ISACompatibleIOPort; /* Byte 0 */ 00213 UCHAR PCIAssignedIRQChannel; /* Byte 1 */ 00214 BOOLEAN LowByteTerminated:1; /* Byte 2 Bit 0 */ 00215 BOOLEAN HighByteTerminated:1; /* Byte 2 Bit 1 */ 00216 UCHAR :2; /* Byte 2 Bits 2-3 */ 00217 BOOLEAN JP1:1; /* Byte 2 Bit 4 */ 00218 BOOLEAN JP2:1; /* Byte 2 Bit 5 */ 00219 BOOLEAN JP3:1; /* Byte 2 Bit 6 */ 00220 BOOLEAN GenericInfoValid:1; /* Byte 2 Bit 7 */ 00221 UCHAR :8; /* Byte 3 */ 00222 }BusLogic_PCIHostAdapterInformation_T; 00223 00224 // Define the Inquire Board ID reply structure. 00225 typedef struct BusLogic_BoardID 00226 { 00227 UCHAR BoardType; /* Byte 0 */ 00228 UCHAR CustomFeatures; /* Byte 1 */ 00229 UCHAR FirmwareVersion1stDigit; /* Byte 2 */ 00230 UCHAR FirmwareVersion2ndDigit; /* Byte 3 */ 00231 } BusLogic_BoardID_T; 00232 #pragma pack () 00233 00234 // Define the Host Adapter Target Flags structure. 00235 typedef struct BusLogic_TargetFlags 00236 { 00237 BOOLEAN TargetExists:1; 00238 BOOLEAN TaggedQueuingSupported:1; 00239 BOOLEAN WideTransfersSupported:1; 00240 BOOLEAN TaggedQueuingActive:1; 00241 BOOLEAN WideTransfersActive:1; 00242 BOOLEAN CommandSuccessfulFlag:1; 00243 BOOLEAN TargetInfoReported:1; 00244 } 00245 BusLogic_TargetFlags_T; 00246 00247 // Define the Host Adapter Target Statistics structure. 00248 #define BusLogic_SizeBuckets 10 00249 00250 // Define a 10^18 Statistics Byte Counter data type. 00251 typedef struct BusLogic_ByteCounter 00252 { 00253 unsigned int Units; 00254 unsigned int Billions; 00255 }BusLogic_ByteCounter_T; 00256 00257 typedef unsigned int BusLogic_CommandSizeBuckets_T[BusLogic_SizeBuckets]; 00258 00259 typedef struct BusLogic_TargetStatistics 00260 { 00261 unsigned int CommandsAttempted; 00262 unsigned int CommandsCompleted; 00263 unsigned int ReadCommands; 00264 unsigned int WriteCommands; 00265 BusLogic_ByteCounter_T TotalBytesRead; 00266 BusLogic_ByteCounter_T TotalBytesWritten; 00267 BusLogic_CommandSizeBuckets_T ReadCommandSizeBuckets; 00268 BusLogic_CommandSizeBuckets_T WriteCommandSizeBuckets; 00269 unsigned short CommandAbortsRequested; 00270 unsigned short CommandAbortsAttempted; 00271 unsigned short CommandAbortsCompleted; 00272 unsigned short BusDeviceResetsRequested; 00273 unsigned short BusDeviceResetsAttempted; 00274 unsigned short BusDeviceResetsCompleted; 00275 unsigned short HostAdapterResetsRequested; 00276 unsigned short HostAdapterResetsAttempted; 00277 unsigned short HostAdapterResetsCompleted; 00278 } 00279 BusLogic_TargetStatistics_T; 00280 00281 #pragma pack (1) 00282 // Define the Inquire Configuration reply structure. 00283 typedef struct BusLogic_Configuration 00284 { 00285 UCHAR :5; /* Byte 0 Bits 0-4 */ 00286 BOOLEAN DMA_Channel5:1; /* Byte 0 Bit 5 */ 00287 BOOLEAN DMA_Channel6:1; /* Byte 0 Bit 6 */ 00288 BOOLEAN DMA_Channel7:1; /* Byte 0 Bit 7 */ 00289 BOOLEAN IRQ_Channel9:1; /* Byte 1 Bit 0 */ 00290 BOOLEAN IRQ_Channel10:1; /* Byte 1 Bit 1 */ 00291 BOOLEAN IRQ_Channel11:1; /* Byte 1 Bit 2 */ 00292 BOOLEAN IRQ_Channel12:1; /* Byte 1 Bit 3 */ 00293 UCHAR :1; /* Byte 1 Bit 4 */ 00294 BOOLEAN IRQ_Channel14:1; /* Byte 1 Bit 5 */ 00295 BOOLEAN IRQ_Channel15:1; /* Byte 1 Bit 6 */ 00296 UCHAR :1; /* Byte 1 Bit 7 */ 00297 UCHAR HostAdapterID:4; /* Byte 2 Bits 0-3 */ 00298 UCHAR :4; /* Byte 2 Bits 4-7 */ 00299 }BusLogic_Configuration_T; 00300 00301 // Define the Inquire Setup Information reply structure. 00302 typedef struct BusLogic_SynchronousValue 00303 { 00304 UCHAR Offset:4; /* Bits 0-3 */ 00305 UCHAR TransferPeriod:3; /* Bits 4-6 */ 00306 BOOLEAN Synchronous:1; /* Bit 7 */ 00307 }BusLogic_SynchronousValue_T; 00308 00309 typedef BusLogic_SynchronousValue_T 00310 BusLogic_SynchronousValues8_T[8]; 00311 00312 typedef struct BusLogic_SetupInformation 00313 { 00314 BOOLEAN SynchronousInitiationEnabled:1; /* Byte 0 Bit 0 */ 00315 BOOLEAN ParityCheckingEnabled:1; /* Byte 0 Bit 1 */ 00316 UCHAR :6; /* Byte 0 Bits 2-7 */ 00317 UCHAR BusTransferRate; /* Byte 1 */ 00318 UCHAR PreemptTimeOnBus; /* Byte 2 */ 00319 UCHAR TimeOffBus; /* Byte 3 */ 00320 UCHAR MailboxCount; /* Byte 4 */ 00321 UCHAR MailboxAddress[3]; /* Bytes 5-7 */ 00322 BusLogic_SynchronousValues8_T SynchronousValuesID0to7; /* Bytes 8-15 */ 00323 UCHAR DisconnectPermittedID0to7; /* Byte 16 */ 00324 UCHAR Signature; /* Byte 17 */ 00325 UCHAR CharacterD; /* Byte 18 */ 00326 UCHAR HostBusType; /* Byte 19 */ 00327 UCHAR WideTransfersPermittedID0to7; /* Byte 20 */ 00328 UCHAR WideTransfersActiveID0to7; /* Byte 21 */ 00329 BusLogic_SynchronousValues8_T SynchronousValuesID8to15;/* Bytes 22-29 */ 00330 UCHAR DisconnectPermittedID8to15; /* Byte 30 */ 00331 UCHAR :8; /* Byte 31 */ 00332 UCHAR WideTransfersPermittedID8to15; /* Byte 32 */ 00333 UCHAR WideTransfersActiveID8to15; /* Byte 33 */ 00334 }BusLogic_SetupInformation_T; 00335 00336 // Something has to be done about the packing machanism of these structures - Namita 00337 // Define the Inquire Extended Setup Information reply structure. 00338 typedef struct BusLogic_ExtendedSetupInformation 00339 { 00340 UCHAR BusType; // Byte 0 00341 UCHAR BIOS_Address; // Byte 1 00342 unsigned short ScatterGatherLimit; // Bytes 2-3 00343 UCHAR MailboxCount; // Byte 4 00344 BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8 00345 struct 00346 { 00347 UCHAR :2; // Byte 9 Bits 0-1 00348 BOOLEAN FastOnEISA:1; // Byte 9 Bit 2 00349 UCHAR :3; // Byte 9 Bits 3-5 00350 BOOLEAN LevelSensitiveInterrupt:1; // Byte 9 Bit 6 00351 UCHAR :1; 00352 } Misc; // Byte 9 Bit 7 00353 UCHAR FirmwareRevision[3]; // Bytes 10-12 00354 BOOLEAN HostWideSCSI:1; // Byte 13 Bit 0 00355 BOOLEAN HostDifferentialSCSI:1; // Byte 13 Bit 1 00356 BOOLEAN HostSupportsSCAM:1; // Byte 13 Bit 2 00357 BOOLEAN HostUltraSCSI:1; // Byte 13 Bit 3 00358 BOOLEAN HostSmartTermination:1; // Byte 13 Bit 4 00359 UCHAR :3; // Byte 13 Bits 5-7 00360 }BusLogic_ExtendedSetupInformation_T; 00361 00362 // Define the Host Adapter Local RAM AutoSCSI structure. 00363 typedef struct BusLogic_AutoSCSIData 00364 { 00365 UCHAR InternalFactorySignature[2];/* Bytes 0-1 */ 00366 UCHAR InformationByteCount; /* Byte 2 */ 00367 UCHAR HostAdapterType[6]; /* Bytes 3-8 */ 00368 UCHAR :8; /* Byte 9 */ 00369 UCHAR FloppyEnabled:1; /* Byte 10 Bit 0 */ 00370 UCHAR FloppySecondary:1; /* Byte 10 Bit 1 */ 00371 UCHAR LevelSensitiveInterrupt:1; /* Byte 10 Bit 2 */ 00372 UCHAR :2; /* Byte 10 Bits 3-4 */ 00373 UCHAR SystemRAMAreaForBIOS:3; /* Byte 10 Bits 5-7 */ 00374 UCHAR DMA_Channel:7; /* Byte 11 Bits 0-6 */ 00375 UCHAR DMA_AutoConfiguration:1; /* Byte 11 Bit 7 */ 00376 UCHAR IRQ_Channel:7; /* Byte 12 Bits 0-6 */ 00377 UCHAR IRQ_AutoConfiguration:1; /* Byte 12 Bit 7 */ 00378 UCHAR DMA_TransferRate; /* Byte 13 */ 00379 UCHAR SCSI_ID; /* Byte 14 */ 00380 UCHAR LowByteTerminated:1; /* Byte 15 Bit 0 */ 00381 UCHAR ParityCheckingEnabled:1; /* Byte 15 Bit 1 */ 00382 UCHAR HighByteTerminated:1; /* Byte 15 Bit 2 */ 00383 UCHAR NoisyCablingEnvironment:1; /* Byte 15 Bit 3 */ 00384 UCHAR FastSynchronousNegotiation:1; /* Byte 15 Bit 4 */ 00385 UCHAR BusResetEnabled:1; /* Byte 15 Bit 5 */ 00386 UCHAR :1; /* Byte 15 Bit 6 */ 00387 UCHAR ActiveNegationEnabled:1; /* Byte 15 Bit 7 */ 00388 UCHAR BusOnDelay; /* Byte 16 */ 00389 UCHAR BusOffDelay; /* Byte 17 */ 00390 UCHAR HostAdapterBIOSEnabled:1; /* Byte 18 Bit 0 */ 00391 UCHAR BIOSRedirectionOfINT19Enabled:1; /* Byte 18 Bit 1 */ 00392 UCHAR ExtendedTranslationEnabled:1; /* Byte 18 Bit 2 */ 00393 UCHAR MapRemovableAsFixedEnabled:1; /* Byte 18 Bit 3 */ 00394 UCHAR :1; /* Byte 18 Bit 4 */ 00395 UCHAR BIOSSupportsMoreThan2DrivesEnabled:1;/* Byte 18 Bit 5 */ 00396 UCHAR BIOSInterruptModeEnabled:1; /* Byte 18 Bit 6 */ 00397 UCHAR FlopticalSupportEnabled:1; /* Byte 19 Bit 7 */ 00398 unsigned short DeviceEnabled:16; /* Bytes 19-20 */ 00399 unsigned short WidePermitted:16; /* Bytes 21-22 */ 00400 unsigned short FastPermitted:16; /* Bytes 23-24 */ 00401 unsigned short SynchronousPermitted:16; /* Bytes 25-26 */ 00402 unsigned short DisconnectPermitted:16; /* Bytes 27-28 */ 00403 unsigned short SendStartUnitCommand:16; /* Bytes 29-30 */ 00404 unsigned short IgnoreInBIOSScan:16; /* Bytes 31-32 */ 00405 UCHAR PCIInterruptPin:2; /* Byte 33 Bits 0-1 */ 00406 UCHAR HostAdapterIOPortAddress:2; /* Byte 33 Bits 2-3 */ 00407 UCHAR StrictRoundRobinModeEnabled:1; /* Byte 33 Bit 4 */ 00408 UCHAR VESABusSpeedGreaterThan33MHz:1; /* Byte 33 Bit 5 */ 00409 UCHAR VESABurstWriteEnabled:1; /* Byte 33 Bit 6 */ 00410 UCHAR VESABurstReadEnabled:1; /* Byte 33 Bit 7 */ 00411 unsigned short UltraPermitted:16; /* Bytes 34-35 */ 00412 unsigned int :32; /* Bytes 36-39 */ 00413 UCHAR :8; /* Byte 40 */ 00414 UCHAR AutoSCSIMaximumLUN; /* Byte 41 */ 00415 UCHAR :1; /* Byte 42 Bit 0 */ 00416 UCHAR SCAM_Dominant:1; /* Byte 42 Bit 1 */ 00417 UCHAR SCAM_Enabled:1; /* Byte 42 Bit 2 */ 00418 UCHAR SCAM_Level2:1; /* Byte 42 Bit 3 */ 00419 UCHAR :4; /* Byte 42 Bits 4-7 */ 00420 UCHAR INT13ExtensionEnabled:1; /* Byte 43 Bit 0 */ 00421 UCHAR :1; /* Byte 43 Bit 1 */ 00422 UCHAR CDROMBootEnabled:1; /* Byte 43 Bit 2 */ 00423 UCHAR :5; /* Byte 43 Bits 3-7 */ 00424 UCHAR BootTargetID:4; /* Byte 44 Bits 0-3 */ 00425 UCHAR BootChannel:4; /* Byte 44 Bits 4-7 */ 00426 UCHAR ForceBusDeviceScanningOrder:1; /* Byte 45 Bit 0 */ 00427 UCHAR :7; /* Byte 45 Bits 1-7 */ 00428 unsigned short NonTaggedToAlternateLUNPermitted; /* Bytes 46-47 */ 00429 unsigned short RenegotiateSyncAfterCheckCondition; /* Bytes 48-49 */ 00430 UCHAR Reserved[10]; /* Bytes 50-59 */ 00431 UCHAR ManufacturingDiagnostic[2]; /* Bytes 60-61 */ 00432 unsigned short Checksum:16; /* Bytes 62-63 */ 00433 }BusLogic_AutoSCSIData_T; 00434 #pragma pack() 00435 00436 // Define the Outgoing Mailbox Action Codes. 00437 typedef enum 00438 { 00439 BusLogic_OutgoingMailboxFree = 0x00, 00440 BusLogic_MailboxStartCommand = 0x01, 00441 BusLogic_MailboxAbortCommand = 0x02 00442 }BusLogic_ActionCode_T; 00443 00444 00445 // Define the Incoming Mailbox Completion Codes. The MultiMaster Firmware 00446 // only uses codes 0 - 4. The FlashPoint SCCB Manager has no mailboxes, so 00447 // completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5. 00448 typedef enum 00449 { 00450 BusLogic_IncomingMailboxFree = 0x00, 00451 BusLogic_CommandCompletedWithoutError = 0x01, 00452 BusLogic_CommandAbortedAtHostRequest = 0x02, 00453 BusLogic_AbortedCommandNotFound = 0x03, 00454 BusLogic_CommandCompletedWithError = 0x04, 00455 BusLogic_InvalidCCB = 0x05 00456 }BusLogic_CompletionCode_T; 00457 00458 // Define the Command Control Block (CCB) Opcodes. 00459 typedef enum 00460 { 00461 BusLogic_InitiatorCCB = 0x00, 00462 BusLogic_TargetCCB = 0x01, 00463 BusLogic_InitiatorCCB_ScatterGather = 0x02, 00464 BusLogic_InitiatorCCB_ResidualDataLength = 0x03, 00465 BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04, 00466 BusLogic_BusDeviceReset = 0x81 00467 }BusLogic_CCB_Opcode_T; 00468 00469 00470 // Define the CCB Data Direction Codes. 00471 typedef enum 00472 { 00473 BusLogic_UncheckedDataTransfer = 0, 00474 BusLogic_DataInLengthChecked = 1, 00475 BusLogic_DataOutLengthChecked = 2, 00476 BusLogic_NoDataTransfer = 3 00477 }BusLogic_DataDirection_T; 00478 00479 00480 // Define the Host Adapter Status Codes. The MultiMaster Firmware does not 00481 // return status code 0x0C; it uses 0x12 for both overruns and underruns. 00482 typedef enum 00483 { 00484 BusLogic_CommandCompletedNormally = 0x00, 00485 BusLogic_LinkedCommandCompleted = 0x0A, 00486 BusLogic_LinkedCommandCompletedWithFlag = 0x0B, 00487 BusLogic_DataUnderRun = 0x0C, 00488 BusLogic_SCSISelectionTimeout = 0x11, 00489 BusLogic_DataOverRun = 0x12, 00490 BusLogic_UnexpectedBusFree = 0x13, 00491 BusLogic_InvalidBusPhaseRequested = 0x14, 00492 BusLogic_InvalidOutgoingMailboxActionCode = 0x15, 00493 BusLogic_InvalidCommandOperationCode = 0x16, 00494 BusLogic_LinkedCCBhasInvalidLUN = 0x17, 00495 BusLogic_InvalidCommandParameter = 0x1A, 00496 BusLogic_AutoRequestSenseFailed = 0x1B, 00497 BusLogic_TaggedQueuingMessageRejected = 0x1C, 00498 BusLogic_UnsupportedMessageReceived = 0x1D, 00499 BusLogic_HostAdapterHardwareFailed = 0x20, 00500 BusLogic_TargetFailedResponseToATN = 0x21, 00501 BusLogic_HostAdapterAssertedRST = 0x22, 00502 BusLogic_OtherDeviceAssertedRST = 0x23, 00503 BusLogic_TargetDeviceReconnectedImproperly = 0x24, 00504 BusLogic_HostAdapterAssertedBusDeviceReset = 0x25, 00505 BusLogic_AbortQueueGenerated = 0x26, 00506 BusLogic_HostAdapterSoftwareError = 0x27, 00507 BusLogic_HostAdapterHardwareTimeoutError= 0x30, 00508 BusLogic_SCSIParityErrorDetected = 0x34 00509 }BusLogic_HostAdapterStatus_T; 00510 00511 // Define the SCSI Target Device Status Codes. 00512 typedef enum 00513 { 00514 BusLogic_OperationGood = 0x00, 00515 BusLogic_CheckCondition = 0x02, 00516 BusLogic_DeviceBusy = 0x08 00517 }BusLogic_TargetDeviceStatus_T; 00518 00519 // Define the Queue Tag Codes. 00520 typedef enum 00521 { 00522 BusLogic_SimpleQueueTag = 0, 00523 BusLogic_HeadOfQueueTag = 1, 00524 BusLogic_OrderedQueueTag = 2, 00525 BusLogic_ReservedQT = 3 00526 }BusLogic_QueueTag_T; 00527 00528 // Define the Scatter/Gather Segment structure required by the MultiMaster 00529 // Firmware Interface and the FlashPoint SCCB Manager. 00530 typedef struct BusLogic_ScatterGatherSegment 00531 { 00532 BusLogic_ByteCount_T SegmentByteCount; /* Bytes 0-3 */ 00533 BusLogic_BusAddress_T SegmentDataPointer; /* Bytes 4-7 */ 00534 }BusLogic_ScatterGatherSegment_T; 00535 00536 00537 typedef UCHAR SCSI_CDB_T[BusLogic_CDB_MaxLength]; 00538 00539 // Define the Driver CCB Status Codes. 00540 typedef enum 00541 { 00542 BusLogic_CCB_Free = 0, 00543 BusLogic_CCB_Active = 1, 00544 BusLogic_CCB_Completed = 2, 00545 BusLogic_CCB_Reset = 3 00546 }BusLogic_CCB_Status_T; 00547 00548 // Define the 32 Bit Mode Command Control Block (CCB) structure. The first 40 00549 // bytes are defined by the MultiMaster Firmware The remaining components are 00550 // defined by the Scsi MiniportDriver. 00551 // Extended LUN Format CCBs differ from Legacy LUN Format 32 Bit Mode 00552 // CCBs only in having the TagEnable and QueueTag fields moved from byte 17 to 00553 // byte 1, and the Logical Unit field in byte 17 expanded to 6 bits. In theory, 00554 // Extended LUN Format CCBs can support up to 64 Logical Units, but in practice 00555 // many devices will respond improperly to Logical Units between 32 and 63, and 00556 // the SCSI-2 specification defines Bit 5 as LUNTAR. Extended LUN Format CCBs 00557 // are used by recent versions of the MultiMaster Firmware. 00558 // Since 64 Logical Units are unlikely to be needed in practice, and 00559 // since they are problematic for the above reasons, and since limiting them to 00560 // 5 bits simplifies the CCB structure definition, this driver only supports 00561 // 32 Logical Units per Target Device. 00562 typedef struct BusLogic_CCB 00563 { 00564 UCHAR Opcode; /* Byte 0 */ 00565 UCHAR :3; /* Byte 1 Bits 0-2 */ 00566 UCHAR DataDirection:2; /* Byte 1 Bits 3-4 */ 00567 UCHAR TagEnable:1; /* Byte 1 Bit 5 */ 00568 UCHAR QueueTag:2; /* Byte 1 Bits 6-7 */ 00569 UCHAR CDB_Length; /* Byte 2 */ 00570 UCHAR SenseDataLength; /* Byte 3 */ 00571 BusLogic_ByteCount_T DataLength; /* Bytes 4-7 */ 00572 BusLogic_BusAddress_T DataPointer;/* Bytes 8-11 */ 00573 UCHAR :8; /* Byte 12 */ 00574 UCHAR :8; /* Byte 13 */ 00575 UCHAR HostAdapterStatus; /* Byte 14 */ 00576 UCHAR TargetDeviceStatus; /* Byte 15 */ 00577 UCHAR TargetID; /* Byte 16 */ 00578 UCHAR LogicalUnit:5; /* Byte 17 Bits 0-4 */ 00579 UCHAR LegacyTagEnable:1; /* Byte 17 Bit 5 */ 00580 UCHAR LegacyQueueTag:2; /* Byte 17 Bits 6-7 */ 00581 SCSI_CDB_T CDB; /* Bytes 18-29 */ 00582 UCHAR :8; /* Byte 30 */ 00583 UCHAR :8; /* Byte 31 */ 00584 unsigned int :32; /* Bytes 32-35 */ 00585 BusLogic_BusAddress_T SenseDataPointer;/* Bytes 36-39 */ 00586 00587 // BusLogic Driver Defined Portion. 00588 BusLogic_CCB_Status_T Status; 00589 unsigned long SerialNumber; 00590 struct BusLogic_HostAdapter *HostAdapter; 00591 struct BusLogic_CCB *Next; 00592 BusLogic_ScatterGatherSegment_T ScatterGatherList[BusLogic_ScatterGatherLimit]; 00593 00594 BusLogic_CompletionCode_T CompletionCode; 00595 // Pointer to the CCB 00596 PVOID SrbAddress; 00597 PVOID AbortSrb; 00598 }BusLogic_CCB_T, *PBuslogic_CCB_T; 00599 00600 #pragma pack(1) 00601 // Define the 32 Bit Mode Outgoing Mailbox structure. 00602 typedef struct BusLogic_OutgoingMailbox 00603 { 00604 BusLogic_BusAddress_T CCB;/* Bytes 0-3 */ 00605 UCHAR :8; /* Bytes 4 */ 00606 UCHAR :8; /* Bytes 5 */ 00607 UCHAR :8; /* Bytes 6 */ 00608 UCHAR ActionCode; /* Byte 7 */ 00609 }BusLogic_OutgoingMailbox_T; 00610 00611 // Define the 32 Bit Mode Incoming Mailbox structure. 00612 typedef struct BusLogic_IncomingMailbox 00613 { 00614 BusLogic_BusAddress_T CCB; /* Bytes 0-3 */ 00615 UCHAR HostAdapterStatus; /* Byte 4 */ 00616 UCHAR TargetDeviceStatus; /* Byte 5 */ 00617 UCHAR :8; /* Byte 6 */ 00618 UCHAR CompletionCode; /* Byte 7 */ 00619 }BusLogic_IncomingMailbox_T; 00620 #pragma pack () 00621 00622 // 00623 // The following structure is allocated 00624 // from noncached memory as data will be DMA'd to 00625 // and from it. 00626 typedef struct _NONCACHED_EXTENSION 00627 { 00628 // Physical base address of mailboxes 00629 ULONG MailboxPA; 00630 00631 // Mailboxes 00632 UCHAR MailboxOut[BusLogic_MaxMailboxes * sizeof(BusLogic_OutgoingMailbox_T)]; 00633 UCHAR MailboxIn[BusLogic_MaxMailboxes * sizeof(BusLogic_IncomingMailbox_T)]; 00634 } NONCACHED_EXTENSION, *PNONCACHED_EXTENSION; 00635 00636 // Define the types of BusLogic Host Adapters that are supported and the number 00637 // of I/O Addresses required by each type. 00638 typedef enum 00639 { 00640 BusLogic_MultiMaster = 1, 00641 BusLogic_FlashPoint = 2 00642 }BusLogic_HostAdapterType_T; 00643 00644 // Define the possible Host Adapter Bus Types. 00645 typedef enum 00646 { 00647 BusLogic_Unknown_Bus = 0, 00648 BusLogic_ISA_Bus = 1, 00649 BusLogic_EISA_Bus = 2, 00650 BusLogic_PCI_Bus = 3, 00651 BusLogic_VESA_Bus = 4, 00652 BusLogic_MCA_Bus = 5 00653 }BusLogic_HostAdapterBusType_T; 00654 00655 #if 0 00656 static char *BusLogic_HostAdapterBusNames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" }; 00657 #endif 00658 static BusLogic_HostAdapterBusType_T 00659 BusLogic_HostAdapterBusTypes[] ={ BusLogic_VESA_Bus, /* BT-4xx */ 00660 BusLogic_ISA_Bus, /* BT-5xx */ 00661 BusLogic_MCA_Bus, /* BT-6xx */ 00662 BusLogic_EISA_Bus, /* BT-7xx */ 00663 BusLogic_Unknown_Bus, /* BT-8xx */ 00664 BusLogic_PCI_Bus /* BT-9xx */ 00665 }; 00666 00667 // Define the BusLogic Driver Host Adapter structure 00668 typedef struct BusLogic_HostAdapter 00669 { 00670 00671 BusLogic_HostAdapterType_T HostAdapterType; 00672 BusLogic_HostAdapterBusType_T HostAdapterBusType; 00673 00674 UCHAR ModelName[9]; 00675 UCHAR FirmwareVersion[6]; 00676 UCHAR FullModelName[18]; 00677 UCHAR Bus; 00678 00679 PUCHAR IO_Address; 00680 UCHAR IRQ_Channel; 00681 UCHAR SCSI_ID; 00682 00683 BOOLEAN ExtendedTranslationEnabled:1; 00684 BOOLEAN ParityCheckingEnabled:1; 00685 BOOLEAN BusResetEnabled:1; 00686 BOOLEAN LevelSensitiveInterrupt:1; 00687 BOOLEAN HostWideSCSI:1; 00688 BOOLEAN HostDifferentialSCSI:1; 00689 BOOLEAN HostSupportsSCAM:1; 00690 BOOLEAN HostUltraSCSI:1; 00691 BOOLEAN ExtendedLUNSupport:1; 00692 BOOLEAN TerminationInfoValid:1; 00693 BOOLEAN LowByteTerminated:1; 00694 BOOLEAN HighByteTerminated:1; 00695 BOOLEAN BounceBuffersRequired:1; 00696 BOOLEAN StrictRoundRobinModeSupport:1; 00697 BOOLEAN SCAM_Enabled:1; 00698 BOOLEAN SCAM_Level2:1; 00699 BOOLEAN HostAdapterInitialized:1; 00700 BOOLEAN HostAdapterExternalReset:1; 00701 BOOLEAN HostAdapterInternalError:1; 00702 00703 BOOLEAN ProcessCompletedCCBsActive; 00704 volatile BOOLEAN HostAdapterCommandCompleted; 00705 unsigned short HostAdapterScatterGatherLimit; 00706 unsigned short DriverScatterGatherLimit; 00707 00708 UCHAR MaxTargetDevices; 00709 UCHAR MaxLogicalUnits; 00710 00711 unsigned short DriverQueueDepth; 00712 unsigned short HostAdapterQueueDepth; 00713 unsigned short UntaggedQueueDepth; 00714 unsigned short CommonQueueDepth; 00715 unsigned short BusSettleTime; 00716 unsigned short SynchronousPermitted; 00717 unsigned short FastPermitted; 00718 unsigned short UltraPermitted; 00719 unsigned short WidePermitted; 00720 unsigned short DisconnectPermitted; 00721 unsigned short TaggedQueuingPermitted; 00722 unsigned short ExternalHostAdapterResets; 00723 unsigned short HostAdapterInternalErrors; 00724 unsigned short TargetDeviceCount; 00725 00726 BusLogic_BusAddress_T BIOS_Address; 00727 00728 BusLogic_CCB_T *FirstCompletedCCB; 00729 BusLogic_CCB_T *LastCompletedCCB; 00730 BusLogic_CCB_T *BusDeviceResetPendingCCB[BusLogic_MaxTargetDevices]; 00731 00732 BusLogic_TargetFlags_T TargetFlags[BusLogic_MaxTargetDevices]; 00733 UCHAR SynchronousPeriod[BusLogic_MaxTargetDevices]; 00734 UCHAR SynchronousOffset[BusLogic_MaxTargetDevices]; 00735 UCHAR ActiveCommandsPerTarget[BusLogic_MaxTargetDevices]; 00736 UCHAR ActiveCommandsPerLun[BusLogic_MaxTargetDevices][BusLogic_MaxLogicalUnits]; 00737 unsigned int CommandsSinceReset[BusLogic_MaxTargetDevices]; 00738 unsigned long LastSequencePoint[BusLogic_MaxTargetDevices]; 00739 unsigned long LastResetAttempted[BusLogic_MaxTargetDevices]; 00740 unsigned long LastResetCompleted[BusLogic_MaxTargetDevices]; 00741 00742 UCHAR MailboxCount; 00743 BusLogic_OutgoingMailbox_T *FirstOutgoingMailbox; 00744 BusLogic_OutgoingMailbox_T *LastOutgoingMailbox; 00745 BusLogic_OutgoingMailbox_T *NextOutgoingMailbox; 00746 BusLogic_IncomingMailbox_T *FirstIncomingMailbox; 00747 BusLogic_IncomingMailbox_T *LastIncomingMailbox; 00748 BusLogic_IncomingMailbox_T *NextIncomingMailbox; 00749 BusLogic_TargetStatistics_T TargetStatistics[BusLogic_MaxTargetDevices]; 00750 }BusLogic_HostAdapter_T; 00751 00752 00753 // Buslogic specific port driver device object extension. 00754 typedef struct 00755 _HW_DEVICE_EXTENSION 00756 { 00757 BusLogic_HostAdapter_T hcs; 00758 PNONCACHED_EXTENSION NoncachedExtension; 00759 SCSI_WMILIB_CONTEXT WmiLibContext; 00760 00761 } HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION; 00762 00763 00764 // Define a structure for the SCSI Inquiry command results. 00765 #pragma pack (1) 00766 typedef struct SCSI_Inquiry 00767 { 00768 UCHAR PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */ 00769 UCHAR PeripheralQualifier:3; /* Byte 0 Bits 5-7 */ 00770 UCHAR DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */ 00771 BOOLEAN RMB:1; /* Byte 1 Bit 7 */ 00772 UCHAR ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */ 00773 UCHAR ECMA_Version:3; /* Byte 2 Bits 3-5 */ 00774 UCHAR ISO_Version:2; /* Byte 2 Bits 6-7 */ 00775 UCHAR ResponseDataFormat:4; /* Byte 3 Bits 0-3 */ 00776 UCHAR :2; /* Byte 3 Bits 4-5 */ 00777 BOOLEAN TrmIOP:1; /* Byte 3 Bit 6 */ 00778 BOOLEAN AENC:1; /* Byte 3 Bit 7 */ 00779 UCHAR AdditionalLength; /* Byte 4 */ 00780 UCHAR :8; /* Byte 5 */ 00781 UCHAR :8; /* Byte 6 */ 00782 BOOLEAN SftRe:1; /* Byte 7 Bit 0 */ 00783 BOOLEAN CmdQue:1; /* Byte 7 Bit 1 */ 00784 BOOLEAN :1; /* Byte 7 Bit 2 */ 00785 BOOLEAN Linked:1; /* Byte 7 Bit 3 */ 00786 BOOLEAN Sync:1; /* Byte 7 Bit 4 */ 00787 BOOLEAN WBus16:1; /* Byte 7 Bit 5 */ 00788 BOOLEAN WBus32:1; /* Byte 7 Bit 6 */ 00789 BOOLEAN RelAdr:1; /* Byte 7 Bit 7 */ 00790 UCHAR VendorIdentification[8];/* Bytes 8-15 */ 00791 UCHAR ProductIdentification[16];/* Bytes 16-31 */ 00792 UCHAR ProductRevisionLevel[4];/* Bytes 32-35 */ 00793 }SCSI_Inquiry_T; 00794 00795 typedef struct BusLogic_WmiExtendedSetupInformation 00796 { 00797 UCHAR BusType; // Byte 0 00798 UCHAR BIOS_Address; // Byte 1 00799 unsigned short ScatterGatherLimit; // Bytes 2-3 00800 UCHAR MailboxCount; // Byte 4 00801 BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8 00802 BOOLEAN FastOnEISA; // Byte 9 00803 BOOLEAN LevelSensitiveInterrupt; // Byte 10 00804 UCHAR FirmwareRevision[3]; // Bytes 11-14 00805 BOOLEAN HostWideSCSI; // Byte 15 00806 BOOLEAN HostDifferentialSCSI; // Byte 16 00807 BOOLEAN HostSupportsSCAM; // Byte 17 00808 BOOLEAN HostUltraSCSI; // Byte 18 00809 BOOLEAN HostSmartTermination; // Byte 19 00810 }BusLogic_WmiExtendedSetupInformation_T, *PBusLogic_WmiExtendedSetupInformation_T; 00811 00812 #pragma pack () 00813 00814 //_________________________________________________________________________________________ 00815 // function declaractions 00816 //_________________________________________________________________________________________ 00817 ULONG 00818 NTAPI 00819 DriverEntry(IN PVOID DriverObject, 00820 IN PVOID Argument2 00821 ); 00822 00823 ULONG 00824 NTAPI 00825 BT958HwFindAdapter(IN PVOID HwDeviceExtension, 00826 IN PVOID Context, 00827 IN PVOID BusInformation, 00828 IN PCHAR ArgumentString, 00829 IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, 00830 OUT PBOOLEAN Again 00831 ); 00832 00833 BOOLEAN 00834 NTAPI 00835 BT958HwInitialize(IN PVOID HwDeviceExtension); 00836 00837 BOOLEAN 00838 NTAPI 00839 BT958HwStartIO(IN PVOID HwDeviceExtension, 00840 IN PSCSI_REQUEST_BLOCK Srb 00841 ); 00842 00843 BOOLEAN 00844 NTAPI 00845 BT958HwInterrupt(IN PVOID HwDeviceExtension); 00846 00847 BOOLEAN 00848 NTAPI 00849 BT958HwResetBus(IN PVOID HwDeviceExtension, 00850 IN ULONG PathId 00851 ); 00852 00853 SCSI_ADAPTER_CONTROL_STATUS 00854 NTAPI 00855 BT958HwAdapterControl(IN PVOID HwDeviceExtension, 00856 IN SCSI_ADAPTER_CONTROL_TYPE ControlType, 00857 IN PVOID Parameters 00858 ); 00859 #if 0 00860 BOOLEAN 00861 BT958WmiSrb(IN PHW_DEVICE_EXTENSION HwDeviceExtension, 00862 IN OUT PSCSI_WMI_REQUEST_BLOCK Srb); 00863 #endif 00864 void 00865 BT958WmiInitialize( IN PHW_DEVICE_EXTENSION HwDeviceExtension); 00866 00867 00868 BOOLEAN 00869 Buslogic_InitBT958(PHW_DEVICE_EXTENSION deviceExtension, 00870 PPORT_CONFIGURATION_INFORMATION ConfigInfo); 00871 00872 BOOLEAN 00873 BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter); 00874 00875 BOOLEAN 00876 BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, 00877 BOOLEAN HardReset); 00878 00879 BOOLEAN 00880 BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter); 00881 00882 int 00883 BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, 00884 BusLogic_OperationCode_T OperationCode, 00885 void *ParameterData, 00886 int ParameterLength, 00887 void *ReplyData, 00888 int ReplyLength); 00889 00890 BOOLEAN 00891 BusLogic_ReadHostAdapterConfiguration( BusLogic_HostAdapter_T *HostAdapter); 00892 00893 BOOLEAN 00894 BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, 00895 PPORT_CONFIGURATION_INFORMATION ConfigInfo); 00896 00897 BOOLEAN 00898 BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *HostAdapter); 00899 00900 int 00901 BusLogic_QueueCommand(IN PVOID HwDeviceExtension, 00902 IN PSCSI_REQUEST_BLOCK Srb, 00903 IN PBuslogic_CCB_T ccb); 00904 00905 BOOLEAN 00906 BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension , 00907 BusLogic_ActionCode_T ActionCode, 00908 BusLogic_CCB_T *CCB); 00909 00910 void 00911 BusLogic_ScanIncomingMailboxes(PHW_DEVICE_EXTENSION deviceExtension); 00912 00913 void 00914 BusLogic_QueueCompletedCCB(PHW_DEVICE_EXTENSION deviceExtension, BusLogic_CCB_T *CCB); 00915 00916 void 00917 BusLogic_ProcessCompletedCCBs(PHW_DEVICE_EXTENSION deviceExtension); 00918 00919 UCHAR 00920 BusLogic_ComputeResultCode(BusLogic_HostAdapter_T *HostAdapter, 00921 BusLogic_HostAdapterStatus_T HostAdapterStatus, 00922 BusLogic_TargetDeviceStatus_T TargetDeviceStatus, 00923 UCHAR SenseDataLength); 00924 00925 BOOLEAN 00926 BusLogic_SendBusDeviceReset(IN PVOID HwDeviceExtension, 00927 PSCSI_REQUEST_BLOCK Srb); 00928 00929 static UCHAR 00930 ReadBusLogicPort(PUCHAR adr ) 00931 { 00932 return ScsiPortReadPortUchar( adr ); 00933 } 00934 00935 static VOID 00936 WriteBusLogicPort(UCHAR data, 00937 PUCHAR adr) 00938 { 00939 ScsiPortWritePortUchar(adr, data); 00940 } 00941 00942 //_________________________________________________________________________________________ 00943 // Declarations for the device registers and rewading and writing to them 00944 //_________________________________________________________________________________________ 00945 00946 // Define the BusLogic SCSI Host Adapter I/O Register Offsets. 00947 #define BusLogic_ControlRegisterOffset 0 // WO register 00948 #define BusLogic_StatusRegisterOffset 0 // RO register 00949 #define BusLogic_CommandParameterRegisterOffset 1 // WO register 00950 #define BusLogic_DataInRegisterOffset 1 // RO register 00951 #define BusLogic_InterruptRegisterOffset 2 // RO register 00952 #define BusLogic_GeometryRegisterOffset 3 // RO register 00953 00954 00955 // Define the structure of the write-only Control Register. 00956 typedef union BusLogic_ControlRegister 00957 { 00958 UCHAR All; 00959 struct 00960 { 00961 UCHAR :4; // Bits 0-3 00962 BOOLEAN SCSIBusReset:1; // Bit 4 00963 BOOLEAN InterruptReset:1; // Bit 5 00964 BOOLEAN SoftReset:1; // Bit 6 00965 BOOLEAN HardReset:1; // Bit 7 00966 } Bits; 00967 }BusLogic_ControlRegister_T; 00968 00969 00970 // Define the structure of the read-only Status Register. 00971 typedef union BusLogic_StatusRegister 00972 { 00973 UCHAR All; 00974 struct 00975 { 00976 BOOLEAN CommandInvalid:1; // Bit 0 00977 BOOLEAN Reserved:1; // Bit 1 00978 BOOLEAN DataInRegisterReady:1; // Bit 2 00979 BOOLEAN CommandParameterRegisterBusy:1; // Bit 3 00980 BOOLEAN HostAdapterReady:1; // Bit 4 00981 BOOLEAN InitializationRequired:1; // Bit 5 00982 BOOLEAN DiagnosticFailure:1; // Bit 6 00983 BOOLEAN DiagnosticActive:1; // Bit 7 00984 } Bits; 00985 }BusLogic_StatusRegister_T; 00986 00987 00988 00989 // Define the structure of the read-only Interrupt Register. 00990 typedef union BusLogic_InterruptRegister 00991 { 00992 UCHAR All; 00993 struct 00994 { 00995 BOOLEAN IncomingMailboxLoaded:1; // Bit 0 00996 BOOLEAN OutgoingMailboxAvailable:1; // Bit 1 00997 BOOLEAN CommandComplete:1; // Bit 2 00998 BOOLEAN ExternalBusReset:1; // Bit 3 00999 UCHAR Reserved:3; // Bits 4-6 01000 BOOLEAN InterruptValid:1; // Bit 7 01001 } Bits; 01002 }BusLogic_InterruptRegister_T; 01003 01004 // Define the possible Host Adapter BIOS Disk Geometry Translations. 01005 typedef enum BusLogic_BIOS_DiskGeometryTranslation 01006 { 01007 BusLogic_BIOS_Disk_Not_Installed = 0, 01008 BusLogic_BIOS_Disk_Installed_64x32 = 1, 01009 BusLogic_BIOS_Disk_Installed_128x32 = 2, 01010 BusLogic_BIOS_Disk_Installed_255x63 = 3 01011 }BusLogic_BIOS_DiskGeometryTranslation_T; 01012 01013 // Define the structure of the read-only Geometry Register 01014 typedef union BusLogic_GeometryRegister 01015 { 01016 UCHAR All; 01017 struct 01018 { 01019 BusLogic_BIOS_DiskGeometryTranslation_T Drive0Geometry:2; // Bits 0-1 01020 BusLogic_BIOS_DiskGeometryTranslation_T Drive1Geometry:2; // Bits 2-3 01021 UCHAR :3; // Bits 4-6 01022 BOOLEAN ExtendedTranslationEnabled:1; // Bit 7 01023 } Bits; 01024 } 01025 BusLogic_GeometryRegister_T; 01026 01027 static void 01028 BusLogic_InterruptReset(BusLogic_HostAdapter_T *HostAdapter) 01029 { 01030 BusLogic_ControlRegister_T ControlRegister; 01031 ControlRegister.All = 0; 01032 ControlRegister.Bits.InterruptReset = TRUE; 01033 01034 WriteBusLogicPort(ControlRegister.All, 01035 HostAdapter->IO_Address + BusLogic_ControlRegisterOffset); 01036 } 01037 01038 static void 01039 BusLogic_SoftReset(BusLogic_HostAdapter_T *HostAdapter) 01040 { 01041 BusLogic_ControlRegister_T ControlRegister; 01042 ControlRegister.All = 0; 01043 ControlRegister.Bits.SoftReset = TRUE; 01044 WriteBusLogicPort(ControlRegister.All, 01045 HostAdapter->IO_Address + BusLogic_ControlRegisterOffset); 01046 } 01047 01048 static void 01049 BusLogic_HardReset(BusLogic_HostAdapter_T *HostAdapter) 01050 { 01051 BusLogic_ControlRegister_T ControlRegister; 01052 ControlRegister.All = 0; 01053 ControlRegister.Bits.HardReset = TRUE; 01054 WriteBusLogicPort(ControlRegister.All, 01055 HostAdapter->IO_Address + BusLogic_ControlRegisterOffset); 01056 } 01057 01058 static UCHAR 01059 BusLogic_ReadStatusRegister(BusLogic_HostAdapter_T *HostAdapter) 01060 { 01061 return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset); 01062 } 01063 01064 static UCHAR 01065 BusLogic_ReadInterruptRegister(BusLogic_HostAdapter_T *HostAdapter) 01066 { 01067 return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset); 01068 } 01069 01070 static UCHAR 01071 BusLogic_ReadGeometryRegister(BusLogic_HostAdapter_T *HostAdapter) 01072 { 01073 return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset); 01074 } 01075 01076 static UCHAR 01077 BusLogic_ReadDataInRegister(BusLogic_HostAdapter_T *HostAdapter) 01078 { 01079 return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset); 01080 } 01081 01082 static void 01083 BusLogic_WriteCommandParameterRegister(BusLogic_HostAdapter_T *HostAdapter, 01084 UCHAR Value) 01085 { 01086 WriteBusLogicPort(Value, 01087 HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset); 01088 } 01089 01090 // BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which 01091 // notifies the Host Adapter that an entry has been made in an Outgoing 01092 // Mailbox. 01093 static void 01094 BusLogic_StartMailboxCommand(BusLogic_HostAdapter_T *HostAdapter) 01095 { 01096 BusLogic_WriteCommandParameterRegister(HostAdapter, 01097 BusLogic_ExecuteMailboxCommand); 01098 } 01099 01100 // Define the Inquire Synchronous Period reply type. For each Target Device, 01101 // a byte is returned which represents the Synchronous Transfer Period in units 01102 // of 10 nanoseconds. 01103 typedef UCHAR BusLogic_SynchronousPeriod_T[BusLogic_MaxTargetDevices]; 01104 01105 // Define the Inquire Installed Devices ID 0 to 7 and Inquire Installed 01106 // Devices ID 8 to 15 reply type. For each Target Device, a byte is returned 01107 // where bit 0 set indicates that Logical Unit 0 exists, bit 1 set indicates 01108 // that Logical Unit 1 exists, and so on. 01109 typedef UCHAR BusLogic_InstalledDevices8_T[8]; 01110 01111 // Define the Inquire Target Devices reply type. Inquire Target Devices only 01112 // tests Logical Unit 0 of each Target Device unlike the Inquire Installed 01113 // Devices commands which test Logical Units 0 - 7. Two bytes are returned, 01114 // where byte 0 bit 0 set indicates that Target Device 0 exists, and so on. 01115 typedef unsigned short BusLogic_InstalledDevices_T; 01116 01117 // Define the Initialize Extended Mailbox request structure. 01118 #pragma pack (1) 01119 typedef struct BusLogic_ExtendedMailboxRequest 01120 { 01121 UCHAR MailboxCount; /* Byte 0 */ 01122 ULONG BaseMailboxAddress; /* Bytes 1-4 */ 01123 }BusLogic_ExtendedMailboxRequest_T; 01124 #pragma pack () 01125 01126 // Define the Set CCB Format request type. Extended LUN Format CCBs are 01127 // necessary to support more than 8 Logical Units per Target Device. 01128 typedef enum BusLogic_SetCCBFormatRequest 01129 { 01130 BusLogic_LegacyLUNFormatCCB = 0, 01131 BusLogic_ExtendedLUNFormatCCB = 1 01132 }BusLogic_SetCCBFormatRequest_T; 01133 01134 //______________________________________________________________________________________ 01135 // Statistics 01136 //______________________________________________________________________________________ 01137 // BusLogic_IncrementByteCounter increments Byte Counter by Amount. 01138 static void 01139 BusLogic_IncrementByteCounter(BusLogic_ByteCounter_T *ByteCounter, 01140 unsigned int Amount) 01141 { 01142 ByteCounter->Units += Amount; 01143 if (ByteCounter->Units > 999999999) 01144 { 01145 ByteCounter->Units -= 1000000000; 01146 ByteCounter->Billions++; 01147 } 01148 } 01149 01150 // BusLogic_IncrementSizeBucket increments the Bucket for Amount. 01151 static void 01152 BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets, 01153 unsigned int Amount) 01154 { 01155 int Index = 0; 01156 if (Amount < 8*1024) 01157 { 01158 if (Amount < 2*1024) 01159 Index = (Amount < 1*1024 ? 0 : 1); 01160 else 01161 Index = (Amount < 4*1024 ? 2 : 3); 01162 } 01163 else if (Amount < 128*1024) 01164 { 01165 if (Amount < 32*1024) 01166 Index = (Amount < 16*1024 ? 4 : 5); 01167 else 01168 Index = (Amount < 64*1024 ? 6 : 7); 01169 } 01170 else 01171 Index = (Amount < 256*1024 ? 8 : 9); 01172 CommandSizeBuckets[Index]++; 01173 } 01174 01175 01176 // BusLogic_IncrementErrorCounter increments Error Counter by 1, stopping at 01177 // 65535 rather than wrapping around to 0. 01178 static void 01179 BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter) 01180 { 01181 if (*ErrorCounter < 65535) (*ErrorCounter)++; 01182 } 01183 //____________________________________________________________________________________________ Generated on Sat May 26 2012 04:27:01 for ReactOS by
1.7.6.1
|