buslogic958.c
来自「一个类似windows」· C语言 代码 · 共 1,684 行 · 第 1/5 页
C
1,684 行
InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
if (InterruptRegister.Bits.CommandComplete)
break;
if (HostAdapter->HostAdapterCommandCompleted)
break;
if (StatusRegister.Bits.DataInRegisterReady)
break;
if (StatusRegister.Bits.CommandParameterRegisterBusy)
continue;
BusLogic_WriteCommandParameterRegister(HostAdapter, *ParameterPointer++);
ParameterLength--;
}
if (TimeoutCounter < 0)
{
//BusLogic_CommandFailureReason = "Timeout waiting for Parameter Acceptance";
Result = -2;
goto Done;
}
// The Modify I/O Address command does not cause a Command Complete Interrupt.
if (OperationCode == BusLogic_ModifyIOAddress)
{
StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
if (StatusRegister.Bits.CommandInvalid)
{
//BusLogic_CommandFailureReason = "Modify I/O Address Invalid";
Result = -1;
goto Done;
}
Result = 0;
goto Done;
}
// Select an appropriate timeout value for awaiting command completion.
switch (OperationCode)
{
case BusLogic_InquireInstalledDevicesID0to7:
case BusLogic_InquireInstalledDevicesID8to15:
case BusLogic_InquireTargetDevices:
// Approximately 60 seconds.
TimeoutCounter = 60*10000;
break;
default:
// Approximately 1 second.
TimeoutCounter = 10000;
break;
}
//
// Receive any Reply Bytes, waiting for either the Command Complete bit to
// be set in the Interrupt Register, or for the Interrupt Handler to set the
// Host Adapter Command Completed bit in the Host Adapter structure.
while (--TimeoutCounter >= 0)
{
InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
StatusRegister.All = BusLogic_ReadStatusRegister(HostAdapter);
if (InterruptRegister.Bits.CommandComplete)
break;
if (HostAdapter->HostAdapterCommandCompleted)
break;
if (StatusRegister.Bits.DataInRegisterReady)
{
if (++ReplyBytes <= ReplyLength)
{
*ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter);
}
else
{
BusLogic_ReadDataInRegister(HostAdapter);
}
}
if (OperationCode == BusLogic_FetchHostAdapterLocalRAM &&
StatusRegister.Bits.HostAdapterReady)
{
break;
}
ScsiPortStallExecution(100);
}
if (TimeoutCounter < 0)
{
//BusLogic_CommandFailureReason = "Timeout waiting for Command Complete";
Result = -2;
goto Done;
}
// Clear any pending Command Complete Interrupt.
BusLogic_InterruptReset(HostAdapter);
// Process Command Invalid conditions.
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.
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.
if (ParameterLength > 0)
{
//BusLogic_CommandFailureReason = "Excess Parameters Supplied";
Result = -1;
goto Done;
}
// Indicate the command completed successfully.
Result = ReplyBytes;
// Restore the interrupt status if necessary and return.
Done:
return Result;
}// end BusLogic_Command
BOOLEAN
BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter)
//___________________________________________________________________________________________
// Routine Description:
// BusLogic_ReadHostAdapterConfiguration reads the Configuration Information
// from Host Adapter and initializes the Host Adapter structure.
// Arguments:
// 1. Host adapter structure
// Return Value:
// TRUE : Configuration read properly
// FALSE : Encounter failure
//___________________________________________________________________________________________
{
BusLogic_BoardID_T BoardID;
BusLogic_Configuration_T Configuration;
BusLogic_SetupInformation_T SetupInformation;
BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation;
BusLogic_HostAdapterModelNumber_T HostAdapterModelNumber;
BusLogic_FirmwareVersion3rdDigit_T FirmwareVersion3rdDigit;
BusLogic_FirmwareVersionLetter_T FirmwareVersionLetter;
BusLogic_PCIHostAdapterInformation_T PCIHostAdapterInformation;
BusLogic_FetchHostAdapterLocalRAMRequest_T FetchHostAdapterLocalRAMRequest;
BusLogic_AutoSCSIData_T AutoSCSIData;
BusLogic_GeometryRegister_T GeometryRegister;
BusLogic_RequestedReplyLength_T RequestedReplyLength;
UCHAR *TargetPointer, Character;
ULONG /*TargetID,*/ i;
// Issue the Inquire Board ID command.
if (BusLogic_Command(HostAdapter,
BusLogic_InquireBoardID,
NULL,
0,
&BoardID, sizeof(BoardID))
!= sizeof(BoardID))
{
DebugPrint((0,"BusLogic_Failure: INQUIRE BOARD ID"));
return FALSE;
}
// Issue the Inquire Configuration command.
if (BusLogic_Command(HostAdapter,
BusLogic_InquireConfiguration,
NULL,
0,
&Configuration, sizeof(Configuration))
!= sizeof(Configuration))
{
DebugPrint((0,"BusLogic_Failure: INQUIRE CONFIGURATION"));
return FALSE;
}
// Issue the Inquire Setup Information command.
RequestedReplyLength = sizeof(SetupInformation);
if (BusLogic_Command(HostAdapter,
BusLogic_InquireSetupInformation,
&RequestedReplyLength,
sizeof(RequestedReplyLength),
&SetupInformation,
sizeof(SetupInformation))
!= sizeof(SetupInformation))
{
DebugPrint((0,"BusLogic_Failure: INQUIRE SETUP INFORMATION"));
return FALSE;
}
// Issue the Inquire Extended Setup Information command.
RequestedReplyLength = sizeof(ExtendedSetupInformation);
if (BusLogic_Command(HostAdapter,
BusLogic_InquireExtendedSetupInformation,
&RequestedReplyLength,
sizeof(RequestedReplyLength),
&ExtendedSetupInformation,
sizeof(ExtendedSetupInformation))
!= sizeof(ExtendedSetupInformation))
{
DebugPrint((0,"BusLogic_Failure: INQUIRE EXTENDED SETUP INFORMATION"));
return FALSE;
}
// Issue the Inquire Firmware Version 3rd Digit command.
FirmwareVersion3rdDigit = '\0';
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;
}
}
// 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))
{
DebugPrint((0,"BusLogic_Failure: INQUIRE HOST ADAPTER MODEL NUMBER"));
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
// Save the Model Name and Host Adapter Name in the Host Adapter structure.
TargetPointer = HostAdapter->ModelName;
*TargetPointer++ = 'B';
*TargetPointer++ = 'T';
*TargetPointer++ = '-';
for (i = 0; i < sizeof(HostAdapterModelNumber); i++)
{
Character = HostAdapterModelNumber[i];
if (Character == ' ' || Character == '\0') break;
*TargetPointer++ = Character;
}
*TargetPointer++ = '\0';
// Save the Firmware Version in the Host Adapter structure.
TargetPointer = HostAdapter->FirmwareVersion;
*TargetPointer++ = BoardID.FirmwareVersion1stDigit;
*TargetPointer++ = '.';
*TargetPointer++ = BoardID.FirmwareVersion2ndDigit;
if (FirmwareVersion3rdDigit != ' ' && FirmwareVersion3rdDigit != '\0')
*TargetPointer++ = FirmwareVersion3rdDigit;
*TargetPointer = '\0';
// Issue the Inquire Firmware Version Letter command.
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;
}
if (FirmwareVersionLetter != ' ' && FirmwareVersionLetter != '\0')
{
*TargetPointer++ = FirmwareVersionLetter;
}
*TargetPointer = '\0';
}
// Save the Host Adapter SCSI ID in the Host Adapter structure.
HostAdapter->SCSI_ID = Configuration.HostAdapterID;
// Determine the Bus Type and save it in the Host Adapter structure, determine
// and save the IRQ Channel if necessary, and determine and save the DMA
// Channel for ISA Host Adapters.
HostAdapter->HostAdapterBusType = BusLogic_HostAdapterBusTypes[HostAdapter->ModelName[3] - '4'];
GeometryRegister.All = BusLogic_ReadGeometryRegister(HostAdapter);
// Determine whether Extended Translation is enabled and save it in
// the Host Adapter structure.
// HostAdapter->ExtendedTranslationEnabled = GeometryRegister.Bits.ExtendedTranslationEnabled;
HostAdapter->ExtendedTranslationEnabled = GeometryRegister.All;
// Save the Scatter Gather Limits, Level Sensitive Interrupt flag, Wide
// SCSI flag, Differential SCSI flag, SCAM Supported flag, and
// Ultra SCSI flag in the Host Adapter structure.
HostAdapter->HostAdapterScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit;
HostAdapter->DriverScatterGatherLimit = HostAdapter->HostAdapterScatterGatherLimit;
if (HostAdapter->HostAdapterScatterGatherLimit > BusLogic_ScatterGatherLimit)
{
HostAdapter->DriverScatterGatherLimit = BusLogic_ScatterGatherLimit;
}
if (ExtendedSetupInformation.Misc.LevelSensitiveInterrupt)
{
HostAdapter->LevelSensitiveInterrupt = TRUE;
}
HostAdapter->HostWideSCSI = ExtendedSetupInformation.HostWideSCSI;
HostAdapter->HostDifferentialSCSI = ExtendedSetupInformation.HostDifferentialSCSI;
HostAdapter->HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM;
HostAdapter->HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?