diff --git a/reactos/drivers/storage/buslogic/BT958.mof b/reactos/drivers/storage/buslogic/BT958.mof index bdb4e7743a1..3566f0e23dc 100644 --- a/reactos/drivers/storage/buslogic/BT958.mof +++ b/reactos/drivers/storage/buslogic/BT958.mof @@ -17,14 +17,14 @@ class BT958ExtendedSetupInfoGuid [read, WmiDataId(3), WmiVersion(1)] uint16 ScatterGatherLimit; [read, WmiDataId(4), WmiVersion(1)] uint8 MailboxCount; [read, WmiDataId(5), WmiVersion(1)] uint32 BaseMailboxAddress; - [read, WmiDataId(6), WmiVersion(1)] boolean FastOnEISA:1; - [read, WmiDataId(7), WmiVersion(1)] boolean LevelSensitiveInterrupt:1; + [read, WmiDataId(6), WmiVersion(1)] boolean FastOnEISA; + [read, WmiDataId(7), WmiVersion(1)] boolean LevelSensitiveInterrupt; [read, WmiDataId(8), WmiVersion(1), max(3)] uint8 FirmwareRevision[]; - [read, WmiDataId(9), WmiVersion(1)] boolean HostWideSCSI:1; - [read, WmiDataId(10), WmiVersion(1)] boolean HostDifferentialSCSI:1; - [read, WmiDataId(11), WmiVersion(1)] boolean HostSupportsSCAM:1; - [read, WmiDataId(12), WmiVersion(1)] boolean HostUltraSCSI:1; - [read, WmiDataId(13), WmiVersion(1)] boolean HostSmartTermination:1; + [read, WmiDataId(9), WmiVersion(1)] boolean HostWideSCSI; + [read, WmiDataId(10), WmiVersion(1)] boolean HostDifferentialSCSI; + [read, WmiDataId(11), WmiVersion(1)] boolean HostSupportsSCAM; + [read, WmiDataId(12), WmiVersion(1)] boolean HostUltraSCSI; + [read, WmiDataId(13), WmiVersion(1)] boolean HostSmartTermination; }; diff --git a/reactos/drivers/storage/buslogic/BusLogic958.c b/reactos/drivers/storage/buslogic/BusLogic958.c index 0653c6e2810..ae5ac5be639 100644 --- a/reactos/drivers/storage/buslogic/BusLogic958.c +++ b/reactos/drivers/storage/buslogic/BusLogic958.c @@ -50,20 +50,30 @@ v1.0.0.5 // Sep 2001 release to VMware, with WMI | v v1.0.0.6 // Fix for bug with Nero Burning ROM in XP - | // where SCSI_AUTO_SENSE is turned off at times + | // where SCSI_AUTO_SENSE is turned off at times | | - |---------> v1.1.0.0 // Performance optimizations: - | | // A. WMI disabled, B. Queueing depth increased - | | // C. Control flow changed (bug) - | | - | v - | v1.1.0.1 // Fix for .NET restart freeze with 1.1.0.0 - | // Breaks on XP + |---------> v1.1.0.0 // Performance optimizations: + | | // A. WMI disabled, B. Queueing depth increased + | | // C. Control flow changed (bug) + | | + | v + | v1.1.0.1 // Fix for .NET restart freeze with 1.1.0.0 + | // Breaks on XP | v v1.2.0.0 // A. WMI disabled, B. Queueing depth increased - // CURRENT VERSION + | + | + | + v +v1.2.0.1 // Fix PR 40284, affects pure ACPI Win2k systems. + | + | + | + v +v1.2.0.2 // Fix PR 40284 correctly, disable interrupts in the initialization routine. + // CURRENT VERSION */ //____________________________________________________________________________________ @@ -72,8 +82,8 @@ v1.2.0.0 // A. WMI disabled, B. Queueing depth increased ULONG STDCALL DriverEntry(IN PVOID DriverObject, - IN PVOID Argument2 - ) + IN PVOID Argument2 + ) //_________________________________________________________________________ // Routine Description: // Installable driver initialization entry point for system. @@ -92,9 +102,9 @@ DriverEntry(IN PVOID DriverObject, UCHAR VendorId[4] = { '1', '0', '4', 'b' }; UCHAR DeviceId[4] = { '1', '0', '4', '0' }; - DebugPrint((0,"\n BusLogic - Inside the DriverEntry function \n")); + DebugPrint((TRACE,"\n BusLogic - Inside the DriverEntry function \n")); - // Zero out structure. + // Zero out structure. for (i = 0; i < sizeof(HW_INITIALIZATION_DATA); i++) { ((PUCHAR) & hwInitializationData)[i] = 0; @@ -131,7 +141,7 @@ DriverEntry(IN PVOID DriverObject, hwInitializationData.VendorIdLength = 4; hwInitializationData.DeviceId = &DeviceId; hwInitializationData.DeviceIdLength = 4; - + hwInitializationData.NumberOfAccessRanges = 2; @@ -144,15 +154,15 @@ DriverEntry(IN PVOID DriverObject, HwContext = 0; - DebugPrint((0,"\n BusLogic - Calling the ScsiPortInitialize Routine\n")); + DebugPrint((TRACE,"\n BusLogic - Calling the ScsiPortInitialize Routine\n")); Status = ScsiPortInitialize(DriverObject, - Argument2, - &hwInitializationData, - &HwContext); + Argument2, + &hwInitializationData, + &HwContext); - DebugPrint((0,"\n BusLogic - Exiting the DriverEntry function \n")); - DebugPrint((0,"\n BusLogic - Status = %ul \n", Status)); + DebugPrint((TRACE,"\n BusLogic - Exiting the DriverEntry function \n")); + DebugPrint((INFO,"\n BusLogic - Status = %ul \n", Status)); return( Status ); } // end DriverEntry() @@ -161,11 +171,12 @@ DriverEntry(IN PVOID DriverObject, ULONG STDCALL BT958HwFindAdapter(IN PVOID HwDeviceExtension, - IN PVOID Context, - IN PVOID BusInformation, - IN PCHAR ArgumentString, - IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, - OUT PBOOLEAN Again) + IN PVOID Context, + IN PVOID BusInformation, + IN PCHAR ArgumentString, + IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, + OUT PBOOLEAN Again + ) //_________________________________________________________________________________________________ // Routine Description: // This function is called by the OS-specific port driver after the necessary storage @@ -179,16 +190,16 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, // // Return Value: // HwScsiFindAdapter must return one of the following status values: -// SP_RETURN_FOUND: Indicates a supported HBA was found and that the HBA-relevant -// configuration information was successfully determined and set in -// the PORT_CONFIGURATION_INFORMATION structure. -// SP_RETURN_ERROR: Indicates an HBA was found but there was error obtaining the -// configuration information. If possible, such an error should be -// logged with ScsiPortLogError. -// SP_RETURN_BAD_CONFIG: Indicates the supplied configuration information was invalid -// for the adapter. -// SP_RETURN_NOT_FOUND: Indicates no supported HBA was found for the supplied -// configuration information. +// SP_RETURN_FOUND: Indicates a supported HBA was found and that the HBA-relevant +// configuration information was successfully determined and set in +// the PORT_CONFIGURATION_INFORMATION structure. +// SP_RETURN_ERROR: Indicates an HBA was found but there was error obtaining the +// configuration information. If possible, such an error should be +// logged with ScsiPortLogError. +// SP_RETURN_BAD_CONFIG: Indicates the supplied configuration information was invalid +// for the adapter. +// SP_RETURN_NOT_FOUND: Indicates no supported HBA was found for the supplied +// configuration information. //________________________________________________________________________________________________ { PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; @@ -199,7 +210,7 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, PUCHAR pciAddress, portFound; char NumPort = 0; - DebugPrint((0,"\n BusLogic - Inside the Find Adapter Routine\n")); + DebugPrint((TRACE,"\n BusLogic - Inside the Find Adapter Routine\n")); *Again = FALSE; @@ -214,50 +225,50 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, if ((*ConfigInfo->AccessRanges)[0].RangeLength != 0) { // check if the system supplied bus-relative address is valid and has not been - // claimed by anyother device - if ( ScsiPortValidateRange(deviceExtension, - ConfigInfo->AdapterInterfaceType, + // claimed by anyother device + if ( ScsiPortValidateRange(deviceExtension, + ConfigInfo->AdapterInterfaceType, ConfigInfo->SystemIoBusNumber, accessRange->RangeStart, accessRange->RangeLength, TRUE) ) // TRUE: iniospace - { - DebugPrint((0,"\n BusLogic - BusLogic - Validate Range function suceeded \n")); + { + DebugPrint((INFO,"\n BusLogic - Validate Range function succeeded \n")); - // Map the Bus-relative range addresses to system-space logical range addresses - // so that these mapped logical addresses can be called with SciPortRead/Writexxx - // to determine whether the adapter is an HBA that the driver supports + // Map the Bus-relative range addresses to system-space logical range addresses + // so that these mapped logical addresses can be called with SciPortRead/Writexxx + // to determine whether the adapter is an HBA that the driver supports - pciAddress = (PUCHAR) ScsiPortGetDeviceBase(deviceExtension, - ConfigInfo->AdapterInterfaceType, - ConfigInfo->SystemIoBusNumber, - accessRange->RangeStart, - accessRange->RangeLength, - TRUE); // TRUE: iniospace + pciAddress = (PUCHAR) ScsiPortGetDeviceBase(deviceExtension, + ConfigInfo->AdapterInterfaceType, + ConfigInfo->SystemIoBusNumber, + accessRange->RangeStart, + accessRange->RangeLength, + TRUE); // TRUE: iniospace - if(pciAddress) - { - DebugPrint((0,"\n BusLogic - Get Device Base function suceeded \n")); + if(pciAddress) + { + DebugPrint((INFO,"\n BusLogic - Get Device Base function succeeded \n")); - memset(hcsp, 0, sizeof(BusLogic_HostAdapter_T)); + memset(hcsp, 0, sizeof(BusLogic_HostAdapter_T)); - // points to structure of type BT958_HA which has device specific information. This needs - // to be either changed or modified with our specific info. - hcsp->IO_Address = pciAddress; - hcsp->IRQ_Channel = (UCHAR)ConfigInfo->BusInterruptLevel; - NumPort++; - } - } - } + // points to structure of type BT958_HA which has device specific information. This needs + // to be either changed or modified with our specific info. + hcsp->IO_Address = pciAddress; + hcsp->IRQ_Channel = (UCHAR)ConfigInfo->BusInterruptLevel; + NumPort++; + } + } + } if (NumPort == 0) - { + { return(SP_RETURN_NOT_FOUND); } // Hardware found, let's find out hardware configuration // and fill out ConfigInfo table for WinNT - ConfigInfo->NumberOfBuses = 1; + ConfigInfo->NumberOfBuses = 1; ConfigInfo->MaximumTransferLength = MAX_TRANSFER_SIZE; #if SG_SUPPORT @@ -277,13 +288,13 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, ConfigInfo->TaggedQueuing = FALSE; #endif - // Should we change this to double-word aligned to increase performance - ConfigInfo->AlignmentMask = 0x0; - + // Should we change this to double-word aligned to increase performance + ConfigInfo->AlignmentMask = 0x0; + portFound = hcsp->IO_Address; if (!Buslogic_InitBT958(deviceExtension,ConfigInfo)) // harware specific initializations. Find what's for our card - { + { ScsiPortLogError(deviceExtension, NULL, 0, @@ -293,9 +304,9 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, 7 << 8); return(SP_RETURN_ERROR); - } - - if (NumPort != 0) + } + + if (NumPort != 0) *Again = TRUE; return(SP_RETURN_FOUND); @@ -305,13 +316,13 @@ BT958HwFindAdapter(IN PVOID HwDeviceExtension, BOOLEAN Buslogic_InitBT958(PHW_DEVICE_EXTENSION deviceExtension, - PPORT_CONFIGURATION_INFORMATION ConfigInfo) + PPORT_CONFIGURATION_INFORMATION ConfigInfo) //_________________________________________________________________________ // Routine Description: -// This routine is called from the driver's FindAdapter routine -// On invocation this routine probes the host adapter to check -// if its hardware registers are responding correctly, and -// initializes the device and makes it ready for IO +// This routine is called from the driver's FindAdapter routine +// On invocation this routine probes the host adapter to check +// if its hardware registers are responding correctly, and +// initializes the device and makes it ready for IO // Arguments: // 1. deviceExtension // 2. Port Configuration info @@ -320,74 +331,86 @@ Buslogic_InitBT958(PHW_DEVICE_EXTENSION deviceExtension, // FALSE : Device failed to initialize //_________________________________________________________________________ { + CHAR ch; - BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); - - // Probe the Host Adapter. - // If unsuccessful, abort further initialization. + BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); + + // Probe the Host Adapter. + // If unsuccessful, abort further initialization. if (!BusLogic_ProbeHostAdapter(HostAdapter)) - return FALSE; + return FALSE; - // Hard Reset the Host Adapter. - // If unsuccessful, abort further initialization. + // Hard Reset the Host Adapter. + // If unsuccessful, abort further initialization. if (!BusLogic_HardwareResetHostAdapter(HostAdapter, TRUE)) - return FALSE; + return FALSE; - // Check the Host Adapter. - // If unsuccessful, abort further initialization. + /* + * PR 40284 -- Disable interrupts until driver initialization is complete. + */ + ch = 0; + if (BusLogic_Command(HostAdapter, BusLogic_DisableHostAdapterInterrupt, + &ch, sizeof(ch), NULL, 0) < 0) { + DebugPrint((WARNING, "\n BusLogic - Could not disable interrupts!\n")); + } else { + DebugPrint((INFO, "\n BusLogic - Disabled interrupts.\n")); + } + + // Check the Host Adapter. + // If unsuccessful, abort further initialization. if (!BusLogic_CheckHostAdapter(HostAdapter)) - return FALSE; - - // Allocate a Noncached Extension to use for mail boxes. - deviceExtension->NoncachedExtension = ScsiPortGetUncachedExtension(deviceExtension, - ConfigInfo, - sizeof(NONCACHED_EXTENSION)); + return FALSE; + + // Allocate a Noncached Extension to use for mail boxes. + deviceExtension->NoncachedExtension = ScsiPortGetUncachedExtension(deviceExtension, + ConfigInfo, + sizeof(NONCACHED_EXTENSION)); - if (deviceExtension->NoncachedExtension == NULL) - { - // Log error. - ScsiPortLogError(deviceExtension, - NULL, - 0, - 0, - 0, - SP_INTERNAL_ADAPTER_ERROR, - 7 << 8); + if (deviceExtension->NoncachedExtension == NULL) + { + // Log error. + ScsiPortLogError(deviceExtension, + NULL, + 0, + 0, + 0, + SP_INTERNAL_ADAPTER_ERROR, + 7 << 8); - // abort further initialization - return FALSE; - } + // abort further initialization + return FALSE; + } - // Read the Host Adapter Configuration, Configure the Host Adapter, - // Acquire the System Resources necessary to use the Host Adapter, then - // Create the Initial CCBs, Initialize the Host Adapter, and finally - // perform Target Device Inquiry. + // Read the Host Adapter Configuration, Configure the Host Adapter, + // Acquire the System Resources necessary to use the Host Adapter, then + // Create the Initial CCBs, Initialize the Host Adapter, and finally + // perform Target Device Inquiry. if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) && - //BusLogic_ReportHostAdapterConfiguration(HostAdapter) && - BusLogic_InitializeHostAdapter(deviceExtension, ConfigInfo) && - BusLogic_TargetDeviceInquiry(HostAdapter)) - { - // Fill in the: - // 1.Maximum number of scsi target devices that are supported by our adapter - ConfigInfo->MaximumNumberOfTargets = HostAdapter->MaxTargetDevices; - // 2. Maximum number of logical units per target the HBA can control. - ConfigInfo->MaximumNumberOfLogicalUnits = HostAdapter->MaxLogicalUnits; - ConfigInfo->InitiatorBusId[0] = HostAdapter->SCSI_ID; - // Maximum number of breaks between address ranges that a data buffer can - // have if the HBA supports scatter/gather. In other words, the number of - // scatter/gather lists minus one. - ConfigInfo->NumberOfPhysicalBreaks = HostAdapter->DriverScatterGatherLimit; - } + //BusLogic_ReportHostAdapterConfiguration(HostAdapter) && + BusLogic_InitializeHostAdapter(deviceExtension, ConfigInfo) && + BusLogic_TargetDeviceInquiry(HostAdapter)) + { + // Fill in the: + // 1.Maximum number of scsi target devices that are supported by our adapter + ConfigInfo->MaximumNumberOfTargets = HostAdapter->MaxTargetDevices; + // 2. Maximum number of logical units per target the HBA can control. + ConfigInfo->MaximumNumberOfLogicalUnits = HostAdapter->MaxLogicalUnits; + ConfigInfo->InitiatorBusId[0] = HostAdapter->SCSI_ID; + // Maximum number of breaks between address ranges that a data buffer can + // have if the HBA supports scatter/gather. In other words, the number of + // scatter/gather lists minus one. + ConfigInfo->NumberOfPhysicalBreaks = HostAdapter->DriverScatterGatherLimit; + } else - { - // An error occurred during Host Adapter Configuration Querying, Host - // Adapter Configuration, Host Adapter Initialization, or Target Device Inquiry, - // so return FALSE - - return FALSE; - } - // Initialization completed successfully - return TRUE; + { + // An error occurred during Host Adapter Configuration Querying, Host + // Adapter Configuration, Host Adapter Initialization, or Target Device Inquiry, + // so return FALSE + + return FALSE; + } + // Initialization completed successfully + return TRUE; } // end Buslogic_InitBT958 @@ -395,8 +418,8 @@ BOOLEAN BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter) //____________________________________________________________________________________ // Routine Description: BusLogic_ProbeHostAdapter probes for a BusLogic Host Adapter. -// The routine reads the status, interrupt and geometry regiter and -// checks if their contents are valid +// The routine reads the status, interrupt and geometry regiter and +// checks if their contents are valid // Arguments: // 1. Host Adapter structure // @@ -409,7 +432,7 @@ BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter) BusLogic_InterruptRegister_T InterruptRegister; BusLogic_GeometryRegister_T GeometryRegister; - DebugPrint((0,"\n BusLogic - Inside ProbeHostaAdapter funtion \n")); + DebugPrint((TRACE,"\n BusLogic - Inside ProbeHostaAdapter function \n")); // Read the Status, Interrupt, and Geometry Registers to test if there are I/O // ports that respond, and to check the values to determine if they are from a // BusLogic Host Adapter. A nonexistent I/O port will return 0xFF, in which @@ -447,12 +470,12 @@ BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter) BOOLEAN BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, - BOOLEAN HardReset) + BOOLEAN HardReset) //_________________________________________________________________________ // Routine Description: BusLogic_HardwareResetHostAdapter issues a Hardware // Reset to the Host Adapter and waits for Host Adapter // Diagnostics to complete. If HardReset is TRUE, a -// Hard Reset is performed which also initiates a SCSI +// Hard Reset is performed which also initiates a SCSI // Bus Reset. Otherwise, a Soft Reset is performed which // only resets the Host Adapter without forcing a SCSI // Bus Reset. @@ -470,23 +493,22 @@ BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, // Issue a Hard Reset or Soft Reset Command to the Host Adapter. The Host // Adapter should respond by setting Diagnostic Active in the Status Register. if (HardReset) - BusLogic_HardReset(HostAdapter); + BusLogic_HardReset(HostAdapter); else - BusLogic_SoftReset(HostAdapter); + BusLogic_SoftReset(HostAdapter); // Wait until Diagnostic Active is set in the Status Register. - TimeoutCounter = 5*10000; + TimeoutCounter = 100; while (--TimeoutCounter >= 0) { StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if (StatusRegister.Bits.DiagnosticActive) - break; - ScsiPortStallExecution(100); + break; } // if inspite of waiting for time out period , if it didn't et set, then something is wrong-- so just return. if (TimeoutCounter < 0) - return FALSE; + return FALSE; // // Wait 100 microseconds to allow completion of any initial diagnostic @@ -500,12 +522,12 @@ BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, { StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if (!StatusRegister.Bits.DiagnosticActive) - break; + break; ScsiPortStallExecution(100); } if (TimeoutCounter < 0) - return FALSE; + return FALSE; // Wait until at least one of the Diagnostic Failure, Host Adapter Ready, // or Data In Register Ready bits is set in the Status Register. @@ -514,31 +536,33 @@ BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, { StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if (StatusRegister.Bits.DiagnosticFailure || - StatusRegister.Bits.HostAdapterReady || - StatusRegister.Bits.DataInRegisterReady) - { - break; - } + StatusRegister.Bits.HostAdapterReady || + StatusRegister.Bits.DataInRegisterReady) + { + break; + } ScsiPortStallExecution(100); } //device didn't respond to reset if (TimeoutCounter < 0) - return FALSE; + return FALSE; // If Diagnostic Failure is set or Host Adapter Ready is reset, then an // error occurred during the Host Adapter diagnostics. If Data In Register // Ready is set, then there is an Error Code available. if (StatusRegister.Bits.DiagnosticFailure || !StatusRegister.Bits.HostAdapterReady) { - DebugPrint((0,"Failure - HOST ADAPTER STATUS REGISTER = %02X\n", StatusRegister.All)); + DebugPrint((ERROR, "\n BusLogic - Failure - HOST ADAPTER STATUS REGISTER = %02X\n", StatusRegister.All)); if (StatusRegister.Bits.DataInRegisterReady) - { - DebugPrint((0,"HOST ADAPTER ERROR CODE = %d\n", BusLogic_ReadDataInRegister(HostAdapter))); - } + { + UCHAR ErrorCode = BusLogic_ReadDataInRegister(HostAdapter); + DebugPrint((ERROR, "HOST ADAPTER ERROR CODE = %d\n", ErrorCode)); + } return FALSE; - } + } + // Indicate the Host Adapter Hard Reset completed successfully. return TRUE; }// end BusLogic_HardwareResetHostAdapter @@ -560,7 +584,7 @@ BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter) BusLogic_RequestedReplyLength_T RequestedReplyLength; BOOLEAN Result = TRUE; - DebugPrint((0,"\n BusLogic - Inside BusLogic_CheckHostAdapter funtion \n")); + DebugPrint((TRACE, "\n BusLogic - Inside BusLogic_CheckHostAdapter function \n")); // // Issue the Inquire Extended Setup Information command. Only genuine @@ -569,11 +593,11 @@ BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter) // fail this command. RequestedReplyLength = sizeof(ExtendedSetupInformation); if (BusLogic_Command(HostAdapter, - BusLogic_InquireExtendedSetupInformation, - &RequestedReplyLength, - sizeof(RequestedReplyLength), - &ExtendedSetupInformation, - sizeof(ExtendedSetupInformation)) + BusLogic_InquireExtendedSetupInformation, + &RequestedReplyLength, + sizeof(RequestedReplyLength), + &ExtendedSetupInformation, + sizeof(ExtendedSetupInformation)) != sizeof(ExtendedSetupInformation)) { Result = FALSE; @@ -583,36 +607,36 @@ BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter) int BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, - BusLogic_OperationCode_T OperationCode, - void *ParameterData, - int ParameterLength, - void *ReplyData, - int ReplyLength) + BusLogic_OperationCode_T OperationCode, + void *ParameterData, + int ParameterLength, + void *ReplyData, + int ReplyLength) //______________________________________________________________________________________________ // Routine Description: -// BusLogic_Command sends the command OperationCode to HostAdapter, optionally -// providing ParameterLength bytes of ParameterData and receiving at most -// ReplyLength bytes of ReplyData; any excess reply data is received but -// discarded. +// BusLogic_Command sends the command OperationCode to HostAdapter, optionally +// providing ParameterLength bytes of ParameterData and receiving at most +// ReplyLength bytes of ReplyData; any excess reply data is received but +// discarded. // -// BusLogic_Command is called exclusively during host adapter detection and -// initialization, so performance and latency are not critical, and exclusive -// access to the Host Adapter hardware is assumed. Once the host adapter and -// driver are initialized, the only Host Adapter command that is issued is the -// single byte Execute Mailbox Command operation code, which does not require -// waiting for the Host Adapter Ready bit to be set in the Status Register. +// BusLogic_Command is called exclusively during host adapter detection and +// initialization, so performance and latency are not critical, and exclusive +// access to the Host Adapter hardware is assumed. Once the host adapter and +// driver are initialized, the only Host Adapter command that is issued is the +// single byte Execute Mailbox Command operation code, which does not require +// waiting for the Host Adapter Ready bit to be set in the Status Register. // Arguments: // 1. HostAdapter - Host Adapter structure // 2. OperationCode - Operation code for the command -// 3. ParameterData - Buffer containing parameters that needs to be passed as part -// of the command -// 4. ParameterLength - Number of parameters -// 5. ReplyData - Buffer where reply data is copied -// 6. ReplyLength - The length of the reply data +// 3. ParameterData - Buffer containing parameters that needs to be passed as part +// of the command +// 4. ParameterLength - Number of parameters +// 5. ReplyData - Buffer where reply data is copied +// 6. ReplyLength - The length of the reply data // Return Value: -// On success, this function returns the number of reply bytes read from -// the Host Adapter (including any discarded data); on failure, it returns -// -1 if the command was invalid, or -2 if a timeout occurred. +// On success, this function returns the number of reply bytes read from +// the Host Adapter (including any discarded data); on failure, it returns +// -1 if the command was invalid, or -2 if a timeout occurred. //_________________________________________________________________________________________________ { UCHAR *ParameterPointer = (UCHAR *) ParameterData; @@ -638,10 +662,10 @@ BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, { StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if ( StatusRegister.Bits.HostAdapterReady && - !StatusRegister.Bits.CommandParameterRegisterBusy) - { - break; - } + !StatusRegister.Bits.CommandParameterRegisterBusy) + { + break; + } ScsiPortStallExecution(100); } if (TimeoutCounter < 0) @@ -660,28 +684,28 @@ BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, while (ParameterLength > 0 && --TimeoutCounter >= 0) { // - // Wait 100 microseconds to give the Host Adapter enough time to determine - // whether the last value written to the Command/Parameter Register was - // valid or not. If the Command Complete bit is set in the Interrupt - // Register, then the Command Invalid bit in the Status Register will be - // reset if the Operation Code or Parameter was valid and the command - // has completed, or set if the Operation Code or Parameter was invalid. - // If the Data In Register Ready bit is set in the Status Register, then - // the Operation Code was valid, and data is waiting to be read back - // from the Host Adapter. Otherwise, wait for the Command/Parameter - // Register Busy bit in the Status Register to be reset. + // Wait 100 microseconds to give the Host Adapter enough time to determine + // whether the last value written to the Command/Parameter Register was + // valid or not. If the Command Complete bit is set in the Interrupt + // Register, then the Command Invalid bit in the Status Register will be + // reset if the Operation Code or Parameter was valid and the command + // has completed, or set if the Operation Code or Parameter was invalid. + // If the Data In Register Ready bit is set in the Status Register, then + // the Operation Code was valid, and data is waiting to be read back + // from the Host Adapter. Otherwise, wait for the Command/Parameter + // Register Busy bit in the Status Register to be reset. ScsiPortStallExecution(100); InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter); StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if (InterruptRegister.Bits.CommandComplete) - break; + break; if (HostAdapter->HostAdapterCommandCompleted) - break; + break; if (StatusRegister.Bits.DataInRegisterReady) - break; + break; if (StatusRegister.Bits.CommandParameterRegisterBusy) - continue; + continue; BusLogic_WriteCommandParameterRegister(HostAdapter, *ParameterPointer++); ParameterLength--; } @@ -697,11 +721,11 @@ BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, { StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if (StatusRegister.Bits.CommandInvalid) - { - //BusLogic_CommandFailureReason = "Modify I/O Address Invalid"; - Result = -1; - goto Done; - } + { + //BusLogic_CommandFailureReason = "Modify I/O Address Invalid"; + Result = -1; + goto Done; + } Result = 0; goto Done; } @@ -730,25 +754,25 @@ BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter); StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); if (InterruptRegister.Bits.CommandComplete) - break; + break; if (HostAdapter->HostAdapterCommandCompleted) - break; + break; if (StatusRegister.Bits.DataInRegisterReady) - { - if (++ReplyBytes <= ReplyLength) - { - *ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter); - } - else - { - BusLogic_ReadDataInRegister(HostAdapter); - } - } + { + if (++ReplyBytes <= ReplyLength) + { + *ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter); + } + else + { + BusLogic_ReadDataInRegister(HostAdapter); + } + } if (OperationCode == BusLogic_FetchHostAdapterLocalRAM && - StatusRegister.Bits.HostAdapterReady) - { - break; - } + StatusRegister.Bits.HostAdapterReady) + { + break; + } ScsiPortStallExecution(100); } if (TimeoutCounter < 0) @@ -765,30 +789,30 @@ BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, if (StatusRegister.Bits.CommandInvalid) { // - // Some early BusLogic Host Adapters may not recover properly from - // a Command Invalid condition, so if this appears to be the case, - // a Soft Reset is issued to the Host Adapter. Potentially invalid - // commands are never attempted after Mailbox Initialization is - // performed, so there should be no Host Adapter state lost by a - // Soft Reset in response to a Command Invalid condition. + // Some early BusLogic Host Adapters may not recover properly from + // a Command Invalid condition, so if this appears to be the case, + // a Soft Reset is issued to the Host Adapter. Potentially invalid + // commands are never attempted after Mailbox Initialization is + // performed, so there should be no Host Adapter state lost by a + // Soft Reset in response to a Command Invalid condition. - ScsiPortStallExecution(1000); - StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); - if (StatusRegister.Bits.CommandInvalid || - StatusRegister.Bits.Reserved || - StatusRegister.Bits.DataInRegisterReady || - StatusRegister.Bits.CommandParameterRegisterBusy || - !StatusRegister.Bits.HostAdapterReady || - !StatusRegister.Bits.InitializationRequired || - StatusRegister.Bits.DiagnosticActive || - StatusRegister.Bits.DiagnosticFailure) - { - BusLogic_SoftReset(HostAdapter); - ScsiPortStallExecution(1000); - } - //BusLogic_CommandFailureReason = "Command Invalid"; - Result = -1; - goto Done; + ScsiPortStallExecution(1000); + StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter); + if (StatusRegister.Bits.CommandInvalid || + StatusRegister.Bits.Reserved || + StatusRegister.Bits.DataInRegisterReady || + StatusRegister.Bits.CommandParameterRegisterBusy || + !StatusRegister.Bits.HostAdapterReady || + !StatusRegister.Bits.InitializationRequired || + StatusRegister.Bits.DiagnosticActive || + StatusRegister.Bits.DiagnosticFailure) + { + BusLogic_SoftReset(HostAdapter); + ScsiPortStallExecution(1000); + } + //BusLogic_CommandFailureReason = "Command Invalid"; + Result = -1; + goto Done; } // Handle Excess Parameters Supplied conditions. @@ -812,8 +836,8 @@ BOOLEAN BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) //___________________________________________________________________________________________ // Routine Description: -// BusLogic_ReadHostAdapterConfiguration reads the Configuration Information -// from Host Adapter and initializes the Host Adapter structure. +// BusLogic_ReadHostAdapterConfiguration reads the Configuration Information +// from Host Adapter and initializes the Host Adapter structure. // Arguments: // 1. Host adapter structure // Return Value: @@ -839,53 +863,53 @@ BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) // Issue the Inquire Board ID command. if (BusLogic_Command(HostAdapter, - BusLogic_InquireBoardID, - NULL, - 0, - &BoardID, sizeof(BoardID)) - != sizeof(BoardID)) + BusLogic_InquireBoardID, + NULL, + 0, + &BoardID, sizeof(BoardID)) + != sizeof(BoardID)) { - DebugPrint((0,"BusLogic_Failure: INQUIRE BOARD ID")); - return FALSE; + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE BOARD ID\n")); + return FALSE; } // Issue the Inquire Configuration command. if (BusLogic_Command(HostAdapter, - BusLogic_InquireConfiguration, - NULL, - 0, - &Configuration, sizeof(Configuration)) + BusLogic_InquireConfiguration, + NULL, + 0, + &Configuration, sizeof(Configuration)) != sizeof(Configuration)) { - DebugPrint((0,"BusLogic_Failure: INQUIRE CONFIGURATION")); + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE CONFIGURATION\n")); return FALSE; } // Issue the Inquire Setup Information command. RequestedReplyLength = sizeof(SetupInformation); if (BusLogic_Command(HostAdapter, - BusLogic_InquireSetupInformation, - &RequestedReplyLength, - sizeof(RequestedReplyLength), - &SetupInformation, - sizeof(SetupInformation)) + BusLogic_InquireSetupInformation, + &RequestedReplyLength, + sizeof(RequestedReplyLength), + &SetupInformation, + sizeof(SetupInformation)) != sizeof(SetupInformation)) { - DebugPrint((0,"BusLogic_Failure: INQUIRE SETUP INFORMATION")); - return FALSE; + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE SETUP INFORMATION\n")); + return FALSE; } // Issue the Inquire Extended Setup Information command. RequestedReplyLength = sizeof(ExtendedSetupInformation); if (BusLogic_Command(HostAdapter, - BusLogic_InquireExtendedSetupInformation, - &RequestedReplyLength, - sizeof(RequestedReplyLength), - &ExtendedSetupInformation, - sizeof(ExtendedSetupInformation)) + BusLogic_InquireExtendedSetupInformation, + &RequestedReplyLength, + sizeof(RequestedReplyLength), + &ExtendedSetupInformation, + sizeof(ExtendedSetupInformation)) != sizeof(ExtendedSetupInformation)) { - DebugPrint((0,"BusLogic_Failure: INQUIRE EXTENDED SETUP INFORMATION")); + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE EXTENDED SETUP INFORMATION\n")); return FALSE; } @@ -894,37 +918,37 @@ BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) if (BoardID.FirmwareVersion1stDigit > '0') { if (BusLogic_Command(HostAdapter, - BusLogic_InquireFirmwareVersion3rdDigit, - NULL, - 0, - &FirmwareVersion3rdDigit, - sizeof(FirmwareVersion3rdDigit)) - != sizeof(FirmwareVersion3rdDigit)) - { - DebugPrint((0,"BusLogic_Failure: INQUIRE FIRMWARE 3RD DIGIT")); - return FALSE; - } + BusLogic_InquireFirmwareVersion3rdDigit, + NULL, + 0, + &FirmwareVersion3rdDigit, + sizeof(FirmwareVersion3rdDigit)) + != sizeof(FirmwareVersion3rdDigit)) + { + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE FIRMWARE 3RD DIGIT\n")); + return FALSE; + } } // Issue the Inquire Host Adapter Model Number command. RequestedReplyLength = sizeof(HostAdapterModelNumber); if (BusLogic_Command(HostAdapter, - BusLogic_InquireHostAdapterModelNumber, - &RequestedReplyLength, - sizeof(RequestedReplyLength), - &HostAdapterModelNumber, - sizeof(HostAdapterModelNumber)) - != sizeof(HostAdapterModelNumber)) + BusLogic_InquireHostAdapterModelNumber, + &RequestedReplyLength, + sizeof(RequestedReplyLength), + &HostAdapterModelNumber, + sizeof(HostAdapterModelNumber)) + != sizeof(HostAdapterModelNumber)) { - DebugPrint((0,"BusLogic_Failure: INQUIRE HOST ADAPTER MODEL NUMBER")); - return FALSE; + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE HOST ADAPTER MODEL NUMBER\n")); + return FALSE; } // BusLogic MultiMaster Host Adapters can be identified by their model number // and the major version number of their firmware as follows: - // - // 5.xx BusLogic "W" Series Host Adapters: - // BT-948/958/958D + // + // 5.xx BusLogic "W" Series Host Adapters: + // BT-948/958/958D // Save the Model Name and Host Adapter Name in the Host Adapter structure. TargetPointer = HostAdapter->ModelName; *TargetPointer++ = 'B'; @@ -951,20 +975,20 @@ BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) if (strcmp((char*)HostAdapter->FirmwareVersion, "3.3") >= 0) { if (BusLogic_Command(HostAdapter, - BusLogic_InquireFirmwareVersionLetter, - NULL, - 0, - &FirmwareVersionLetter, - sizeof(FirmwareVersionLetter)) - != sizeof(FirmwareVersionLetter)) - { - DebugPrint((0,"BusLogic_Failure: INQUIRE FIRMWARE VERSION LETTER")); - return FALSE; - } + BusLogic_InquireFirmwareVersionLetter, + NULL, + 0, + &FirmwareVersionLetter, + sizeof(FirmwareVersionLetter)) + != sizeof(FirmwareVersionLetter)) + { + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE FIRMWARE VERSION LETTER\n")); + return FALSE; + } if (FirmwareVersionLetter != ' ' && FirmwareVersionLetter != '\0') - { - *TargetPointer++ = FirmwareVersionLetter; - } + { + *TargetPointer++ = FirmwareVersionLetter; + } *TargetPointer = '\0'; } @@ -1022,72 +1046,72 @@ BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) if (HostAdapter->FirmwareVersion[0] == '5') { if (BusLogic_Command(HostAdapter, - BusLogic_InquirePCIHostAdapterInformation, - NULL, - 0, - &PCIHostAdapterInformation, - sizeof(PCIHostAdapterInformation)) - != sizeof(PCIHostAdapterInformation)) - { - DebugPrint((0, "BusLogic_Failure: INQUIRE PCI HOST ADAPTER INFORMATION")); - return FALSE; - } + BusLogic_InquirePCIHostAdapterInformation, + NULL, + 0, + &PCIHostAdapterInformation, + sizeof(PCIHostAdapterInformation)) + != sizeof(PCIHostAdapterInformation)) + { + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE PCI HOST ADAPTER INFORMATION\n")); + return FALSE; + } // Save the Termination Information in the Host Adapter structure. if (PCIHostAdapterInformation.GenericInfoValid) - { - HostAdapter->TerminationInfoValid = TRUE; - HostAdapter->LowByteTerminated = PCIHostAdapterInformation.LowByteTerminated; - HostAdapter->HighByteTerminated = PCIHostAdapterInformation.HighByteTerminated; - } + { + HostAdapter->TerminationInfoValid = TRUE; + HostAdapter->LowByteTerminated = PCIHostAdapterInformation.LowByteTerminated; + HostAdapter->HighByteTerminated = PCIHostAdapterInformation.HighByteTerminated; + } } // Issue the Fetch Host Adapter Local RAM command to read the AutoSCSI data // from "W" and "C" series MultiMaster Host Adapters. if (HostAdapter->FirmwareVersion[0] >= '4') { - FetchHostAdapterLocalRAMRequest.ByteOffset = BusLogic_AutoSCSI_BaseOffset; + FetchHostAdapterLocalRAMRequest.ByteOffset = BusLogic_AutoSCSI_BaseOffset; FetchHostAdapterLocalRAMRequest.ByteCount = sizeof(AutoSCSIData); if (BusLogic_Command(HostAdapter, - BusLogic_FetchHostAdapterLocalRAM, - &FetchHostAdapterLocalRAMRequest, - sizeof(FetchHostAdapterLocalRAMRequest), - &AutoSCSIData, - sizeof(AutoSCSIData)) - != sizeof(AutoSCSIData)) - { - DebugPrint((0, "BusLogic_Failure: FETCH HOST ADAPTER LOCAL RAM")); - return FALSE; - } - // Save the Parity Checking Enabled, Bus Reset Enabled, and Termination - // Information in the Host Adapter structure. + BusLogic_FetchHostAdapterLocalRAM, + &FetchHostAdapterLocalRAMRequest, + sizeof(FetchHostAdapterLocalRAMRequest), + &AutoSCSIData, + sizeof(AutoSCSIData)) + != sizeof(AutoSCSIData)) + { + DebugPrint((ERROR, "\n BusLogic - Failure: FETCH HOST ADAPTER LOCAL RAM\n")); + return FALSE; + } + // Save the Parity Checking Enabled, Bus Reset Enabled, and Termination + // Information in the Host Adapter structure. HostAdapter->ParityCheckingEnabled = AutoSCSIData.ParityCheckingEnabled; HostAdapter->BusResetEnabled = AutoSCSIData.BusResetEnabled; // Save the Wide Permitted, Fast Permitted, Synchronous Permitted, - // Disconnect Permitted, Ultra Permitted, and SCAM Information in the - // Host Adapter structure. + // Disconnect Permitted, Ultra Permitted, and SCAM Information in the + // Host Adapter structure. HostAdapter->WidePermitted = AutoSCSIData.WidePermitted; HostAdapter->FastPermitted = AutoSCSIData.FastPermitted; - HostAdapter->SynchronousPermitted = AutoSCSIData.SynchronousPermitted; - HostAdapter->DisconnectPermitted = AutoSCSIData.DisconnectPermitted; + HostAdapter->SynchronousPermitted = AutoSCSIData.SynchronousPermitted; + HostAdapter->DisconnectPermitted = AutoSCSIData.DisconnectPermitted; if (HostAdapter->HostUltraSCSI) - { - HostAdapter->UltraPermitted = AutoSCSIData.UltraPermitted; - } + { + HostAdapter->UltraPermitted = AutoSCSIData.UltraPermitted; + } if (HostAdapter->HostSupportsSCAM) - { - HostAdapter->SCAM_Enabled = AutoSCSIData.SCAM_Enabled; - HostAdapter->SCAM_Level2 = AutoSCSIData.SCAM_Level2; - } - } - + { + HostAdapter->SCAM_Enabled = AutoSCSIData.SCAM_Enabled; + HostAdapter->SCAM_Level2 = AutoSCSIData.SCAM_Level2; + } + } + // Determine the maximum number of Target IDs and Logical Units supported by // this driver for Wide and Narrow Host Adapters. - HostAdapter->MaxTargetDevices = (HostAdapter->HostWideSCSI ? 16 : 8); - HostAdapter->MaxLogicalUnits = (HostAdapter->ExtendedLUNSupport ? 32 : 8); - - // Select appropriate values for the Mailbox Count, + HostAdapter->MaxTargetDevices = (HostAdapter->HostWideSCSI ? 16 : 8); + HostAdapter->MaxLogicalUnits = (HostAdapter->ExtendedLUNSupport ? 32 : 8); + + // Select appropriate values for the Mailbox Count, // Initial CCBs, and Incremental CCBs variables based on whether or not Strict // Round Robin Mode is supported. If Strict Round Robin Mode is supported, // then there is no performance degradation in using the maximum possible @@ -1104,26 +1128,26 @@ BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) // queued commands waiting in Outgoing Mailboxes if necessary than to block // the process in the higher levels of the SCSI Subsystem. // - // 192 BT-948/958/958D - if (HostAdapter->FirmwareVersion[0] == '5') - { - HostAdapter->HostAdapterQueueDepth = 192; - } - - if (strcmp((char*)HostAdapter->FirmwareVersion, "3.31") >= 0) + // 192 BT-948/958/958D + if (HostAdapter->FirmwareVersion[0] == '5') + { + HostAdapter->HostAdapterQueueDepth = 192; + } + + if (strcmp((char*)HostAdapter->FirmwareVersion, "3.31") >= 0) { HostAdapter->StrictRoundRobinModeSupport = TRUE; HostAdapter->MailboxCount = BusLogic_MaxMailboxes; } - // + // // Tagged Queuing support is available and operates properly on all "W" series // MultiMaster Host Adapters, on "C" series MultiMaster Host Adapters with // firmware version 4.22 and above, and on "S" series MultiMaster Host // Adapters with firmware version 3.35 and above. HostAdapter->TaggedQueuingPermitted = 0xFFFF; - // + // // Determine the Host Adapter BIOS Address if the BIOS is enabled and ///save it in the Host Adapter structure. The BIOS is disabled if the // BIOS_Address is 0. @@ -1142,22 +1166,22 @@ BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter) // Disconnect/Reconnect Permitted bits. HostAdapter->TaggedQueuingPermitted &= HostAdapter->DisconnectPermitted; - // Select an appropriate value for Bus Settle Time either from a BusLogic + // Select an appropriate value for Bus Settle Time either from a BusLogic // Driver Options specification, or from BusLogic_DefaultBusSettleTime. HostAdapter->BusSettleTime = BusLogic_DefaultBusSettleTime; - // Indicate reading the Host Adapter Configuration completed successfully. + // Indicate reading the Host Adapter Configuration completed successfully. return TRUE; }// end BusLogic_ReadHostAdapterConfiguration BOOLEAN BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, - PPORT_CONFIGURATION_INFORMATION ConfigInfo) + PPORT_CONFIGURATION_INFORMATION ConfigInfo) //_____________________________________________________________________________________________ // Routine Description: -// BusLogic_InitializeHostAdapter initializes Host Adapter. This is the only -// function called during SCSI Host Adapter detection which modifies the state -// of the Host Adapter from its initial power on or hard reset state. +// BusLogic_InitializeHostAdapter initializes Host Adapter. This is the only +// function called during SCSI Host Adapter detection which modifies the state +// of the Host Adapter from its initial power on or hard reset state. // Arguments: // 1. device extension // 2. port config information @@ -1189,19 +1213,19 @@ BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = FALSE; HostAdapter->TargetFlags[TargetID].CommandSuccessfulFlag = FALSE; - HostAdapter->ActiveCommandsPerTarget[TargetID] = 0; - for (LunID = 0; LunID < HostAdapter->MaxLogicalUnits; LunID++) - HostAdapter->ActiveCommandsPerLun[TargetID][LunID] = 0; + HostAdapter->ActiveCommandsPerTarget[TargetID] = 0; + for (LunID = 0; LunID < HostAdapter->MaxLogicalUnits; LunID++) + HostAdapter->ActiveCommandsPerLun[TargetID][LunID] = 0; HostAdapter->CommandsSinceReset[TargetID] = 0; } // Convert virtual to physical mailbox address. deviceExtension->NoncachedExtension->MailboxPA = ScsiPortConvertPhysicalAddressToUlong( - ScsiPortGetPhysicalAddress(deviceExtension, - NULL, - deviceExtension->NoncachedExtension->MailboxOut, - &length)); + ScsiPortGetPhysicalAddress(deviceExtension, + NULL, + deviceExtension->NoncachedExtension->MailboxOut, + &length)); HostAdapter->FirstOutgoingMailbox = (BusLogic_OutgoingMailbox_T *) deviceExtension->NoncachedExtension->MailboxOut; HostAdapter->LastOutgoingMailbox = HostAdapter->FirstOutgoingMailbox + HostAdapter->MailboxCount - 1; @@ -1213,25 +1237,25 @@ BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, // Initialize the Outgoing and Incoming Mailbox structures. memset(HostAdapter->FirstOutgoingMailbox, - 0, - HostAdapter->MailboxCount * sizeof(BusLogic_OutgoingMailbox_T)); + 0, + HostAdapter->MailboxCount * sizeof(BusLogic_OutgoingMailbox_T)); memset(HostAdapter->FirstIncomingMailbox, - 0, - HostAdapter->MailboxCount * sizeof(BusLogic_IncomingMailbox_T)); + 0, + HostAdapter->MailboxCount * sizeof(BusLogic_IncomingMailbox_T)); ExtendedMailboxRequest.MailboxCount = HostAdapter->MailboxCount; ExtendedMailboxRequest.BaseMailboxAddress = deviceExtension->NoncachedExtension->MailboxPA ; if (BusLogic_Command(HostAdapter, - BusLogic_InitializeExtendedMailbox, - &ExtendedMailboxRequest, - sizeof(ExtendedMailboxRequest), - NULL, 0) - < 0) + BusLogic_InitializeExtendedMailbox, + &ExtendedMailboxRequest, + sizeof(ExtendedMailboxRequest), + NULL, 0) + < 0) { - DebugPrint((0,"BusLogic_Failure: MAILBOX INITIALIZATION")); - return FALSE; + DebugPrint((ERROR, "\n BusLogic - Failure: MAILBOX INITIALIZATION\n")); + return FALSE; } // Enable Strict Round Robin Mode if supported by the Host Adapter. In @@ -1241,18 +1265,18 @@ BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, // Round Robin Mode is significantly more efficient. if (HostAdapter->StrictRoundRobinModeSupport) { - RoundRobinModeRequest = BusLogic_StrictRoundRobinMode; - if (BusLogic_Command(HostAdapter, - BusLogic_EnableStrictRoundRobinMode, - &RoundRobinModeRequest, - sizeof(RoundRobinModeRequest), - NULL, - 0) - < 0) - { - DebugPrint((0,"BusLogic_Failure: ENABLE STRICT ROUND ROBIN MODE")); - return FALSE; - } + RoundRobinModeRequest = BusLogic_StrictRoundRobinMode; + if (BusLogic_Command(HostAdapter, + BusLogic_EnableStrictRoundRobinMode, + &RoundRobinModeRequest, + sizeof(RoundRobinModeRequest), + NULL, + 0) + < 0) + { + DebugPrint((ERROR, "\n BusLogic - Failure: ENABLE STRICT ROUND ROBIN MODE\n")); + return FALSE; + } } // For Host Adapters that support Extended LUN Format CCBs, issue the Set CCB @@ -1262,26 +1286,28 @@ BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, { SetCCBFormatRequest = BusLogic_ExtendedLUNFormatCCB; if (BusLogic_Command(HostAdapter, - BusLogic_SetCCBFormat, - &SetCCBFormatRequest, - sizeof(SetCCBFormatRequest), - NULL, - 0) - < 0) - { - DebugPrint((0, "BusLogic_Failure: SET CCB FORMAT")); - return FALSE; - } + BusLogic_SetCCBFormat, + &SetCCBFormatRequest, + sizeof(SetCCBFormatRequest), + NULL, + 0) + < 0) + { + DebugPrint((ERROR, "\n BusLogic - Failure: SET CCB FORMAT\n")); + return FALSE; + } } // Announce Successful Initialization. if (!HostAdapter->HostAdapterInitialized) { - DebugPrint((0,"Info *** %s Initialized Successfully ***\n", HostAdapter, HostAdapter->FullModelName)); + DebugPrint((INFO, "\n BusLogic - %s Initialized Successfully\n", + HostAdapter, HostAdapter->FullModelName)); } else { - DebugPrint((0,"Warning *** %s Initialized Successfully ***\n", HostAdapter, HostAdapter->FullModelName)); + DebugPrint((WARNING, "\n BusLogic - %s not initialized Successfully\n", + HostAdapter, HostAdapter->FullModelName)); } HostAdapter->HostAdapterInitialized = TRUE; // Indicate the Host Adapter Initialization completed successfully. @@ -1293,8 +1319,8 @@ BOOLEAN BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *HostAdapter) //_________________________________________________________________________________________ // Routine Description: -// BusLogic_TargetDeviceInquiry inquires about the Target Devices accessible -// through Host Adapter. +// BusLogic_TargetDeviceInquiry inquires about the Target Devices accessible +// through Host Adapter. // Arguments: // 1. Host Adpater structure // 2. @@ -1326,51 +1352,51 @@ BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *HostAdapter) if (strcmp((char*)HostAdapter->FirmwareVersion, "4.25") >= 0) { if (BusLogic_Command(HostAdapter, - BusLogic_InquireTargetDevices, - NULL, - 0, - &InstalledDevices, - sizeof(InstalledDevices)) - != sizeof(InstalledDevices)) - { - DebugPrint((0, "BusLogic_Failure: INQUIRE TARGET DEVICES")); - return FALSE; - } + BusLogic_InquireTargetDevices, + NULL, + 0, + &InstalledDevices, + sizeof(InstalledDevices)) + != sizeof(InstalledDevices)) + { + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE TARGET DEVICES\n")); + return FALSE; + } for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) - { - HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevices & (1 << TargetID) ? TRUE : FALSE); - } + { + HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevices & (1 << TargetID) ? TRUE : FALSE); + } } // Issue the Inquire Setup Information command. RequestedReplyLength = sizeof(SetupInformation); if (BusLogic_Command(HostAdapter, - BusLogic_InquireSetupInformation, - &RequestedReplyLength, - sizeof(RequestedReplyLength), - &SetupInformation, sizeof(SetupInformation)) + BusLogic_InquireSetupInformation, + &RequestedReplyLength, + sizeof(RequestedReplyLength), + &SetupInformation, sizeof(SetupInformation)) != sizeof(SetupInformation)) { - DebugPrint((0, "BusLogic_Failure: INQUIRE SETUP INFORMATION")); - return FALSE; + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE SETUP INFORMATION\n")); + return FALSE; } for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) { HostAdapter->SynchronousOffset[TargetID] = (TargetID < 8 - ? SetupInformation.SynchronousValuesID0to7[TargetID].Offset - : SetupInformation.SynchronousValuesID8to15[TargetID-8].Offset); + ? SetupInformation.SynchronousValuesID0to7[TargetID].Offset + : SetupInformation.SynchronousValuesID8to15[TargetID-8].Offset); } if (strcmp((char*)HostAdapter->FirmwareVersion, "5.06L") >= 0) { for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) - { + { HostAdapter->TargetFlags[TargetID].WideTransfersActive = (TargetID < 8 - ? (SetupInformation.WideTransfersActiveID0to7 & (1 << TargetID) - ? TRUE : FALSE) - : (SetupInformation.WideTransfersActiveID8to15 & (1 << (TargetID-8)) - ? TRUE : FALSE)); - } + ? (SetupInformation.WideTransfersActiveID0to7 & (1 << TargetID) + ? TRUE : FALSE) + : (SetupInformation.WideTransfersActiveID8to15 & (1 << (TargetID-8)) + ? TRUE : FALSE)); + } } @@ -1379,43 +1405,42 @@ BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *HostAdapter) { RequestedReplyLength = sizeof(SynchronousPeriod); if (BusLogic_Command(HostAdapter, - BusLogic_InquireSynchronousPeriod, - &RequestedReplyLength, - sizeof(RequestedReplyLength), - &SynchronousPeriod, - sizeof(SynchronousPeriod)) - != sizeof(SynchronousPeriod)) - { - DebugPrint((0, "BusLogic_Failure: INQUIRE SYNCHRONOUS PERIOD")); - return FALSE; - } + BusLogic_InquireSynchronousPeriod, + &RequestedReplyLength, + sizeof(RequestedReplyLength), + &SynchronousPeriod, + sizeof(SynchronousPeriod)) + != sizeof(SynchronousPeriod)) + { + DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE SYNCHRONOUS PERIOD\n")); + return FALSE; + } for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++) - { - HostAdapter->SynchronousPeriod[TargetID] = SynchronousPeriod[TargetID]; - } + { + HostAdapter->SynchronousPeriod[TargetID] = SynchronousPeriod[TargetID]; + } } // Indicate the Target Device Inquiry completed successfully. return TRUE; }// end BusLogic_TargetDeviceInquiry -VOID -BusLogic_InitializeCCB( PBuslogic_CCB_T CCB) +VOID BusLogic_InitializeCCB( PBuslogic_CCB_T CCB) { CCB->Opcode = BusLogic_InitiatorCCB; - CCB->DataDirection = 0; - CCB->TagEnable = 0; - CCB->QueueTag = 0 ; - CCB->CDB_Length = 0; - CCB->SenseDataLength = 0; + CCB->DataDirection = 0; + CCB->TagEnable = 0; + CCB->QueueTag = 0 ; + CCB->CDB_Length = 0; + CCB->SenseDataLength = 0; CCB->DataLength = 0; CCB->DataPointer = 0; CCB->HostAdapterStatus = 0; CCB->TargetDeviceStatus = 0; - CCB->TargetID = 0; - CCB->LogicalUnit = 0; - CCB->LegacyTagEnable = 0; - CCB->LegacyQueueTag = 0; + CCB->TargetID = 0; + CCB->LogicalUnit = 0; + CCB->LegacyTagEnable = 0; + CCB->LegacyQueueTag = 0; CCB->SenseDataPointer = 0; @@ -1434,7 +1459,7 @@ BusLogic_InitializeCCB( PBuslogic_CCB_T CCB) BOOLEAN STDCALL BT958HwStartIO(IN PVOID HwDeviceExtension, - IN PSCSI_REQUEST_BLOCK Srb + IN PSCSI_REQUEST_BLOCK Srb ) //__________________________________________________________________________________ // Routine Description: @@ -1445,33 +1470,30 @@ BT958HwStartIO(IN PVOID HwDeviceExtension, // and is expected to complete it. // Arguments: // 1. DeviceExtension: Points to the miniport driver's per-HBA storage area. -// 2. Srb: Points to the SCSI request block to be started. +// 2. Srb: Points to the SCSI request block to be started. // Return Value: // TRUE : HwScsiStartIo returns TRUE to acknowledge receipt of the SRB. //__________________________________________________________________________________ { - PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; + PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; // PNONCACHED_EXTENSION noncachedExtension = deviceExtension->NoncachedExtension; - BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); + BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); // BusLogic_OutgoingMailbox_T mailboxOut; PSCSI_REQUEST_BLOCK AbortSRB; - PBuslogic_CCB_T ccb; - BusLogic_TargetFlags_T *TargetFlags = &HostAdapter->TargetFlags[Srb->TargetId]; + PBuslogic_CCB_T ccb; + BusLogic_TargetFlags_T *TargetFlags = &HostAdapter->TargetFlags[Srb->TargetId]; - DebugPrint((0,"BusLogic: Inside Start IO routine\n")); + DebugPrint((TRACE, "\n BusLogic - Inside Start IO routine\n")); // Make sure that this request isn't too long for the adapter. If so // bounce it back as an invalid request - if (BusLogic_CDB_MaxLength && - (BusLogic_CDB_MaxLength< Srb->CdbLength)) - { + if (BusLogic_CDB_MaxLength < Srb->CdbLength) + { - DebugPrint((0,"DebugPrint: Srb->CdbLength [%d] > MaxCdbLength [%d]. Invalid request\n", - Srb->CdbLength, - BusLogic_CDB_MaxLength - )); + DebugPrint((WARNING, "\n BusLogic - Srb->CdbLength [%d] > MaxCdbLength [%d]." + " Invalid request\n", Srb->CdbLength, BusLogic_CDB_MaxLength)); Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; ScsiPortNotification(RequestComplete,deviceExtension,Srb); @@ -1480,181 +1502,186 @@ BT958HwStartIO(IN PVOID HwDeviceExtension, } switch (Srb->Function) - { + { /* - Sirish, 10th June 2002 - // Check if command is a WMI request. - case SRB_FUNCTION_WMI: - // Process the WMI request and return. - return BT958WmiSrb(HwDeviceExtension, (PSCSI_WMI_REQUEST_BLOCK) Srb); - */ + Sirish, 10th June 2002 + // Check if command is a WMI request. + case SRB_FUNCTION_WMI: + // Process the WMI request and return. + return BT958WmiSrb(HwDeviceExtension, (PSCSI_WMI_REQUEST_BLOCK) Srb); + */ case SRB_FUNCTION_EXECUTE_SCSI: - // get the ccb structure from the extension - ccb = Srb->SrbExtension; - BusLogic_InitializeCCB(ccb); + // get the ccb structure from the extension + ccb = Srb->SrbExtension; + BusLogic_InitializeCCB(ccb); - // Save SRB back pointer in CCB. - ccb->SrbAddress = Srb; + // Save SRB back pointer in CCB. + ccb->SrbAddress = Srb; // Build CCB. - Have some way of knowing that a srb has already been - // completed and you just need to return from here - BusLogic_QueueCommand(HwDeviceExtension ,Srb, ccb); + // completed and you just need to return from here + BusLogic_QueueCommand(HwDeviceExtension ,Srb, ccb); - // Place the CCB in an Outgoing Mailbox. The higher levels of the SCSI - // Subsystem should not attempt to queue more commands than can be placed - // in Outgoing Mailboxes, so there should always be one free. In the - // unlikely event that there are none available, wait 1 second and try - // again. If that fails, the Host Adapter is probably hung so signal an - // error as a Host Adapter Hard Reset should be initiated soon. + // Place the CCB in an Outgoing Mailbox. The higher levels of the SCSI + // Subsystem should not attempt to queue more commands than can be placed + // in Outgoing Mailboxes, so there should always be one free. In the + // unlikely event that there are none available, wait 1 second and try + // again. If that fails, the Host Adapter is probably hung so signal an + // error as a Host Adapter Hard Reset should be initiated soon. - if (!BusLogic_WriteOutgoingMailbox(deviceExtension , BusLogic_MailboxStartCommand, ccb)) - { - DebugPrint((0,"Unable to write Outgoing Mailbox - " "Pausing for 1 second\n")); - ScsiPortStallExecution(1000); - if (!BusLogic_WriteOutgoingMailbox(deviceExtension , BusLogic_MailboxStartCommand, ccb)) - { - DebugPrint((0,"Still unable to write Outgoing Mailbox - " "Host Adapter Dead?\n")); + if (!BusLogic_WriteOutgoingMailbox(deviceExtension , BusLogic_MailboxStartCommand, ccb)) + { + DebugPrint((ERROR, "\n BusLogic - Unable to write Outgoing Mailbox - " + "Pausing for 1 second\n")); + ScsiPortStallExecution(1000); + if (!BusLogic_WriteOutgoingMailbox(deviceExtension , BusLogic_MailboxStartCommand, ccb)) + { + DebugPrint((ERROR, "\n BusLogic - Still unable to write Outgoing" + "Mailbox - Host Adapter Dead?\n")); - Srb->SrbStatus = SRB_STATUS_ERROR; - ScsiPortNotification(RequestComplete,deviceExtension,Srb); - ScsiPortNotification(NextRequest,deviceExtension,NULL); + Srb->SrbStatus = SRB_STATUS_ERROR; + ScsiPortNotification(RequestComplete,deviceExtension,Srb); + ScsiPortNotification(NextRequest,deviceExtension,NULL); - } - } - else - { - /* - * Reverted to pre 1.1.0.0 control flow - * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts - * And the fix for that in 1.1.0.1 causes BSODs in XP - * Side note: Ben: the Buslogic emulation never exports more than 1 lun - */ - if (TargetFlags->TaggedQueuingActive - && HostAdapter->ActiveCommandsPerLun[Srb->TargetId][Srb->Lun] < BUSLOGIC_MAXIMUM_TAGS) { - ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); - } - else { - ScsiPortNotification(NextRequest,deviceExtension,NULL); - } - } - return TRUE; + } + } + else + { + /* + * Reverted to pre 1.1.0.0 control flow + * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts + * And the fix for that in 1.1.0.1 causes BSODs in XP + * Side note: Ben: the Buslogic emulation never exports more than 1 lun + */ + if (TargetFlags->TaggedQueuingActive + && HostAdapter->ActiveCommandsPerLun[Srb->TargetId][Srb->Lun] < BUSLOGIC_MAXIMUM_TAGS) { + ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); + } + else { + ScsiPortNotification(NextRequest,deviceExtension,NULL); + } + } + return TRUE; - case SRB_FUNCTION_ABORT_COMMAND: - - // Get CCB to abort. - ccb = Srb->NextSrb->SrbExtension; + case SRB_FUNCTION_ABORT_COMMAND: + + // Get CCB to abort. + ccb = Srb->NextSrb->SrbExtension; - // Set abort SRB for completion. - ccb->AbortSrb = Srb; + // Set abort SRB for completion. + ccb->AbortSrb = Srb; AbortSRB = ScsiPortGetSrb(HwDeviceExtension, - Srb->PathId, - Srb->TargetId, - Srb->Lun, - Srb->QueueTag); - - if ((AbortSRB != Srb->NextSrb) || (AbortSRB->SrbStatus != SRB_STATUS_PENDING)) - { - Srb->SrbStatus = SRB_STATUS_ABORT_FAILED; - ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); - ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); - return TRUE; - } + Srb->PathId, + Srb->TargetId, + Srb->Lun, + Srb->QueueTag); + + if ((AbortSRB != Srb->NextSrb) || (AbortSRB->SrbStatus != SRB_STATUS_PENDING)) + { + Srb->SrbStatus = SRB_STATUS_ABORT_FAILED; + ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); + ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); + return TRUE; + } - // write the abort information into a mailbox - if (BusLogic_WriteOutgoingMailbox( deviceExtension, BusLogic_MailboxAbortCommand, ccb)) - { - DebugPrint((0, "BusLogic_Warning: Aborting CCB #%ld to Target %d\n",ccb->SerialNumber, Srb->TargetId)); - // Adapter ready for next request. + // write the abort information into a mailbox + if (BusLogic_WriteOutgoingMailbox( deviceExtension, BusLogic_MailboxAbortCommand, ccb)) + { + DebugPrint((WARNING, "\n BusLogic - Aborting CCB #%ld to Target %d\n", + ccb->SerialNumber, Srb->TargetId)); + // Adapter ready for next request. - /* - * Reverted to pre 1.1.0.0 control flow - * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts - * And the fix for that in 1.1.0.1 causes BSODs in XP - * Side note: Ben: the Buslogic emulation never exports more than 1 lun - */ - if (TargetFlags->TaggedQueuingActive - && HostAdapter->ActiveCommandsPerLun[Srb->TargetId][Srb->Lun] < BUSLOGIC_MAXIMUM_TAGS) { - ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); - } - else { - ScsiPortNotification(NextRequest,deviceExtension,NULL); - } - } - else - { - DebugPrint((0,"BusLogic_Warning: Unable to Abort CCB #%ld to Target %d - ""No Outgoing Mailboxes\n",ccb->SerialNumber, Srb->TargetId)); - Srb->SrbStatus = SRB_STATUS_ERROR; - ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); - ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); - } - return TRUE; + /* + * Reverted to pre 1.1.0.0 control flow + * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts + * And the fix for that in 1.1.0.1 causes BSODs in XP + * Side note: Ben: the Buslogic emulation never exports more than 1 lun + */ + if (TargetFlags->TaggedQueuingActive + && HostAdapter->ActiveCommandsPerLun[Srb->TargetId][Srb->Lun] < BUSLOGIC_MAXIMUM_TAGS) { + ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); + } + else { + ScsiPortNotification(NextRequest,deviceExtension,NULL); + } + } + else + { + DebugPrint((WARNING, "\n BusLogic - Unable to Abort CCB #%ld to Target %d" + " - No Outgoing Mailboxes\n", ccb->SerialNumber, + Srb->TargetId)); + Srb->SrbStatus = SRB_STATUS_ERROR; + ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); + ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); + } + return TRUE; - case SRB_FUNCTION_RESET_BUS: - - // Reset SCSI bus. - DebugPrint((0,"BusLogic - SRB_FUNCTION_RESET_BUS,srb=%x \n",Srb)); - BT958HwResetBus(HwDeviceExtension, Srb->PathId); + case SRB_FUNCTION_RESET_BUS: + + // Reset SCSI bus. + DebugPrint((INFO, "\n BusLogic - SRB_FUNCTION_RESET_BUS, srb=%x \n",Srb)); + BT958HwResetBus(HwDeviceExtension, Srb->PathId); - Srb->SrbStatus = SRB_STATUS_SUCCESS; - ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); - ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); - return TRUE; - + Srb->SrbStatus = SRB_STATUS_SUCCESS; + ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); + ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); + return TRUE; + case SRB_FUNCTION_RESET_DEVICE: - - ccb = Srb->SrbExtension; - BusLogic_InitializeCCB(ccb); + + ccb = Srb->SrbExtension; + BusLogic_InitializeCCB(ccb); - // Save SRB back pointer in CCB. - ccb->SrbAddress = Srb; + // Save SRB back pointer in CCB. + ccb->SrbAddress = Srb; if(!BusLogic_SendBusDeviceReset(HostAdapter, Srb)) - { - BT958HwResetBus(HwDeviceExtension, SP_UNTAGGED); - Srb->SrbStatus = SRB_STATUS_SUCCESS; - ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); - ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); - return TRUE; - } - - /* - * Reverted to pre 1.1.0.0 control flow - * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts - * And the fix for that in 1.1.0.1 causes BSODs in XP - * Side note: Ben: the Buslogic emulation never exports more than 1 lun - */ - if (TargetFlags->TaggedQueuingActive - && HostAdapter->ActiveCommandsPerLun[Srb->TargetId][Srb->Lun] < BUSLOGIC_MAXIMUM_TAGS) { - ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); - } - else { - ScsiPortNotification(NextRequest,deviceExtension,NULL); - } - return TRUE; - + { + BT958HwResetBus(HwDeviceExtension, SP_UNTAGGED); + Srb->SrbStatus = SRB_STATUS_SUCCESS; + ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb); + ScsiPortNotification(NextRequest, HwDeviceExtension, NULL); + return TRUE; + } + + /* + * Reverted to pre 1.1.0.0 control flow + * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts + * And the fix for that in 1.1.0.1 causes BSODs in XP + * Side note: Ben: the Buslogic emulation never exports more than 1 lun + */ + if (TargetFlags->TaggedQueuingActive + && HostAdapter->ActiveCommandsPerLun[Srb->TargetId][Srb->Lun] < BUSLOGIC_MAXIMUM_TAGS) { + ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun); + } + else { + ScsiPortNotification(NextRequest,deviceExtension,NULL); + } + return TRUE; + default: // Set error, complete request and signal ready for next request. - Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; + Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST; ScsiPortNotification(RequestComplete,deviceExtension,Srb); ScsiPortNotification(NextRequest,deviceExtension,NULL); return TRUE; } // end switch - + }// end BusLogic_TargetDeviceInquiry BOOLEAN BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension , - BusLogic_ActionCode_T ActionCode, - BusLogic_CCB_T *CCB) + BusLogic_ActionCode_T ActionCode, + BusLogic_CCB_T *CCB) //______________________________________________________________________________________________ // Routine Description: // BusLogic_WriteOutgoingMailbox places CCB and Action Code into an Outgoing @@ -1664,10 +1691,10 @@ BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension , // Arguments: // 1. deviceExtension: device extension // 2. ActionCode : action code for the mailbox which can be -// BusLogic_OutgoingMailboxFree = 0x00, -// BusLogic_MailboxStartCommand = 0x01, -// BusLogic_MailboxAbortCommand = 0x02 -// 3. CCB :The CCB that has to be written into the mailbox +// BusLogic_OutgoingMailboxFree = 0x00, +// BusLogic_MailboxStartCommand = 0x01, +// BusLogic_MailboxAbortCommand = 0x02 +// 3. CCB :The CCB that has to be written into the mailbox // Return Value: // TRUE : write to the mailbox was successful // FALSE : write failed @@ -1683,36 +1710,36 @@ BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension , { CCB->Status = BusLogic_CCB_Active; - // The CCB field must be written before the Action Code field since - // the Host Adapter is operating asynchronously and the locking code - // does not protect against simultaneous access by the Host Adapter. + // The CCB field must be written before the Action Code field since + // the Host Adapter is operating asynchronously and the locking code + // does not protect against simultaneous access by the Host Adapter. - // Get CCB physical address. + // Get CCB physical address. NextOutgoingMailbox->CCB = ScsiPortConvertPhysicalAddressToUlong( ScsiPortGetPhysicalAddress(deviceExtension, - NULL, - CCB, - &length)); + NULL, + CCB, + &length)); NextOutgoingMailbox->ActionCode = (UCHAR)ActionCode; - BusLogic_StartMailboxCommand(HostAdapter); + BusLogic_StartMailboxCommand(HostAdapter); if (++NextOutgoingMailbox > HostAdapter->LastOutgoingMailbox) - { - NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox; - } + { + NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox; + } HostAdapter->NextOutgoingMailbox = NextOutgoingMailbox; if (ActionCode == BusLogic_MailboxStartCommand) - { - HostAdapter->ActiveCommandsPerTarget[CCB->TargetID]++; - // check this Namita - HostAdapter->ActiveCommandsPerLun[CCB->TargetID][CCB->LogicalUnit]++; - if (CCB->Opcode != BusLogic_BusDeviceReset) - { - HostAdapter->TargetStatistics[CCB->TargetID].CommandsAttempted++; - } - } + { + HostAdapter->ActiveCommandsPerTarget[CCB->TargetID]++; + // check this Namita + HostAdapter->ActiveCommandsPerLun[CCB->TargetID][CCB->LogicalUnit]++; + if (CCB->Opcode != BusLogic_BusDeviceReset) + { + HostAdapter->TargetStatistics[CCB->TargetID].CommandsAttempted++; + } + } return TRUE; } return FALSE; @@ -1721,15 +1748,15 @@ BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension , int BusLogic_QueueCommand(IN PVOID HwDeviceExtension , - IN PSCSI_REQUEST_BLOCK Srb, - PBuslogic_CCB_T CCB) + IN PSCSI_REQUEST_BLOCK Srb, + PBuslogic_CCB_T CCB) //_________________________________________________________________________ // Routine Description: -// BusLogic_QueueCommand creates a CCB for Command +// BusLogic_QueueCommand creates a CCB for Command // Arguments: // 1. HwDeviceExtemsion: device extension // 2. Srb: Pointe to the SRB -// 3. CCB: POinter to the buffer containing the space for CCB +// 3. CCB: POinter to the buffer containing the space for CCB // Return Value: // Function returns 0 if successful //_________________________________________________________________________ @@ -1751,26 +1778,26 @@ BusLogic_QueueCommand(IN PVOID HwDeviceExtension , if (Srb->DataTransferLength > 0) { - CCB->DataLength = Srb->DataTransferLength; + CCB->DataLength = Srb->DataTransferLength; // Initialize the fields in the BusLogic Command Control Block (CCB). #if SG_SUPPORT - { - ULONG length, xferLength, remainLength; - PVOID virtualAddress; - UCHAR i = 0; - - virtualAddress = Srb->DataBuffer; - xferLength = Srb->DataTransferLength; - remainLength = xferLength; + { + ULONG xferLength, remainLength; + PVOID virtualAddress; + UCHAR i = 0; + + virtualAddress = Srb->DataBuffer; + xferLength = Srb->DataTransferLength; + remainLength = xferLength; /* Build scatter gather list */ do - { + { CCB->ScatterGatherList[i].SegmentDataPointer = (ULONG)ScsiPortConvertPhysicalAddressToUlong( - ScsiPortGetPhysicalAddress(HwDeviceExtension, - Srb, - virtualAddress, - &length)); + ScsiPortGetPhysicalAddress(HwDeviceExtension, + Srb, + virtualAddress, + &length)); if ( length > remainLength ) length = remainLength; CCB->ScatterGatherList[i].SegmentByteCount = length; @@ -1783,68 +1810,68 @@ BusLogic_QueueCommand(IN PVOID HwDeviceExtension , i++; } while ( remainLength > 0); - // For data transfers that have less than one scatter gather element, convert + // For data transfers that have less than one scatter gather element, convert // CCB to one transfer without using SG element. This will clear up the data // overrun/underrun problem with small transfers that reak havoc with scanners // and CD-ROM's etc. This is the method employed in ASPI4DOS to avoid similar // problems. if (i > 1) - { + { CCB->Opcode = BusLogic_InitiatorCCB_ScatterGather; CCB->DataLength = i * sizeof(BusLogic_ScatterGatherSegment_T); - virtualAddress = (PVOID) & (CCB->ScatterGatherList); + virtualAddress = (PVOID) & (CCB->ScatterGatherList); CCB->DataPointer = ScsiPortConvertPhysicalAddressToUlong( - ScsiPortGetPhysicalAddress(HwDeviceExtension, - 0, - (PVOID)virtualAddress, - &length)); + ScsiPortGetPhysicalAddress(HwDeviceExtension, + 0, + (PVOID)virtualAddress, + &length)); } - else /* Turn off SG */ - { + else /* Turn off SG */ + { CCB->Opcode = BusLogic_InitiatorCCB; - CCB->DataLength = CCB->ScatterGatherList[0].SegmentByteCount; + CCB->DataLength = CCB->ScatterGatherList[0].SegmentByteCount; CCB->DataPointer = CCB->ScatterGatherList[0].SegmentDataPointer; } - } + } #else CCB->Opcode = BusLogic_InitiatorCCB; CCB->DataLength = BufferLength; CCB->DataPointer = ScsiPortConvertPhysicalAddressToUlong(ScsiPortGetPhysicalAddress(deviceExtension, - Srb, - BufferPointer, - &length)); + Srb, + BufferPointer, + &length)); #endif } switch (Srb->SrbFlags & SRB_FLAGS_UNSPECIFIED_DIRECTION) { case SRB_FLAGS_NO_DATA_TRANSFER: - CCB->DataDirection = BusLogic_NoDataTransfer; + CCB->DataDirection = BusLogic_NoDataTransfer; break; case SRB_FLAGS_DATA_IN: - CCB->DataDirection = BusLogic_DataInLengthChecked; - TargetStatistics[TargetID].ReadCommands++; - BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesRead, - BufferLength); - BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].ReadCommandSizeBuckets, - BufferLength); + CCB->DataDirection = BusLogic_DataInLengthChecked; + TargetStatistics[TargetID].ReadCommands++; + BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesRead, + BufferLength); + BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].ReadCommandSizeBuckets, + BufferLength); break; case SRB_FLAGS_DATA_OUT: - CCB->DataDirection = BusLogic_DataOutLengthChecked; - TargetStatistics[TargetID].WriteCommands++; - BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesWritten, - BufferLength); - BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].WriteCommandSizeBuckets, - BufferLength); - + CCB->DataDirection = BusLogic_DataOutLengthChecked; + TargetStatistics[TargetID].WriteCommands++; + BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesWritten, + BufferLength); + BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].WriteCommandSizeBuckets, + BufferLength); + break; - - case SRB_FLAGS_UNSPECIFIED_DIRECTION: /* let device decide direction */ + + case SRB_FLAGS_UNSPECIFIED_DIRECTION: /* let device decide direction */ default: - CCB->DataDirection = BusLogic_UncheckedDataTransfer; + CCB->DataDirection = BusLogic_UncheckedDataTransfer; break; } @@ -1872,48 +1899,49 @@ BusLogic_QueueCommand(IN PVOID HwDeviceExtension , // before queuing tagged commands. if (HostAdapter->CommandsSinceReset[TargetID]++ >= BusLogic_MaxTaggedQueueDepth && - HostAdapter->ActiveCommandsPerTarget[TargetID] == 0 && - !TargetFlags->TaggedQueuingActive && - TargetFlags->TaggedQueuingSupported && + HostAdapter->ActiveCommandsPerTarget[TargetID] == 0 && + !TargetFlags->TaggedQueuingActive && + TargetFlags->TaggedQueuingSupported && (HostAdapter->TaggedQueuingPermitted & (1 << TargetID))) { - TargetFlags->TaggedQueuingActive = TRUE; - DebugPrint((0,"Tagged Queuing now active for Target %d\n", TargetID)); + TargetFlags->TaggedQueuingActive = TRUE; + DebugPrint((INFO, "\n BusLogic - Tagged Queuing now active for Target %d\n", + TargetID)); } if (TargetFlags->TaggedQueuingActive) { BusLogic_QueueTag_T QueueTag = BusLogic_SimpleQueueTag; - // When using Tagged Queuing with Simple Queue Tags, it appears that disk - // drive controllers do not guarantee that a queued command will not - // remain in a disconnected state indefinitely if commands that read or - // write nearer the head position continue to arrive without interruption. - // Therefore, for each Target Device this driver keeps track of the last - // time either the queue was empty or an Ordered Queue Tag was issued. If - // more than 4 seconds (one fifth of the 20 second disk timeout) have - // elapsed since this last sequence point, this command will be issued - // with an Ordered Queue Tag rather than a Simple Queue Tag, which forces - // the Target Device to complete all previously queued commands before - // this command may be executed. + // When using Tagged Queuing with Simple Queue Tags, it appears that disk + // drive controllers do not guarantee that a queued command will not + // remain in a disconnected state indefinitely if commands that read or + // write nearer the head position continue to arrive without interruption. + // Therefore, for each Target Device this driver keeps track of the last + // time either the queue was empty or an Ordered Queue Tag was issued. If + // more than 4 seconds (one fifth of the 20 second disk timeout) have + // elapsed since this last sequence point, this command will be issued + // with an Ordered Queue Tag rather than a Simple Queue Tag, which forces + // the Target Device to complete all previously queued commands before + // this command may be executed. /* if (HostAdapter->ActiveCommandsPerTarget[TargetID] == 0) - HostAdapter->LastSequencePoint[TargetID] = jiffies; + HostAdapter->LastSequencePoint[TargetID] = jiffies; else if (jiffies - HostAdapter->LastSequencePoint[TargetID] > 4*HZ) - { - HostAdapter->LastSequencePoint[TargetID] = jiffies; - QueueTag = BusLogic_OrderedQueueTag; - } - */ + { + HostAdapter->LastSequencePoint[TargetID] = jiffies; + QueueTag = BusLogic_OrderedQueueTag; + } + */ if (HostAdapter->ExtendedLUNSupport) - { - CCB->TagEnable = TRUE; - CCB->QueueTag = (UCHAR)QueueTag; - } + { + CCB->TagEnable = TRUE; + CCB->QueueTag = (UCHAR)QueueTag; + } else - { - CCB->LegacyTagEnable = TRUE; - CCB->LegacyQueueTag = (UCHAR)QueueTag; - } + { + CCB->LegacyTagEnable = TRUE; + CCB->LegacyQueueTag = (UCHAR)QueueTag; + } } ScsiPortMoveMemory(CCB->CDB, Srb->Cdb, CDB_Length); @@ -1922,21 +1950,21 @@ BusLogic_QueueCommand(IN PVOID HwDeviceExtension , //{sirish, shobhit}@calsoftinc.com if ((Srb->SrbFlags & SRB_FLAGS_DISABLE_AUTOSENSE) || (Srb->SenseInfoBufferLength <= 0)) { - - //Disable auto request sense - CCB->SenseDataLength = BusLogic_DisableAutoReqSense; + + //Disable auto request sense + CCB->SenseDataLength = BusLogic_DisableAutoReqSense; } else { - //Enable auto request sense - CCB->SenseDataLength = (unsigned char) Srb->SenseInfoBufferLength; + //Enable auto request sense + CCB->SenseDataLength = (unsigned char) Srb->SenseInfoBufferLength; - //Sense Buffer physical addr - CCB->SenseDataPointer = ScsiPortConvertPhysicalAddressToUlong(ScsiPortGetPhysicalAddress(HwDeviceExtension, - Srb, - Srb->SenseInfoBuffer, - &length)); - if (Srb->SenseInfoBufferLength > length ) { - CCB->SenseDataLength = (unsigned char) length; - } + //Sense Buffer physical addr + CCB->SenseDataPointer = ScsiPortConvertPhysicalAddressToUlong(ScsiPortGetPhysicalAddress(HwDeviceExtension, + Srb, + Srb->SenseInfoBuffer, + &length)); + if (Srb->SenseInfoBufferLength > length ) { + CCB->SenseDataLength = (unsigned char) length; + } } return 0; @@ -1948,73 +1976,73 @@ STDCALL BT958HwInterrupt(IN PVOID HwDeviceExtension) //_________________________________________________________________________ // Routine Description: -// HwScsiInterrupt is called when the HBA generates an -// interrupt. Miniport drivers of HBAs that do not -// generate interrupts do not have this routine. -// HwScsiInterrupt is responsible for completing -// interrupt-driven I/O operations. This routine must -// clear the interrupt on the HBA before it returns TRUE. +// HwScsiInterrupt is called when the HBA generates an +// interrupt. Miniport drivers of HBAs that do not +// generate interrupts do not have this routine. +// HwScsiInterrupt is responsible for completing +// interrupt-driven I/O operations. This routine must +// clear the interrupt on the HBA before it returns TRUE. // Arguments: // 1. HwDeviceExtension: Points to the miniport driver's per-HBA storage area. // Return Value: // TRUE : Acknowledged the interrupts on the HBA // FALSE: If the miniport finds that its HBA did not generate // the interrupt, HwScsiInterrupt should return FALSE -// as soon as possible. +// as soon as possible. //_________________________________________________________________________ { - PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; + PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; // PNONCACHED_EXTENSION noncachedExtension = deviceExtension->NoncachedExtension; - BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); + BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); // PBuslogic_CCB_T ccb; // PSCSI_REQUEST_BLOCK srb; // ULONG residualBytes; // ULONG i; - - BusLogic_InterruptRegister_T InterruptRegister; + + BusLogic_InterruptRegister_T InterruptRegister; - - // Read the Host Adapter Interrupt Register. + + // Read the Host Adapter Interrupt Register. InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter); if (InterruptRegister.Bits.InterruptValid) - { - - // Acknowledge the interrupt and reset the Host Adapter - // Interrupt Register. - BusLogic_InterruptReset(HostAdapter); - // Process valid External SCSI Bus Reset and Incoming Mailbox - // Loaded Interrupts. Command Complete Interrupts are noted, - // and Outgoing Mailbox Available Interrupts are ignored, as - // they are never enabled. - if (InterruptRegister.Bits.ExternalBusReset) - { - HostAdapter->HostAdapterExternalReset = TRUE; - } - else if (InterruptRegister.Bits.IncomingMailboxLoaded) - { - BusLogic_ScanIncomingMailboxes(deviceExtension); - } - else if (InterruptRegister.Bits.CommandComplete) - { - HostAdapter->HostAdapterCommandCompleted = TRUE; - } - } - else - return FALSE; - + { + + // Acknowledge the interrupt and reset the Host Adapter + // Interrupt Register. + BusLogic_InterruptReset(HostAdapter); + // Process valid External SCSI Bus Reset and Incoming Mailbox + // Loaded Interrupts. Command Complete Interrupts are noted, + // and Outgoing Mailbox Available Interrupts are ignored, as + // they are never enabled. + if (InterruptRegister.Bits.ExternalBusReset) + { + HostAdapter->HostAdapterExternalReset = TRUE; + } + else if (InterruptRegister.Bits.IncomingMailboxLoaded) + { + BusLogic_ScanIncomingMailboxes(deviceExtension); + } + else if (InterruptRegister.Bits.CommandComplete) + { + HostAdapter->HostAdapterCommandCompleted = TRUE; + } + } + else + return FALSE; + // Process any completed CCBs. if (HostAdapter->FirstCompletedCCB != NULL) - BusLogic_ProcessCompletedCCBs(deviceExtension); + BusLogic_ProcessCompletedCCBs(deviceExtension); - // Reset the Host Adapter if requested. + // Reset the Host Adapter if requested. if (HostAdapter->HostAdapterExternalReset || HostAdapter->HostAdapterInternalError) { - // I have replaced the NULL with srb->pathid check if this is correct + // I have replaced the NULL with srb->pathid check if this is correct BT958HwResetBus(HwDeviceExtension, SP_UNTAGGED); HostAdapter->HostAdapterExternalReset = FALSE; - HostAdapter->HostAdapterInternalError = FALSE; + HostAdapter->HostAdapterInternalError = FALSE; } return TRUE; }// end BT958HwInterrupt @@ -2023,7 +2051,7 @@ void BusLogic_ScanIncomingMailboxes(PHW_DEVICE_EXTENSION deviceExtension) //________________________________________________________________________________________ // Routine Description: -// BusLogic_ScanIncomingMailboxes scans the Incoming Mailboxes saving any +// BusLogic_ScanIncomingMailboxes scans the Incoming Mailboxes saving any // Incoming Mailbox entries for completion processing. // Arguments: // 1. deviceExtension : pointer to the device extension @@ -2047,32 +2075,33 @@ BusLogic_ScanIncomingMailboxes(PHW_DEVICE_EXTENSION deviceExtension) while ((CompletionCode = NextIncomingMailbox->CompletionCode) != BusLogic_IncomingMailboxFree) { - // Convert Physical CCB to Virtual. + // Convert Physical CCB to Virtual. BusLogic_CCB_T *CCB = (BusLogic_CCB_T *) ScsiPortGetVirtualAddress(deviceExtension, - ScsiPortConvertUlongToPhysicalAddress(NextIncomingMailbox->CCB)); + ScsiPortConvertUlongToPhysicalAddress(NextIncomingMailbox->CCB)); - DebugPrint((0, "Buslogic: Virtual CCB %lx\n", CCB)); + DebugPrint((INFO, "\n Buslogic - Virtual CCB %lx\n", CCB)); if (CompletionCode != BusLogic_AbortedCommandNotFound) - { - if (CCB->Status == BusLogic_CCB_Active || CCB->Status == BusLogic_CCB_Reset) - { - - // Save the Completion Code for this CCB and queue the CCB - // for completion processing. - CCB->CompletionCode = CompletionCode; - BusLogic_QueueCompletedCCB(deviceExtension,CCB); - } - else - { - // If a CCB ever appears in an Incoming Mailbox and is not marked - // as status Active or Reset, then there is most likely a bug in - // the Host Adapter firmware. - DebugPrint((0,"Illegal CCB #%ld status %d in " "Incoming Mailbox\n",CCB->SerialNumber, CCB->Status)); - } - } + { + if (CCB->Status == BusLogic_CCB_Active || CCB->Status == BusLogic_CCB_Reset) + { + + // Save the Completion Code for this CCB and queue the CCB + // for completion processing. + CCB->CompletionCode = CompletionCode; + BusLogic_QueueCompletedCCB(deviceExtension,CCB); + } + else + { + // If a CCB ever appears in an Incoming Mailbox and is not marked + // as status Active or Reset, then there is most likely a bug in + // the Host Adapter firmware. + DebugPrint((ERROR, "\n BusLogic - Illegal CCB #%ld status %d in " + "Incoming Mailbox\n", CCB->SerialNumber, CCB->Status)); + } + } NextIncomingMailbox->CompletionCode = BusLogic_IncomingMailboxFree; if (++NextIncomingMailbox > HostAdapter->LastIncomingMailbox) - NextIncomingMailbox = HostAdapter->FirstIncomingMailbox; + NextIncomingMailbox = HostAdapter->FirstIncomingMailbox; } HostAdapter->NextIncomingMailbox = NextIncomingMailbox; }// end BusLogic_ScanIncomingMailboxes @@ -2080,10 +2109,10 @@ BusLogic_ScanIncomingMailboxes(PHW_DEVICE_EXTENSION deviceExtension) void BusLogic_QueueCompletedCCB(PHW_DEVICE_EXTENSION deviceExtension, - BusLogic_CCB_T *CCB) + BusLogic_CCB_T *CCB) //_________________________________________________________________________________ // Routine Description: -// BusLogic_QueueCompletedCCB queues CCB for completion processing. +// BusLogic_QueueCompletedCCB queues CCB for completion processing. // Arguments: // 1. deviceExtension : pointer to device extension // 2. CCB: pointe t CCB that needs to be queued @@ -2115,8 +2144,8 @@ BusLogic_ProcessCompletedCCBs(PHW_DEVICE_EXTENSION deviceExtension) // Routine Description: // BusLogic_ProcessCompletedCCBs iterates over the completed CCBs for Host // Adapter setting the SCSI Command Result Codes, deallocating the CCBs, and -// calling the SCSI Subsystem Completion Routines. The Host Adapter's Lock -// should already have been acquired by the caller. +// calling the SCSI Subsystem Completion Routines. The Host Adapter's Lock +// should already have been acquired by the caller. // // Arguments: // 1. deviceExtension : pointer to device extension @@ -2127,150 +2156,153 @@ BusLogic_ProcessCompletedCCBs(PHW_DEVICE_EXTENSION deviceExtension) PCDB RealCdb; if (HostAdapter->ProcessCompletedCCBsActive) - return; + return; HostAdapter->ProcessCompletedCCBsActive = TRUE; while (HostAdapter->FirstCompletedCCB != NULL) { BusLogic_CCB_T *CCB = HostAdapter->FirstCompletedCCB; - // Get SRB from CCB. + // Get SRB from CCB. srb = CCB->SrbAddress; - HostAdapter->FirstCompletedCCB = CCB->Next; + HostAdapter->FirstCompletedCCB = CCB->Next; if (HostAdapter->FirstCompletedCCB == NULL) - HostAdapter->LastCompletedCCB = NULL; + HostAdapter->LastCompletedCCB = NULL; - // Process the Completed CCB. + // Process the Completed CCB. if (CCB->Opcode == BusLogic_BusDeviceReset) - { - int TargetID = CCB->TargetID, LunID; - DebugPrint((0,"Bus Device Reset CCB #%ld to Target " "%d Completed\n", CCB->SerialNumber, TargetID)); - BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].BusDeviceResetsCompleted); - - HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = FALSE; - HostAdapter->CommandsSinceReset[TargetID] = 0; - //HostAdapter->LastResetCompleted[TargetID] = jiffies; - HostAdapter->ActiveCommandsPerTarget[TargetID] = 0; - for (LunID = 0; LunID < HostAdapter->MaxLogicalUnits; LunID++) - HostAdapter->ActiveCommandsPerLun[TargetID][LunID] = 0; + { + int TargetID = CCB->TargetID, LunID; + DebugPrint((TRACE, "\n BusLogic - Bus Device Reset CCB #%ld to Target " + "%d Completed\n", CCB->SerialNumber, TargetID)); + BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].BusDeviceResetsCompleted); + + HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = FALSE; + HostAdapter->CommandsSinceReset[TargetID] = 0; + //HostAdapter->LastResetCompleted[TargetID] = jiffies; + HostAdapter->ActiveCommandsPerTarget[TargetID] = 0; + for (LunID = 0; LunID < HostAdapter->MaxLogicalUnits; LunID++) + HostAdapter->ActiveCommandsPerLun[TargetID][LunID] = 0; - // Complete all outstanding requests with SRB_STATUS_BUS_RESET. - ScsiPortCompleteRequest(deviceExtension, - (UCHAR)srb->PathId, - srb->TargetId, - 0xFF, - (ULONG)SRB_STATUS_BUS_RESET); + // Complete all outstanding requests with SRB_STATUS_BUS_RESET. + ScsiPortCompleteRequest(deviceExtension, + (UCHAR)srb->PathId, + srb->TargetId, + 0xFF, + (ULONG)SRB_STATUS_BUS_RESET); - - HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL; - } + + HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL; + } else - { - // Translate the Completion Code, Host Adapter Status, and Target - // Device Status into a SCSI Subsystem Result Code. - switch (CCB->CompletionCode) - { - case BusLogic_IncomingMailboxFree: - case BusLogic_InvalidCCB: - { - DebugPrint((0," CCB #%ld to Target %d Impossible State\n", CCB->SerialNumber, CCB->TargetID)); - break; - } + { + // Translate the Completion Code, Host Adapter Status, and Target + // Device Status into a SCSI Subsystem Result Code. + switch (CCB->CompletionCode) + { + case BusLogic_IncomingMailboxFree: + case BusLogic_InvalidCCB: + { + DebugPrint((ERROR, "\n BusLogic - CCB #%ld to Target %d Impossible " + "State\n", CCB->SerialNumber, CCB->TargetID)); + break; + } - //Processing for CCB that was to be aborted - case BusLogic_AbortedCommandNotFound: - { - srb = CCB->AbortSrb; - srb->SrbStatus = SRB_STATUS_ABORT_FAILED; - break; - } + //Processing for CCB that was to be aborted + case BusLogic_AbortedCommandNotFound: + { + srb = CCB->AbortSrb; + srb->SrbStatus = SRB_STATUS_ABORT_FAILED; + break; + } - case BusLogic_CommandCompletedWithoutError: - { - HostAdapter->TargetStatistics[CCB->TargetID].CommandsCompleted++; - HostAdapter->TargetFlags[CCB->TargetID].CommandSuccessfulFlag = TRUE; + case BusLogic_CommandCompletedWithoutError: + { + HostAdapter->TargetStatistics[CCB->TargetID].CommandsCompleted++; + HostAdapter->TargetFlags[CCB->TargetID].CommandSuccessfulFlag = TRUE; - srb->SrbStatus = SRB_STATUS_SUCCESS; - break; - } + srb->SrbStatus = SRB_STATUS_SUCCESS; + break; + } - case BusLogic_CommandAbortedAtHostRequest: - { - DebugPrint((0, "CCB #%ld to Target %d Aborted\n", CCB->SerialNumber, CCB->TargetID)); - //BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[CCB->TargetID].CommandAbortsCompleted); + case BusLogic_CommandAbortedAtHostRequest: + { + DebugPrint((TRACE, "\n BusLogic - CCB #%ld to Target %d Aborted\n", + CCB->SerialNumber, CCB->TargetID)); + //BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[CCB->TargetID].CommandAbortsCompleted); - srb->SrbStatus = SRB_STATUS_ABORTED; + srb->SrbStatus = SRB_STATUS_ABORTED; - // Call notification routine for the aborted SRB. + // Call notification routine for the aborted SRB. ScsiPortNotification(RequestComplete, - deviceExtension, - srb); + deviceExtension, + srb); - // Get the abort SRB from CCB. + // Get the abort SRB from CCB. srb = CCB->AbortSrb; // Set status for completing abort request. srb->SrbStatus = SRB_STATUS_SUCCESS; - break; - } + break; + } - case BusLogic_CommandCompletedWithError: - { -// PCDB RealCdb = (PCDB)CCB->CDB; - DebugPrint((0,"%x Command completed with error Host - %x Target %x \n",((PCDB)CCB->CDB)->CDB6GENERIC.OperationCode, - CCB->HostAdapterStatus, - CCB->TargetDeviceStatus)); + case BusLogic_CommandCompletedWithError: + { + RealCdb = (PCDB)CCB->CDB; + DebugPrint((ERROR, "\n BusLogic - %x Command completed with error Host - " + "%x Target %x \n", RealCdb->CDB6GENERIC.OperationCode, + CCB->HostAdapterStatus, CCB->TargetDeviceStatus)); - srb->SrbStatus = BusLogic_ComputeResultCode(HostAdapter, - CCB->HostAdapterStatus, - CCB->TargetDeviceStatus, - CCB->SenseDataLength); - if (CCB->HostAdapterStatus != BusLogic_SCSISelectionTimeout) - { - HostAdapter->TargetStatistics[CCB->TargetID].CommandsCompleted++; - } - break; - } + srb->SrbStatus = BusLogic_ComputeResultCode(HostAdapter, + CCB->HostAdapterStatus, + CCB->TargetDeviceStatus, + CCB->SenseDataLength); + if (CCB->HostAdapterStatus != BusLogic_SCSISelectionTimeout) + { + HostAdapter->TargetStatistics[CCB->TargetID].CommandsCompleted++; + } + break; + } - default: - { + default: + { // Log the error. ScsiPortLogError(deviceExtension, - NULL, - 0, - srb->TargetId, - 0, - SP_INTERNAL_ADAPTER_ERROR, - 143); + NULL, + 0, + srb->TargetId, + 0, + SP_INTERNAL_ADAPTER_ERROR, + 143); - DebugPrint((0, "BusLogic Interrupt: Unrecognized mailbox status\n")); - } + DebugPrint((ERROR, "\n BusLogic - Unrecognized mailbox status\n")); + } - }// end switch + }// end switch - - // When an INQUIRY command completes normally, save the CmdQue (Tagged Queuing Supported) - // and WBus16 (16 Bit Wide Data Transfers Supported) bits. - RealCdb = (PCDB) CCB->CDB; - if (RealCdb->CDB6INQUIRY.OperationCode == SCSIOP_INQUIRY && - CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally) - { - BusLogic_TargetFlags_T *TargetFlags =&HostAdapter->TargetFlags[CCB->TargetID]; - SCSI_Inquiry_T *InquiryResult =(SCSI_Inquiry_T *) srb->DataBuffer; - TargetFlags->TargetExists = TRUE; - TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue; - TargetFlags->WideTransfersSupported = InquiryResult->WBus16; - } - - DebugPrint((0, "BusLogic: SCSI Status %x\n", srb->ScsiStatus)); - DebugPrint((0, "BusLogic: Adapter Status %x\n", CCB->HostAdapterStatus)); + + // When an INQUIRY command completes normally, save the CmdQue (Tagged Queuing Supported) + // and WBus16 (16 Bit Wide Data Transfers Supported) bits. + RealCdb = (PCDB) CCB->CDB; + if (RealCdb->CDB6INQUIRY.OperationCode == SCSIOP_INQUIRY && + CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally) + { + BusLogic_TargetFlags_T *TargetFlags =&HostAdapter->TargetFlags[CCB->TargetID]; + SCSI_Inquiry_T *InquiryResult =(SCSI_Inquiry_T *) srb->DataBuffer; + TargetFlags->TargetExists = TRUE; + TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue; + TargetFlags->WideTransfersSupported = InquiryResult->WBus16; + } + + DebugPrint((INFO, "\n BusLogic - SCSI Status %x\n", srb->ScsiStatus)); + DebugPrint((INFO, "\n BusLogic - HBA Status %x\n", CCB->HostAdapterStatus)); - // Update target status in SRB. - srb->ScsiStatus = (UCHAR)CCB->TargetDeviceStatus; + // Update target status in SRB. + srb->ScsiStatus = (UCHAR)CCB->TargetDeviceStatus; - // Signal request completion. - ScsiPortNotification(RequestComplete, (PVOID)deviceExtension, srb); - } + // Signal request completion. + ScsiPortNotification(RequestComplete, (PVOID)deviceExtension, srb); + } } HostAdapter->ProcessCompletedCCBsActive = FALSE; }// end BusLogic_ProcessCompletedCCBs @@ -2278,134 +2310,137 @@ BusLogic_ProcessCompletedCCBs(PHW_DEVICE_EXTENSION deviceExtension) UCHAR BusLogic_ComputeResultCode(BusLogic_HostAdapter_T *HostAdapter, - BusLogic_HostAdapterStatus_T HostAdapterStatus, - BusLogic_TargetDeviceStatus_T TargetDeviceStatus, - UCHAR SenseDataLength) + BusLogic_HostAdapterStatus_T HostAdapterStatus, + BusLogic_TargetDeviceStatus_T TargetDeviceStatus, + UCHAR SenseDataLength) //_________________________________________________________________________________________ // Routine Description: -// BusLogic_ComputeResultCode computes a SCSI Subsystem Result Code from -// the Host Adapter Status and Target Device Status. +// BusLogic_ComputeResultCode computes a SCSI Subsystem Result Code from +// the Host Adapter Status and Target Device Status. // Arguments: // 1.HostAdapter: Pointer to the host adapter structure // 2.HostAdapterStatus: Host adapter status returned in the completed CCB -// 3.TargetDeviceStatus: +// 3.TargetDeviceStatus: // Return Value: -// This function returns the error code that should be returned to port driver +// This function returns the error code that should be returned to port driver //_________________________________________________________________________________________ { UCHAR HostStatus = 0; // Namita 2Oct CDROM issue if (TargetDeviceStatus != BusLogic_OperationGood && (HostAdapterStatus == BusLogic_CommandCompletedNormally || - HostAdapterStatus == BusLogic_LinkedCommandCompleted || - HostAdapterStatus == BusLogic_LinkedCommandCompletedWithFlag)) + HostAdapterStatus == BusLogic_LinkedCommandCompleted || + HostAdapterStatus == BusLogic_LinkedCommandCompletedWithFlag)) { - switch(TargetDeviceStatus) - { - case BusLogic_CheckCondition: - { - HostStatus = SRB_STATUS_ERROR; - if(SenseDataLength != BusLogic_DisableAutoReqSense) - HostStatus |= SRB_STATUS_AUTOSENSE_VALID; - break; - } - case BusLogic_DeviceBusy: - { - HostStatus = SRB_STATUS_BUSY; - } - break; - case BusLogic_OperationGood: - - HostStatus = SRB_STATUS_SUCCESS; - break; + switch(TargetDeviceStatus) + { + case BusLogic_CheckCondition: + { + HostStatus = SRB_STATUS_ERROR; + if(SenseDataLength != BusLogic_DisableAutoReqSense) + HostStatus |= SRB_STATUS_AUTOSENSE_VALID; + break; + } + case BusLogic_DeviceBusy: + { + HostStatus = SRB_STATUS_BUSY; + break; + } + case BusLogic_OperationGood: + { + HostStatus = SRB_STATUS_SUCCESS; + break; + } } } else { - switch (HostAdapterStatus) - { - case BusLogic_CommandCompletedNormally: - case BusLogic_LinkedCommandCompleted: - case BusLogic_LinkedCommandCompletedWithFlag: - { - HostStatus = SRB_STATUS_SUCCESS; - break; - } - case BusLogic_SCSISelectionTimeout: - { - HostStatus = SRB_STATUS_SELECTION_TIMEOUT; - break; - } - case BusLogic_InvalidOutgoingMailboxActionCode: - case BusLogic_InvalidCommandOperationCode: - case BusLogic_InvalidCommandParameter: - DebugPrint((0,"BusLogic_Warning!! BusLogic Driver Protocol Error 0x%02X\n",HostAdapterStatus)); - case BusLogic_DataUnderRun: - - case BusLogic_DataOverRun: - // SRB_STATUS_DATA_OVERRUN + switch (HostAdapterStatus) + { + case BusLogic_CommandCompletedNormally: + case BusLogic_LinkedCommandCompleted: + case BusLogic_LinkedCommandCompletedWithFlag: + { + HostStatus = SRB_STATUS_SUCCESS; + break; + } + case BusLogic_SCSISelectionTimeout: + { + HostStatus = SRB_STATUS_SELECTION_TIMEOUT; + break; + } + case BusLogic_InvalidOutgoingMailboxActionCode: + case BusLogic_InvalidCommandOperationCode: + case BusLogic_InvalidCommandParameter: + DebugPrint((WARNING, "\n BusLogic - Driver Protocol Error 0x%02X\n", + HostAdapterStatus)); + case BusLogic_DataUnderRun: + + case BusLogic_DataOverRun: + // SRB_STATUS_DATA_OVERRUN - case BusLogic_LinkedCCBhasInvalidLUN: - - case BusLogic_TaggedQueuingMessageRejected: - // SRB_STATUS_MESSAGE_REJECTED - case BusLogic_TargetDeviceReconnectedImproperly: - case BusLogic_AbortQueueGenerated: - case BusLogic_HostAdapterSoftwareError: - - case BusLogic_HostAdapterHardwareTimeoutError: - // SRB_STATUS_TIMEOUT - { - HostStatus = SRB_STATUS_ERROR; - break; - } - case BusLogic_TargetFailedResponseToATN: - case BusLogic_HostAdapterAssertedRST: - case BusLogic_OtherDeviceAssertedRST: - case BusLogic_HostAdapterAssertedBusDeviceReset: - { - HostStatus = SRB_STATUS_BUS_RESET; - break; - } - case BusLogic_SCSIParityErrorDetected: - { - HostStatus = SRB_STATUS_PARITY_ERROR; - break; - } - case BusLogic_UnexpectedBusFree: - { - HostStatus = SRB_STATUS_UNEXPECTED_BUS_FREE; - break; - } - case BusLogic_InvalidBusPhaseRequested: - { - HostStatus = SRB_STATUS_PHASE_SEQUENCE_FAILURE; - break; - } - case BusLogic_AutoRequestSenseFailed: - { - HostStatus = SRB_STATUS_REQUEST_SENSE_FAILED; - break; - } - case BusLogic_UnsupportedMessageReceived: - { - HostStatus = SRB_STATUS_INVALID_REQUEST; - break; - } - case BusLogic_HostAdapterHardwareFailed: - { - HostStatus = SRB_STATUS_NO_HBA; - break; - } - default: - { - DebugPrint((0,"BusLogic_Warning: Unknown Host Adapter Status 0x%02X\n",HostAdapterStatus)); - HostStatus = SRB_STATUS_ERROR; - break; - } - } + case BusLogic_LinkedCCBhasInvalidLUN: + + case BusLogic_TaggedQueuingMessageRejected: + // SRB_STATUS_MESSAGE_REJECTED + case BusLogic_TargetDeviceReconnectedImproperly: + case BusLogic_AbortQueueGenerated: + case BusLogic_HostAdapterSoftwareError: + + case BusLogic_HostAdapterHardwareTimeoutError: + // SRB_STATUS_TIMEOUT + { + HostStatus = SRB_STATUS_ERROR; + break; + } + case BusLogic_TargetFailedResponseToATN: + case BusLogic_HostAdapterAssertedRST: + case BusLogic_OtherDeviceAssertedRST: + case BusLogic_HostAdapterAssertedBusDeviceReset: + { + HostStatus = SRB_STATUS_BUS_RESET; + break; + } + case BusLogic_SCSIParityErrorDetected: + { + HostStatus = SRB_STATUS_PARITY_ERROR; + break; + } + case BusLogic_UnexpectedBusFree: + { + HostStatus = SRB_STATUS_UNEXPECTED_BUS_FREE; + break; + } + case BusLogic_InvalidBusPhaseRequested: + { + HostStatus = SRB_STATUS_PHASE_SEQUENCE_FAILURE; + break; + } + case BusLogic_AutoRequestSenseFailed: + { + HostStatus = SRB_STATUS_REQUEST_SENSE_FAILED; + break; + } + case BusLogic_UnsupportedMessageReceived: + { + HostStatus = SRB_STATUS_INVALID_REQUEST; + break; + } + case BusLogic_HostAdapterHardwareFailed: + { + HostStatus = SRB_STATUS_NO_HBA; + break; + } + default: + { + DebugPrint((WARNING, "\n BusLogic - Unknown HBA Status 0x%02X\n", + HostAdapterStatus)); + HostStatus = SRB_STATUS_ERROR; + break; + } + } } return HostStatus; }// end BusLogic_ComputeResultCode @@ -2414,13 +2449,13 @@ BusLogic_ComputeResultCode(BusLogic_HostAdapter_T *HostAdapter, BOOLEAN STDCALL BT958HwResetBus(IN PVOID HwDeviceExtension, - IN ULONG PathId) + IN ULONG PathId) //_____________________________________________________________________________________ // Routine Description: -// BT958HwResetBus resets Host Adapter if possible, marking all -// currently executing SCSI Commands as having been Reset. +// BT958HwResetBus resets Host Adapter if possible, marking all +// currently executing SCSI Commands as having been Reset. // Arguments: -// 1. HwDeviceExtension: Points to the miniport driver's per-HBA storage area. +// 1. HwDeviceExtension: Points to the miniport driver's per-HBA storage area. // 2. PathId: Identifies the SCSI bus to be reset. // Return Value: // TRUE : If the bus is successfully reset, HwScsiResetBus returns TRUE. @@ -2434,14 +2469,14 @@ BT958HwResetBus(IN PVOID HwDeviceExtension, BOOLEAN Result; BOOLEAN HardReset; - DebugPrint((0,"BuslogicResetBus: Reset aha154X and SCSI bus\n")); + DebugPrint((TRACE, "\n BusLogic - Reset SCSI bus\n")); // Complete all outstanding requests with SRB_STATUS_BUS_RESET. ScsiPortCompleteRequest(deviceExtension, - (UCHAR)PathId, - 0xFF, - 0xFF, - (ULONG) SRB_STATUS_BUS_RESET); + (UCHAR)PathId, + 0xFF, + 0xFF, + (ULONG) SRB_STATUS_BUS_RESET); if (HostAdapter->HostAdapterExternalReset) { @@ -2463,10 +2498,10 @@ BT958HwResetBus(IN PVOID HwDeviceExtension, /* if(srb == NULL) { - if (HostAdapter->HostAdapterInternalError) - DebugPrint((0,"BusLogic Warning: Resetting %s due to Host Adapter Internal Error\n",HostAdapter->FullModelName)); - else - DebugPrint((0,"BUsLogic Warning: Resetting %s due to External SCSI Bus Reset\n",HostAdapter->FullModelName)); + if (HostAdapter->HostAdapterInternalError) + DebugPrint((0,"BusLogic Warning: Resetting %s due to Host Adapter Internal Error\n",HostAdapter->FullModelName)); + else + DebugPrint((0,"BUsLogic Warning: Resetting %s due to External SCSI Bus Reset\n",HostAdapter->FullModelName)); } else { @@ -2479,7 +2514,8 @@ BT958HwResetBus(IN PVOID HwDeviceExtension, // Change the initialize routine to make allocation some place else if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, HardReset) && BusLogic_InitializeHostAdapter(deviceExtension, NULL))) { - DebugPrint((0,"Buslogic Error, Resetting %s Failed\n", HostAdapter->FullModelName)); + DebugPrint((ERROR, "\n Buslogic - Resetting %s Failed\n", + HostAdapter->FullModelName)); Result = FALSE; goto Done; } @@ -2491,7 +2527,7 @@ BT958HwResetBus(IN PVOID HwDeviceExtension, // Note that a timer interrupt may occur here, but all active CCBs have // already been marked Reset and so a reentrant call will return Pending. if (HardReset) - ScsiPortStallExecution(HostAdapter->BusSettleTime); + ScsiPortStallExecution(HostAdapter->BusSettleTime); Result = TRUE; Done: @@ -2500,13 +2536,13 @@ Done: BOOLEAN BusLogic_SendBusDeviceReset(IN PVOID HwDeviceExtension, - PSCSI_REQUEST_BLOCK Srb) + PSCSI_REQUEST_BLOCK Srb) //_____________________________________________________________________________________ // Routine Description: // BusLogic_SendBusDeviceReset causes a BUS DEVICE reset command to -// be send to particular target. +// be send to particular target. // Arguments: -// 1. HostAdpater: Points to Host adapter structure +// 1. HwDeviceExtension: Points to the miniport driver's per-HBA storage area. // 2. Srb: pointer to the SCSI request block // Return Value: // TRUE : If the bus is successfully reset, HwScsiResetBus returns TRUE. @@ -2521,31 +2557,34 @@ BusLogic_SendBusDeviceReset(IN PVOID HwDeviceExtension, PBuslogic_CCB_T CCB = Srb->SrbExtension; BOOLEAN Result = FALSE; BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[TargetID].BusDeviceResetsRequested); - + // If this is a Synchronous Reset and a Bus Device Reset is already pending // for this Target Device, do not send a second one. Add this Command to // the list of Commands for which completion processing must be performed // when the Bus Device Reset CCB completes. - if ((CCB = HostAdapter->BusDeviceResetPendingCCB[TargetID]) != NULL) + if (HostAdapter->BusDeviceResetPendingCCB[TargetID] != NULL) { - DebugPrint((0,"BusLogic_Warning: Unable to Reset Command to Target %d - Reset Pending\n", TargetID)); - Result = TRUE; - goto Done; + DebugPrint((WARNING, "\n BusLogic - Unable to Reset Command to Target %d - " + "Reset Pending\n", TargetID)); + Result = TRUE; + goto Done; } - DebugPrint((0,"BusLogic_Warning: Sending Bus Device Reset CCB #%ld to Target %d\n",CCB->SerialNumber, TargetID)); + DebugPrint((WARNING, "\n BusLogic - Sending Bus Device Reset CCB #%ld to Target %d\n", + CCB->SerialNumber, TargetID)); CCB->Opcode = BusLogic_BusDeviceReset; CCB->TargetID = TargetID; - // Attempt to write an Outgoing Mailbox with the Bus Device Reset CCB. - // If sending a Bus Device Reset is impossible, attempt a full Host - // Adapter Hard Reset and SCSI Bus Reset. + // Attempt to write an Outgoing Mailbox with the Bus Device Reset CCB. + // If sending a Bus Device Reset is impossible, attempt a full Host + // Adapter Hard Reset and SCSI Bus Reset. if (!(BusLogic_WriteOutgoingMailbox(deviceExtension, BusLogic_MailboxStartCommand, CCB))) { - DebugPrint((0,"BusLogic_Warning: Unable to write Outgoing Mailbox for " "Bus Device Reset\n")); - goto Done; + DebugPrint((WARNING, "\n BusLogic - Unable to write Outgoing Mailbox for " + "Bus Device Reset\n")); + goto Done; } // If there is a currently executing CCB in the Host Adapter for this Command @@ -2584,7 +2623,7 @@ STDCALL BT958HwInitialize(IN PVOID HwDeviceExtension) //_______________________________________________________________________________ // Routine Description: -// This routine initializes the adapter by enabling its interrupts +// This routine initializes the adapter by enabling its interrupts // Arguments: // 1. device extension // Return Value: @@ -2592,29 +2631,29 @@ BT958HwInitialize(IN PVOID HwDeviceExtension) // FALSE : initialization failed //_______________________________________________________________________________ { - PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; + PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension; BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs); - CHAR Parameter = 1; + CHAR Parameter = 1; - // enable interrupts - if (BusLogic_Command(HostAdapter, - BusLogic_DisableHostAdapterInterrupt, - &Parameter, - sizeof(Parameter), - NULL, - 0) - < 0) - { + // enable interrupts + if (BusLogic_Command(HostAdapter, + BusLogic_DisableHostAdapterInterrupt, + &Parameter, + sizeof(Parameter), + NULL, + 0) + < 0) + { return FALSE; - } - return TRUE; + } + return TRUE; }// end BT958HwInitialize SCSI_ADAPTER_CONTROL_STATUS STDCALL BT958HwAdapterControl(IN PVOID HwDeviceExtension, - IN SCSI_ADAPTER_CONTROL_TYPE ControlType, - IN PVOID Parameters) + IN SCSI_ADAPTER_CONTROL_TYPE ControlType, + IN PVOID Parameters) //__________________________________________________________________________________________ // Routine Description: // A miniport driver's HwScsiAdapterControl routine is called to perform @@ -2624,12 +2663,12 @@ BT958HwAdapterControl(IN PVOID HwDeviceExtension, // 1. HwDeviceExtension: device extension // 2. ControlType: Specifies one of the following adapter-control operations. // ScsiQuerySupportedControlTypes : Reports the adapter-control operations -// implemented by the miniport. -// ScsiStopAdapter: Shuts down the HBA. +// implemented by the miniport. +// ScsiStopAdapter: Shuts down the HBA. // ScsiRestartAdapter: Reinitializes an HBA. // ScsiSetBootConfig: Not supported // ScsiSetRunningConfig: Not supported -// 3. Parameters: +// 3. Parameters: // Return Value: // TRUE : // FALSE : @@ -2643,7 +2682,7 @@ BT958HwAdapterControl(IN PVOID HwDeviceExtension, // int Result,ParameterLength; // long TimeoutCounter; - PSCSI_SUPPORTED_CONTROL_TYPE_LIST ControlTypeList; + PSCSI_SUPPORTED_CONTROL_TYPE_LIST ControlTypeList; ULONG AdjustedMaxControlType; ULONG Index; @@ -2656,7 +2695,7 @@ BT958HwAdapterControl(IN PVOID HwDeviceExtension, // Structure defining which functions this miniport supports // BOOLEAN SupportedConrolTypes[ScsiAdapterControlMax] = - { + { TRUE, // ScsiQuerySupportedControlTypes TRUE, // ScsiStopAdapter TRUE, // ScsiRestartAdapter @@ -2664,17 +2703,17 @@ BT958HwAdapterControl(IN PVOID HwDeviceExtension, FALSE // ScsiSetRunningConfig }; - DebugPrint((0,"\n BusLogic - Inside HwAdapterControl funtion \n")); + DebugPrint((TRACE, "\n BusLogic - Inside HwAdapterControl function \n")); switch(ControlType) - { - case ScsiQuerySupportedControlTypes: - // Reports the adapter-control operations implemented by the miniport. The port - // driver calls HwScsiAdapterControl with this control type after the HBA has been - // initialized but before the first I/O. The miniport fills in the - // SCSI_SUPPORTED_CONTROL_TYPE_LIST structure at Parameters with the operations it - // supports. After HwScsiAdapterControl returns from this call, the port driver - // calls the miniport's HwScsiAdapterControl only for supported operations. - { + { + case ScsiQuerySupportedControlTypes: + // Reports the adapter-control operations implemented by the miniport. The port + // driver calls HwScsiAdapterControl with this control type after the HBA has been + // initialized but before the first I/O. The miniport fills in the + // SCSI_SUPPORTED_CONTROL_TYPE_LIST structure at Parameters with the operations it + // supports. After HwScsiAdapterControl returns from this call, the port driver + // calls the miniport's HwScsiAdapterControl only for supported operations. + { // This entry point provides the method by which SCSIPort determines the // supported ControlTypes. Parameters is a pointer to a @@ -2683,68 +2722,72 @@ BT958HwAdapterControl(IN PVOID HwDeviceExtension, ControlTypeList = Parameters; AdjustedMaxControlType = (ControlTypeList->MaxControlType < ScsiAdapterControlMax) ? ControlTypeList->MaxControlType :ScsiAdapterControlMax; for (Index = 0; Index < AdjustedMaxControlType; Index++) - { + { ControlTypeList->SupportedTypeList[Index] = SupportedConrolTypes[Index]; } break; - } - - case ScsiStopAdapter: - // Shuts down the HBA. The port driver calls HwScsiAdapterControl with this control - // type when the HBA has been removed from the system, stopped for resource reconfiguration, - // shut down for power management, or otherwise reconfigured or disabled. The port driver - // ensures that there are no uncompleted requests and issues an SRB_FUNCTION_FLUSH request - // to the miniport before calling this routine. The miniport disables interrupts on its HBA, - // halts all processing, (including background processing not subject to interrupts or processing - // of which the port driver is unaware, such as reconstructing fault-tolerant volumes), flushes - // any remaining cached data to persistent storage, and puts the HBA into a state from which it - // can be reinitialized or restarted. - // The miniport should not free its resources when stopping its HBA. If the HBA was removed or - // stopped for PnP resource reconfiguration, the port driver releases resources on behalf of the - // miniport driver. If the HBA is shut down for power management, the miniport's resources are - // preserved so the HBA can be restarted. - { - CHAR Parameter = 0; - DebugPrint((0,"\n BusLogic - stopping the device \n")); - if (BusLogic_Command(HostAdapter, - BusLogic_DisableHostAdapterInterrupt, - &Parameter, - sizeof(Parameter), - NULL, - 0) - < 0) - { - return ScsiAdapterControlUnsuccessful; - } - break; } - case ScsiRestartAdapter: - // Reinitializes an HBA. The port driver calls HwScsiAdapterControl with this control type to power - // up an HBA that was shut down for power management. All resources previously assigned to the miniport - // are still available, and its device extension and logical unit extensions, if any, are intact. - // The miniport performs the same operations as in its HwScsiInitialize routine, such as setting up - // the HBA's registers and its initial state, if any. - // The miniport must not call routines that can only be called from HwScsiFindAdapter or from - // HwScsiAdapterControl when the control type is ScsiSetRunningConfig, such as ScsiPortGetBusData and - // ScsiPortSetBusDataByOffset. If the miniport must call such routines to restart its HBA, it must also - // implement ScsiSetRunningConfig. - // If the miniport does not implement ScsiRestartAdapter, the port driver calls the miniport's HwScsiFindAdapter and HwScsiInitialize routines. However, because such routines might do detection work which is unnecessary for restarting the HBA, such a miniport will not power up its HBA as quickly as a miniport that implements ScsiRestartAdapter. - { - if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, TRUE) && - BusLogic_InitializeHostAdapter(deviceExtension, NULL)) && - BT958HwInitialize(HwDeviceExtension) - ) - { - DebugPrint((0,"Buslogic Error, Resetting %s Failed\n", HostAdapter->FullModelName)); - return ScsiAdapterControlUnsuccessful; - } + case ScsiStopAdapter: + // Shuts down the HBA. The port driver calls HwScsiAdapterControl with this control + // type when the HBA has been removed from the system, stopped for resource reconfiguration, + // shut down for power management, or otherwise reconfigured or disabled. The port driver + // ensures that there are no uncompleted requests and issues an SRB_FUNCTION_FLUSH request + // to the miniport before calling this routine. The miniport disables interrupts on its HBA, + // halts all processing, (including background processing not subject to interrupts or processing + // of which the port driver is unaware, such as reconstructing fault-tolerant volumes), flushes + // any remaining cached data to persistent storage, and puts the HBA into a state from which it + // can be reinitialized or restarted. + // The miniport should not free its resources when stopping its HBA. If the HBA was removed or + // stopped for PnP resource reconfiguration, the port driver releases resources on behalf of the + // miniport driver. If the HBA is shut down for power management, the miniport's resources are + // preserved so the HBA can be restarted. + { + CHAR Parameter = 0; + DebugPrint((INFO, "\n BusLogic - stopping the device \n")); + if (BusLogic_Command(HostAdapter, + BusLogic_DisableHostAdapterInterrupt, + &Parameter, + sizeof(Parameter), + NULL, + 0) + < 0) + { + return ScsiAdapterControlUnsuccessful; + } + break; + } - ScsiPortStallExecution(HostAdapter->BusSettleTime); - break; - } + case ScsiRestartAdapter: + // Reinitializes an HBA. The port driver calls HwScsiAdapterControl with this control type to power + // up an HBA that was shut down for power management. All resources previously assigned to the miniport + // are still available, and its device extension and logical unit extensions, if any, are intact. + // The miniport performs the same operations as in its HwScsiInitialize routine, such as setting up + // the HBA's registers and its initial state, if any. + // The miniport must not call routines that can only be called from HwScsiFindAdapter or from + // HwScsiAdapterControl when the control type is ScsiSetRunningConfig, such as ScsiPortGetBusData and + // ScsiPortSetBusDataByOffset. If the miniport must call such routines to restart its HBA, it must also + // implement ScsiSetRunningConfig. + // If the miniport does not implement ScsiRestartAdapter, the port driver calls the miniport's HwScsiFindAdapter and HwScsiInitialize routines. However, because such routines might do detection work which is unnecessary for restarting the HBA, such a miniport will not power up its HBA as quickly as a miniport that implements ScsiRestartAdapter. + + // See PR 69004. We were not calling BT958HwInitialize earlier if the + // first two calls succeeded thus causing resume from standby to fail. + { + if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, TRUE) && + BusLogic_InitializeHostAdapter(deviceExtension, NULL) && + BT958HwInitialize(HwDeviceExtension)) + ) + { + DebugPrint((ERROR, "\n Buslogic - Resetting %s Failed\n", + HostAdapter->FullModelName)); + return ScsiAdapterControlUnsuccessful; + } + + ScsiPortStallExecution(HostAdapter->BusSettleTime); + break; + } default: - { + { return ScsiAdapterControlUnsuccessful; } } diff --git a/reactos/drivers/storage/buslogic/BusLogic958.h b/reactos/drivers/storage/buslogic/BusLogic958.h index abac3927dda..8bdbf76248e 100644 --- a/reactos/drivers/storage/buslogic/BusLogic958.h +++ b/reactos/drivers/storage/buslogic/BusLogic958.h @@ -48,11 +48,16 @@ //#include "miniport.h" //#include "scsi.h" //#include "scsiwmi.h" - //_________________________________________________________________________________________ // #defines //_________________________________________________________________________________________ +// Debug levels +#define ERROR 1 +#define WARNING 2 +#define TRACE 3 +#define INFO 4 + // Max transfer size #define MAX_TRANSFER_SIZE 64 * 1024 // flag to turn on Scatter gather support @@ -65,16 +70,16 @@ // Define the maximum, maximum automatic, minimum automatic, and default Queue // Depth to allow for Target Devices depending on whether or not they support // Tagged Queuing and whether or not ISA Bounce Buffers are required. -#define BusLogic_MaxTaggedQueueDepth 128 +#define BusLogic_MaxTaggedQueueDepth 128 // Define the default amount of time in seconds to wait between a Host Adapter // Hard Reset which initiates a SCSI Bus Reset and issuing any SCSI commands. // Some SCSI devices get confused if they receive SCSI commands too soon after // a SCSI Bus Reset. -#define BusLogic_DefaultBusSettleTime 2 +#define BusLogic_DefaultBusSettleTime 2 // Define the maximum number of Target Devices supported by this driver. -#define BusLogic_MaxTargetDevices 16 +#define BusLogic_MaxTargetDevices 16 // Define the maximum number of Logical unit supported/Target Devices supported by this driver. #define BusLogic_MaxLogicalUnits 32 @@ -83,27 +88,27 @@ // Host Adapters. This number is chosen to be larger than the maximum Host // Adapter Queue Depth and small enough so that the Host Adapter structure // does not cross an allocation block size boundary. -#define BusLogic_MaxMailboxes 211 +#define BusLogic_MaxMailboxes 211 // Define the Fetch Host Adapter Local RAM request type. -#define BusLogic_BIOS_BaseOffset 0 -#define BusLogic_AutoSCSI_BaseOffset 64 +#define BusLogic_BIOS_BaseOffset 0 +#define BusLogic_AutoSCSI_BaseOffset 64 // Define the SCSI Command Descriptor Block (CDB). -#define BusLogic_CDB_MaxLength 12 +#define BusLogic_CDB_MaxLength 12 // Define the maximum number of Scatter/Gather Segments used by this driver. // For optimal performance, it is important that this limit be at least as // large as the largest single request generated by the I/O Subsystem. -#define BusLogic_ScatterGatherLimit 128 +#define BusLogic_ScatterGatherLimit 128 #define MAX_SG_LIMIT BusLogic_ScatterGatherLimit #define BusLogic_AggressiveRoundRobinMode 0 -#define BusLogic_StrictRoundRobinMode 1 +#define BusLogic_StrictRoundRobinMode 1 // Define the Codes for byte 3 (Request sense allocation length) of the CCB structure. -#define BusLogic_Allocate14Bytes 0x00 -#define BusLogic_DisableAutoReqSense 0x01 +#define BusLogic_Allocate14Bytes 0x00 +#define BusLogic_DisableAutoReqSense 0x01 //_________________________________________________________________________________________ @@ -113,49 +118,49 @@ typedef enum { BusLogic_TestCommandCompleteInterrupt = 0x00, - BusLogic_InitializeMailbox = 0x01, - BusLogic_ExecuteMailboxCommand = 0x02, - BusLogic_ExecuteBIOSCommand = 0x03, - BusLogic_InquireBoardID = 0x04, - BusLogic_EnableOutgoingMailboxAvailableInt = 0x05, - BusLogic_SetSCSISelectionTimeout = 0x06, - BusLogic_SetPreemptTimeOnBus = 0x07, - BusLogic_SetTimeOffBus = 0x08, - BusLogic_SetBusTransferRate = 0x09, + BusLogic_InitializeMailbox = 0x01, + BusLogic_ExecuteMailboxCommand = 0x02, + BusLogic_ExecuteBIOSCommand = 0x03, + BusLogic_InquireBoardID = 0x04, + BusLogic_EnableOutgoingMailboxAvailableInt = 0x05, + BusLogic_SetSCSISelectionTimeout = 0x06, + BusLogic_SetPreemptTimeOnBus = 0x07, + BusLogic_SetTimeOffBus = 0x08, + BusLogic_SetBusTransferRate = 0x09, BusLogic_InquireInstalledDevicesID0to7 =0x0A, - BusLogic_InquireConfiguration = 0x0B, - BusLogic_EnableTargetMode = 0x0C, - BusLogic_InquireSetupInformation = 0x0D, - BusLogic_WriteAdapterLocalRAM = 0x1A, - BusLogic_ReadAdapterLocalRAM = 0x1B, - BusLogic_WriteBusMasterChipFIFO = 0x1C, - BusLogic_ReadBusMasterChipFIFO = 0x1D, - BusLogic_EchoCommandData = 0x1F, - BusLogic_HostAdapterDiagnostic = 0x20, - BusLogic_SetAdapterOptions = 0x21, - BusLogic_InquireInstalledDevicesID8to15 = 0x23, - BusLogic_InquireTargetDevices = 0x24, + BusLogic_InquireConfiguration = 0x0B, + BusLogic_EnableTargetMode = 0x0C, + BusLogic_InquireSetupInformation = 0x0D, + BusLogic_WriteAdapterLocalRAM = 0x1A, + BusLogic_ReadAdapterLocalRAM = 0x1B, + BusLogic_WriteBusMasterChipFIFO = 0x1C, + BusLogic_ReadBusMasterChipFIFO = 0x1D, + BusLogic_EchoCommandData = 0x1F, + BusLogic_HostAdapterDiagnostic = 0x20, + BusLogic_SetAdapterOptions = 0x21, + BusLogic_InquireInstalledDevicesID8to15 = 0x23, + BusLogic_InquireTargetDevices = 0x24, BusLogic_DisableHostAdapterInterrupt = 0x25, - BusLogic_InitializeExtendedMailbox = 0x81, - BusLogic_ExecuteSCSICommand = 0x83, - BusLogic_InquireFirmwareVersion3rdDigit = 0x84, + BusLogic_InitializeExtendedMailbox = 0x81, + BusLogic_ExecuteSCSICommand = 0x83, + BusLogic_InquireFirmwareVersion3rdDigit = 0x84, BusLogic_InquireFirmwareVersionLetter = 0x85, BusLogic_InquirePCIHostAdapterInformation = 0x86, BusLogic_InquireHostAdapterModelNumber =0x8B, - BusLogic_InquireSynchronousPeriod = 0x8C, + BusLogic_InquireSynchronousPeriod = 0x8C, BusLogic_InquireExtendedSetupInformation = 0x8D, - BusLogic_EnableStrictRoundRobinMode = 0x8F, - BusLogic_StoreHostAdapterLocalRAM = 0x90, - BusLogic_FetchHostAdapterLocalRAM = 0x91, - BusLogic_StoreLocalDataInEEPROM = 0x92, - BusLogic_UploadAutoSCSICode = 0x94, - BusLogic_ModifyIOAddress = 0x95, - BusLogic_SetCCBFormat = 0x96, - BusLogic_WriteInquiryBuffer = 0x9A, - BusLogic_ReadInquiryBuffer = 0x9B, - BusLogic_FlashROMUploadDownload = 0xA7, - BusLogic_ReadSCAMData = 0xA8, - BusLogic_WriteSCAMData = 0xA9 + BusLogic_EnableStrictRoundRobinMode = 0x8F, + BusLogic_StoreHostAdapterLocalRAM = 0x90, + BusLogic_FetchHostAdapterLocalRAM = 0x91, + BusLogic_StoreLocalDataInEEPROM = 0x92, + BusLogic_UploadAutoSCSICode = 0x94, + BusLogic_ModifyIOAddress = 0x95, + BusLogic_SetCCBFormat = 0x96, + BusLogic_WriteInquiryBuffer = 0x9A, + BusLogic_ReadInquiryBuffer = 0x9B, + BusLogic_FlashROMUploadDownload = 0xA7, + BusLogic_ReadSCAMData = 0xA8, + BusLogic_WriteSCAMData = 0xA9 }BusLogic_OperationCode_T; @@ -181,8 +186,8 @@ typedef unsigned int BusLogic_ByteCount_T; typedef struct BusLogic_FetchHostAdapterLocalRAMRequest { - UCHAR ByteOffset; // Byte 0 - UCHAR ByteCount; // Byte 1 + UCHAR ByteOffset; // Byte 0 + UCHAR ByteCount; // Byte 1 } BusLogic_FetchHostAdapterLocalRAMRequest_T; @@ -191,39 +196,39 @@ BusLogic_FetchHostAdapterLocalRAMRequest_T; // the Modify I/O Address command. typedef enum BusLogic_ISACompatibleIOPort { - BusLogic_IO_330 = 0, - BusLogic_IO_334 = 1, - BusLogic_IO_230 = 2, - BusLogic_IO_234 = 3, - BusLogic_IO_130 = 4, - BusLogic_IO_134 = 5, - BusLogic_IO_Disable = 6, - BusLogic_IO_Disable2 = 7 + BusLogic_IO_330 = 0, + BusLogic_IO_334 = 1, + BusLogic_IO_230 = 2, + BusLogic_IO_234 = 3, + BusLogic_IO_130 = 4, + BusLogic_IO_134 = 5, + BusLogic_IO_Disable = 6, + BusLogic_IO_Disable2 = 7 } BusLogic_ISACompatibleIOPort_T; #pragma pack (1) typedef struct BusLogic_PCIHostAdapterInformation { - UCHAR ISACompatibleIOPort; /* Byte 0 */ - UCHAR PCIAssignedIRQChannel; /* Byte 1 */ - BOOLEAN LowByteTerminated:1; /* Byte 2 Bit 0 */ - BOOLEAN HighByteTerminated:1; /* Byte 2 Bit 1 */ - UCHAR :2; /* Byte 2 Bits 2-3 */ - BOOLEAN JP1:1; /* Byte 2 Bit 4 */ - BOOLEAN JP2:1; /* Byte 2 Bit 5 */ - BOOLEAN JP3:1; /* Byte 2 Bit 6 */ - BOOLEAN GenericInfoValid:1; /* Byte 2 Bit 7 */ - UCHAR :8; /* Byte 3 */ + UCHAR ISACompatibleIOPort; /* Byte 0 */ + UCHAR PCIAssignedIRQChannel; /* Byte 1 */ + BOOLEAN LowByteTerminated:1; /* Byte 2 Bit 0 */ + BOOLEAN HighByteTerminated:1; /* Byte 2 Bit 1 */ + UCHAR :2; /* Byte 2 Bits 2-3 */ + BOOLEAN JP1:1; /* Byte 2 Bit 4 */ + BOOLEAN JP2:1; /* Byte 2 Bit 5 */ + BOOLEAN JP3:1; /* Byte 2 Bit 6 */ + BOOLEAN GenericInfoValid:1; /* Byte 2 Bit 7 */ + UCHAR :8; /* Byte 3 */ }BusLogic_PCIHostAdapterInformation_T; // Define the Inquire Board ID reply structure. typedef struct BusLogic_BoardID { - UCHAR BoardType; /* Byte 0 */ - UCHAR CustomFeatures; /* Byte 1 */ - UCHAR FirmwareVersion1stDigit; /* Byte 2 */ - UCHAR FirmwareVersion2ndDigit; /* Byte 3 */ + UCHAR BoardType; /* Byte 0 */ + UCHAR CustomFeatures; /* Byte 1 */ + UCHAR FirmwareVersion1stDigit; /* Byte 2 */ + UCHAR FirmwareVersion2ndDigit; /* Byte 3 */ } BusLogic_BoardID_T; #pragma pack () @@ -241,7 +246,7 @@ typedef struct BusLogic_TargetFlags BusLogic_TargetFlags_T; // Define the Host Adapter Target Statistics structure. -#define BusLogic_SizeBuckets 10 +#define BusLogic_SizeBuckets 10 // Define a 10^18 Statistics Byte Counter data type. typedef struct BusLogic_ByteCounter @@ -278,28 +283,28 @@ BusLogic_TargetStatistics_T; // Define the Inquire Configuration reply structure. typedef struct BusLogic_Configuration { - UCHAR :5; /* Byte 0 Bits 0-4 */ - BOOLEAN DMA_Channel5:1; /* Byte 0 Bit 5 */ - BOOLEAN DMA_Channel6:1; /* Byte 0 Bit 6 */ - BOOLEAN DMA_Channel7:1; /* Byte 0 Bit 7 */ - BOOLEAN IRQ_Channel9:1; /* Byte 1 Bit 0 */ - BOOLEAN IRQ_Channel10:1; /* Byte 1 Bit 1 */ - BOOLEAN IRQ_Channel11:1; /* Byte 1 Bit 2 */ - BOOLEAN IRQ_Channel12:1; /* Byte 1 Bit 3 */ - UCHAR :1; /* Byte 1 Bit 4 */ - BOOLEAN IRQ_Channel14:1; /* Byte 1 Bit 5 */ - BOOLEAN IRQ_Channel15:1; /* Byte 1 Bit 6 */ - UCHAR :1; /* Byte 1 Bit 7 */ - UCHAR HostAdapterID:4; /* Byte 2 Bits 0-3 */ - UCHAR :4; /* Byte 2 Bits 4-7 */ + UCHAR :5; /* Byte 0 Bits 0-4 */ + BOOLEAN DMA_Channel5:1; /* Byte 0 Bit 5 */ + BOOLEAN DMA_Channel6:1; /* Byte 0 Bit 6 */ + BOOLEAN DMA_Channel7:1; /* Byte 0 Bit 7 */ + BOOLEAN IRQ_Channel9:1; /* Byte 1 Bit 0 */ + BOOLEAN IRQ_Channel10:1; /* Byte 1 Bit 1 */ + BOOLEAN IRQ_Channel11:1; /* Byte 1 Bit 2 */ + BOOLEAN IRQ_Channel12:1; /* Byte 1 Bit 3 */ + UCHAR :1; /* Byte 1 Bit 4 */ + BOOLEAN IRQ_Channel14:1; /* Byte 1 Bit 5 */ + BOOLEAN IRQ_Channel15:1; /* Byte 1 Bit 6 */ + UCHAR :1; /* Byte 1 Bit 7 */ + UCHAR HostAdapterID:4; /* Byte 2 Bits 0-3 */ + UCHAR :4; /* Byte 2 Bits 4-7 */ }BusLogic_Configuration_T; // Define the Inquire Setup Information reply structure. typedef struct BusLogic_SynchronousValue { - UCHAR Offset:4; /* Bits 0-3 */ - UCHAR TransferPeriod:3; /* Bits 4-6 */ - BOOLEAN Synchronous:1; /* Bit 7 */ + UCHAR Offset:4; /* Bits 0-3 */ + UCHAR TransferPeriod:3; /* Bits 4-6 */ + BOOLEAN Synchronous:1; /* Bit 7 */ }BusLogic_SynchronousValue_T; typedef BusLogic_SynchronousValue_T @@ -308,133 +313,133 @@ typedef BusLogic_SynchronousValue_T typedef struct BusLogic_SetupInformation { BOOLEAN SynchronousInitiationEnabled:1; /* Byte 0 Bit 0 */ - BOOLEAN ParityCheckingEnabled:1; /* Byte 0 Bit 1 */ - UCHAR :6; /* Byte 0 Bits 2-7 */ - UCHAR BusTransferRate; /* Byte 1 */ - UCHAR PreemptTimeOnBus; /* Byte 2 */ - UCHAR TimeOffBus; /* Byte 3 */ - UCHAR MailboxCount; /* Byte 4 */ - UCHAR MailboxAddress[3]; /* Bytes 5-7 */ + BOOLEAN ParityCheckingEnabled:1; /* Byte 0 Bit 1 */ + UCHAR :6; /* Byte 0 Bits 2-7 */ + UCHAR BusTransferRate; /* Byte 1 */ + UCHAR PreemptTimeOnBus; /* Byte 2 */ + UCHAR TimeOffBus; /* Byte 3 */ + UCHAR MailboxCount; /* Byte 4 */ + UCHAR MailboxAddress[3]; /* Bytes 5-7 */ BusLogic_SynchronousValues8_T SynchronousValuesID0to7; /* Bytes 8-15 */ - UCHAR DisconnectPermittedID0to7; /* Byte 16 */ - UCHAR Signature; /* Byte 17 */ - UCHAR CharacterD; /* Byte 18 */ - UCHAR HostBusType; /* Byte 19 */ - UCHAR WideTransfersPermittedID0to7; /* Byte 20 */ - UCHAR WideTransfersActiveID0to7; /* Byte 21 */ + UCHAR DisconnectPermittedID0to7; /* Byte 16 */ + UCHAR Signature; /* Byte 17 */ + UCHAR CharacterD; /* Byte 18 */ + UCHAR HostBusType; /* Byte 19 */ + UCHAR WideTransfersPermittedID0to7; /* Byte 20 */ + UCHAR WideTransfersActiveID0to7; /* Byte 21 */ BusLogic_SynchronousValues8_T SynchronousValuesID8to15;/* Bytes 22-29 */ - UCHAR DisconnectPermittedID8to15; /* Byte 30 */ - UCHAR :8; /* Byte 31 */ - UCHAR WideTransfersPermittedID8to15; /* Byte 32 */ - UCHAR WideTransfersActiveID8to15; /* Byte 33 */ + UCHAR DisconnectPermittedID8to15; /* Byte 30 */ + UCHAR :8; /* Byte 31 */ + UCHAR WideTransfersPermittedID8to15; /* Byte 32 */ + UCHAR WideTransfersActiveID8to15; /* Byte 33 */ }BusLogic_SetupInformation_T; // Something has to be done about the packing machanism of these structures - Namita // Define the Inquire Extended Setup Information reply structure. typedef struct BusLogic_ExtendedSetupInformation { - UCHAR BusType; // Byte 0 - UCHAR BIOS_Address; // Byte 1 - unsigned short ScatterGatherLimit; // Bytes 2-3 - UCHAR MailboxCount; // Byte 4 - BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8 + UCHAR BusType; // Byte 0 + UCHAR BIOS_Address; // Byte 1 + unsigned short ScatterGatherLimit; // Bytes 2-3 + UCHAR MailboxCount; // Byte 4 + BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8 struct { - UCHAR :2; // Byte 9 Bits 0-1 - BOOLEAN FastOnEISA:1; // Byte 9 Bit 2 - UCHAR :3; // Byte 9 Bits 3-5 - BOOLEAN LevelSensitiveInterrupt:1; // Byte 9 Bit 6 - UCHAR :1; - } Misc; // Byte 9 Bit 7 - UCHAR FirmwareRevision[3]; // Bytes 10-12 - BOOLEAN HostWideSCSI:1; // Byte 13 Bit 0 - BOOLEAN HostDifferentialSCSI:1; // Byte 13 Bit 1 - BOOLEAN HostSupportsSCAM:1; // Byte 13 Bit 2 - BOOLEAN HostUltraSCSI:1; // Byte 13 Bit 3 - BOOLEAN HostSmartTermination:1; // Byte 13 Bit 4 - UCHAR :3; // Byte 13 Bits 5-7 + UCHAR :2; // Byte 9 Bits 0-1 + BOOLEAN FastOnEISA:1; // Byte 9 Bit 2 + UCHAR :3; // Byte 9 Bits 3-5 + BOOLEAN LevelSensitiveInterrupt:1; // Byte 9 Bit 6 + UCHAR :1; + } Misc; // Byte 9 Bit 7 + UCHAR FirmwareRevision[3]; // Bytes 10-12 + BOOLEAN HostWideSCSI:1; // Byte 13 Bit 0 + BOOLEAN HostDifferentialSCSI:1; // Byte 13 Bit 1 + BOOLEAN HostSupportsSCAM:1; // Byte 13 Bit 2 + BOOLEAN HostUltraSCSI:1; // Byte 13 Bit 3 + BOOLEAN HostSmartTermination:1; // Byte 13 Bit 4 + UCHAR :3; // Byte 13 Bits 5-7 }BusLogic_ExtendedSetupInformation_T; // Define the Host Adapter Local RAM AutoSCSI structure. typedef struct BusLogic_AutoSCSIData { UCHAR InternalFactorySignature[2];/* Bytes 0-1 */ - UCHAR InformationByteCount; /* Byte 2 */ - UCHAR HostAdapterType[6]; /* Bytes 3-8 */ - UCHAR :8; /* Byte 9 */ - UCHAR FloppyEnabled:1; /* Byte 10 Bit 0 */ - UCHAR FloppySecondary:1; /* Byte 10 Bit 1 */ - UCHAR LevelSensitiveInterrupt:1; /* Byte 10 Bit 2 */ - UCHAR :2; /* Byte 10 Bits 3-4 */ - UCHAR SystemRAMAreaForBIOS:3; /* Byte 10 Bits 5-7 */ - UCHAR DMA_Channel:7; /* Byte 11 Bits 0-6 */ - UCHAR DMA_AutoConfiguration:1; /* Byte 11 Bit 7 */ - UCHAR IRQ_Channel:7; /* Byte 12 Bits 0-6 */ - UCHAR IRQ_AutoConfiguration:1; /* Byte 12 Bit 7 */ - UCHAR DMA_TransferRate; /* Byte 13 */ - UCHAR SCSI_ID; /* Byte 14 */ - UCHAR LowByteTerminated:1; /* Byte 15 Bit 0 */ - UCHAR ParityCheckingEnabled:1; /* Byte 15 Bit 1 */ - UCHAR HighByteTerminated:1; /* Byte 15 Bit 2 */ - UCHAR NoisyCablingEnvironment:1; /* Byte 15 Bit 3 */ - UCHAR FastSynchronousNegotiation:1; /* Byte 15 Bit 4 */ - UCHAR BusResetEnabled:1; /* Byte 15 Bit 5 */ - UCHAR :1; /* Byte 15 Bit 6 */ - UCHAR ActiveNegationEnabled:1; /* Byte 15 Bit 7 */ - UCHAR BusOnDelay; /* Byte 16 */ - UCHAR BusOffDelay; /* Byte 17 */ - UCHAR HostAdapterBIOSEnabled:1; /* Byte 18 Bit 0 */ - UCHAR BIOSRedirectionOfINT19Enabled:1; /* Byte 18 Bit 1 */ - UCHAR ExtendedTranslationEnabled:1; /* Byte 18 Bit 2 */ - UCHAR MapRemovableAsFixedEnabled:1; /* Byte 18 Bit 3 */ - UCHAR :1; /* Byte 18 Bit 4 */ + UCHAR InformationByteCount; /* Byte 2 */ + UCHAR HostAdapterType[6]; /* Bytes 3-8 */ + UCHAR :8; /* Byte 9 */ + UCHAR FloppyEnabled:1; /* Byte 10 Bit 0 */ + UCHAR FloppySecondary:1; /* Byte 10 Bit 1 */ + UCHAR LevelSensitiveInterrupt:1; /* Byte 10 Bit 2 */ + UCHAR :2; /* Byte 10 Bits 3-4 */ + UCHAR SystemRAMAreaForBIOS:3; /* Byte 10 Bits 5-7 */ + UCHAR DMA_Channel:7; /* Byte 11 Bits 0-6 */ + UCHAR DMA_AutoConfiguration:1; /* Byte 11 Bit 7 */ + UCHAR IRQ_Channel:7; /* Byte 12 Bits 0-6 */ + UCHAR IRQ_AutoConfiguration:1; /* Byte 12 Bit 7 */ + UCHAR DMA_TransferRate; /* Byte 13 */ + UCHAR SCSI_ID; /* Byte 14 */ + UCHAR LowByteTerminated:1; /* Byte 15 Bit 0 */ + UCHAR ParityCheckingEnabled:1; /* Byte 15 Bit 1 */ + UCHAR HighByteTerminated:1; /* Byte 15 Bit 2 */ + UCHAR NoisyCablingEnvironment:1; /* Byte 15 Bit 3 */ + UCHAR FastSynchronousNegotiation:1; /* Byte 15 Bit 4 */ + UCHAR BusResetEnabled:1; /* Byte 15 Bit 5 */ + UCHAR :1; /* Byte 15 Bit 6 */ + UCHAR ActiveNegationEnabled:1; /* Byte 15 Bit 7 */ + UCHAR BusOnDelay; /* Byte 16 */ + UCHAR BusOffDelay; /* Byte 17 */ + UCHAR HostAdapterBIOSEnabled:1; /* Byte 18 Bit 0 */ + UCHAR BIOSRedirectionOfINT19Enabled:1; /* Byte 18 Bit 1 */ + UCHAR ExtendedTranslationEnabled:1; /* Byte 18 Bit 2 */ + UCHAR MapRemovableAsFixedEnabled:1; /* Byte 18 Bit 3 */ + UCHAR :1; /* Byte 18 Bit 4 */ UCHAR BIOSSupportsMoreThan2DrivesEnabled:1;/* Byte 18 Bit 5 */ - UCHAR BIOSInterruptModeEnabled:1; /* Byte 18 Bit 6 */ - UCHAR FlopticalSupportEnabled:1; /* Byte 19 Bit 7 */ - unsigned short DeviceEnabled:16; /* Bytes 19-20 */ - unsigned short WidePermitted:16; /* Bytes 21-22 */ - unsigned short FastPermitted:16; /* Bytes 23-24 */ - unsigned short SynchronousPermitted:16; /* Bytes 25-26 */ - unsigned short DisconnectPermitted:16; /* Bytes 27-28 */ - unsigned short SendStartUnitCommand:16; /* Bytes 29-30 */ - unsigned short IgnoreInBIOSScan:16; /* Bytes 31-32 */ - UCHAR PCIInterruptPin:2; /* Byte 33 Bits 0-1 */ - UCHAR HostAdapterIOPortAddress:2; /* Byte 33 Bits 2-3 */ - UCHAR StrictRoundRobinModeEnabled:1; /* Byte 33 Bit 4 */ - UCHAR VESABusSpeedGreaterThan33MHz:1; /* Byte 33 Bit 5 */ - UCHAR VESABurstWriteEnabled:1; /* Byte 33 Bit 6 */ - UCHAR VESABurstReadEnabled:1; /* Byte 33 Bit 7 */ - unsigned short UltraPermitted:16; /* Bytes 34-35 */ - unsigned int :32; /* Bytes 36-39 */ - UCHAR :8; /* Byte 40 */ - UCHAR AutoSCSIMaximumLUN; /* Byte 41 */ - UCHAR :1; /* Byte 42 Bit 0 */ - UCHAR SCAM_Dominant:1; /* Byte 42 Bit 1 */ - UCHAR SCAM_Enabled:1; /* Byte 42 Bit 2 */ - UCHAR SCAM_Level2:1; /* Byte 42 Bit 3 */ - UCHAR :4; /* Byte 42 Bits 4-7 */ - UCHAR INT13ExtensionEnabled:1; /* Byte 43 Bit 0 */ - UCHAR :1; /* Byte 43 Bit 1 */ - UCHAR CDROMBootEnabled:1; /* Byte 43 Bit 2 */ - UCHAR :5; /* Byte 43 Bits 3-7 */ - UCHAR BootTargetID:4; /* Byte 44 Bits 0-3 */ - UCHAR BootChannel:4; /* Byte 44 Bits 4-7 */ - UCHAR ForceBusDeviceScanningOrder:1; /* Byte 45 Bit 0 */ - UCHAR :7; /* Byte 45 Bits 1-7 */ - unsigned short NonTaggedToAlternateLUNPermitted; /* Bytes 46-47 */ + UCHAR BIOSInterruptModeEnabled:1; /* Byte 18 Bit 6 */ + UCHAR FlopticalSupportEnabled:1; /* Byte 19 Bit 7 */ + unsigned short DeviceEnabled:16; /* Bytes 19-20 */ + unsigned short WidePermitted:16; /* Bytes 21-22 */ + unsigned short FastPermitted:16; /* Bytes 23-24 */ + unsigned short SynchronousPermitted:16; /* Bytes 25-26 */ + unsigned short DisconnectPermitted:16; /* Bytes 27-28 */ + unsigned short SendStartUnitCommand:16; /* Bytes 29-30 */ + unsigned short IgnoreInBIOSScan:16; /* Bytes 31-32 */ + UCHAR PCIInterruptPin:2; /* Byte 33 Bits 0-1 */ + UCHAR HostAdapterIOPortAddress:2; /* Byte 33 Bits 2-3 */ + UCHAR StrictRoundRobinModeEnabled:1; /* Byte 33 Bit 4 */ + UCHAR VESABusSpeedGreaterThan33MHz:1; /* Byte 33 Bit 5 */ + UCHAR VESABurstWriteEnabled:1; /* Byte 33 Bit 6 */ + UCHAR VESABurstReadEnabled:1; /* Byte 33 Bit 7 */ + unsigned short UltraPermitted:16; /* Bytes 34-35 */ + unsigned int :32; /* Bytes 36-39 */ + UCHAR :8; /* Byte 40 */ + UCHAR AutoSCSIMaximumLUN; /* Byte 41 */ + UCHAR :1; /* Byte 42 Bit 0 */ + UCHAR SCAM_Dominant:1; /* Byte 42 Bit 1 */ + UCHAR SCAM_Enabled:1; /* Byte 42 Bit 2 */ + UCHAR SCAM_Level2:1; /* Byte 42 Bit 3 */ + UCHAR :4; /* Byte 42 Bits 4-7 */ + UCHAR INT13ExtensionEnabled:1; /* Byte 43 Bit 0 */ + UCHAR :1; /* Byte 43 Bit 1 */ + UCHAR CDROMBootEnabled:1; /* Byte 43 Bit 2 */ + UCHAR :5; /* Byte 43 Bits 3-7 */ + UCHAR BootTargetID:4; /* Byte 44 Bits 0-3 */ + UCHAR BootChannel:4; /* Byte 44 Bits 4-7 */ + UCHAR ForceBusDeviceScanningOrder:1; /* Byte 45 Bit 0 */ + UCHAR :7; /* Byte 45 Bits 1-7 */ + unsigned short NonTaggedToAlternateLUNPermitted; /* Bytes 46-47 */ unsigned short RenegotiateSyncAfterCheckCondition; /* Bytes 48-49 */ - UCHAR Reserved[10]; /* Bytes 50-59 */ - UCHAR ManufacturingDiagnostic[2]; /* Bytes 60-61 */ - unsigned short Checksum:16; /* Bytes 62-63 */ + UCHAR Reserved[10]; /* Bytes 50-59 */ + UCHAR ManufacturingDiagnostic[2]; /* Bytes 60-61 */ + unsigned short Checksum:16; /* Bytes 62-63 */ }BusLogic_AutoSCSIData_T; #pragma pack() // Define the Outgoing Mailbox Action Codes. typedef enum { - BusLogic_OutgoingMailboxFree = 0x00, - BusLogic_MailboxStartCommand = 0x01, - BusLogic_MailboxAbortCommand = 0x02 + BusLogic_OutgoingMailboxFree = 0x00, + BusLogic_MailboxStartCommand = 0x01, + BusLogic_MailboxAbortCommand = 0x02 }BusLogic_ActionCode_T; @@ -443,33 +448,33 @@ typedef enum // completion codes are stored in the CCB; it only uses codes 1, 2, 4, and 5. typedef enum { - BusLogic_IncomingMailboxFree = 0x00, - BusLogic_CommandCompletedWithoutError = 0x01, - BusLogic_CommandAbortedAtHostRequest = 0x02, - BusLogic_AbortedCommandNotFound = 0x03, - BusLogic_CommandCompletedWithError = 0x04, - BusLogic_InvalidCCB = 0x05 + BusLogic_IncomingMailboxFree = 0x00, + BusLogic_CommandCompletedWithoutError = 0x01, + BusLogic_CommandAbortedAtHostRequest = 0x02, + BusLogic_AbortedCommandNotFound = 0x03, + BusLogic_CommandCompletedWithError = 0x04, + BusLogic_InvalidCCB = 0x05 }BusLogic_CompletionCode_T; // Define the Command Control Block (CCB) Opcodes. typedef enum { - BusLogic_InitiatorCCB = 0x00, - BusLogic_TargetCCB = 0x01, - BusLogic_InitiatorCCB_ScatterGather = 0x02, - BusLogic_InitiatorCCB_ResidualDataLength = 0x03, - BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04, - BusLogic_BusDeviceReset = 0x81 + BusLogic_InitiatorCCB = 0x00, + BusLogic_TargetCCB = 0x01, + BusLogic_InitiatorCCB_ScatterGather = 0x02, + BusLogic_InitiatorCCB_ResidualDataLength = 0x03, + BusLogic_InitiatorCCB_ScatterGatherResidual = 0x04, + BusLogic_BusDeviceReset = 0x81 }BusLogic_CCB_Opcode_T; // Define the CCB Data Direction Codes. typedef enum { - BusLogic_UncheckedDataTransfer = 0, - BusLogic_DataInLengthChecked = 1, - BusLogic_DataOutLengthChecked = 2, - BusLogic_NoDataTransfer = 3 + BusLogic_UncheckedDataTransfer = 0, + BusLogic_DataInLengthChecked = 1, + BusLogic_DataOutLengthChecked = 2, + BusLogic_NoDataTransfer = 3 }BusLogic_DataDirection_T; @@ -477,56 +482,56 @@ typedef enum // return status code 0x0C; it uses 0x12 for both overruns and underruns. typedef enum { - BusLogic_CommandCompletedNormally = 0x00, - BusLogic_LinkedCommandCompleted = 0x0A, - BusLogic_LinkedCommandCompletedWithFlag = 0x0B, - BusLogic_DataUnderRun = 0x0C, - BusLogic_SCSISelectionTimeout = 0x11, - BusLogic_DataOverRun = 0x12, - BusLogic_UnexpectedBusFree = 0x13, - BusLogic_InvalidBusPhaseRequested = 0x14, - BusLogic_InvalidOutgoingMailboxActionCode = 0x15, - BusLogic_InvalidCommandOperationCode = 0x16, - BusLogic_LinkedCCBhasInvalidLUN = 0x17, - BusLogic_InvalidCommandParameter = 0x1A, - BusLogic_AutoRequestSenseFailed = 0x1B, - BusLogic_TaggedQueuingMessageRejected = 0x1C, - BusLogic_UnsupportedMessageReceived = 0x1D, - BusLogic_HostAdapterHardwareFailed = 0x20, - BusLogic_TargetFailedResponseToATN = 0x21, - BusLogic_HostAdapterAssertedRST = 0x22, - BusLogic_OtherDeviceAssertedRST = 0x23, - BusLogic_TargetDeviceReconnectedImproperly = 0x24, - BusLogic_HostAdapterAssertedBusDeviceReset = 0x25, - BusLogic_AbortQueueGenerated = 0x26, - BusLogic_HostAdapterSoftwareError = 0x27, - BusLogic_HostAdapterHardwareTimeoutError= 0x30, - BusLogic_SCSIParityErrorDetected = 0x34 + BusLogic_CommandCompletedNormally = 0x00, + BusLogic_LinkedCommandCompleted = 0x0A, + BusLogic_LinkedCommandCompletedWithFlag = 0x0B, + BusLogic_DataUnderRun = 0x0C, + BusLogic_SCSISelectionTimeout = 0x11, + BusLogic_DataOverRun = 0x12, + BusLogic_UnexpectedBusFree = 0x13, + BusLogic_InvalidBusPhaseRequested = 0x14, + BusLogic_InvalidOutgoingMailboxActionCode = 0x15, + BusLogic_InvalidCommandOperationCode = 0x16, + BusLogic_LinkedCCBhasInvalidLUN = 0x17, + BusLogic_InvalidCommandParameter = 0x1A, + BusLogic_AutoRequestSenseFailed = 0x1B, + BusLogic_TaggedQueuingMessageRejected = 0x1C, + BusLogic_UnsupportedMessageReceived = 0x1D, + BusLogic_HostAdapterHardwareFailed = 0x20, + BusLogic_TargetFailedResponseToATN = 0x21, + BusLogic_HostAdapterAssertedRST = 0x22, + BusLogic_OtherDeviceAssertedRST = 0x23, + BusLogic_TargetDeviceReconnectedImproperly = 0x24, + BusLogic_HostAdapterAssertedBusDeviceReset = 0x25, + BusLogic_AbortQueueGenerated = 0x26, + BusLogic_HostAdapterSoftwareError = 0x27, + BusLogic_HostAdapterHardwareTimeoutError= 0x30, + BusLogic_SCSIParityErrorDetected = 0x34 }BusLogic_HostAdapterStatus_T; // Define the SCSI Target Device Status Codes. typedef enum { - BusLogic_OperationGood = 0x00, - BusLogic_CheckCondition = 0x02, - BusLogic_DeviceBusy = 0x08 + BusLogic_OperationGood = 0x00, + BusLogic_CheckCondition = 0x02, + BusLogic_DeviceBusy = 0x08 }BusLogic_TargetDeviceStatus_T; // Define the Queue Tag Codes. typedef enum { - BusLogic_SimpleQueueTag = 0, - BusLogic_HeadOfQueueTag = 1, - BusLogic_OrderedQueueTag = 2, - BusLogic_ReservedQT = 3 + BusLogic_SimpleQueueTag = 0, + BusLogic_HeadOfQueueTag = 1, + BusLogic_OrderedQueueTag = 2, + BusLogic_ReservedQT = 3 }BusLogic_QueueTag_T; // Define the Scatter/Gather Segment structure required by the MultiMaster // Firmware Interface and the FlashPoint SCCB Manager. typedef struct BusLogic_ScatterGatherSegment { - BusLogic_ByteCount_T SegmentByteCount; /* Bytes 0-3 */ - BusLogic_BusAddress_T SegmentDataPointer; /* Bytes 4-7 */ + BusLogic_ByteCount_T SegmentByteCount; /* Bytes 0-3 */ + BusLogic_BusAddress_T SegmentDataPointer; /* Bytes 4-7 */ }BusLogic_ScatterGatherSegment_T; @@ -535,10 +540,10 @@ typedef UCHAR SCSI_CDB_T[BusLogic_CDB_MaxLength]; // Define the Driver CCB Status Codes. typedef enum { - BusLogic_CCB_Free = 0, - BusLogic_CCB_Active = 1, - BusLogic_CCB_Completed = 2, - BusLogic_CCB_Reset = 3 + BusLogic_CCB_Free = 0, + BusLogic_CCB_Active = 1, + BusLogic_CCB_Completed = 2, + BusLogic_CCB_Reset = 3 }BusLogic_CCB_Status_T; // Define the 32 Bit Mode Command Control Block (CCB) structure. The first 40 @@ -557,27 +562,27 @@ typedef enum // 32 Logical Units per Target Device. typedef struct BusLogic_CCB { - UCHAR Opcode; /* Byte 0 */ - UCHAR :3; /* Byte 1 Bits 0-2 */ - UCHAR DataDirection:2; /* Byte 1 Bits 3-4 */ - UCHAR TagEnable:1; /* Byte 1 Bit 5 */ - UCHAR QueueTag:2; /* Byte 1 Bits 6-7 */ - UCHAR CDB_Length; /* Byte 2 */ - UCHAR SenseDataLength; /* Byte 3 */ - BusLogic_ByteCount_T DataLength; /* Bytes 4-7 */ + UCHAR Opcode; /* Byte 0 */ + UCHAR :3; /* Byte 1 Bits 0-2 */ + UCHAR DataDirection:2; /* Byte 1 Bits 3-4 */ + UCHAR TagEnable:1; /* Byte 1 Bit 5 */ + UCHAR QueueTag:2; /* Byte 1 Bits 6-7 */ + UCHAR CDB_Length; /* Byte 2 */ + UCHAR SenseDataLength; /* Byte 3 */ + BusLogic_ByteCount_T DataLength; /* Bytes 4-7 */ BusLogic_BusAddress_T DataPointer;/* Bytes 8-11 */ - UCHAR :8; /* Byte 12 */ - UCHAR :8; /* Byte 13 */ - UCHAR HostAdapterStatus; /* Byte 14 */ - UCHAR TargetDeviceStatus; /* Byte 15 */ - UCHAR TargetID; /* Byte 16 */ - UCHAR LogicalUnit:5; /* Byte 17 Bits 0-4 */ - UCHAR LegacyTagEnable:1; /* Byte 17 Bit 5 */ - UCHAR LegacyQueueTag:2; /* Byte 17 Bits 6-7 */ - SCSI_CDB_T CDB; /* Bytes 18-29 */ - UCHAR :8; /* Byte 30 */ - UCHAR :8; /* Byte 31 */ - unsigned int :32; /* Bytes 32-35 */ + UCHAR :8; /* Byte 12 */ + UCHAR :8; /* Byte 13 */ + UCHAR HostAdapterStatus; /* Byte 14 */ + UCHAR TargetDeviceStatus; /* Byte 15 */ + UCHAR TargetID; /* Byte 16 */ + UCHAR LogicalUnit:5; /* Byte 17 Bits 0-4 */ + UCHAR LegacyTagEnable:1; /* Byte 17 Bit 5 */ + UCHAR LegacyQueueTag:2; /* Byte 17 Bits 6-7 */ + SCSI_CDB_T CDB; /* Bytes 18-29 */ + UCHAR :8; /* Byte 30 */ + UCHAR :8; /* Byte 31 */ + unsigned int :32; /* Bytes 32-35 */ BusLogic_BusAddress_T SenseDataPointer;/* Bytes 36-39 */ // BusLogic Driver Defined Portion. @@ -598,20 +603,20 @@ typedef struct BusLogic_CCB typedef struct BusLogic_OutgoingMailbox { BusLogic_BusAddress_T CCB;/* Bytes 0-3 */ - UCHAR :8; /* Bytes 4 */ - UCHAR :8; /* Bytes 5 */ - UCHAR :8; /* Bytes 6 */ - UCHAR ActionCode; /* Byte 7 */ + UCHAR :8; /* Bytes 4 */ + UCHAR :8; /* Bytes 5 */ + UCHAR :8; /* Bytes 6 */ + UCHAR ActionCode; /* Byte 7 */ }BusLogic_OutgoingMailbox_T; // Define the 32 Bit Mode Incoming Mailbox structure. typedef struct BusLogic_IncomingMailbox { - BusLogic_BusAddress_T CCB; /* Bytes 0-3 */ - UCHAR HostAdapterStatus; /* Byte 4 */ - UCHAR TargetDeviceStatus; /* Byte 5 */ - UCHAR :8; /* Byte 6 */ - UCHAR CompletionCode; /* Byte 7 */ + BusLogic_BusAddress_T CCB; /* Bytes 0-3 */ + UCHAR HostAdapterStatus; /* Byte 4 */ + UCHAR TargetDeviceStatus; /* Byte 5 */ + UCHAR :8; /* Byte 6 */ + UCHAR CompletionCode; /* Byte 7 */ }BusLogic_IncomingMailbox_T; #pragma pack () @@ -625,40 +630,41 @@ typedef struct _NONCACHED_EXTENSION ULONG MailboxPA; // Mailboxes - UCHAR MailboxOut[BusLogic_MaxMailboxes * sizeof(BusLogic_OutgoingMailbox_T)]; - UCHAR MailboxIn[BusLogic_MaxMailboxes * sizeof(BusLogic_IncomingMailbox_T)]; + UCHAR MailboxOut[BusLogic_MaxMailboxes * sizeof(BusLogic_OutgoingMailbox_T)]; + UCHAR MailboxIn[BusLogic_MaxMailboxes * sizeof(BusLogic_IncomingMailbox_T)]; } NONCACHED_EXTENSION, *PNONCACHED_EXTENSION; // Define the types of BusLogic Host Adapters that are supported and the number // of I/O Addresses required by each type. typedef enum { - BusLogic_MultiMaster = 1, - BusLogic_FlashPoint = 2 + BusLogic_MultiMaster = 1, + BusLogic_FlashPoint = 2 }BusLogic_HostAdapterType_T; // Define the possible Host Adapter Bus Types. typedef enum { - BusLogic_Unknown_Bus = 0, - BusLogic_ISA_Bus = 1, - BusLogic_EISA_Bus = 2, - BusLogic_PCI_Bus = 3, - BusLogic_VESA_Bus = 4, - BusLogic_MCA_Bus = 5 + BusLogic_Unknown_Bus = 0, + BusLogic_ISA_Bus = 1, + BusLogic_EISA_Bus = 2, + BusLogic_PCI_Bus = 3, + BusLogic_VESA_Bus = 4, + BusLogic_MCA_Bus = 5 }BusLogic_HostAdapterBusType_T; #if 0 static char *BusLogic_HostAdapterBusNames[] = { "Unknown", "ISA", "EISA", "PCI", "VESA", "MCA" }; #endif static BusLogic_HostAdapterBusType_T - BusLogic_HostAdapterBusTypes[] ={ BusLogic_VESA_Bus, /* BT-4xx */ - BusLogic_ISA_Bus, /* BT-5xx */ - BusLogic_MCA_Bus, /* BT-6xx */ - BusLogic_EISA_Bus, /* BT-7xx */ - BusLogic_Unknown_Bus, /* BT-8xx */ - BusLogic_PCI_Bus /* BT-9xx */ - }; + BusLogic_HostAdapterBusTypes[] ={ BusLogic_VESA_Bus, /* BT-4xx */ + BusLogic_ISA_Bus, /* BT-5xx */ + BusLogic_MCA_Bus, /* BT-6xx */ + BusLogic_EISA_Bus, /* BT-7xx */ + BusLogic_Unknown_Bus, /* BT-8xx */ + BusLogic_PCI_Bus /* BT-9xx */ + }; + // Define the BusLogic Driver Host Adapter structure typedef struct BusLogic_HostAdapter { @@ -760,28 +766,28 @@ _HW_DEVICE_EXTENSION #pragma pack (1) typedef struct SCSI_Inquiry { - UCHAR PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */ - UCHAR PeripheralQualifier:3; /* Byte 0 Bits 5-7 */ - UCHAR DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */ - BOOLEAN RMB:1; /* Byte 1 Bit 7 */ - UCHAR ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */ - UCHAR ECMA_Version:3; /* Byte 2 Bits 3-5 */ - UCHAR ISO_Version:2; /* Byte 2 Bits 6-7 */ - UCHAR ResponseDataFormat:4; /* Byte 3 Bits 0-3 */ - UCHAR :2; /* Byte 3 Bits 4-5 */ - BOOLEAN TrmIOP:1; /* Byte 3 Bit 6 */ - BOOLEAN AENC:1; /* Byte 3 Bit 7 */ - UCHAR AdditionalLength; /* Byte 4 */ - UCHAR :8; /* Byte 5 */ - UCHAR :8; /* Byte 6 */ - BOOLEAN SftRe:1; /* Byte 7 Bit 0 */ - BOOLEAN CmdQue:1; /* Byte 7 Bit 1 */ - BOOLEAN :1; /* Byte 7 Bit 2 */ - BOOLEAN Linked:1; /* Byte 7 Bit 3 */ - BOOLEAN Sync:1; /* Byte 7 Bit 4 */ - BOOLEAN WBus16:1; /* Byte 7 Bit 5 */ - BOOLEAN WBus32:1; /* Byte 7 Bit 6 */ - BOOLEAN RelAdr:1; /* Byte 7 Bit 7 */ + UCHAR PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */ + UCHAR PeripheralQualifier:3; /* Byte 0 Bits 5-7 */ + UCHAR DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */ + BOOLEAN RMB:1; /* Byte 1 Bit 7 */ + UCHAR ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */ + UCHAR ECMA_Version:3; /* Byte 2 Bits 3-5 */ + UCHAR ISO_Version:2; /* Byte 2 Bits 6-7 */ + UCHAR ResponseDataFormat:4; /* Byte 3 Bits 0-3 */ + UCHAR :2; /* Byte 3 Bits 4-5 */ + BOOLEAN TrmIOP:1; /* Byte 3 Bit 6 */ + BOOLEAN AENC:1; /* Byte 3 Bit 7 */ + UCHAR AdditionalLength; /* Byte 4 */ + UCHAR :8; /* Byte 5 */ + UCHAR :8; /* Byte 6 */ + BOOLEAN SftRe:1; /* Byte 7 Bit 0 */ + BOOLEAN CmdQue:1; /* Byte 7 Bit 1 */ + BOOLEAN :1; /* Byte 7 Bit 2 */ + BOOLEAN Linked:1; /* Byte 7 Bit 3 */ + BOOLEAN Sync:1; /* Byte 7 Bit 4 */ + BOOLEAN WBus16:1; /* Byte 7 Bit 5 */ + BOOLEAN WBus32:1; /* Byte 7 Bit 6 */ + BOOLEAN RelAdr:1; /* Byte 7 Bit 7 */ UCHAR VendorIdentification[8];/* Bytes 8-15 */ UCHAR ProductIdentification[16];/* Bytes 16-31 */ UCHAR ProductRevisionLevel[4];/* Bytes 32-35 */ @@ -789,19 +795,19 @@ typedef struct SCSI_Inquiry typedef struct BusLogic_WmiExtendedSetupInformation { - UCHAR BusType; // Byte 0 - UCHAR BIOS_Address; // Byte 1 - unsigned short ScatterGatherLimit; // Bytes 2-3 - UCHAR MailboxCount; // Byte 4 - BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8 - BOOLEAN FastOnEISA; // Byte 9 - BOOLEAN LevelSensitiveInterrupt; // Byte 10 - UCHAR FirmwareRevision[3]; // Bytes 11-14 - BOOLEAN HostWideSCSI; // Byte 15 - BOOLEAN HostDifferentialSCSI; // Byte 16 - BOOLEAN HostSupportsSCAM; // Byte 17 - BOOLEAN HostUltraSCSI; // Byte 18 - BOOLEAN HostSmartTermination; // Byte 19 + UCHAR BusType; // Byte 0 + UCHAR BIOS_Address; // Byte 1 + unsigned short ScatterGatherLimit; // Bytes 2-3 + UCHAR MailboxCount; // Byte 4 + BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8 + BOOLEAN FastOnEISA; // Byte 9 + BOOLEAN LevelSensitiveInterrupt; // Byte 10 + UCHAR FirmwareRevision[3]; // Bytes 11-14 + BOOLEAN HostWideSCSI; // Byte 15 + BOOLEAN HostDifferentialSCSI; // Byte 16 + BOOLEAN HostSupportsSCAM; // Byte 17 + BOOLEAN HostUltraSCSI; // Byte 18 + BOOLEAN HostSmartTermination; // Byte 19 }BusLogic_WmiExtendedSetupInformation_T, *PBusLogic_WmiExtendedSetupInformation_T; #pragma pack () @@ -812,27 +818,28 @@ typedef struct BusLogic_WmiExtendedSetupInformation ULONG STDCALL DriverEntry(IN PVOID DriverObject, - IN PVOID Argument2 - ); + IN PVOID Argument2 + ); ULONG STDCALL BT958HwFindAdapter(IN PVOID HwDeviceExtension, - IN PVOID Context, - IN PVOID BusInformation, - IN PCHAR ArgumentString, - IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, - OUT PBOOLEAN Again); + IN PVOID Context, + IN PVOID BusInformation, + IN PCHAR ArgumentString, + IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, + OUT PBOOLEAN Again + ); -BOOLEAN +BOOLEAN STDCALL BT958HwInitialize(IN PVOID HwDeviceExtension); BOOLEAN STDCALL BT958HwStartIO(IN PVOID HwDeviceExtension, - IN PSCSI_REQUEST_BLOCK Srb - ); + IN PSCSI_REQUEST_BLOCK Srb + ); BOOLEAN STDCALL @@ -841,19 +848,19 @@ BT958HwInterrupt(IN PVOID HwDeviceExtension); BOOLEAN STDCALL BT958HwResetBus(IN PVOID HwDeviceExtension, - IN ULONG PathId - ); + IN ULONG PathId + ); SCSI_ADAPTER_CONTROL_STATUS STDCALL BT958HwAdapterControl(IN PVOID HwDeviceExtension, - IN SCSI_ADAPTER_CONTROL_TYPE ControlType, - IN PVOID Parameters - ); + IN SCSI_ADAPTER_CONTROL_TYPE ControlType, + IN PVOID Parameters + ); #if 0 BOOLEAN BT958WmiSrb(IN PHW_DEVICE_EXTENSION HwDeviceExtension, - IN OUT PSCSI_WMI_REQUEST_BLOCK Srb); + IN OUT PSCSI_WMI_REQUEST_BLOCK Srb); #endif void BT958WmiInitialize( IN PHW_DEVICE_EXTENSION HwDeviceExtension); @@ -861,45 +868,45 @@ BT958WmiInitialize( IN PHW_DEVICE_EXTENSION HwDeviceExtension); BOOLEAN Buslogic_InitBT958(PHW_DEVICE_EXTENSION deviceExtension, - PPORT_CONFIGURATION_INFORMATION ConfigInfo); + PPORT_CONFIGURATION_INFORMATION ConfigInfo); BOOLEAN BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter); BOOLEAN BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, - BOOLEAN HardReset); + BOOLEAN HardReset); BOOLEAN BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter); int BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, - BusLogic_OperationCode_T OperationCode, - void *ParameterData, - int ParameterLength, - void *ReplyData, - int ReplyLength); + BusLogic_OperationCode_T OperationCode, + void *ParameterData, + int ParameterLength, + void *ReplyData, + int ReplyLength); BOOLEAN BusLogic_ReadHostAdapterConfiguration( BusLogic_HostAdapter_T *HostAdapter); - + BOOLEAN BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, - PPORT_CONFIGURATION_INFORMATION ConfigInfo); + PPORT_CONFIGURATION_INFORMATION ConfigInfo); BOOLEAN BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *HostAdapter); int BusLogic_QueueCommand(IN PVOID HwDeviceExtension, - IN PSCSI_REQUEST_BLOCK Srb, - IN PBuslogic_CCB_T ccb); + IN PSCSI_REQUEST_BLOCK Srb, + IN PBuslogic_CCB_T ccb); BOOLEAN BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension , - BusLogic_ActionCode_T ActionCode, - BusLogic_CCB_T *CCB); + BusLogic_ActionCode_T ActionCode, + BusLogic_CCB_T *CCB); void BusLogic_ScanIncomingMailboxes(PHW_DEVICE_EXTENSION deviceExtension); @@ -912,25 +919,25 @@ BusLogic_ProcessCompletedCCBs(PHW_DEVICE_EXTENSION deviceExtension); UCHAR BusLogic_ComputeResultCode(BusLogic_HostAdapter_T *HostAdapter, - BusLogic_HostAdapterStatus_T HostAdapterStatus, - BusLogic_TargetDeviceStatus_T TargetDeviceStatus, - UCHAR SenseDataLength); + BusLogic_HostAdapterStatus_T HostAdapterStatus, + BusLogic_TargetDeviceStatus_T TargetDeviceStatus, + UCHAR SenseDataLength); BOOLEAN BusLogic_SendBusDeviceReset(IN PVOID HwDeviceExtension, - PSCSI_REQUEST_BLOCK Srb); + PSCSI_REQUEST_BLOCK Srb); -UCHAR +static UCHAR ReadBusLogicPort(PUCHAR adr ) { - return ScsiPortReadPortUchar( adr ); + return ScsiPortReadPortUchar( adr ); } -VOID +static VOID WriteBusLogicPort(UCHAR data, - PUCHAR adr) + PUCHAR adr) { - ScsiPortWritePortUchar(adr, data); + ScsiPortWritePortUchar(adr, data); } //_________________________________________________________________________________________ @@ -938,12 +945,12 @@ WriteBusLogicPort(UCHAR data, //_________________________________________________________________________________________ // Define the BusLogic SCSI Host Adapter I/O Register Offsets. -#define BusLogic_ControlRegisterOffset 0 // WO register -#define BusLogic_StatusRegisterOffset 0 // RO register -#define BusLogic_CommandParameterRegisterOffset 1 // WO register -#define BusLogic_DataInRegisterOffset 1 // RO register -#define BusLogic_InterruptRegisterOffset 2 // RO register -#define BusLogic_GeometryRegisterOffset 3 // RO register +#define BusLogic_ControlRegisterOffset 0 // WO register +#define BusLogic_StatusRegisterOffset 0 // RO register +#define BusLogic_CommandParameterRegisterOffset 1 // WO register +#define BusLogic_DataInRegisterOffset 1 // RO register +#define BusLogic_InterruptRegisterOffset 2 // RO register +#define BusLogic_GeometryRegisterOffset 3 // RO register // Define the structure of the write-only Control Register. @@ -952,11 +959,11 @@ typedef union BusLogic_ControlRegister UCHAR All; struct { - UCHAR :4; // Bits 0-3 - BOOLEAN SCSIBusReset:1; // Bit 4 - BOOLEAN InterruptReset:1; // Bit 5 - BOOLEAN SoftReset:1; // Bit 6 - BOOLEAN HardReset:1; // Bit 7 + UCHAR :4; // Bits 0-3 + BOOLEAN SCSIBusReset:1; // Bit 4 + BOOLEAN InterruptReset:1; // Bit 5 + BOOLEAN SoftReset:1; // Bit 6 + BOOLEAN HardReset:1; // Bit 7 } Bits; }BusLogic_ControlRegister_T; @@ -967,14 +974,14 @@ typedef union BusLogic_StatusRegister UCHAR All; struct { - BOOLEAN CommandInvalid:1; // Bit 0 - BOOLEAN Reserved:1; // Bit 1 - BOOLEAN DataInRegisterReady:1; // Bit 2 - BOOLEAN CommandParameterRegisterBusy:1; // Bit 3 - BOOLEAN HostAdapterReady:1; // Bit 4 - BOOLEAN InitializationRequired:1; // Bit 5 - BOOLEAN DiagnosticFailure:1; // Bit 6 - BOOLEAN DiagnosticActive:1; // Bit 7 + BOOLEAN CommandInvalid:1; // Bit 0 + BOOLEAN Reserved:1; // Bit 1 + BOOLEAN DataInRegisterReady:1; // Bit 2 + BOOLEAN CommandParameterRegisterBusy:1; // Bit 3 + BOOLEAN HostAdapterReady:1; // Bit 4 + BOOLEAN InitializationRequired:1; // Bit 5 + BOOLEAN DiagnosticFailure:1; // Bit 6 + BOOLEAN DiagnosticActive:1; // Bit 7 } Bits; }BusLogic_StatusRegister_T; @@ -986,22 +993,22 @@ typedef union BusLogic_InterruptRegister UCHAR All; struct { - BOOLEAN IncomingMailboxLoaded:1; // Bit 0 - BOOLEAN OutgoingMailboxAvailable:1; // Bit 1 - BOOLEAN CommandComplete:1; // Bit 2 - BOOLEAN ExternalBusReset:1; // Bit 3 - UCHAR Reserved:3; // Bits 4-6 - BOOLEAN InterruptValid:1; // Bit 7 + BOOLEAN IncomingMailboxLoaded:1; // Bit 0 + BOOLEAN OutgoingMailboxAvailable:1; // Bit 1 + BOOLEAN CommandComplete:1; // Bit 2 + BOOLEAN ExternalBusReset:1; // Bit 3 + UCHAR Reserved:3; // Bits 4-6 + BOOLEAN InterruptValid:1; // Bit 7 } Bits; }BusLogic_InterruptRegister_T; // Define the possible Host Adapter BIOS Disk Geometry Translations. typedef enum BusLogic_BIOS_DiskGeometryTranslation { - BusLogic_BIOS_Disk_Not_Installed = 0, - BusLogic_BIOS_Disk_Installed_64x32 = 1, - BusLogic_BIOS_Disk_Installed_128x32 = 2, - BusLogic_BIOS_Disk_Installed_255x63 = 3 + BusLogic_BIOS_Disk_Not_Installed = 0, + BusLogic_BIOS_Disk_Installed_64x32 = 1, + BusLogic_BIOS_Disk_Installed_128x32 = 2, + BusLogic_BIOS_Disk_Installed_255x63 = 3 }BusLogic_BIOS_DiskGeometryTranslation_T; // Define the structure of the read-only Geometry Register @@ -1012,13 +1019,13 @@ typedef union BusLogic_GeometryRegister { BusLogic_BIOS_DiskGeometryTranslation_T Drive0Geometry:2; // Bits 0-1 BusLogic_BIOS_DiskGeometryTranslation_T Drive1Geometry:2; // Bits 2-3 - UCHAR :3; // Bits 4-6 - BOOLEAN ExtendedTranslationEnabled:1; // Bit 7 + UCHAR :3; // Bits 4-6 + BOOLEAN ExtendedTranslationEnabled:1; // Bit 7 } Bits; } BusLogic_GeometryRegister_T; -void +static void BusLogic_InterruptReset(BusLogic_HostAdapter_T *HostAdapter) { BusLogic_ControlRegister_T ControlRegister; @@ -1029,7 +1036,7 @@ BusLogic_InterruptReset(BusLogic_HostAdapter_T *HostAdapter) HostAdapter->IO_Address + BusLogic_ControlRegisterOffset); } -void +static void BusLogic_SoftReset(BusLogic_HostAdapter_T *HostAdapter) { BusLogic_ControlRegister_T ControlRegister; @@ -1039,7 +1046,7 @@ BusLogic_SoftReset(BusLogic_HostAdapter_T *HostAdapter) HostAdapter->IO_Address + BusLogic_ControlRegisterOffset); } -void +static void BusLogic_HardReset(BusLogic_HostAdapter_T *HostAdapter) { BusLogic_ControlRegister_T ControlRegister; @@ -1049,46 +1056,46 @@ BusLogic_HardReset(BusLogic_HostAdapter_T *HostAdapter) HostAdapter->IO_Address + BusLogic_ControlRegisterOffset); } -UCHAR +static UCHAR BusLogic_ReadStatusRegister(BusLogic_HostAdapter_T *HostAdapter) { return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset); } -UCHAR +static UCHAR BusLogic_ReadInterruptRegister(BusLogic_HostAdapter_T *HostAdapter) { return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset); } -UCHAR +static UCHAR BusLogic_ReadGeometryRegister(BusLogic_HostAdapter_T *HostAdapter) { return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset); } -UCHAR +static UCHAR BusLogic_ReadDataInRegister(BusLogic_HostAdapter_T *HostAdapter) { return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset); } -void +static void BusLogic_WriteCommandParameterRegister(BusLogic_HostAdapter_T *HostAdapter, - UCHAR Value) + UCHAR Value) { WriteBusLogicPort(Value, - HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset); + HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset); } // BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which // notifies the Host Adapter that an entry has been made in an Outgoing // Mailbox. -void +static void BusLogic_StartMailboxCommand(BusLogic_HostAdapter_T *HostAdapter) { BusLogic_WriteCommandParameterRegister(HostAdapter, - BusLogic_ExecuteMailboxCommand); + BusLogic_ExecuteMailboxCommand); } // Define the Inquire Synchronous Period reply type. For each Target Device, @@ -1112,8 +1119,8 @@ typedef unsigned short BusLogic_InstalledDevices_T; #pragma pack (1) typedef struct BusLogic_ExtendedMailboxRequest { - UCHAR MailboxCount; /* Byte 0 */ - ULONG BaseMailboxAddress; /* Bytes 1-4 */ + UCHAR MailboxCount; /* Byte 0 */ + ULONG BaseMailboxAddress; /* Bytes 1-4 */ }BusLogic_ExtendedMailboxRequest_T; #pragma pack () @@ -1121,17 +1128,17 @@ typedef struct BusLogic_ExtendedMailboxRequest // necessary to support more than 8 Logical Units per Target Device. typedef enum BusLogic_SetCCBFormatRequest { - BusLogic_LegacyLUNFormatCCB = 0, - BusLogic_ExtendedLUNFormatCCB = 1 + BusLogic_LegacyLUNFormatCCB = 0, + BusLogic_ExtendedLUNFormatCCB = 1 }BusLogic_SetCCBFormatRequest_T; //______________________________________________________________________________________ // Statistics //______________________________________________________________________________________ // BusLogic_IncrementByteCounter increments Byte Counter by Amount. -void +static void BusLogic_IncrementByteCounter(BusLogic_ByteCounter_T *ByteCounter, - unsigned int Amount) + unsigned int Amount) { ByteCounter->Units += Amount; if (ByteCounter->Units > 999999999) @@ -1142,34 +1149,34 @@ BusLogic_IncrementByteCounter(BusLogic_ByteCounter_T *ByteCounter, } // BusLogic_IncrementSizeBucket increments the Bucket for Amount. -void +static void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets, - unsigned int Amount) + unsigned int Amount) { int Index = 0; if (Amount < 8*1024) { if (Amount < 2*1024) - Index = (Amount < 1*1024 ? 0 : 1); + Index = (Amount < 1*1024 ? 0 : 1); else - Index = (Amount < 4*1024 ? 2 : 3); + Index = (Amount < 4*1024 ? 2 : 3); } else if (Amount < 128*1024) { if (Amount < 32*1024) - Index = (Amount < 16*1024 ? 4 : 5); + Index = (Amount < 16*1024 ? 4 : 5); else - Index = (Amount < 64*1024 ? 6 : 7); + Index = (Amount < 64*1024 ? 6 : 7); } else - Index = (Amount < 256*1024 ? 8 : 9); + Index = (Amount < 256*1024 ? 8 : 9); CommandSizeBuckets[Index]++; } // BusLogic_IncrementErrorCounter increments Error Counter by 1, stopping at // 65535 rather than wrapping around to 0. -void +static void BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter) { if (*ErrorCounter < 65535) (*ErrorCounter)++; diff --git a/reactos/drivers/storage/buslogic/BusLogic958.rc b/reactos/drivers/storage/buslogic/BusLogic958.rc index ff3191dc7c0..5109439ce70 100644 --- a/reactos/drivers/storage/buslogic/BusLogic958.rc +++ b/reactos/drivers/storage/buslogic/BusLogic958.rc @@ -21,6 +21,10 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 +#define DRIVER_VERSION 1,2,0,4 +#define DRIVER_VERSION_STRING "1.2.0.4" +#define DRIVER_NAME "VMware SCSI Controller Driver" + #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // @@ -28,34 +32,30 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2,0,0 - PRODUCTVERSION 1,2,0,0 - FILEFLAGSMASK 0x3fL + FILEVERSION DRIVER_VERSION + PRODUCTVERSION DRIVER_VERSION +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK #ifdef _DEBUG - FILEFLAGS 0x1L + FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0x0L #endif - FILEOS 0x40004L - FILETYPE 0x3L - FILESUBTYPE 0x7L +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DRV +FILESUBTYPE VFT2_DRV_SYSTEM BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "VMware, Inc.\0" - VALUE "FileDescription", "VMware SCSI Controller\0" - VALUE "FileVersion", "1, 2, 0, 0\0" - VALUE "InternalName", "vmscsi.sys\0" - VALUE "LegalCopyright", "Copyright © 1998-2003 VMware, Inc.\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "vmscsi.sys\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "VMware, Inc. Script1 Application\0" - VALUE "ProductVersion", "1, 2, 0, 0\0" - VALUE "SpecialBuild", "\0" + VALUE "CompanyName", "VMware, Inc." "\0" + VALUE "FileDescription", DRIVER_NAME "\0" + VALUE "FileVersion", DRIVER_VERSION_STRING "\0" + VALUE "InternalName", "vmscsi.sys" "\0" + VALUE "LegalCopyright", "Copyright © 1998-2004 VMware, Inc." "\0" + VALUE "OriginalFilename", "vmscsi.sys" "\0" + VALUE "ProductName", DRIVER_NAME "\0" + VALUE "ProductVersion", DRIVER_VERSION_STRING "\0" END END BLOCK "VarFileInfo" diff --git a/reactos/drivers/storage/buslogic/makefile.inc b/reactos/drivers/storage/buslogic/makefile.inc index 828967cf25b..f45fd63b317 100644 --- a/reactos/drivers/storage/buslogic/makefile.inc +++ b/reactos/drivers/storage/buslogic/makefile.inc @@ -1,5 +1,8 @@ clean: - del BT958dt.h BT958.bmf + del $(O)\BT958dt.h $(O)\BT958.bmf -BT958dt.h: BT958.bmf - wmimofck -hBT958dt.h BT958.bmf +$(O)\BT958.bmf: BT958.mof + mofcomp -B:$(O)\BT958.bmf BT958.mof + +$(O)\BT958dt.h: $(O)\BT958.bmf + wmimofck -h$(O)\BT958dt.h $(O)\BT958.bmf diff --git a/reactos/drivers/storage/buslogic/sources b/reactos/drivers/storage/buslogic/sources index 27e6cf1103d..57f6166321e 100644 --- a/reactos/drivers/storage/buslogic/sources +++ b/reactos/drivers/storage/buslogic/sources @@ -1,17 +1,26 @@ TARGETNAME=vmscsi -TARGETPATH=obj TARGETTYPE=MINIPORT +NT_UP=0 + +!if ("$(DDK_TARGET_OS)" == "Win2K") +TARGETPATH=win2k +!elseif ("$(DDK_TARGET_OS)" == "WinNET") +TARGETPATH=wnet +!endif TARGETLIBS=$(DDK_LIB_PATH)\scsiport.lib \ - $(DDK_LIB_PATH)\scsiwmi.lib \ + $(DDK_LIB_PATH)\scsiwmi.lib \ $(SDK_LIB_PATH)\ntoskrnl.lib +INCLUDES = $(INCLUDES) $(O) MSC_WARNING_LEVEL=/W3 /WX -SOURCES=BT958.mof \ - BusLogic958.c \ - BusLogic958.rc \ - wmi.c \ - Log.c +LINKER_FLAGS=$(LINKER_FLAGS) -debugtype:cv,fixup +USER_C_FLAGS=-Zi $(USER_C_FLAGS) -NTTARGETFILE0=BT958dt.h +SOURCES=BusLogic958.c \ + BusLogic958.rc \ + wmi.c \ + Log.c + +NTTARGETFILE0=$(O)\BT958dt.h $(O)\BT958.bmf diff --git a/reactos/drivers/storage/buslogic/wmi.c b/reactos/drivers/storage/buslogic/wmi.c index a1b7c64812f..b8bb5db4ad1 100644 --- a/reactos/drivers/storage/buslogic/wmi.c +++ b/reactos/drivers/storage/buslogic/wmi.c @@ -232,7 +232,7 @@ Return Value: --*/ { PHW_DEVICE_EXTENSION HwDeviceExtension = (PHW_DEVICE_EXTENSION)Context; - ULONG size; + ULONG size = 0; UCHAR status; // @@ -391,21 +391,21 @@ Return Value: Result = FALSE; } - WmiExtendedSetupInfo.BusType = ExtendedSetupInformation.BusType; - WmiExtendedSetupInfo.BIOS_Address = ExtendedSetupInformation.BIOS_Address; - WmiExtendedSetupInfo.ScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit; - WmiExtendedSetupInfo.MailboxCount = ExtendedSetupInformation.MailboxCount; - WmiExtendedSetupInfo.BaseMailboxAddress = ExtendedSetupInformation.BaseMailboxAddress; - WmiExtendedSetupInfo.FastOnEISA = ExtendedSetupInformation.Misc.FastOnEISA; + WmiExtendedSetupInfo.BusType = ExtendedSetupInformation.BusType; + WmiExtendedSetupInfo.BIOS_Address = ExtendedSetupInformation.BIOS_Address; + WmiExtendedSetupInfo.ScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit; + WmiExtendedSetupInfo.MailboxCount = ExtendedSetupInformation.MailboxCount; + WmiExtendedSetupInfo.BaseMailboxAddress = ExtendedSetupInformation.BaseMailboxAddress; + WmiExtendedSetupInfo.FastOnEISA = ExtendedSetupInformation.Misc.FastOnEISA; WmiExtendedSetupInfo.LevelSensitiveInterrupt = ExtendedSetupInformation.Misc.LevelSensitiveInterrupt; - WmiExtendedSetupInfo.FirmwareRevision[3] = ExtendedSetupInformation.FirmwareRevision[3]; - WmiExtendedSetupInfo.FirmwareRevision[3] = ExtendedSetupInformation.FirmwareRevision[3]; - WmiExtendedSetupInfo.FirmwareRevision[3] = ExtendedSetupInformation.FirmwareRevision[3]; - WmiExtendedSetupInfo.HostWideSCSI = ExtendedSetupInformation.HostWideSCSI; - WmiExtendedSetupInfo.HostDifferentialSCSI= ExtendedSetupInformation.HostDifferentialSCSI; - WmiExtendedSetupInfo.HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM; - WmiExtendedSetupInfo.HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI; - WmiExtendedSetupInfo.HostSmartTermination= ExtendedSetupInformation.HostSmartTermination; + WmiExtendedSetupInfo.FirmwareRevision[0] = ExtendedSetupInformation.FirmwareRevision[0]; + WmiExtendedSetupInfo.FirmwareRevision[1] = ExtendedSetupInformation.FirmwareRevision[1]; + WmiExtendedSetupInfo.FirmwareRevision[2] = ExtendedSetupInformation.FirmwareRevision[2]; + WmiExtendedSetupInfo.HostWideSCSI = ExtendedSetupInformation.HostWideSCSI; + WmiExtendedSetupInfo.HostDifferentialSCSI= ExtendedSetupInformation.HostDifferentialSCSI; + WmiExtendedSetupInfo.HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM; + WmiExtendedSetupInfo.HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI; + WmiExtendedSetupInfo.HostSmartTermination= ExtendedSetupInformation.HostSmartTermination; for (; numberOfBytes; numberOfBytes--) {