ReactOS 0.4.15-dev-7958-gcd0bb1a
BusLogic958.c File Reference
#include "BusLogic958.h"
Include dependency graph for BusLogic958.c:

Go to the source code of this file.

Functions

ULONG NTAPI DriverEntry (IN PVOID DriverObject, IN PVOID Argument2)
 
ULONG NTAPI BT958HwFindAdapter (IN PVOID HwDeviceExtension, IN PVOID Context, IN PVOID BusInformation, IN PCHAR ArgumentString, IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, OUT PBOOLEAN Again)
 
BOOLEAN Buslogic_InitBT958 (PHW_DEVICE_EXTENSION deviceExtension, PPORT_CONFIGURATION_INFORMATION ConfigInfo)
 
BOOLEAN BusLogic_ProbeHostAdapter (BusLogic_HostAdapter_T *HostAdapter)
 
BOOLEAN BusLogic_HardwareResetHostAdapter (BusLogic_HostAdapter_T *HostAdapter, 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)
 
BOOLEAN BusLogic_ReadHostAdapterConfiguration (BusLogic_HostAdapter_T *HostAdapter)
 
BOOLEAN BusLogic_InitializeHostAdapter (PHW_DEVICE_EXTENSION deviceExtension, PPORT_CONFIGURATION_INFORMATION ConfigInfo)
 
BOOLEAN BusLogic_TargetDeviceInquiry (BusLogic_HostAdapter_T *HostAdapter)
 
VOID BusLogic_InitializeCCB (PBuslogic_CCB_T CCB)
 
BOOLEAN NTAPI BT958HwStartIO (IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
 
BOOLEAN BusLogic_WriteOutgoingMailbox (PHW_DEVICE_EXTENSION deviceExtension, BusLogic_ActionCode_T ActionCode, BusLogic_CCB_T *CCB)
 
int BusLogic_QueueCommand (IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, PBuslogic_CCB_T CCB)
 
BOOLEAN NTAPI BT958HwInterrupt (IN PVOID HwDeviceExtension)
 
void BusLogic_ScanIncomingMailboxes (PHW_DEVICE_EXTENSION deviceExtension)
 
void BusLogic_QueueCompletedCCB (PHW_DEVICE_EXTENSION deviceExtension, BusLogic_CCB_T *CCB)
 
void BusLogic_ProcessCompletedCCBs (PHW_DEVICE_EXTENSION deviceExtension)
 
UCHAR BusLogic_ComputeResultCode (BusLogic_HostAdapter_T *HostAdapter, BusLogic_HostAdapterStatus_T HostAdapterStatus, BusLogic_TargetDeviceStatus_T TargetDeviceStatus, UCHAR SenseDataLength)
 
BOOLEAN NTAPI BT958HwResetBus (IN PVOID HwDeviceExtension, IN ULONG PathId)
 
BOOLEAN BusLogic_SendBusDeviceReset (IN PVOID HwDeviceExtension, PSCSI_REQUEST_BLOCK Srb)
 
BOOLEAN NTAPI BT958HwInitialize (IN PVOID HwDeviceExtension)
 
SCSI_ADAPTER_CONTROL_STATUS NTAPI BT958HwAdapterControl (IN PVOID HwDeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, IN PVOID Parameters)
 

Function Documentation

◆ BT958HwAdapterControl()

SCSI_ADAPTER_CONTROL_STATUS NTAPI BT958HwAdapterControl ( IN PVOID  HwDeviceExtension,
IN SCSI_ADAPTER_CONTROL_TYPE  ControlType,
IN PVOID  Parameters 
)

Definition at line 2651 of file BusLogic958.c.

2673{
2674 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
2675 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2676// UCHAR *ParameterPointer;
2677// BusLogic_StatusRegister_T StatusRegister;
2678// BusLogic_InterruptRegister_T InterruptRegister;
2679// int Result,ParameterLength;
2680// long TimeoutCounter;
2681
2682 PSCSI_SUPPORTED_CONTROL_TYPE_LIST ControlTypeList;
2683 ULONG AdjustedMaxControlType;
2684
2685 ULONG Index;
2686// UCHAR Retries;
2687
2688 // Default Status
2689// SCSI_ADAPTER_CONTROL_STATUS Status = ScsiAdapterControlSuccess;
2690
2691 //
2692 // Structure defining which functions this miniport supports
2693 //
2694 BOOLEAN SupportedConrolTypes[ScsiAdapterControlMax] =
2695 {
2696 TRUE, // ScsiQuerySupportedControlTypes
2697 TRUE, // ScsiStopAdapter
2698 TRUE, // ScsiRestartAdapter
2699 FALSE, // ScsiSetBootConfig
2700 FALSE // ScsiSetRunningConfig
2701 };
2702
2703 DebugPrint((TRACE, "\n BusLogic - Inside HwAdapterControl function \n"));
2704 switch(ControlType)
2705 {
2707 // Reports the adapter-control operations implemented by the miniport. The port
2708 // driver calls HwScsiAdapterControl with this control type after the HBA has been
2709 // initialized but before the first I/O. The miniport fills in the
2710 // SCSI_SUPPORTED_CONTROL_TYPE_LIST structure at Parameters with the operations it
2711 // supports. After HwScsiAdapterControl returns from this call, the port driver
2712 // calls the miniport's HwScsiAdapterControl only for supported operations.
2713 {
2714
2715 // This entry point provides the method by which SCSIPort determines the
2716 // supported ControlTypes. Parameters is a pointer to a
2717 // SCSI_SUPPORTED_CONTROL_TYPE_LIST structure. Fill in this structure
2718 // honoring the size limits.
2719 ControlTypeList = Parameters;
2720 AdjustedMaxControlType = (ControlTypeList->MaxControlType < ScsiAdapterControlMax) ? ControlTypeList->MaxControlType :ScsiAdapterControlMax;
2721 for (Index = 0; Index < AdjustedMaxControlType; Index++)
2722 {
2723 ControlTypeList->SupportedTypeList[Index] = SupportedConrolTypes[Index];
2724 }
2725 break;
2726 }
2727
2728 case ScsiStopAdapter:
2729 // Shuts down the HBA. The port driver calls HwScsiAdapterControl with this control
2730 // type when the HBA has been removed from the system, stopped for resource reconfiguration,
2731 // shut down for power management, or otherwise reconfigured or disabled. The port driver
2732 // ensures that there are no uncompleted requests and issues an SRB_FUNCTION_FLUSH request
2733 // to the miniport before calling this routine. The miniport disables interrupts on its HBA,
2734 // halts all processing, (including background processing not subject to interrupts or processing
2735 // of which the port driver is unaware, such as reconstructing fault-tolerant volumes), flushes
2736 // any remaining cached data to persistent storage, and puts the HBA into a state from which it
2737 // can be reinitialized or restarted.
2738 // The miniport should not free its resources when stopping its HBA. If the HBA was removed or
2739 // stopped for PnP resource reconfiguration, the port driver releases resources on behalf of the
2740 // miniport driver. If the HBA is shut down for power management, the miniport's resources are
2741 // preserved so the HBA can be restarted.
2742 {
2743 CHAR Parameter = 0;
2744 DebugPrint((INFO, "\n BusLogic - stopping the device \n"));
2745 if (BusLogic_Command(HostAdapter,
2747 &Parameter,
2748 sizeof(Parameter),
2749 NULL,
2750 0)
2751 < 0)
2752 {
2754 }
2755 break;
2756 }
2757
2758 case ScsiRestartAdapter:
2759 // Reinitializes an HBA. The port driver calls HwScsiAdapterControl with this control type to power
2760 // up an HBA that was shut down for power management. All resources previously assigned to the miniport
2761 // are still available, and its device extension and logical unit extensions, if any, are intact.
2762 // The miniport performs the same operations as in its HwScsiInitialize routine, such as setting up
2763 // the HBA's registers and its initial state, if any.
2764 // The miniport must not call routines that can only be called from HwScsiFindAdapter or from
2765 // HwScsiAdapterControl when the control type is ScsiSetRunningConfig, such as ScsiPortGetBusData and
2766 // ScsiPortSetBusDataByOffset. If the miniport must call such routines to restart its HBA, it must also
2767 // implement ScsiSetRunningConfig.
2768 // 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.
2769
2770 // See PR 69004. We were not calling BT958HwInitialize earlier if the
2771 // first two calls succeeded thus causing resume from standby to fail.
2772 {
2773 if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, TRUE) &&
2774 BusLogic_InitializeHostAdapter(deviceExtension, NULL) &&
2775 BT958HwInitialize(HwDeviceExtension))
2776 )
2777 {
2778 DebugPrint((ERROR, "\n Buslogic - Resetting %s Failed\n",
2779 HostAdapter->FullModelName));
2781 }
2782
2784 break;
2785 }
2786 default:
2787 {
2789 }
2790 }
2792}// end BT958HwAdapterControl
BOOLEAN NTAPI BT958HwInitialize(IN PVOID HwDeviceExtension)
Definition: BusLogic958.c:2620
BOOLEAN BusLogic_HardwareResetHostAdapter(BusLogic_HostAdapter_T *HostAdapter, BOOLEAN HardReset)
Definition: BusLogic958.c:470
int BusLogic_Command(BusLogic_HostAdapter_T *HostAdapter, BusLogic_OperationCode_T OperationCode, void *ParameterData, int ParameterLength, void *ReplyData, int ReplyLength)
Definition: BusLogic958.c:606
BOOLEAN BusLogic_InitializeHostAdapter(PHW_DEVICE_EXTENSION deviceExtension, PPORT_CONFIGURATION_INFORMATION ConfigInfo)
Definition: BusLogic958.c:1175
@ BusLogic_DisableHostAdapterInterrupt
Definition: BusLogic958.h:142
unsigned char BOOLEAN
VOID NTAPI ScsiPortStallExecution(IN ULONG Delay)
Definition: scsiport.c:1489
#define DebugPrint(x)
Definition: classpnp.h:125
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ ScsiRestartAdapter
Definition: srb.h:179
@ ScsiQuerySupportedControlTypes
Definition: srb.h:177
@ ScsiAdapterControlMax
Definition: srb.h:182
@ ScsiStopAdapter
Definition: srb.h:178
@ ScsiAdapterControlSuccess
Definition: srb.h:191
@ ScsiAdapterControlUnsuccessful
Definition: srb.h:192
#define ERROR(name)
Definition: error_private.h:53
#define for
Definition: utility.h:88
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short BusSettleTime
Definition: BusLogic958.h:715
UCHAR FullModelName[18]
Definition: BusLogic958.h:676
BusLogic_HostAdapter_T hcs
Definition: BusLogic958.h:757
Definition: precomp.h:84
OUT BOOLEAN SupportedTypeList[0]
Definition: srb.h:221
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:323
char CHAR
Definition: xmlstorage.h:175

Referenced by DriverEntry().

◆ BT958HwFindAdapter()

ULONG NTAPI BT958HwFindAdapter ( IN PVOID  HwDeviceExtension,
IN PVOID  Context,
IN PVOID  BusInformation,
IN PCHAR  ArgumentString,
IN OUT PPORT_CONFIGURATION_INFORMATION  ConfigInfo,
OUT PBOOLEAN  Again 
)

Definition at line 173 of file BusLogic958.c.

204{
205 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
206 BusLogic_HostAdapter_T *hcsp = &(deviceExtension->hcs);
207// static UCHAR k = 0;
208 PACCESS_RANGE accessRange;
209// PCI_COMMON_CONFIG PCICommonConfig;
210 PUCHAR pciAddress;
211 char NumPort = 0;
212
213 DebugPrint((TRACE,"\n BusLogic - Inside the Find Adapter Routine\n"));
214
215 *Again = FALSE;
216
217 accessRange = &((*(ConfigInfo->AccessRanges))[0]);
218
219 // Inform SCSIPORT that we are NOT a WMI data provider
220 // Sirish, 10th June 2002
221 ConfigInfo->WmiDataProvider = FALSE;
222 /*Sirish, 10th June 2002 BT958WmiInitialize(deviceExtension);*/
223
224 // Check for configuration information passed in form the system
225 if ((*ConfigInfo->AccessRanges)[0].RangeLength != 0)
226 {
227 // check if the system supplied bus-relative address is valid and has not been
228 // claimed by another device
229 if ( ScsiPortValidateRange(deviceExtension,
230 ConfigInfo->AdapterInterfaceType,
231 ConfigInfo->SystemIoBusNumber,
232 accessRange->RangeStart,
233 accessRange->RangeLength,
234 TRUE) ) // TRUE: iniospace
235 {
236 DebugPrint((INFO,"\n BusLogic - Validate Range function succeeded \n"));
237
238 // Map the Bus-relative range addresses to system-space logical range addresses
239 // so that these mapped logical addresses can be called with SciPortRead/Writexxx
240 // to determine whether the adapter is an HBA that the driver supports
241
242 pciAddress = (PUCHAR) ScsiPortGetDeviceBase(deviceExtension,
243 ConfigInfo->AdapterInterfaceType,
244 ConfigInfo->SystemIoBusNumber,
245 accessRange->RangeStart,
246 accessRange->RangeLength,
247 TRUE); // TRUE: iniospace
248
249 if(pciAddress)
250 {
251 DebugPrint((INFO,"\n BusLogic - Get Device Base function succeeded \n"));
252
253 memset(hcsp, 0, sizeof(BusLogic_HostAdapter_T));
254
255 // points to structure of type BT958_HA which has device specific information. This needs
256 // to be either changed or modified with our specific info.
257 hcsp->IO_Address = pciAddress;
258 hcsp->IRQ_Channel = (UCHAR)ConfigInfo->BusInterruptLevel;
259 NumPort++;
260 }
261 }
262 }
263
264 if (NumPort == 0)
265 {
266 return(SP_RETURN_NOT_FOUND);
267 }
268
269 // Hardware found, let's find out hardware configuration
270 // and fill out ConfigInfo table for WinNT
271 ConfigInfo->NumberOfBuses = 1;
272 ConfigInfo->MaximumTransferLength = MAX_TRANSFER_SIZE;
273
274#if SG_SUPPORT
275 ConfigInfo->ScatterGather = TRUE;
276#else
277 ConfigInfo->ScatterGather = FALSE;
278#endif
279
280 ConfigInfo->Master = TRUE;
281 ConfigInfo->NeedPhysicalAddresses = TRUE;
282 ConfigInfo->Dma32BitAddresses = TRUE;
283 ConfigInfo->InterruptMode = LevelSensitive;
284
285#if TAG_QUEUING
286 ConfigInfo->TaggedQueuing = TRUE;
287#else
288 ConfigInfo->TaggedQueuing = FALSE;
289#endif
290
291 // Should we change this to double-word aligned to increase performance
292 ConfigInfo->AlignmentMask = 0x0;
293
294 if (!Buslogic_InitBT958(deviceExtension,ConfigInfo)) // hardware specific initializations. Find what's for our card
295 {
296 ScsiPortLogError(deviceExtension,
297 NULL,
298 0,
299 0,
300 0,
302 7 << 8);
303
304 return(SP_RETURN_ERROR);
305 }
306
307 if (NumPort != 0)
308 *Again = TRUE;
309
310 return(SP_RETURN_FOUND);
311
312} // end BT958FindAdapter()
BOOLEAN Buslogic_InitBT958(PHW_DEVICE_EXTENSION deviceExtension, PPORT_CONFIGURATION_INFORMATION ConfigInfo)
Definition: BusLogic958.c:316
#define MAX_TRANSFER_SIZE
Definition: BusLogic958.h:61
BOOLEAN NTAPI ScsiPortValidateRange(IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, IN ULONG SystemIoBusNumber, IN SCSI_PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfBytes, IN BOOLEAN InIoSpace)
Definition: scsiport.c:1497
VOID NTAPI ScsiPortLogError(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun, IN ULONG ErrorCode, IN ULONG UniqueId)
Definition: scsiport.c:1299
PVOID NTAPI ScsiPortGetDeviceBase(IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, IN ULONG SystemIoBusNumber, IN SCSI_PHYSICAL_ADDRESS IoAddress, IN ULONG NumberOfBytes, IN BOOLEAN InIoSpace)
Definition: scsiport.c:571
#define SP_RETURN_ERROR
Definition: srb.h:523
#define SP_RETURN_FOUND
Definition: srb.h:522
#define SP_INTERNAL_ADAPTER_ERROR
Definition: srb.h:509
#define SP_RETURN_NOT_FOUND
Definition: srb.h:521
@ LevelSensitive
Definition: miniport.h:80
#define memset(x, y, z)
Definition: compat.h:39
ULONG RangeLength
Definition: srb.h:42
SCSI_PHYSICAL_ADDRESS RangeStart
Definition: srb.h:41
unsigned char * PUCHAR
Definition: typedefs.h:53
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DriverEntry().

◆ BT958HwInitialize()

BOOLEAN NTAPI BT958HwInitialize ( IN PVOID  HwDeviceExtension)

Definition at line 2620 of file BusLogic958.c.

2630{
2631 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
2632 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2633 CHAR Parameter = 1;
2634
2635 // enable interrupts
2636 if (BusLogic_Command(HostAdapter,
2638 &Parameter,
2639 sizeof(Parameter),
2640 NULL,
2641 0)
2642 < 0)
2643 {
2644 return FALSE;
2645 }
2646 return TRUE;
2647}// end BT958HwInitialize

Referenced by BT958HwAdapterControl(), and DriverEntry().

◆ BT958HwInterrupt()

BOOLEAN NTAPI BT958HwInterrupt ( IN PVOID  HwDeviceExtension)

Definition at line 1973 of file BusLogic958.c.

1990{
1991 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
1992// PNONCACHED_EXTENSION noncachedExtension = deviceExtension->NoncachedExtension;
1993 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
1994// PBuslogic_CCB_T ccb;
1995// PSCSI_REQUEST_BLOCK srb;
1996
1997// ULONG residualBytes;
1998// ULONG i;
1999
2000 BusLogic_InterruptRegister_T InterruptRegister;
2001
2002
2003 // Read the Host Adapter Interrupt Register.
2004 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
2005 if (InterruptRegister.Bits.InterruptValid)
2006 {
2007
2008 // Acknowledge the interrupt and reset the Host Adapter
2009 // Interrupt Register.
2010 BusLogic_InterruptReset(HostAdapter);
2011 // Process valid External SCSI Bus Reset and Incoming Mailbox
2012 // Loaded Interrupts. Command Complete Interrupts are noted,
2013 // and Outgoing Mailbox Available Interrupts are ignored, as
2014 // they are never enabled.
2015 if (InterruptRegister.Bits.ExternalBusReset)
2016 {
2017 HostAdapter->HostAdapterExternalReset = TRUE;
2018 }
2019 else if (InterruptRegister.Bits.IncomingMailboxLoaded)
2020 {
2021 BusLogic_ScanIncomingMailboxes(deviceExtension);
2022 }
2023 else if (InterruptRegister.Bits.CommandComplete)
2024 {
2025 HostAdapter->HostAdapterCommandCompleted = TRUE;
2026 }
2027 }
2028 else
2029 return FALSE;
2030
2031 // Process any completed CCBs.
2032 if (HostAdapter->FirstCompletedCCB != NULL)
2033 BusLogic_ProcessCompletedCCBs(deviceExtension);
2034
2035 // Reset the Host Adapter if requested.
2036 if (HostAdapter->HostAdapterExternalReset ||
2037 HostAdapter->HostAdapterInternalError)
2038 {
2039 // I have replaced the NULL with srb->pathid check if this is correct
2040 BT958HwResetBus(HwDeviceExtension, SP_UNTAGGED);
2041 HostAdapter->HostAdapterExternalReset = FALSE;
2042 HostAdapter->HostAdapterInternalError = FALSE;
2043 }
2044 return TRUE;
2045}// end BT958HwInterrupt
void BusLogic_ScanIncomingMailboxes(PHW_DEVICE_EXTENSION deviceExtension)
Definition: BusLogic958.c:2048
void BusLogic_ProcessCompletedCCBs(PHW_DEVICE_EXTENSION deviceExtension)
Definition: BusLogic958.c:2139
BOOLEAN NTAPI BT958HwResetBus(IN PVOID HwDeviceExtension, IN ULONG PathId)
Definition: BusLogic958.c:2448
static UCHAR BusLogic_ReadInterruptRegister(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1065
static void BusLogic_InterruptReset(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1028
#define SP_UNTAGGED
Definition: srb.h:233
BusLogic_CCB_T * FirstCompletedCCB
Definition: BusLogic958.h:728
volatile BOOLEAN HostAdapterCommandCompleted
Definition: BusLogic958.h:704
BOOLEAN HostAdapterInternalError
Definition: BusLogic958.h:701
BOOLEAN HostAdapterExternalReset
Definition: BusLogic958.h:700
struct BusLogic_InterruptRegister::@1326 Bits

Referenced by DriverEntry().

◆ BT958HwResetBus()

BOOLEAN NTAPI BT958HwResetBus ( IN PVOID  HwDeviceExtension,
IN ULONG  PathId 
)

Definition at line 2448 of file BusLogic958.c.

2461{
2462 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
2463 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2464// BusLogic_CCB_T *CCB;
2465// int TargetID;
2467 BOOLEAN HardReset;
2468
2469 DebugPrint((TRACE, "\n BusLogic - Reset SCSI bus\n"));
2470
2471 // Complete all outstanding requests with SRB_STATUS_BUS_RESET.
2472 ScsiPortCompleteRequest(deviceExtension,
2473 (UCHAR)PathId,
2474 0xFF,
2475 0xFF,
2477
2478 if (HostAdapter->HostAdapterExternalReset)
2479 {
2480 //BusLogic_IncrementErrorCounter(&HostAdapter->ExternalHostAdapterResets);
2481 HardReset = FALSE;
2482 }
2483 else if (HostAdapter->HostAdapterInternalError)
2484 {
2485 //BusLogic_IncrementErrorCounter(&HostAdapter->HostAdapterInternalErrors);
2486 HardReset = TRUE;
2487 }
2488 else
2489 {
2490 //BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[srb->TargetId].HostAdapterResetsRequested);
2491 HardReset = TRUE;
2492 }
2493
2494 // Think of a way of doing this - Namita
2495 /*
2496 if(srb == NULL)
2497 {
2498 if (HostAdapter->HostAdapterInternalError)
2499 DebugPrint((0,"BusLogic Warning: Resetting %s due to Host Adapter Internal Error\n",HostAdapter->FullModelName));
2500 else
2501 DebugPrint((0,"BUsLogic Warning: Resetting %s due to External SCSI Bus Reset\n",HostAdapter->FullModelName));
2502 }
2503 else
2504 {
2505 DebugPrint((0,"BusLogic Warning: Resetting %s due to Target %d\n", HostAdapter->FullModelName, srb->TargetId));
2506 //BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[srb->TargetId].HostAdapterResetsAttempted);
2507 }
2508 */
2509
2510 // Attempt to Reset and Reinitialize the Host Adapter.
2511 // Change the initialize routine to make allocation some place else
2512 if (!(BusLogic_HardwareResetHostAdapter(HostAdapter, HardReset) && BusLogic_InitializeHostAdapter(deviceExtension, NULL)))
2513 {
2514 DebugPrint((ERROR, "\n Buslogic - Resetting %s Failed\n",
2515 HostAdapter->FullModelName));
2516 Result = FALSE;
2517 goto Done;
2518 }
2519
2520 // Check if we have to do this, document says that the scsi port driver takes care of the reset delays - Namita
2521 // Wait a few seconds between the Host Adapter Hard Reset which initiates
2522 // a SCSI Bus Reset and issuing any SCSI Commands. Some SCSI devices get
2523 // confused if they receive SCSI Commands too soon after a SCSI Bus Reset.
2524 // Note that a timer interrupt may occur here, but all active CCBs have
2525 // already been marked Reset and so a reentrant call will return Pending.
2526 if (HardReset)
2528 Result = TRUE;
2529
2530Done:
2531 return Result;
2532}// end BT958HwResetBus
VOID NTAPI ScsiPortCompleteRequest(IN PVOID HwDeviceExtension, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun, IN UCHAR SrbStatus)
Definition: scsiport.c:507
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1313
#define SRB_STATUS_BUS_RESET
Definition: srb.h:353
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by BT958HwInterrupt(), BT958HwStartIO(), and DriverEntry().

◆ BT958HwStartIO()

BOOLEAN NTAPI BT958HwStartIO ( IN PVOID  HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 1458 of file BusLogic958.c.

1474{
1475 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
1476// PNONCACHED_EXTENSION noncachedExtension = deviceExtension->NoncachedExtension;
1477 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
1478// BusLogic_OutgoingMailbox_T mailboxOut;
1479 PSCSI_REQUEST_BLOCK AbortSRB;
1480
1482 BusLogic_TargetFlags_T *TargetFlags = &HostAdapter->TargetFlags[Srb->TargetId];
1483
1484
1485 DebugPrint((TRACE, "\n BusLogic - Inside Start IO routine\n"));
1486
1487 // Make sure that this request isn't too long for the adapter. If so
1488 // bounce it back as an invalid request
1489 if (BusLogic_CDB_MaxLength < Srb->CdbLength)
1490 {
1491
1492 DebugPrint((WARNING, "\n BusLogic - Srb->CdbLength [%d] > MaxCdbLength [%d]."
1493 " Invalid request\n", Srb->CdbLength, BusLogic_CDB_MaxLength));
1494
1496 ScsiPortNotification(RequestComplete,deviceExtension,Srb);
1497 ScsiPortNotification(NextRequest,deviceExtension,NULL);
1498 return TRUE;
1499 }
1500
1501 switch (Srb->Function)
1502 {
1503 /*
1504 Sirish, 10th June 2002
1505 // Check if command is a WMI request.
1506 case SRB_FUNCTION_WMI:
1507 // Process the WMI request and return.
1508 return BT958WmiSrb(HwDeviceExtension, (PSCSI_WMI_REQUEST_BLOCK) Srb);
1509 */
1510
1512
1513 // get the ccb structure from the extension
1514 ccb = Srb->SrbExtension;
1516
1517 // Save SRB back pointer in CCB.
1518 ccb->SrbAddress = Srb;
1519
1520 // Build CCB. - Have some way of knowing that a srb has already been
1521 // completed and you just need to return from here
1522 BusLogic_QueueCommand(HwDeviceExtension ,Srb, ccb);
1523
1524 // Place the CCB in an Outgoing Mailbox. The higher levels of the SCSI
1525 // Subsystem should not attempt to queue more commands than can be placed
1526 // in Outgoing Mailboxes, so there should always be one free. In the
1527 // unlikely event that there are none available, wait 1 second and try
1528 // again. If that fails, the Host Adapter is probably hung so signal an
1529 // error as a Host Adapter Hard Reset should be initiated soon.
1530
1532 {
1533 DebugPrint((ERROR, "\n BusLogic - Unable to write Outgoing Mailbox - "
1534 "Pausing for 1 second\n"));
1537 {
1538 DebugPrint((ERROR, "\n BusLogic - Still unable to write Outgoing"
1539 "Mailbox - Host Adapter Dead?\n"));
1540
1542 ScsiPortNotification(RequestComplete,deviceExtension,Srb);
1543 ScsiPortNotification(NextRequest,deviceExtension,NULL);
1544
1545 }
1546 }
1547 else
1548 {
1549 /*
1550 * Reverted to pre 1.1.0.0 control flow
1551 * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts
1552 * And the fix for that in 1.1.0.1 causes BSODs in XP
1553 * Side note: Ben: the Buslogic emulation never exports more than 1 lun
1554 */
1555 if (TargetFlags->TaggedQueuingActive
1557 ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
1558 }
1559 else {
1560 ScsiPortNotification(NextRequest,deviceExtension,NULL);
1561 }
1562 }
1563 return TRUE;
1564
1566
1567 // Get CCB to abort.
1568 ccb = Srb->NextSrb->SrbExtension;
1569
1570 // Set abort SRB for completion.
1571 ccb->AbortSrb = Srb;
1572
1573 AbortSRB = ScsiPortGetSrb(HwDeviceExtension,
1574 Srb->PathId,
1575 Srb->TargetId,
1576 Srb->Lun,
1577 Srb->QueueTag);
1578
1579 if ((AbortSRB != Srb->NextSrb) || (AbortSRB->SrbStatus != SRB_STATUS_PENDING))
1580 {
1582 ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb);
1583 ScsiPortNotification(NextRequest, HwDeviceExtension, NULL);
1584 return TRUE;
1585 }
1586
1587 // write the abort information into a mailbox
1589 {
1590 DebugPrint((WARNING, "\n BusLogic - Aborting CCB #%ld to Target %d\n",
1591 ccb->SerialNumber, Srb->TargetId));
1592 // Adapter ready for next request.
1593
1594 /*
1595 * Reverted to pre 1.1.0.0 control flow
1596 * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts
1597 * And the fix for that in 1.1.0.1 causes BSODs in XP
1598 * Side note: Ben: the Buslogic emulation never exports more than 1 lun
1599 */
1600 if (TargetFlags->TaggedQueuingActive
1602 ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
1603 }
1604 else {
1605 ScsiPortNotification(NextRequest,deviceExtension,NULL);
1606 }
1607 }
1608 else
1609 {
1610 DebugPrint((WARNING, "\n BusLogic - Unable to Abort CCB #%ld to Target %d"
1611 " - No Outgoing Mailboxes\n", ccb->SerialNumber,
1612 Srb->TargetId));
1614 ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb);
1615 ScsiPortNotification(NextRequest, HwDeviceExtension, NULL);
1616 }
1617 return TRUE;
1618
1619
1621
1622 // Reset SCSI bus.
1623 DebugPrint((INFO, "\n BusLogic - SRB_FUNCTION_RESET_BUS, srb=%x \n",Srb));
1624 BT958HwResetBus(HwDeviceExtension, Srb->PathId);
1625
1627 ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb);
1628 ScsiPortNotification(NextRequest, HwDeviceExtension, NULL);
1629 return TRUE;
1630
1631
1633
1634 ccb = Srb->SrbExtension;
1636
1637 // Save SRB back pointer in CCB.
1638 ccb->SrbAddress = Srb;
1639
1640 if(!BusLogic_SendBusDeviceReset(HostAdapter, Srb))
1641 {
1642 BT958HwResetBus(HwDeviceExtension, SP_UNTAGGED);
1644 ScsiPortNotification(RequestComplete, HwDeviceExtension, Srb);
1645 ScsiPortNotification(NextRequest, HwDeviceExtension, NULL);
1646 return TRUE;
1647 }
1648
1649 /*
1650 * Reverted to pre 1.1.0.0 control flow
1651 * The 1.1.0.0 control flow causes the .NET Server freeze during installs/restarts
1652 * And the fix for that in 1.1.0.1 causes BSODs in XP
1653 * Side note: Ben: the Buslogic emulation never exports more than 1 lun
1654 */
1655 if (TargetFlags->TaggedQueuingActive
1657 ScsiPortNotification(NextLuRequest, HwDeviceExtension, Srb->PathId, Srb->TargetId, Srb->Lun);
1658 }
1659 else {
1660 ScsiPortNotification(NextRequest,deviceExtension,NULL);
1661 }
1662 return TRUE;
1663
1664 default:
1665
1666 // Set error, complete request and signal ready for next request.
1668 ScsiPortNotification(RequestComplete,deviceExtension,Srb);
1669 ScsiPortNotification(NextRequest,deviceExtension,NULL);
1670
1671 return TRUE;
1672
1673 } // end switch
1674
1675}// end BusLogic_TargetDeviceInquiry
BOOLEAN BusLogic_SendBusDeviceReset(IN PVOID HwDeviceExtension, PSCSI_REQUEST_BLOCK Srb)
Definition: BusLogic958.c:2535
int BusLogic_QueueCommand(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, PBuslogic_CCB_T CCB)
Definition: BusLogic958.c:1747
BOOLEAN BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension, BusLogic_ActionCode_T ActionCode, BusLogic_CCB_T *CCB)
Definition: BusLogic958.c:1679
VOID BusLogic_InitializeCCB(PBuslogic_CCB_T CCB)
Definition: BusLogic958.c:1425
#define BusLogic_CDB_MaxLength
Definition: BusLogic958.h:97
#define BUSLOGIC_MAXIMUM_TAGS
Definition: BusLogic958.h:67
#define WARNING
Definition: BusLogic958.h:56
@ BusLogic_MailboxStartCommand
Definition: BusLogic958.h:440
@ BusLogic_MailboxAbortCommand
Definition: BusLogic958.h:441
VOID __cdecl ScsiPortNotification(IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, IN ...)
Definition: scsiport.c:1324
PSCSI_REQUEST_BLOCK NTAPI ScsiPortGetSrb(IN PVOID DeviceExtension, IN UCHAR PathId, IN UCHAR TargetId, IN UCHAR Lun, IN LONG QueueTag)
Definition: scsiport.c:658
struct _ccb ccb
_In_ PSCSI_REQUEST_BLOCK Srb
Definition: cdrom.h:989
#define SRB_FUNCTION_RESET_DEVICE
Definition: srb.h:327
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_STATUS_PENDING
Definition: srb.h:340
#define SRB_FUNCTION_RESET_BUS
Definition: srb.h:326
#define SRB_STATUS_ERROR
Definition: srb.h:344
#define SRB_STATUS_ABORT_FAILED
Definition: srb.h:343
@ RequestComplete
Definition: srb.h:531
@ NextRequest
Definition: srb.h:532
@ NextLuRequest
Definition: srb.h:533
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
#define SRB_STATUS_INVALID_REQUEST
Definition: srb.h:346
#define SRB_FUNCTION_ABORT_COMMAND
Definition: srb.h:324
UCHAR ActiveCommandsPerLun[BusLogic_MaxTargetDevices][BusLogic_MaxLogicalUnits]
Definition: BusLogic958.h:736
BusLogic_TargetFlags_T TargetFlags[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:732
BOOLEAN TaggedQueuingActive
Definition: BusLogic958.h:240
UCHAR QueueTag
Definition: srb.h:256
UCHAR TargetId
Definition: srb.h:254
UCHAR PathId
Definition: srb.h:253
UCHAR CdbLength
Definition: srb.h:258
UCHAR Function
Definition: srb.h:250
PVOID SrbExtension
Definition: srb.h:267
struct _SCSI_REQUEST_BLOCK * NextSrb
Definition: srb.h:265
UCHAR SrbStatus
Definition: srb.h:251

Referenced by DriverEntry().

◆ BusLogic_CheckHostAdapter()

BOOLEAN BusLogic_CheckHostAdapter ( BusLogic_HostAdapter_T HostAdapter)

Definition at line 569 of file BusLogic958.c.

579{
580 BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation;
581 BusLogic_RequestedReplyLength_T RequestedReplyLength;
583
584 DebugPrint((TRACE, "\n BusLogic - Inside BusLogic_CheckHostAdapter function \n"));
585
586 //
587 // Issue the Inquire Extended Setup Information command. Only genuine
588 // BusLogic Host Adapters and TRUE clones support this command. Adaptec 1542C
589 // series Host Adapters that respond to the Geometry Register I/O port will
590 // fail this command.
591 RequestedReplyLength = sizeof(ExtendedSetupInformation);
592 if (BusLogic_Command(HostAdapter,
594 &RequestedReplyLength,
595 sizeof(RequestedReplyLength),
596 &ExtendedSetupInformation,
597 sizeof(ExtendedSetupInformation))
598 != sizeof(ExtendedSetupInformation))
599 {
600 Result = FALSE;
601 }
602 return Result;
603}// end BusLogic_CheckHostAdapter
@ BusLogic_InquireExtendedSetupInformation
Definition: BusLogic958.h:150
UCHAR BusLogic_RequestedReplyLength_T
Definition: BusLogic958.h:169

Referenced by Buslogic_InitBT958().

◆ BusLogic_Command()

int BusLogic_Command ( BusLogic_HostAdapter_T HostAdapter,
BusLogic_OperationCode_T  OperationCode,
void ParameterData,
int  ParameterLength,
void ReplyData,
int  ReplyLength 
)

Definition at line 606 of file BusLogic958.c.

638{
639 UCHAR *ParameterPointer = (UCHAR *) ParameterData;
640 UCHAR *ReplyPointer = (UCHAR *) ReplyData;
642 BusLogic_InterruptRegister_T InterruptRegister;
643 int ReplyBytes = 0, Result;
644 long TimeoutCounter;
645
646 // Clear out the Reply Data if provided.
647 if (ReplyLength > 0)
648 memset(ReplyData, 0, ReplyLength);
649
650 // If the IRQ Channel has not yet been acquired, then interrupts must be
651 // disabled while issuing host adapter commands since a Command Complete
652 // interrupt could occur if the IRQ Channel was previously enabled by another
653 // BusLogic Host Adapter or another driver sharing the same IRQ Channel.
654
655 // Wait for the Host Adapter Ready bit to be set and the Command/Parameter
656 // Register Busy bit to be reset in the Status Register.
657 TimeoutCounter = 10000;
658 while (--TimeoutCounter >= 0)
659 {
661 if ( StatusRegister.Bits.HostAdapterReady &&
662 !StatusRegister.Bits.CommandParameterRegisterBusy)
663 {
664 break;
665 }
667 }
668 if (TimeoutCounter < 0)
669 {
670 //BusLogic_CommandFailureReason = "Timeout waiting for Host Adapter Ready";
671 Result = -2;
672 goto Done;
673 }
674
675 // Write the OperationCode to the Command/Parameter Register.
676 HostAdapter->HostAdapterCommandCompleted = FALSE;
677 BusLogic_WriteCommandParameterRegister(HostAdapter, (UCHAR)OperationCode);
678
679 //Write any additional Parameter Bytes.
680 TimeoutCounter = 10000;
681 while (ParameterLength > 0 && --TimeoutCounter >= 0)
682 {
683 //
684 // Wait 100 microseconds to give the Host Adapter enough time to determine
685 // whether the last value written to the Command/Parameter Register was
686 // valid or not. If the Command Complete bit is set in the Interrupt
687 // Register, then the Command Invalid bit in the Status Register will be
688 // reset if the Operation Code or Parameter was valid and the command
689 // has completed, or set if the Operation Code or Parameter was invalid.
690 // If the Data In Register Ready bit is set in the Status Register, then
691 // the Operation Code was valid, and data is waiting to be read back
692 // from the Host Adapter. Otherwise, wait for the Command/Parameter
693 // Register Busy bit in the Status Register to be reset.
694
696 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
698 if (InterruptRegister.Bits.CommandComplete)
699 break;
700 if (HostAdapter->HostAdapterCommandCompleted)
701 break;
702 if (StatusRegister.Bits.DataInRegisterReady)
703 break;
704 if (StatusRegister.Bits.CommandParameterRegisterBusy)
705 continue;
706 BusLogic_WriteCommandParameterRegister(HostAdapter, *ParameterPointer++);
708 }
709 if (TimeoutCounter < 0)
710 {
711 //BusLogic_CommandFailureReason = "Timeout waiting for Parameter Acceptance";
712 Result = -2;
713 goto Done;
714 }
715
716 // The Modify I/O Address command does not cause a Command Complete Interrupt.
717 if (OperationCode == BusLogic_ModifyIOAddress)
718 {
720 if (StatusRegister.Bits.CommandInvalid)
721 {
722 //BusLogic_CommandFailureReason = "Modify I/O Address Invalid";
723 Result = -1;
724 goto Done;
725 }
726 Result = 0;
727 goto Done;
728 }
729
730 // Select an appropriate timeout value for awaiting command completion.
731 switch (OperationCode)
732 {
736 // Approximately 60 seconds.
737 TimeoutCounter = 60*10000;
738 break;
739 default:
740 // Approximately 1 second.
741 TimeoutCounter = 10000;
742 break;
743 }
744
745 //
746 // Receive any Reply Bytes, waiting for either the Command Complete bit to
747 // be set in the Interrupt Register, or for the Interrupt Handler to set the
748 // Host Adapter Command Completed bit in the Host Adapter structure.
749 while (--TimeoutCounter >= 0)
750 {
751 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
753 if (InterruptRegister.Bits.CommandComplete)
754 break;
755 if (HostAdapter->HostAdapterCommandCompleted)
756 break;
757 if (StatusRegister.Bits.DataInRegisterReady)
758 {
759 if (++ReplyBytes <= ReplyLength)
760 {
761 *ReplyPointer++ = BusLogic_ReadDataInRegister(HostAdapter);
762 }
763 else
764 {
765 BusLogic_ReadDataInRegister(HostAdapter);
766 }
767 }
768 if (OperationCode == BusLogic_FetchHostAdapterLocalRAM &&
769 StatusRegister.Bits.HostAdapterReady)
770 {
771 break;
772 }
774 }
775 if (TimeoutCounter < 0)
776 {
777 //BusLogic_CommandFailureReason = "Timeout waiting for Command Complete";
778 Result = -2;
779 goto Done;
780 }
781
782 // Clear any pending Command Complete Interrupt.
783 BusLogic_InterruptReset(HostAdapter);
784
785 // Process Command Invalid conditions.
786 if (StatusRegister.Bits.CommandInvalid)
787 {
788 //
789 // Some early BusLogic Host Adapters may not recover properly from
790 // a Command Invalid condition, so if this appears to be the case,
791 // a Soft Reset is issued to the Host Adapter. Potentially invalid
792 // commands are never attempted after Mailbox Initialization is
793 // performed, so there should be no Host Adapter state lost by a
794 // Soft Reset in response to a Command Invalid condition.
795
798 if (StatusRegister.Bits.CommandInvalid ||
799 StatusRegister.Bits.Reserved ||
800 StatusRegister.Bits.DataInRegisterReady ||
801 StatusRegister.Bits.CommandParameterRegisterBusy ||
802 !StatusRegister.Bits.HostAdapterReady ||
803 !StatusRegister.Bits.InitializationRequired ||
804 StatusRegister.Bits.DiagnosticActive ||
805 StatusRegister.Bits.DiagnosticFailure)
806 {
807 BusLogic_SoftReset(HostAdapter);
809 }
810 //BusLogic_CommandFailureReason = "Command Invalid";
811 Result = -1;
812 goto Done;
813 }
814
815 // Handle Excess Parameters Supplied conditions.
816 if (ParameterLength > 0)
817 {
818 //BusLogic_CommandFailureReason = "Excess Parameters Supplied";
819 Result = -1;
820 goto Done;
821 }
822
823 // Indicate the command completed successfully.
824 Result = ReplyBytes;
825
826 // Restore the interrupt status if necessary and return.
827Done:
828 return Result;
829}// end BusLogic_Command
static void BusLogic_SoftReset(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1039
static UCHAR BusLogic_ReadStatusRegister(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1059
@ BusLogic_InquireInstalledDevicesID8to15
Definition: BusLogic958.h:140
@ BusLogic_InquireInstalledDevicesID0to7
Definition: BusLogic958.h:129
@ BusLogic_ModifyIOAddress
Definition: BusLogic958.h:156
@ BusLogic_InquireTargetDevices
Definition: BusLogic958.h:141
@ BusLogic_FetchHostAdapterLocalRAM
Definition: BusLogic958.h:153
static void BusLogic_WriteCommandParameterRegister(BusLogic_HostAdapter_T *HostAdapter, UCHAR Value)
Definition: BusLogic958.h:1083
static UCHAR BusLogic_ReadDataInRegister(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1077
_Must_inspect_result_ _In_ PFLT_PORT _In_ ULONG _Out_writes_bytes_opt_ ReplyLength PVOID _Inout_opt_ PULONG ReplyLength
Definition: fltkernel.h:1903
static BYTE StatusRegister
Definition: ps2.c:57
_In_ ULONG ParameterLength
Definition: usbdlib.h:206

Referenced by BT958HwAdapterControl(), BT958HwInitialize(), BT958ReadExtendedSetupInfo(), BusLogic_CheckHostAdapter(), Buslogic_InitBT958(), BusLogic_InitializeHostAdapter(), BusLogic_ReadHostAdapterConfiguration(), and BusLogic_TargetDeviceInquiry().

◆ BusLogic_ComputeResultCode()

UCHAR BusLogic_ComputeResultCode ( BusLogic_HostAdapter_T HostAdapter,
BusLogic_HostAdapterStatus_T  HostAdapterStatus,
BusLogic_TargetDeviceStatus_T  TargetDeviceStatus,
UCHAR  SenseDataLength 
)

Definition at line 2309 of file BusLogic958.c.

2324{
2325 UCHAR HostStatus = 0;
2326
2327 // Namita 2Oct CDROM issue
2328 if (TargetDeviceStatus != BusLogic_OperationGood && (HostAdapterStatus == BusLogic_CommandCompletedNormally ||
2329 HostAdapterStatus == BusLogic_LinkedCommandCompleted ||
2330 HostAdapterStatus == BusLogic_LinkedCommandCompletedWithFlag))
2331 {
2332 switch(TargetDeviceStatus)
2333 {
2335 {
2336 HostStatus = SRB_STATUS_ERROR;
2337 if(SenseDataLength != BusLogic_DisableAutoReqSense)
2338 HostStatus |= SRB_STATUS_AUTOSENSE_VALID;
2339 break;
2340 }
2342 {
2343 HostStatus = SRB_STATUS_BUSY;
2344 break;
2345 }
2347 {
2348 HostStatus = SRB_STATUS_SUCCESS;
2349 break;
2350 }
2351 }
2352 }
2353
2354 else
2355 {
2356
2357 switch (HostAdapterStatus)
2358 {
2362 {
2363 HostStatus = SRB_STATUS_SUCCESS;
2364 break;
2365 }
2367 {
2368 HostStatus = SRB_STATUS_SELECTION_TIMEOUT;
2369 break;
2370 }
2374 DebugPrint((WARNING, "\n BusLogic - Driver Protocol Error 0x%02X\n",
2375 HostAdapterStatus));
2377
2379 // SRB_STATUS_DATA_OVERRUN
2380
2382
2384 // SRB_STATUS_MESSAGE_REJECTED
2388
2390 // SRB_STATUS_TIMEOUT
2391 {
2392 HostStatus = SRB_STATUS_ERROR;
2393 break;
2394 }
2399 {
2400 HostStatus = SRB_STATUS_BUS_RESET;
2401 break;
2402 }
2404 {
2405 HostStatus = SRB_STATUS_PARITY_ERROR;
2406 break;
2407 }
2409 {
2410 HostStatus = SRB_STATUS_UNEXPECTED_BUS_FREE;
2411 break;
2412 }
2414 {
2416 break;
2417 }
2419 {
2421 break;
2422 }
2424 {
2425 HostStatus = SRB_STATUS_INVALID_REQUEST;
2426 break;
2427 }
2429 {
2430 HostStatus = SRB_STATUS_NO_HBA;
2431 break;
2432 }
2433 default:
2434 {
2435 DebugPrint((WARNING, "\n BusLogic - Unknown HBA Status 0x%02X\n",
2436 HostAdapterStatus));
2437 HostStatus = SRB_STATUS_ERROR;
2438 break;
2439 }
2440 }
2441 }
2442 return HostStatus;
2443}// end BusLogic_ComputeResultCode
#define BusLogic_DisableAutoReqSense
Definition: BusLogic958.h:110
@ BusLogic_AbortQueueGenerated
Definition: BusLogic958.h:505
@ BusLogic_UnsupportedMessageReceived
Definition: BusLogic958.h:498
@ BusLogic_TargetDeviceReconnectedImproperly
Definition: BusLogic958.h:503
@ BusLogic_DataUnderRun
Definition: BusLogic958.h:487
@ BusLogic_InvalidCommandParameter
Definition: BusLogic958.h:495
@ BusLogic_HostAdapterAssertedRST
Definition: BusLogic958.h:501
@ BusLogic_LinkedCommandCompleted
Definition: BusLogic958.h:485
@ BusLogic_DataOverRun
Definition: BusLogic958.h:489
@ BusLogic_HostAdapterAssertedBusDeviceReset
Definition: BusLogic958.h:504
@ BusLogic_SCSIParityErrorDetected
Definition: BusLogic958.h:508
@ BusLogic_OtherDeviceAssertedRST
Definition: BusLogic958.h:502
@ BusLogic_LinkedCCBhasInvalidLUN
Definition: BusLogic958.h:494
@ BusLogic_AutoRequestSenseFailed
Definition: BusLogic958.h:496
@ BusLogic_LinkedCommandCompletedWithFlag
Definition: BusLogic958.h:486
@ BusLogic_HostAdapterSoftwareError
Definition: BusLogic958.h:506
@ BusLogic_InvalidOutgoingMailboxActionCode
Definition: BusLogic958.h:492
@ BusLogic_SCSISelectionTimeout
Definition: BusLogic958.h:488
@ BusLogic_CommandCompletedNormally
Definition: BusLogic958.h:484
@ BusLogic_InvalidBusPhaseRequested
Definition: BusLogic958.h:491
@ BusLogic_InvalidCommandOperationCode
Definition: BusLogic958.h:493
@ BusLogic_TaggedQueuingMessageRejected
Definition: BusLogic958.h:497
@ BusLogic_HostAdapterHardwareFailed
Definition: BusLogic958.h:499
@ BusLogic_HostAdapterHardwareTimeoutError
Definition: BusLogic958.h:507
@ BusLogic_TargetFailedResponseToATN
Definition: BusLogic958.h:500
@ BusLogic_UnexpectedBusFree
Definition: BusLogic958.h:490
@ BusLogic_DeviceBusy
Definition: BusLogic958.h:516
@ BusLogic_CheckCondition
Definition: BusLogic958.h:515
@ BusLogic_OperationGood
Definition: BusLogic958.h:514
#define SRB_STATUS_PHASE_SEQUENCE_FAILURE
Definition: srb.h:359
#define SRB_STATUS_NO_HBA
Definition: srb.h:356
#define SRB_STATUS_UNEXPECTED_BUS_FREE
Definition: srb.h:358
#define SRB_STATUS_AUTOSENSE_VALID
Definition: srb.h:387
#define SRB_STATUS_SELECTION_TIMEOUT
Definition: srb.h:350
#define SRB_STATUS_PARITY_ERROR
Definition: srb.h:354
#define SRB_STATUS_BUSY
Definition: srb.h:345
#define SRB_STATUS_REQUEST_SENSE_FAILED
Definition: srb.h:355

Referenced by BusLogic_ProcessCompletedCCBs().

◆ BusLogic_HardwareResetHostAdapter()

BOOLEAN BusLogic_HardwareResetHostAdapter ( BusLogic_HostAdapter_T HostAdapter,
BOOLEAN  HardReset 
)

Definition at line 470 of file BusLogic958.c.

487{
489 int TimeoutCounter;
490
491 // Issue a Hard Reset or Soft Reset Command to the Host Adapter. The Host
492 // Adapter should respond by setting Diagnostic Active in the Status Register.
493 if (HardReset)
494 BusLogic_HardReset(HostAdapter);
495 else
496 BusLogic_SoftReset(HostAdapter);
497
498 // Wait until Diagnostic Active is set in the Status Register.
499 TimeoutCounter = 100;
500 while (--TimeoutCounter >= 0)
501 {
503 if (StatusRegister.Bits.DiagnosticActive)
504 break;
505 }
506
507 // if in spite of waiting for time out period , if it didn't et set, then something is wrong-- so just return.
508 if (TimeoutCounter < 0)
509 return FALSE;
510
511 //
512 // Wait 100 microseconds to allow completion of any initial diagnostic
513 // activity which might leave the contents of the Status Register
514 // unpredictable.
516
517 // Wait until Diagnostic Active is reset in the Status Register.
518 TimeoutCounter = 10*10000;
519 while (--TimeoutCounter >= 0)
520 {
522 if (!StatusRegister.Bits.DiagnosticActive)
523 break;
525 }
526
527 if (TimeoutCounter < 0)
528 return FALSE;
529
530 // Wait until at least one of the Diagnostic Failure, Host Adapter Ready,
531 // or Data In Register Ready bits is set in the Status Register.
532 TimeoutCounter = 10000;
533 while (--TimeoutCounter >= 0)
534 {
536 if (StatusRegister.Bits.DiagnosticFailure ||
537 StatusRegister.Bits.HostAdapterReady ||
538 StatusRegister.Bits.DataInRegisterReady)
539 {
540 break;
541 }
543 }
544
545 //device didn't respond to reset
546 if (TimeoutCounter < 0)
547 return FALSE;
548
549 // If Diagnostic Failure is set or Host Adapter Ready is reset, then an
550 // error occurred during the Host Adapter diagnostics. If Data In Register
551 // Ready is set, then there is an Error Code available.
552 if (StatusRegister.Bits.DiagnosticFailure || !StatusRegister.Bits.HostAdapterReady)
553 {
554 DebugPrint((ERROR, "\n BusLogic - Failure - HOST ADAPTER STATUS REGISTER = %02X\n", StatusRegister.All));
555
556 if (StatusRegister.Bits.DataInRegisterReady)
557 {
558 DebugPrint((ERROR, "HOST ADAPTER ERROR CODE = %d\n", BusLogic_ReadDataInRegister(HostAdapter)));
559 }
560 return FALSE;
561 }
562
563 // Indicate the Host Adapter Hard Reset completed successfully.
564 return TRUE;
565}// end BusLogic_HardwareResetHostAdapter
static void BusLogic_HardReset(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1049

Referenced by BT958HwAdapterControl(), BT958HwResetBus(), and Buslogic_InitBT958().

◆ Buslogic_InitBT958()

BOOLEAN Buslogic_InitBT958 ( PHW_DEVICE_EXTENSION  deviceExtension,
PPORT_CONFIGURATION_INFORMATION  ConfigInfo 
)

Definition at line 316 of file BusLogic958.c.

331{
332 CHAR ch;
333
334 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
335
336 // Probe the Host Adapter.
337 // If unsuccessful, abort further initialization.
338 if (!BusLogic_ProbeHostAdapter(HostAdapter))
339 return FALSE;
340
341 // Hard Reset the Host Adapter.
342 // If unsuccessful, abort further initialization.
343 if (!BusLogic_HardwareResetHostAdapter(HostAdapter, TRUE))
344 return FALSE;
345
346 /*
347 * PR 40284 -- Disable interrupts until driver initialization is complete.
348 */
349 ch = 0;
351 &ch, sizeof(ch), NULL, 0) < 0) {
352 DebugPrint((WARNING, "\n BusLogic - Could not disable interrupts!\n"));
353 } else {
354 DebugPrint((INFO, "\n BusLogic - Disabled interrupts.\n"));
355 }
356
357 // Check the Host Adapter.
358 // If unsuccessful, abort further initialization.
359 if (!BusLogic_CheckHostAdapter(HostAdapter))
360 return FALSE;
361
362 // Allocate a Noncached Extension to use for mail boxes.
363 deviceExtension->NoncachedExtension = ScsiPortGetUncachedExtension(deviceExtension,
364 ConfigInfo,
365 sizeof(NONCACHED_EXTENSION));
366
367 if (deviceExtension->NoncachedExtension == NULL)
368 {
369 // Log error.
370 ScsiPortLogError(deviceExtension,
371 NULL,
372 0,
373 0,
374 0,
376 7 << 8);
377
378 // abort further initialization
379 return FALSE;
380 }
381
382 // Read the Host Adapter Configuration, Configure the Host Adapter,
383 // Acquire the System Resources necessary to use the Host Adapter, then
384 // Create the Initial CCBs, Initialize the Host Adapter, and finally
385 // perform Target Device Inquiry.
386 if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) &&
387 //BusLogic_ReportHostAdapterConfiguration(HostAdapter) &&
388 BusLogic_InitializeHostAdapter(deviceExtension, ConfigInfo) &&
389 BusLogic_TargetDeviceInquiry(HostAdapter))
390 {
391 // Fill in the:
392 // 1.Maximum number of scsi target devices that are supported by our adapter
393 ConfigInfo->MaximumNumberOfTargets = HostAdapter->MaxTargetDevices;
394 // 2. Maximum number of logical units per target the HBA can control.
395 ConfigInfo->MaximumNumberOfLogicalUnits = HostAdapter->MaxLogicalUnits;
396 ConfigInfo->InitiatorBusId[0] = HostAdapter->SCSI_ID;
397 // Maximum number of breaks between address ranges that a data buffer can
398 // have if the HBA supports scatter/gather. In other words, the number of
399 // scatter/gather lists minus one.
400 ConfigInfo->NumberOfPhysicalBreaks = HostAdapter->DriverScatterGatherLimit;
401 }
402 else
403 {
404 // An error occurred during Host Adapter Configuration Querying, Host
405 // Adapter Configuration, Host Adapter Initialization, or Target Device Inquiry,
406 // so return FALSE
407
408 return FALSE;
409 }
410 // Initialization completed successfully
411 return TRUE;
412} // end Buslogic_InitBT958
BOOLEAN BusLogic_TargetDeviceInquiry(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.c:1316
BOOLEAN BusLogic_ReadHostAdapterConfiguration(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.c:833
BOOLEAN BusLogic_CheckHostAdapter(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.c:569
BOOLEAN BusLogic_ProbeHostAdapter(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.c:416
PVOID NTAPI ScsiPortGetUncachedExtension(IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, IN ULONG NumberOfBytes)
Definition: scsiport.c:736
unsigned short DriverScatterGatherLimit
Definition: BusLogic958.h:706
PNONCACHED_EXTENSION NoncachedExtension
Definition: BusLogic958.h:758

Referenced by BT958HwFindAdapter().

◆ BusLogic_InitializeCCB()

VOID BusLogic_InitializeCCB ( PBuslogic_CCB_T  CCB)

Definition at line 1425 of file BusLogic958.c.

1426{
1427 CCB->Opcode = BusLogic_InitiatorCCB;
1428 CCB->DataDirection = 0;
1429 CCB->TagEnable = 0;
1430 CCB->QueueTag = 0 ;
1431 CCB->CDB_Length = 0;
1432 CCB->SenseDataLength = 0;
1433 CCB->DataLength = 0;
1434 CCB->DataPointer = 0;
1435 CCB->HostAdapterStatus = 0;
1436 CCB->TargetDeviceStatus = 0;
1437 CCB->TargetID = 0;
1438 CCB->LogicalUnit = 0;
1439 CCB->LegacyTagEnable = 0;
1440 CCB->LegacyQueueTag = 0;
1441
1442 CCB->SenseDataPointer = 0;
1443
1444 // BusLogic Driver Defined Portion
1445 CCB->Status = 0;
1446 CCB->SerialNumber = 0;
1447 CCB->Next = NULL;
1448 CCB->HostAdapter = NULL;
1449
1450 CCB->CompletionCode = 0;
1451 // Pointer to the CCB
1452 CCB->SrbAddress = NULL;
1453 CCB->AbortSrb = NULL;
1454}
@ BusLogic_InitiatorCCB
Definition: BusLogic958.h:461
Definition: cdstruc.h:1067

Referenced by BT958HwStartIO().

◆ BusLogic_InitializeHostAdapter()

BOOLEAN BusLogic_InitializeHostAdapter ( PHW_DEVICE_EXTENSION  deviceExtension,
PPORT_CONFIGURATION_INFORMATION  ConfigInfo 
)

Definition at line 1175 of file BusLogic958.c.

1189{
1190 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
1191 BusLogic_ExtendedMailboxRequest_T ExtendedMailboxRequest;
1192 UCHAR RoundRobinModeRequest;
1193 UCHAR SetCCBFormatRequest;
1194 int TargetID, LunID;
1195
1196 // Used when we get the Physical address of the mail boxes
1197 ULONG length;
1198
1199 // Initialize the pointers to the first and last CCBs that are queued for
1200 // completion processing.
1201 HostAdapter->FirstCompletedCCB = NULL;
1202 HostAdapter->LastCompletedCCB = NULL;
1203
1204 // Initialize the Bus Device Reset Pending CCB, Tagged Queuing Active,
1205 // Command Successful Flag, Active Commands, and Commands Since Reset
1206 // for each Target Device.
1207 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1208 {
1209 HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL;
1210 HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = FALSE;
1211 HostAdapter->TargetFlags[TargetID].CommandSuccessfulFlag = FALSE;
1212
1213 HostAdapter->ActiveCommandsPerTarget[TargetID] = 0;
1214 for (LunID = 0; LunID < HostAdapter->MaxLogicalUnits; LunID++)
1215 HostAdapter->ActiveCommandsPerLun[TargetID][LunID] = 0;
1216
1217 HostAdapter->CommandsSinceReset[TargetID] = 0;
1218 }
1219
1220 // Convert virtual to physical mailbox address.
1222 ScsiPortGetPhysicalAddress(deviceExtension,
1223 NULL,
1224 deviceExtension->NoncachedExtension->MailboxOut,
1225 &length));
1226
1228 HostAdapter->LastOutgoingMailbox = HostAdapter->FirstOutgoingMailbox + HostAdapter->MailboxCount - 1;
1229 HostAdapter->NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
1230
1232 HostAdapter->LastIncomingMailbox = HostAdapter->FirstIncomingMailbox + HostAdapter->MailboxCount - 1;
1233 HostAdapter->NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
1234
1235 // Initialize the Outgoing and Incoming Mailbox structures.
1236 memset(HostAdapter->FirstOutgoingMailbox,
1237 0,
1238 HostAdapter->MailboxCount * sizeof(BusLogic_OutgoingMailbox_T));
1239 memset(HostAdapter->FirstIncomingMailbox,
1240 0,
1241 HostAdapter->MailboxCount * sizeof(BusLogic_IncomingMailbox_T));
1242
1243
1244 ExtendedMailboxRequest.MailboxCount = HostAdapter->MailboxCount;
1245 ExtendedMailboxRequest.BaseMailboxAddress = deviceExtension->NoncachedExtension->MailboxPA ;
1246
1247 if (BusLogic_Command(HostAdapter,
1249 &ExtendedMailboxRequest,
1250 sizeof(ExtendedMailboxRequest),
1251 NULL, 0)
1252 < 0)
1253 {
1254 DebugPrint((ERROR, "\n BusLogic - Failure: MAILBOX INITIALIZATION\n"));
1255 return FALSE;
1256 }
1257
1258 // Enable Strict Round Robin Mode if supported by the Host Adapter. In
1259 // Strict Round Robin Mode, the Host Adapter only looks at the next Outgoing
1260 // Mailbox for each new command, rather than scanning through all the
1261 // Outgoing Mailboxes to find any that have new commands in them. Strict
1262 // Round Robin Mode is significantly more efficient.
1263 if (HostAdapter->StrictRoundRobinModeSupport)
1264 {
1265 RoundRobinModeRequest = BusLogic_StrictRoundRobinMode;
1266 if (BusLogic_Command(HostAdapter,
1268 &RoundRobinModeRequest,
1269 sizeof(RoundRobinModeRequest),
1270 NULL,
1271 0)
1272 < 0)
1273 {
1274 DebugPrint((ERROR, "\n BusLogic - Failure: ENABLE STRICT ROUND ROBIN MODE\n"));
1275 return FALSE;
1276 }
1277 }
1278
1279 // For Host Adapters that support Extended LUN Format CCBs, issue the Set CCB
1280 // Format command to allow 32 Logical Units per Target Device.
1281
1282 if (HostAdapter->ExtendedLUNSupport)
1283 {
1284 SetCCBFormatRequest = BusLogic_ExtendedLUNFormatCCB;
1285 if (BusLogic_Command(HostAdapter,
1287 &SetCCBFormatRequest,
1288 sizeof(SetCCBFormatRequest),
1289 NULL,
1290 0)
1291 < 0)
1292 {
1293 DebugPrint((ERROR, "\n BusLogic - Failure: SET CCB FORMAT\n"));
1294 return FALSE;
1295 }
1296 }
1297
1298 // Announce Successful Initialization.
1299 if (!HostAdapter->HostAdapterInitialized)
1300 {
1301 DebugPrint((INFO, "\n BusLogic - %s Initialized Successfully\n",
1302 HostAdapter, HostAdapter->FullModelName));
1303 }
1304 else
1305 {
1306 DebugPrint((WARNING, "\n BusLogic - %s not initialized Successfully\n",
1307 HostAdapter, HostAdapter->FullModelName));
1308 }
1309 HostAdapter->HostAdapterInitialized = TRUE;
1310 // Indicate the Host Adapter Initialization completed successfully.
1311 return TRUE;
1312}// end BusLogic_InitializeHostAdapter
@ BusLogic_ExtendedLUNFormatCCB
Definition: BusLogic958.h:1131
@ BusLogic_SetCCBFormat
Definition: BusLogic958.h:157
@ BusLogic_InitializeExtendedMailbox
Definition: BusLogic958.h:143
@ BusLogic_EnableStrictRoundRobinMode
Definition: BusLogic958.h:151
#define BusLogic_StrictRoundRobinMode
Definition: BusLogic958.h:106
SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortGetPhysicalAddress(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, IN PVOID VirtualAddress, OUT ULONG *Length)
Definition: scsiport.c:622
#define ScsiPortConvertPhysicalAddressToUlong(Address)
Definition: srb.h:957
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
BOOLEAN ExtendedLUNSupport
Definition: BusLogic958.h:691
BusLogic_CCB_T * BusDeviceResetPendingCCB[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:730
BusLogic_OutgoingMailbox_T * FirstOutgoingMailbox
Definition: BusLogic958.h:743
BusLogic_OutgoingMailbox_T * NextOutgoingMailbox
Definition: BusLogic958.h:745
BusLogic_IncomingMailbox_T * LastIncomingMailbox
Definition: BusLogic958.h:747
BusLogic_IncomingMailbox_T * FirstIncomingMailbox
Definition: BusLogic958.h:746
BOOLEAN HostAdapterInitialized
Definition: BusLogic958.h:699
BusLogic_OutgoingMailbox_T * LastOutgoingMailbox
Definition: BusLogic958.h:744
BusLogic_IncomingMailbox_T * NextIncomingMailbox
Definition: BusLogic958.h:748
BOOLEAN StrictRoundRobinModeSupport
Definition: BusLogic958.h:696
unsigned int CommandsSinceReset[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:737
UCHAR ActiveCommandsPerTarget[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:735
BusLogic_CCB_T * LastCompletedCCB
Definition: BusLogic958.h:729
BOOLEAN CommandSuccessfulFlag
Definition: BusLogic958.h:242
UCHAR MailboxIn[BusLogic_MaxMailboxes *sizeof(BusLogic_IncomingMailbox_T)]
Definition: BusLogic958.h:633
UCHAR MailboxOut[BusLogic_MaxMailboxes *sizeof(BusLogic_OutgoingMailbox_T)]
Definition: BusLogic958.h:632

Referenced by BT958HwAdapterControl(), BT958HwResetBus(), and Buslogic_InitBT958().

◆ BusLogic_ProbeHostAdapter()

BOOLEAN BusLogic_ProbeHostAdapter ( BusLogic_HostAdapter_T HostAdapter)

Definition at line 416 of file BusLogic958.c.

428{
430 BusLogic_InterruptRegister_T InterruptRegister;
431 BusLogic_GeometryRegister_T GeometryRegister;
432
433 DebugPrint((TRACE,"\n BusLogic - Inside ProbeHostaAdapter function \n"));
434 // Read the Status, Interrupt, and Geometry Registers to test if there are I/O
435 // ports that respond, and to check the values to determine if they are from a
436 // BusLogic Host Adapter. A nonexistent I/O port will return 0xFF, in which
437 // case there is definitely no BusLogic Host Adapter at this base I/O Address.
438 // The test here is a subset of that used by the BusLogic Host Adapter BIOS.
439
440 InterruptRegister.All = BusLogic_ReadInterruptRegister(HostAdapter);
441 GeometryRegister.All = BusLogic_ReadGeometryRegister(HostAdapter);
443
444 if (StatusRegister.All == 0 ||
445 StatusRegister.Bits.DiagnosticActive ||
446 StatusRegister.Bits.CommandParameterRegisterBusy ||
447 StatusRegister.Bits.Reserved ||
448 StatusRegister.Bits.CommandInvalid ||
449 InterruptRegister.Bits.Reserved != 0)
450 return FALSE;
451
452 // Check the undocumented Geometry Register to test if there is an I/O port
453 // that responded. Adaptec Host Adapters do not implement the Geometry
454 // Register, so this test helps serve to avoid incorrectly recognizing an
455 // Adaptec 1542A or 1542B as a BusLogic. Unfortunately, the Adaptec 1542C
456 // series does respond to the Geometry Register I/O port, but it will be
457 // rejected later when the Inquire Extended Setup Information command is
458 // issued in BusLogic_CheckHostAdapter. The AMI FastDisk Host Adapter is a
459 // BusLogic clone that implements the same interface as earlier BusLogic
460 // Host Adapters, including the undocumented commands, and is therefore
461 // supported by this driver. However, the AMI FastDisk always returns 0x00
462 // upon reading the Geometry Register, so the extended translation option
463 // should always be left disabled on the AMI FastDisk.
464
465 if (GeometryRegister.All == 0xFF) return FALSE;
466 return TRUE;
467}// end BusLogic_ProbeHostAdapter
static UCHAR BusLogic_ReadGeometryRegister(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1071

Referenced by Buslogic_InitBT958().

◆ BusLogic_ProcessCompletedCCBs()

void BusLogic_ProcessCompletedCCBs ( PHW_DEVICE_EXTENSION  deviceExtension)

Definition at line 2139 of file BusLogic958.c.

2150{
2151 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2153 PCDB RealCdb;
2154
2155 if (HostAdapter->ProcessCompletedCCBsActive)
2156 return;
2157 HostAdapter->ProcessCompletedCCBsActive = TRUE;
2158 while (HostAdapter->FirstCompletedCCB != NULL)
2159 {
2160 BusLogic_CCB_T *CCB = HostAdapter->FirstCompletedCCB;
2161
2162 // Get SRB from CCB.
2163 srb = CCB->SrbAddress;
2164
2165 HostAdapter->FirstCompletedCCB = CCB->Next;
2166 if (HostAdapter->FirstCompletedCCB == NULL)
2167 HostAdapter->LastCompletedCCB = NULL;
2168
2169 // Process the Completed CCB.
2170 if (CCB->Opcode == BusLogic_BusDeviceReset)
2171 {
2172 int TargetID = CCB->TargetID, LunID;
2173 DebugPrint((TRACE, "\n BusLogic - Bus Device Reset CCB #%ld to Target "
2174 "%d Completed\n", CCB->SerialNumber, TargetID));
2176
2177 HostAdapter->TargetFlags[TargetID].TaggedQueuingActive = FALSE;
2178 HostAdapter->CommandsSinceReset[TargetID] = 0;
2179 //HostAdapter->LastResetCompleted[TargetID] = jiffies;
2180 HostAdapter->ActiveCommandsPerTarget[TargetID] = 0;
2181 for (LunID = 0; LunID < HostAdapter->MaxLogicalUnits; LunID++)
2182 HostAdapter->ActiveCommandsPerLun[TargetID][LunID] = 0;
2183
2184 // Complete all outstanding requests with SRB_STATUS_BUS_RESET.
2185 ScsiPortCompleteRequest(deviceExtension,
2186 (UCHAR)srb->PathId,
2187 srb->TargetId,
2188 0xFF,
2190
2191
2192 HostAdapter->BusDeviceResetPendingCCB[TargetID] = NULL;
2193 }
2194 else
2195 {
2196 // Translate the Completion Code, Host Adapter Status, and Target
2197 // Device Status into a SCSI Subsystem Result Code.
2198 switch (CCB->CompletionCode)
2199 {
2202 {
2203 DebugPrint((ERROR, "\n BusLogic - CCB #%ld to Target %d Impossible "
2204 "State\n", CCB->SerialNumber, CCB->TargetID));
2205 break;
2206 }
2207
2208 //Processing for CCB that was to be aborted
2210 {
2211 srb = CCB->AbortSrb;
2213 break;
2214 }
2215
2217 {
2218 HostAdapter->TargetStatistics[CCB->TargetID].CommandsCompleted++;
2219 HostAdapter->TargetFlags[CCB->TargetID].CommandSuccessfulFlag = TRUE;
2220
2222 break;
2223 }
2224
2226 {
2227 DebugPrint((TRACE, "\n BusLogic - CCB #%ld to Target %d Aborted\n",
2228 CCB->SerialNumber, CCB->TargetID));
2229 //BusLogic_IncrementErrorCounter(&HostAdapter->TargetStatistics[CCB->TargetID].CommandAbortsCompleted);
2230
2232
2233 // Call notification routine for the aborted SRB.
2235 deviceExtension,
2236 srb);
2237
2238 // Get the abort SRB from CCB.
2239 srb = CCB->AbortSrb;
2240
2241 // Set status for completing abort request.
2243 break;
2244 }
2245
2247 {
2248 RealCdb = (PCDB)CCB->CDB;
2249 DebugPrint((ERROR, "\n BusLogic - %x Command completed with error Host - "
2250 "%x Target %x \n", RealCdb->CDB6GENERIC.OperationCode,
2251 CCB->HostAdapterStatus, CCB->TargetDeviceStatus));
2252
2253 srb->SrbStatus = BusLogic_ComputeResultCode(HostAdapter,
2254 CCB->HostAdapterStatus,
2255 CCB->TargetDeviceStatus,
2256 CCB->SenseDataLength);
2257 if (CCB->HostAdapterStatus != BusLogic_SCSISelectionTimeout)
2258 {
2259 HostAdapter->TargetStatistics[CCB->TargetID].CommandsCompleted++;
2260 }
2261 break;
2262 }
2263
2264 default:
2265 {
2266 // Log the error.
2267 ScsiPortLogError(deviceExtension,
2268 NULL,
2269 0,
2270 srb->TargetId,
2271 0,
2273 143);
2274
2275 DebugPrint((ERROR, "\n BusLogic - Unrecognized mailbox status\n"));
2276 }
2277
2278 }// end switch
2279
2280
2281 // When an INQUIRY command completes normally, save the CmdQue (Tagged Queuing Supported)
2282 // and WBus16 (16 Bit Wide Data Transfers Supported) bits.
2283 RealCdb = (PCDB) CCB->CDB;
2284 if (RealCdb->CDB6INQUIRY.OperationCode == SCSIOP_INQUIRY &&
2285 CCB->HostAdapterStatus == BusLogic_CommandCompletedNormally)
2286 {
2287 BusLogic_TargetFlags_T *TargetFlags =&HostAdapter->TargetFlags[CCB->TargetID];
2288 SCSI_Inquiry_T *InquiryResult =(SCSI_Inquiry_T *) srb->DataBuffer;
2289 TargetFlags->TargetExists = TRUE;
2290 TargetFlags->TaggedQueuingSupported = InquiryResult->CmdQue;
2291 TargetFlags->WideTransfersSupported = InquiryResult->WBus16;
2292 }
2293
2294 DebugPrint((INFO, "\n BusLogic - SCSI Status %x\n", srb->ScsiStatus));
2295 DebugPrint((INFO, "\n BusLogic - HBA Status %x\n", CCB->HostAdapterStatus));
2296
2297 // Update target status in SRB.
2298 srb->ScsiStatus = (UCHAR)CCB->TargetDeviceStatus;
2299
2300 // Signal request completion.
2301 ScsiPortNotification(RequestComplete, (PVOID)deviceExtension, srb);
2302 }
2303 }
2304 HostAdapter->ProcessCompletedCCBsActive = FALSE;
2305}// end BusLogic_ProcessCompletedCCBs
UCHAR BusLogic_ComputeResultCode(BusLogic_HostAdapter_T *HostAdapter, BusLogic_HostAdapterStatus_T HostAdapterStatus, BusLogic_TargetDeviceStatus_T TargetDeviceStatus, UCHAR SenseDataLength)
Definition: BusLogic958.c:2309
static void BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter)
Definition: BusLogic958.h:1179
@ BusLogic_BusDeviceReset
Definition: BusLogic958.h:466
@ BusLogic_CommandAbortedAtHostRequest
Definition: BusLogic958.h:452
@ BusLogic_AbortedCommandNotFound
Definition: BusLogic958.h:453
@ BusLogic_InvalidCCB
Definition: BusLogic958.h:455
@ BusLogic_CommandCompletedWithError
Definition: BusLogic958.h:454
@ BusLogic_CommandCompletedWithoutError
Definition: BusLogic958.h:451
@ BusLogic_IncomingMailboxFree
Definition: BusLogic958.h:450
#define SCSIOP_INQUIRY
Definition: cdrw_hw.h:888
union _CDB * PCDB
#define SRB_STATUS_ABORTED
Definition: srb.h:342
if(dx< 0)
Definition: linetemp.h:194
BusLogic_TargetStatistics_T TargetStatistics[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:749
BOOLEAN ProcessCompletedCCBsActive
Definition: BusLogic958.h:703
BOOLEAN WideTransfersSupported
Definition: BusLogic958.h:239
BOOLEAN TaggedQueuingSupported
Definition: BusLogic958.h:238
unsigned int CommandsCompleted
Definition: BusLogic958.h:262
unsigned short BusDeviceResetsCompleted
Definition: BusLogic958.h:274
BOOLEAN CmdQue
Definition: BusLogic958.h:783
BOOLEAN WBus16
Definition: BusLogic958.h:787
PVOID DataBuffer
Definition: srb.h:263
UCHAR ScsiStatus
Definition: srb.h:252
Definition: cdrw_hw.h:28
struct _CDB::_CDB6GENERIC CDB6GENERIC
struct _CDB::_CDB6INQUIRY CDB6INQUIRY

Referenced by BT958HwInterrupt().

◆ BusLogic_QueueCommand()

int BusLogic_QueueCommand ( IN PVOID  HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK  Srb,
PBuslogic_CCB_T  CCB 
)

Definition at line 1747 of file BusLogic958.c.

1760{
1761 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
1762 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
1763 BusLogic_TargetFlags_T *TargetFlags = &HostAdapter->TargetFlags[Srb->TargetId];
1764 BusLogic_TargetStatistics_T *TargetStatistics = HostAdapter->TargetStatistics;
1765
1766 ULONG length;
1767
1768// UCHAR *Cdb = Srb->Cdb;
1769// PCDB RealCdb ;
1770 UCHAR CDB_Length = Srb->CdbLength;
1771 UCHAR TargetID = Srb->TargetId;
1772 UCHAR LogicalUnit = Srb->Lun;
1773// void *BufferPointer = Srb->DataBuffer;
1775
1776 if (Srb->DataTransferLength > 0)
1777 {
1778 CCB->DataLength = Srb->DataTransferLength;
1779
1780 // Initialize the fields in the BusLogic Command Control Block (CCB).
1781#if SG_SUPPORT
1782 {
1783 ULONG xferLength, remainLength;
1784 PVOID virtualAddress;
1785 UCHAR i = 0;
1786
1787 virtualAddress = Srb->DataBuffer;
1788 xferLength = Srb->DataTransferLength;
1789 remainLength = xferLength;
1790 /* Build scatter gather list */
1791 do
1792 {
1793 CCB->ScatterGatherList[i].SegmentDataPointer = (ULONG)ScsiPortConvertPhysicalAddressToUlong(
1794 ScsiPortGetPhysicalAddress(HwDeviceExtension,
1795 Srb,
1796 virtualAddress,
1797 &length));
1798 if ( length > remainLength )
1799 length = remainLength;
1800 CCB->ScatterGatherList[i].SegmentByteCount = length;
1801
1802 virtualAddress = (PUCHAR) virtualAddress + length;
1803 if (length >= remainLength)
1804 remainLength = 0;
1805 else
1806 remainLength -= length;
1807 i++;
1808 } while ( remainLength > 0);
1809
1810 // For data transfers that have less than one scatter gather element, convert
1811 // CCB to one transfer without using SG element. This will clear up the data
1812 // overrun/underrun problem with small transfers that reak havoc with scanners
1813 // and CD-ROM's etc. This is the method employed in ASPI4DOS to avoid similar
1814 // problems.
1815 if (i > 1)
1816 {
1818 CCB->DataLength = i * sizeof(BusLogic_ScatterGatherSegment_T);
1819 virtualAddress = (PVOID) & (CCB->ScatterGatherList);
1821 ScsiPortGetPhysicalAddress(HwDeviceExtension,
1822 0,
1823 (PVOID)virtualAddress,
1824 &length));
1825 }
1826 else /* Turn off SG */
1827 {
1828 CCB->Opcode = BusLogic_InitiatorCCB;
1829 CCB->DataLength = CCB->ScatterGatherList[0].SegmentByteCount;
1830 CCB->DataPointer = CCB->ScatterGatherList[0].SegmentDataPointer;
1831
1832 }
1833 }
1834#else
1835 CCB->Opcode = BusLogic_InitiatorCCB;
1836 CCB->DataLength = BufferLength;
1838 Srb,
1839 BufferPointer,
1840 &length));
1841#endif
1842 }
1843
1845 {
1847 CCB->DataDirection = BusLogic_NoDataTransfer;
1848 break;
1849
1850 case SRB_FLAGS_DATA_IN:
1851 CCB->DataDirection = BusLogic_DataInLengthChecked;
1852 TargetStatistics[TargetID].ReadCommands++;
1853 BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesRead,
1854 BufferLength);
1855 BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].ReadCommandSizeBuckets,
1856 BufferLength);
1857 break;
1858
1859 case SRB_FLAGS_DATA_OUT:
1860 CCB->DataDirection = BusLogic_DataOutLengthChecked;
1861 TargetStatistics[TargetID].WriteCommands++;
1862 BusLogic_IncrementByteCounter(&TargetStatistics[TargetID].TotalBytesWritten,
1863 BufferLength);
1864 BusLogic_IncrementSizeBucket(TargetStatistics[TargetID].WriteCommandSizeBuckets,
1865 BufferLength);
1866
1867 break;
1868
1869 case SRB_FLAGS_UNSPECIFIED_DIRECTION: /* let device decide direction */
1870 default:
1871 CCB->DataDirection = BusLogic_UncheckedDataTransfer;
1872 break;
1873 }
1874
1875
1876 CCB->CDB_Length = CDB_Length;
1877 CCB->SenseDataLength = Srb->SenseInfoBufferLength;
1878 CCB->HostAdapterStatus = 0;
1879 CCB->TargetDeviceStatus = 0;
1880 CCB->TargetID = TargetID;
1881 CCB->LogicalUnit = LogicalUnit;
1882 CCB->TagEnable = FALSE;
1883 CCB->LegacyTagEnable = FALSE;
1884
1885 // BusLogic recommends that after a Reset the first couple of commands that
1886 // are sent to a Target Device be sent in a non Tagged Queue fashion so that
1887 // the Host Adapter and Target Device can establish Synchronous and Wide
1888 // Transfer before Queue Tag messages can interfere with the Synchronous and
1889 // Wide Negotiation messages. By waiting to enable Tagged Queuing until after
1890 // the first BusLogic_MaxTaggedQueueDepth commands have been queued, it is
1891 // assured that after a Reset any pending commands are requeued before Tagged
1892 // Queuing is enabled and that the Tagged Queuing message will not occur while
1893 // the partition table is being printed. In addition, some devices do not
1894 // properly handle the transition from non-tagged to tagged commands, so it is
1895 // necessary to wait until there are no pending commands for a target device
1896 // before queuing tagged commands.
1897
1898 if (HostAdapter->CommandsSinceReset[TargetID]++ >= BusLogic_MaxTaggedQueueDepth &&
1899 HostAdapter->ActiveCommandsPerTarget[TargetID] == 0 &&
1900 !TargetFlags->TaggedQueuingActive &&
1901 TargetFlags->TaggedQueuingSupported &&
1902 (HostAdapter->TaggedQueuingPermitted & (1 << TargetID)))
1903 {
1904 TargetFlags->TaggedQueuingActive = TRUE;
1905 DebugPrint((INFO, "\n BusLogic - Tagged Queuing now active for Target %d\n",
1906 TargetID));
1907 }
1908 if (TargetFlags->TaggedQueuingActive)
1909 {
1911
1912 // When using Tagged Queuing with Simple Queue Tags, it appears that disk
1913 // drive controllers do not guarantee that a queued command will not
1914 // remain in a disconnected state indefinitely if commands that read or
1915 // write nearer the head position continue to arrive without interruption.
1916 // Therefore, for each Target Device this driver keeps track of the last
1917 // time either the queue was empty or an Ordered Queue Tag was issued. If
1918 // more than 4 seconds (one fifth of the 20 second disk timeout) have
1919 // elapsed since this last sequence point, this command will be issued
1920 // with an Ordered Queue Tag rather than a Simple Queue Tag, which forces
1921 // the Target Device to complete all previously queued commands before
1922 // this command may be executed.
1923 /*
1924 if (HostAdapter->ActiveCommandsPerTarget[TargetID] == 0)
1925 HostAdapter->LastSequencePoint[TargetID] = jiffies;
1926 else if (jiffies - HostAdapter->LastSequencePoint[TargetID] > 4*HZ)
1927 {
1928 HostAdapter->LastSequencePoint[TargetID] = jiffies;
1929 QueueTag = BusLogic_OrderedQueueTag;
1930 }
1931 */
1932 if (HostAdapter->ExtendedLUNSupport)
1933 {
1934 CCB->TagEnable = TRUE;
1935 CCB->QueueTag = (UCHAR)QueueTag;
1936 }
1937 else
1938 {
1939 CCB->LegacyTagEnable = TRUE;
1940 CCB->LegacyQueueTag = (UCHAR)QueueTag;
1941 }
1942 }
1943
1944 ScsiPortMoveMemory(CCB->CDB, Srb->Cdb, CDB_Length);
1945
1946 //Fix for the XP Port driver - shuts of auto sense at times. 22nd May 2002
1947 //{sirish, shobhit}@calsoftinc.com
1949 (Srb->SenseInfoBufferLength <= 0)) {
1950
1951 //Disable auto request sense
1952 CCB->SenseDataLength = BusLogic_DisableAutoReqSense;
1953 } else {
1954 //Enable auto request sense
1955 CCB->SenseDataLength = (unsigned char) Srb->SenseInfoBufferLength;
1956
1957 //Sense Buffer physical addr
1958 CCB->SenseDataPointer = ScsiPortConvertPhysicalAddressToUlong(ScsiPortGetPhysicalAddress(HwDeviceExtension,
1959 Srb,
1961 &length));
1963 CCB->SenseDataLength = (unsigned char) length;
1964 }
1965 }
1966
1967 return 0;
1968}// end BusLogic_QueueCommand
BusLogic_QueueTag_T
Definition: BusLogic958.h:521
@ BusLogic_SimpleQueueTag
Definition: BusLogic958.h:522
static void BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets, unsigned int Amount)
Definition: BusLogic958.h:1152
@ BusLogic_InitiatorCCB_ScatterGather
Definition: BusLogic958.h:463
struct BusLogic_ScatterGatherSegment BusLogic_ScatterGatherSegment_T
@ BusLogic_NoDataTransfer
Definition: BusLogic958.h:476
@ BusLogic_UncheckedDataTransfer
Definition: BusLogic958.h:473
@ BusLogic_DataOutLengthChecked
Definition: BusLogic958.h:475
@ BusLogic_DataInLengthChecked
Definition: BusLogic958.h:474
static void BusLogic_IncrementByteCounter(BusLogic_ByteCounter_T *ByteCounter, unsigned int Amount)
Definition: BusLogic958.h:1139
#define BusLogic_MaxTaggedQueueDepth
Definition: BusLogic958.h:72
VOID NTAPI ScsiPortMoveMemory(IN PVOID WriteBuffer, IN PVOID ReadBuffer, IN ULONG Length)
Definition: scsiport.c:1314
unsigned char
Definition: typeof.h:29
#define SRB_FLAGS_DATA_OUT
Definition: srb.h:401
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:402
#define SRB_FLAGS_DISABLE_AUTOSENSE
Definition: srb.h:399
#define SRB_FLAGS_DATA_IN
Definition: srb.h:400
#define SRB_FLAGS_UNSPECIFIED_DIRECTION
Definition: srb.h:403
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned short TaggedQueuingPermitted
Definition: BusLogic958.h:721
unsigned int WriteCommands
Definition: BusLogic958.h:264
UCHAR SenseInfoBufferLength
Definition: srb.h:259
UCHAR Cdb[16]
Definition: srb.h:279
PVOID SenseInfoBuffer
Definition: srb.h:264
ULONG DataTransferLength
Definition: srb.h:261
ULONG SrbFlags
Definition: srb.h:260
void * PVOID
Definition: typedefs.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by BT958HwStartIO().

◆ BusLogic_QueueCompletedCCB()

void BusLogic_QueueCompletedCCB ( PHW_DEVICE_EXTENSION  deviceExtension,
BusLogic_CCB_T CCB 
)

Definition at line 2108 of file BusLogic958.c.

2117{
2118 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2119
2120 CCB->Status = BusLogic_CCB_Completed;
2121 CCB->Next = NULL;
2122 if (HostAdapter->FirstCompletedCCB == NULL)
2123 {
2124 HostAdapter->FirstCompletedCCB = CCB;
2125 HostAdapter->LastCompletedCCB = CCB;
2126 }
2127 else
2128 {
2129 HostAdapter->LastCompletedCCB->Next = CCB;
2130 HostAdapter->LastCompletedCCB = CCB;
2131 }
2132 HostAdapter->ActiveCommandsPerTarget[CCB->TargetID]--;
2133 HostAdapter->ActiveCommandsPerLun[CCB->TargetID][CCB->LogicalUnit]--;
2134
2135}// end BusLogic_QueueCompletedCCB
@ BusLogic_CCB_Completed
Definition: BusLogic958.h:544
struct _CCB CCB
struct BusLogic_CCB * Next
Definition: BusLogic958.h:591

Referenced by BusLogic_ScanIncomingMailboxes().

◆ BusLogic_ReadHostAdapterConfiguration()

BOOLEAN BusLogic_ReadHostAdapterConfiguration ( BusLogic_HostAdapter_T HostAdapter)

save it in the Host Adapter structure. The BIOS is disabled if the

Definition at line 833 of file BusLogic958.c.

844{
845 BusLogic_BoardID_T BoardID;
847 BusLogic_SetupInformation_T SetupInformation;
848 BusLogic_ExtendedSetupInformation_T ExtendedSetupInformation;
849 BusLogic_HostAdapterModelNumber_T HostAdapterModelNumber;
850 BusLogic_FirmwareVersion3rdDigit_T FirmwareVersion3rdDigit;
851 BusLogic_FirmwareVersionLetter_T FirmwareVersionLetter;
852 BusLogic_PCIHostAdapterInformation_T PCIHostAdapterInformation;
853 BusLogic_FetchHostAdapterLocalRAMRequest_T FetchHostAdapterLocalRAMRequest;
854 BusLogic_AutoSCSIData_T AutoSCSIData;
855 BusLogic_GeometryRegister_T GeometryRegister;
856 BusLogic_RequestedReplyLength_T RequestedReplyLength;
857 UCHAR *TargetPointer, Character;
858 ULONG /*TargetID,*/ i;
859
860
861 // Issue the Inquire Board ID command.
862 if (BusLogic_Command(HostAdapter,
864 NULL,
865 0,
866 &BoardID, sizeof(BoardID))
867 != sizeof(BoardID))
868 {
869 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE BOARD ID\n"));
870 return FALSE;
871 }
872
873 // Issue the Inquire Configuration command.
874 if (BusLogic_Command(HostAdapter,
876 NULL,
877 0,
879 != sizeof(Configuration))
880 {
881 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE CONFIGURATION\n"));
882 return FALSE;
883 }
884
885 // Issue the Inquire Setup Information command.
886 RequestedReplyLength = sizeof(SetupInformation);
887 if (BusLogic_Command(HostAdapter,
889 &RequestedReplyLength,
890 sizeof(RequestedReplyLength),
891 &SetupInformation,
892 sizeof(SetupInformation))
893 != sizeof(SetupInformation))
894 {
895 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE SETUP INFORMATION\n"));
896 return FALSE;
897 }
898
899 // Issue the Inquire Extended Setup Information command.
900 RequestedReplyLength = sizeof(ExtendedSetupInformation);
901 if (BusLogic_Command(HostAdapter,
903 &RequestedReplyLength,
904 sizeof(RequestedReplyLength),
905 &ExtendedSetupInformation,
906 sizeof(ExtendedSetupInformation))
907 != sizeof(ExtendedSetupInformation))
908 {
909 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE EXTENDED SETUP INFORMATION\n"));
910 return FALSE;
911 }
912
913 // Issue the Inquire Firmware Version 3rd Digit command.
914 FirmwareVersion3rdDigit = '\0';
915 if (BoardID.FirmwareVersion1stDigit > '0')
916 {
917 if (BusLogic_Command(HostAdapter,
919 NULL,
920 0,
921 &FirmwareVersion3rdDigit,
922 sizeof(FirmwareVersion3rdDigit))
923 != sizeof(FirmwareVersion3rdDigit))
924 {
925 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE FIRMWARE 3RD DIGIT\n"));
926 return FALSE;
927 }
928 }
929
930 // Issue the Inquire Host Adapter Model Number command.
931 RequestedReplyLength = sizeof(HostAdapterModelNumber);
932 if (BusLogic_Command(HostAdapter,
934 &RequestedReplyLength,
935 sizeof(RequestedReplyLength),
936 &HostAdapterModelNumber,
937 sizeof(HostAdapterModelNumber))
938 != sizeof(HostAdapterModelNumber))
939 {
940 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE HOST ADAPTER MODEL NUMBER\n"));
941 return FALSE;
942 }
943
944 // BusLogic MultiMaster Host Adapters can be identified by their model number
945 // and the major version number of their firmware as follows:
946 //
947 // 5.xx BusLogic "W" Series Host Adapters:
948 // BT-948/958/958D
949 // Save the Model Name and Host Adapter Name in the Host Adapter structure.
950 TargetPointer = HostAdapter->ModelName;
951 *TargetPointer++ = 'B';
952 *TargetPointer++ = 'T';
953 *TargetPointer++ = '-';
954 for (i = 0; i < sizeof(HostAdapterModelNumber); i++)
955 {
956 Character = HostAdapterModelNumber[i];
957 if (Character == ' ' || Character == '\0') break;
958 *TargetPointer++ = Character;
959 }
960 *TargetPointer++ = '\0';
961
962 // Save the Firmware Version in the Host Adapter structure.
963 TargetPointer = HostAdapter->FirmwareVersion;
964 *TargetPointer++ = BoardID.FirmwareVersion1stDigit;
965 *TargetPointer++ = '.';
966 *TargetPointer++ = BoardID.FirmwareVersion2ndDigit;
967 if (FirmwareVersion3rdDigit != ' ' && FirmwareVersion3rdDigit != '\0')
968 *TargetPointer++ = FirmwareVersion3rdDigit;
969 *TargetPointer = '\0';
970
971 // Issue the Inquire Firmware Version Letter command.
972 if (strcmp((char*)HostAdapter->FirmwareVersion, "3.3") >= 0)
973 {
974 if (BusLogic_Command(HostAdapter,
976 NULL,
977 0,
978 &FirmwareVersionLetter,
979 sizeof(FirmwareVersionLetter))
980 != sizeof(FirmwareVersionLetter))
981 {
982 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE FIRMWARE VERSION LETTER\n"));
983 return FALSE;
984 }
985 if (FirmwareVersionLetter != ' ' && FirmwareVersionLetter != '\0')
986 {
987 *TargetPointer++ = FirmwareVersionLetter;
988 }
989 *TargetPointer = '\0';
990 }
991
992
993 // Save the Host Adapter SCSI ID in the Host Adapter structure.
994 HostAdapter->SCSI_ID = Configuration.HostAdapterID;
995
996 // Determine the Bus Type and save it in the Host Adapter structure, determine
997 // and save the IRQ Channel if necessary, and determine and save the DMA
998 // Channel for ISA Host Adapters.
999 HostAdapter->HostAdapterBusType = BusLogic_HostAdapterBusTypes[HostAdapter->ModelName[3] - '4'];
1000
1001 GeometryRegister.All = BusLogic_ReadGeometryRegister(HostAdapter);
1002
1003 // Determine whether Extended Translation is enabled and save it in
1004 // the Host Adapter structure.
1005 // HostAdapter->ExtendedTranslationEnabled = GeometryRegister.Bits.ExtendedTranslationEnabled;
1006 HostAdapter->ExtendedTranslationEnabled = GeometryRegister.All;
1007
1008
1009 // Save the Scatter Gather Limits, Level Sensitive Interrupt flag, Wide
1010 // SCSI flag, Differential SCSI flag, SCAM Supported flag, and
1011 // Ultra SCSI flag in the Host Adapter structure.
1012 HostAdapter->HostAdapterScatterGatherLimit = ExtendedSetupInformation.ScatterGatherLimit;
1013
1014 HostAdapter->DriverScatterGatherLimit = HostAdapter->HostAdapterScatterGatherLimit;
1015
1017 {
1019 }
1020 if (ExtendedSetupInformation.Misc.LevelSensitiveInterrupt)
1021 {
1022 HostAdapter->LevelSensitiveInterrupt = TRUE;
1023 }
1024
1025 HostAdapter->HostWideSCSI = ExtendedSetupInformation.HostWideSCSI;
1026
1027 HostAdapter->HostDifferentialSCSI = ExtendedSetupInformation.HostDifferentialSCSI;
1028
1029 HostAdapter->HostSupportsSCAM = ExtendedSetupInformation.HostSupportsSCAM;
1030
1031 HostAdapter->HostUltraSCSI = ExtendedSetupInformation.HostUltraSCSI;
1032
1033
1034 // Determine whether Extended LUN Format CCBs are supported and save the
1035 // information in the Host Adapter structure.
1036 if (HostAdapter->FirmwareVersion[0] == '5' ||
1037 (HostAdapter->FirmwareVersion[0] == '4' && HostAdapter->HostWideSCSI))
1038 {
1039 HostAdapter->ExtendedLUNSupport = TRUE;
1040 }
1041 // Issue the Inquire PCI Host Adapter Information command to read the
1042 // Termination Information from "W" series MultiMaster Host Adapters.
1043 if (HostAdapter->FirmwareVersion[0] == '5')
1044 {
1045 if (BusLogic_Command(HostAdapter,
1047 NULL,
1048 0,
1049 &PCIHostAdapterInformation,
1050 sizeof(PCIHostAdapterInformation))
1051 != sizeof(PCIHostAdapterInformation))
1052 {
1053 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE PCI HOST ADAPTER INFORMATION\n"));
1054 return FALSE;
1055 }
1056
1057 // Save the Termination Information in the Host Adapter structure.
1058 if (PCIHostAdapterInformation.GenericInfoValid)
1059 {
1060 HostAdapter->TerminationInfoValid = TRUE;
1061 HostAdapter->LowByteTerminated = PCIHostAdapterInformation.LowByteTerminated;
1062 HostAdapter->HighByteTerminated = PCIHostAdapterInformation.HighByteTerminated;
1063 }
1064 }
1065
1066 // Issue the Fetch Host Adapter Local RAM command to read the AutoSCSI data
1067 // from "W" and "C" series MultiMaster Host Adapters.
1068 if (HostAdapter->FirmwareVersion[0] >= '4')
1069 {
1070 FetchHostAdapterLocalRAMRequest.ByteOffset = BusLogic_AutoSCSI_BaseOffset;
1071 FetchHostAdapterLocalRAMRequest.ByteCount = sizeof(AutoSCSIData);
1072 if (BusLogic_Command(HostAdapter,
1074 &FetchHostAdapterLocalRAMRequest,
1075 sizeof(FetchHostAdapterLocalRAMRequest),
1076 &AutoSCSIData,
1077 sizeof(AutoSCSIData))
1078 != sizeof(AutoSCSIData))
1079 {
1080 DebugPrint((ERROR, "\n BusLogic - Failure: FETCH HOST ADAPTER LOCAL RAM\n"));
1081 return FALSE;
1082 }
1083 // Save the Parity Checking Enabled, Bus Reset Enabled, and Termination
1084 // Information in the Host Adapter structure.
1085 HostAdapter->ParityCheckingEnabled = AutoSCSIData.ParityCheckingEnabled;
1086 HostAdapter->BusResetEnabled = AutoSCSIData.BusResetEnabled;
1087
1088 // Save the Wide Permitted, Fast Permitted, Synchronous Permitted,
1089 // Disconnect Permitted, Ultra Permitted, and SCAM Information in the
1090 // Host Adapter structure.
1091 HostAdapter->WidePermitted = AutoSCSIData.WidePermitted;
1092 HostAdapter->FastPermitted = AutoSCSIData.FastPermitted;
1093 HostAdapter->SynchronousPermitted = AutoSCSIData.SynchronousPermitted;
1094 HostAdapter->DisconnectPermitted = AutoSCSIData.DisconnectPermitted;
1095 if (HostAdapter->HostUltraSCSI)
1096 {
1097 HostAdapter->UltraPermitted = AutoSCSIData.UltraPermitted;
1098 }
1099 if (HostAdapter->HostSupportsSCAM)
1100 {
1101 HostAdapter->SCAM_Enabled = AutoSCSIData.SCAM_Enabled;
1102 HostAdapter->SCAM_Level2 = AutoSCSIData.SCAM_Level2;
1103 }
1104 }
1105
1106 // Determine the maximum number of Target IDs and Logical Units supported by
1107 // this driver for Wide and Narrow Host Adapters.
1108 HostAdapter->MaxTargetDevices = (HostAdapter->HostWideSCSI ? 16 : 8);
1109 HostAdapter->MaxLogicalUnits = (HostAdapter->ExtendedLUNSupport ? 32 : 8);
1110
1111 // Select appropriate values for the Mailbox Count,
1112 // Initial CCBs, and Incremental CCBs variables based on whether or not Strict
1113 // Round Robin Mode is supported. If Strict Round Robin Mode is supported,
1114 // then there is no performance degradation in using the maximum possible
1115 // number of Outgoing and Incoming Mailboxes and allowing the Tagged and
1116 // Untagged Queue Depths to determine the actual utilization. If Strict Round
1117 // Robin Mode is not supported, then the Host Adapter must scan all the
1118 // Outgoing Mailboxes whenever an Outgoing Mailbox entry is made, which can
1119 // cause a substantial performance penalty. The host adapters actually have
1120 // room to store the following number of CCBs internally; that is, they can
1121 // internally queue and manage this many active commands on the SCSI bus
1122 // simultaneously. Performance measurements demonstrate that the Driver Queue
1123 // Depth should be set to the Mailbox Count, rather than the Host Adapter
1124 // Queue Depth (internal CCB capacity), as it is more efficient to have the
1125 // queued commands waiting in Outgoing Mailboxes if necessary than to block
1126 // the process in the higher levels of the SCSI Subsystem.
1127 //
1128 // 192 BT-948/958/958D
1129 if (HostAdapter->FirmwareVersion[0] == '5')
1130 {
1131 HostAdapter->HostAdapterQueueDepth = 192;
1132 }
1133
1134 if (strcmp((char*)HostAdapter->FirmwareVersion, "3.31") >= 0)
1135 {
1136 HostAdapter->StrictRoundRobinModeSupport = TRUE;
1137 HostAdapter->MailboxCount = BusLogic_MaxMailboxes;
1138 }
1139
1140 //
1141 // Tagged Queuing support is available and operates properly on all "W" series
1142 // MultiMaster Host Adapters, on "C" series MultiMaster Host Adapters with
1143 // firmware version 4.22 and above, and on "S" series MultiMaster Host
1144 // Adapters with firmware version 3.35 and above.
1145 HostAdapter->TaggedQueuingPermitted = 0xFFFF;
1146
1147 //
1148 // Determine the Host Adapter BIOS Address if the BIOS is enabled and
1150 // BIOS_Address is 0.
1151 HostAdapter->BIOS_Address = ExtendedSetupInformation.BIOS_Address << 12;
1152
1153 //
1154 //Initialize parameters for MultiMaster Host Adapters.
1155
1156 //
1157 // Initialize the Host Adapter Full Model Name from the Model Name.
1158 strcpy((char*)HostAdapter->FullModelName, "BusLogic ");
1159 strcat((char*)HostAdapter->FullModelName, (char*)HostAdapter->ModelName);
1160
1161 // Tagged Queuing is only allowed if Disconnect/Reconnect is permitted.
1162 // Therefore, mask the Tagged Queuing Permitted Default bits with the
1163 // Disconnect/Reconnect Permitted bits.
1164 HostAdapter->TaggedQueuingPermitted &= HostAdapter->DisconnectPermitted;
1165
1166 // Select an appropriate value for Bus Settle Time either from a BusLogic
1167 // Driver Options specification, or from BusLogic_DefaultBusSettleTime.
1169
1170 // Indicate reading the Host Adapter Configuration completed successfully.
1171 return TRUE;
1172}// end BusLogic_ReadHostAdapterConfiguration
static BusLogic_HostAdapterBusType_T BusLogic_HostAdapterBusTypes[]
Definition: BusLogic958.h:659
@ BusLogic_InquirePCIHostAdapterInformation
Definition: BusLogic958.h:147
@ BusLogic_InquireHostAdapterModelNumber
Definition: BusLogic958.h:148
@ BusLogic_InquireFirmwareVersionLetter
Definition: BusLogic958.h:146
@ BusLogic_InquireBoardID
Definition: BusLogic958.h:123
@ BusLogic_InquireSetupInformation
Definition: BusLogic958.h:132
@ BusLogic_InquireFirmwareVersion3rdDigit
Definition: BusLogic958.h:145
@ BusLogic_InquireConfiguration
Definition: BusLogic958.h:130
UCHAR BusLogic_HostAdapterModelNumber_T[5]
Definition: BusLogic958.h:175
#define BusLogic_AutoSCSI_BaseOffset
Definition: BusLogic958.h:94
#define BusLogic_ScatterGatherLimit
Definition: BusLogic958.h:102
#define BusLogic_DefaultBusSettleTime
Definition: BusLogic958.h:78
UCHAR BusLogic_FirmwareVersion3rdDigit_T
Definition: BusLogic958.h:178
UCHAR BusLogic_FirmwareVersionLetter_T
Definition: BusLogic958.h:181
#define BusLogic_MaxMailboxes
Definition: BusLogic958.h:90
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned short WidePermitted
Definition: BusLogic958.h:399
unsigned short DisconnectPermitted
Definition: BusLogic958.h:402
unsigned short FastPermitted
Definition: BusLogic958.h:400
unsigned short UltraPermitted
Definition: BusLogic958.h:411
unsigned short SynchronousPermitted
Definition: BusLogic958.h:401
UCHAR FirmwareVersion1stDigit
Definition: BusLogic958.h:229
UCHAR FirmwareVersion2ndDigit
Definition: BusLogic958.h:230
struct BusLogic_ExtendedSetupInformation::@1323 Misc
unsigned short DisconnectPermitted
Definition: BusLogic958.h:720
unsigned short WidePermitted
Definition: BusLogic958.h:719
BOOLEAN ExtendedTranslationEnabled
Definition: BusLogic958.h:683
BOOLEAN LevelSensitiveInterrupt
Definition: BusLogic958.h:686
BOOLEAN HostDifferentialSCSI
Definition: BusLogic958.h:688
BOOLEAN ParityCheckingEnabled
Definition: BusLogic958.h:684
UCHAR FirmwareVersion[6]
Definition: BusLogic958.h:675
BOOLEAN TerminationInfoValid
Definition: BusLogic958.h:692
unsigned short UltraPermitted
Definition: BusLogic958.h:718
unsigned short HostAdapterQueueDepth
Definition: BusLogic958.h:712
BOOLEAN HighByteTerminated
Definition: BusLogic958.h:694
BusLogic_BusAddress_T BIOS_Address
Definition: BusLogic958.h:726
BusLogic_HostAdapterBusType_T HostAdapterBusType
Definition: BusLogic958.h:672
unsigned short FastPermitted
Definition: BusLogic958.h:717
unsigned short SynchronousPermitted
Definition: BusLogic958.h:716
unsigned short HostAdapterScatterGatherLimit
Definition: BusLogic958.h:705
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG Configuration
Definition: wdfinterrupt.h:374

Referenced by Buslogic_InitBT958().

◆ BusLogic_ScanIncomingMailboxes()

void BusLogic_ScanIncomingMailboxes ( PHW_DEVICE_EXTENSION  deviceExtension)

Definition at line 2048 of file BusLogic958.c.

2056{
2057 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2058
2059
2060 // Scan through the Incoming Mailboxes in Strict Round Robin fashion, saving
2061 // any completed CCBs for further processing. It is essential that for each
2062 // CCB and SCSI Command issued, command completion processing is performed
2063 // exactly once. Therefore, only Incoming Mailboxes with completion code
2064 // Command Completed Without Error, Command Completed With Error, or Command
2065 // Aborted At Host Request are saved for completion processing. When an
2066 // Incoming Mailbox has a completion code of Aborted Command Not Found, the
2067 // CCB had already completed or been aborted before the current Abort request
2068 // was processed, and so completion processing has already occurred and no
2069 // further action should be taken.
2070 BusLogic_IncomingMailbox_T *NextIncomingMailbox = HostAdapter->NextIncomingMailbox;
2071 BusLogic_CompletionCode_T CompletionCode;
2072
2073 while ((CompletionCode = NextIncomingMailbox->CompletionCode) != BusLogic_IncomingMailboxFree)
2074 {
2075 // Convert Physical CCB to Virtual.
2077 ScsiPortConvertUlongToPhysicalAddress(NextIncomingMailbox->CCB));
2078
2079 DebugPrint((INFO, "\n Buslogic - Virtual CCB %lx\n", CCB));
2080 if (CompletionCode != BusLogic_AbortedCommandNotFound)
2081 {
2082 if (CCB->Status == BusLogic_CCB_Active || CCB->Status == BusLogic_CCB_Reset)
2083 {
2084
2085 // Save the Completion Code for this CCB and queue the CCB
2086 // for completion processing.
2087 CCB->CompletionCode = CompletionCode;
2088 BusLogic_QueueCompletedCCB(deviceExtension,CCB);
2089 }
2090 else
2091 {
2092 // If a CCB ever appears in an Incoming Mailbox and is not marked
2093 // as status Active or Reset, then there is most likely a bug in
2094 // the Host Adapter firmware.
2095 DebugPrint((ERROR, "\n BusLogic - Illegal CCB #%ld status %d in "
2096 "Incoming Mailbox\n", CCB->SerialNumber, CCB->Status));
2097 }
2098 }
2099 NextIncomingMailbox->CompletionCode = BusLogic_IncomingMailboxFree;
2100 if (++NextIncomingMailbox > HostAdapter->LastIncomingMailbox)
2101 NextIncomingMailbox = HostAdapter->FirstIncomingMailbox;
2102 }
2103 HostAdapter->NextIncomingMailbox = NextIncomingMailbox;
2104}// end BusLogic_ScanIncomingMailboxes
void BusLogic_QueueCompletedCCB(PHW_DEVICE_EXTENSION deviceExtension, BusLogic_CCB_T *CCB)
Definition: BusLogic958.c:2108
BusLogic_CompletionCode_T
Definition: BusLogic958.h:449
@ BusLogic_CCB_Reset
Definition: BusLogic958.h:545
@ BusLogic_CCB_Active
Definition: BusLogic958.h:543
SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress(IN ULONG_PTR UlongAddress)
Definition: scsiport.c:529
PVOID NTAPI ScsiPortGetVirtualAddress(IN PVOID HwDeviceExtension, IN SCSI_PHYSICAL_ADDRESS PhysicalAddress)
Definition: scsiport.c:821
BusLogic_BusAddress_T CCB
Definition: BusLogic958.h:614

Referenced by BT958HwInterrupt().

◆ BusLogic_SendBusDeviceReset()

BOOLEAN BusLogic_SendBusDeviceReset ( IN PVOID  HwDeviceExtension,
PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 2535 of file BusLogic958.c.

2548{
2549
2550 PHW_DEVICE_EXTENSION deviceExtension = HwDeviceExtension;
2551 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
2552
2553 UCHAR TargetID = Srb->TargetId;
2557
2558 // If this is a Synchronous Reset and a Bus Device Reset is already pending
2559 // for this Target Device, do not send a second one. Add this Command to
2560 // the list of Commands for which completion processing must be performed
2561 // when the Bus Device Reset CCB completes.
2562
2563 if (HostAdapter->BusDeviceResetPendingCCB[TargetID] != NULL)
2564 {
2565 DebugPrint((WARNING, "\n BusLogic - Unable to Reset Command to Target %d - "
2566 "Reset Pending\n", TargetID));
2567 Result = TRUE;
2568 goto Done;
2569 }
2570
2571 DebugPrint((WARNING, "\n BusLogic - Sending Bus Device Reset CCB #%ld to Target %d\n",
2572 CCB->SerialNumber, TargetID));
2573 CCB->Opcode = BusLogic_BusDeviceReset;
2574 CCB->TargetID = TargetID;
2575
2576
2577 // Attempt to write an Outgoing Mailbox with the Bus Device Reset CCB.
2578 // If sending a Bus Device Reset is impossible, attempt a full Host
2579 // Adapter Hard Reset and SCSI Bus Reset.
2581 {
2582 DebugPrint((WARNING, "\n BusLogic - Unable to write Outgoing Mailbox for "
2583 "Bus Device Reset\n"));
2584 goto Done;
2585 }
2586
2587 // If there is a currently executing CCB in the Host Adapter for this Command
2588 // (i.e. this is an Asynchronous Reset), then an Incoming Mailbox entry may be
2589 // made with a completion code of BusLogic_HostAdapterAssertedBusDeviceReset.
2590 // If there is no active CCB for this Command (i.e. this is a Synchronous
2591 // Reset), then the Bus Device Reset CCB's Command field will have been set
2592 // to the Command so that the interrupt for the completion of the Bus Device
2593 // Reset can call the Completion Routine for the Command. On successful
2594 // execution of a Bus Device Reset, older firmware versions did return the
2595 // pending CCBs with the appropriate completion code, but more recent firmware
2596 // versions only return the Bus Device Reset CCB itself. This driver handles
2597 // both cases by marking all the currently executing CCBs to this Target
2598 // Device as Reset. When the Bus Device Reset CCB is processed by the
2599 // interrupt handler, any remaining CCBs marked as Reset will have completion
2600 // processing performed.
2601
2603 HostAdapter->BusDeviceResetPendingCCB[TargetID] = CCB;
2604 //HostAdapter->LastResetAttempted[TargetID] = jiffies;
2605
2606 // FlashPoint Host Adapters may have already completed the Bus Device
2607 // Reset and BusLogic_QueueCompletedCCB been called, or it may still be
2608 // pending.
2609
2610 Result = TRUE;
2611 // If a Bus Device Reset was not possible for some reason, force a full
2612 // Host Adapter Hard Reset and SCSI Bus Reset.
2613
2614Done:
2615 return Result;
2616}
unsigned short BusDeviceResetsAttempted
Definition: BusLogic958.h:273
unsigned short BusDeviceResetsRequested
Definition: BusLogic958.h:272

Referenced by BT958HwStartIO().

◆ BusLogic_TargetDeviceInquiry()

BOOLEAN BusLogic_TargetDeviceInquiry ( BusLogic_HostAdapter_T HostAdapter)

Definition at line 1316 of file BusLogic958.c.

1328{
1329 BusLogic_InstalledDevices_T InstalledDevices;
1330// BusLogic_InstalledDevices8_T InstalledDevicesID0to7;
1331 BusLogic_SetupInformation_T SetupInformation;
1332 BusLogic_SynchronousPeriod_T SynchronousPeriod;
1333 BusLogic_RequestedReplyLength_T RequestedReplyLength;
1334 int TargetID;
1335
1336 // Wait a few seconds between the Host Adapter Hard Reset which initiates
1337 // a SCSI Bus Reset and issuing any SCSI Commands. Some SCSI devices get
1338 // confused if they receive SCSI Commands too soon after a SCSI Bus Reset.
1340
1341 //
1342 // Issue the Inquire Target Devices command for host adapters with firmware
1343 // version 4.25 or later, or the Inquire Installed Devices ID 0 to 7 command
1344 // for older host adapters. This is necessary to force Synchronous Transfer
1345 // Negotiation so that the Inquire Setup Information and Inquire Synchronous
1346 // Period commands will return valid data. The Inquire Target Devices command
1347 // is preferable to Inquire Installed Devices ID 0 to 7 since it only probes
1348 // Logical Unit 0 of each Target Device.
1349 if (strcmp((char*)HostAdapter->FirmwareVersion, "4.25") >= 0)
1350 {
1351 if (BusLogic_Command(HostAdapter,
1353 NULL,
1354 0,
1355 &InstalledDevices,
1356 sizeof(InstalledDevices))
1357 != sizeof(InstalledDevices))
1358 {
1359 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE TARGET DEVICES\n"));
1360 return FALSE;
1361 }
1362 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1363 {
1364 HostAdapter->TargetFlags[TargetID].TargetExists = (InstalledDevices & (1 << TargetID) ? TRUE : FALSE);
1365 }
1366 }
1367
1368 // Issue the Inquire Setup Information command.
1369 RequestedReplyLength = sizeof(SetupInformation);
1370 if (BusLogic_Command(HostAdapter,
1372 &RequestedReplyLength,
1373 sizeof(RequestedReplyLength),
1374 &SetupInformation, sizeof(SetupInformation))
1375 != sizeof(SetupInformation))
1376 {
1377 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE SETUP INFORMATION\n"));
1378 return FALSE;
1379 }
1380
1381 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1382 {
1383 HostAdapter->SynchronousOffset[TargetID] = (TargetID < 8
1384 ? SetupInformation.SynchronousValuesID0to7[TargetID].Offset
1385 : SetupInformation.SynchronousValuesID8to15[TargetID-8].Offset);
1386 }
1387 if (strcmp((char*)HostAdapter->FirmwareVersion, "5.06L") >= 0)
1388 {
1389 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1390 {
1391 HostAdapter->TargetFlags[TargetID].WideTransfersActive = (TargetID < 8
1392 ? (SetupInformation.WideTransfersActiveID0to7 & (1 << TargetID)
1393 ? TRUE : FALSE)
1394 : (SetupInformation.WideTransfersActiveID8to15 & (1 << (TargetID-8))
1395 ? TRUE : FALSE));
1396 }
1397 }
1398
1399
1400 // Issue the Inquire Synchronous Period command.
1401 if (HostAdapter->FirmwareVersion[0] >= '3')
1402 {
1403 RequestedReplyLength = sizeof(SynchronousPeriod);
1404 if (BusLogic_Command(HostAdapter,
1406 &RequestedReplyLength,
1407 sizeof(RequestedReplyLength),
1408 &SynchronousPeriod,
1409 sizeof(SynchronousPeriod))
1410 != sizeof(SynchronousPeriod))
1411 {
1412 DebugPrint((ERROR, "\n BusLogic - Failure: INQUIRE SYNCHRONOUS PERIOD\n"));
1413 return FALSE;
1414 }
1415 for (TargetID = 0; TargetID < HostAdapter->MaxTargetDevices; TargetID++)
1416 {
1417 HostAdapter->SynchronousPeriod[TargetID] = SynchronousPeriod[TargetID];
1418 }
1419 }
1420
1421 // Indicate the Target Device Inquiry completed successfully.
1422 return TRUE;
1423}// end BusLogic_TargetDeviceInquiry
@ BusLogic_InquireSynchronousPeriod
Definition: BusLogic958.h:149
unsigned short BusLogic_InstalledDevices_T
Definition: BusLogic958.h:1115
UCHAR BusLogic_SynchronousPeriod_T[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:1103
UCHAR SynchronousPeriod[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:733
UCHAR SynchronousOffset[BusLogic_MaxTargetDevices]
Definition: BusLogic958.h:734
BusLogic_SynchronousValues8_T SynchronousValuesID0to7
Definition: BusLogic958.h:322
BusLogic_SynchronousValues8_T SynchronousValuesID8to15
Definition: BusLogic958.h:329
BOOLEAN WideTransfersActive
Definition: BusLogic958.h:241

Referenced by Buslogic_InitBT958().

◆ BusLogic_WriteOutgoingMailbox()

BOOLEAN BusLogic_WriteOutgoingMailbox ( PHW_DEVICE_EXTENSION  deviceExtension,
BusLogic_ActionCode_T  ActionCode,
BusLogic_CCB_T CCB 
)

Definition at line 1679 of file BusLogic958.c.

1699{
1700 BusLogic_HostAdapter_T *HostAdapter = &(deviceExtension->hcs);
1701 BusLogic_OutgoingMailbox_T *NextOutgoingMailbox;
1702 ULONG length;
1703
1704 NextOutgoingMailbox = HostAdapter->NextOutgoingMailbox;
1705
1706 if (NextOutgoingMailbox->ActionCode == BusLogic_OutgoingMailboxFree)
1707 {
1708 CCB->Status = BusLogic_CCB_Active;
1709
1710 // The CCB field must be written before the Action Code field since
1711 // the Host Adapter is operating asynchronously and the locking code
1712 // does not protect against simultaneous access by the Host Adapter.
1713
1714 // Get CCB physical address.
1715 NextOutgoingMailbox->CCB = ScsiPortConvertPhysicalAddressToUlong( ScsiPortGetPhysicalAddress(deviceExtension,
1716 NULL,
1717 CCB,
1718 &length));
1719
1720 NextOutgoingMailbox->ActionCode = (UCHAR)ActionCode;
1721
1722 BusLogic_StartMailboxCommand(HostAdapter);
1723
1724 if (++NextOutgoingMailbox > HostAdapter->LastOutgoingMailbox)
1725 {
1726 NextOutgoingMailbox = HostAdapter->FirstOutgoingMailbox;
1727 }
1728
1729 HostAdapter->NextOutgoingMailbox = NextOutgoingMailbox;
1730 if (ActionCode == BusLogic_MailboxStartCommand)
1731 {
1732 HostAdapter->ActiveCommandsPerTarget[CCB->TargetID]++;
1733 // check this Namita
1734 HostAdapter->ActiveCommandsPerLun[CCB->TargetID][CCB->LogicalUnit]++;
1735 if (CCB->Opcode != BusLogic_BusDeviceReset)
1736 {
1737 HostAdapter->TargetStatistics[CCB->TargetID].CommandsAttempted++;
1738 }
1739 }
1740 return TRUE;
1741 }
1742 return FALSE;
1743}// end BusLogic_WriteOutgoingMailbox
static void BusLogic_StartMailboxCommand(BusLogic_HostAdapter_T *HostAdapter)
Definition: BusLogic958.h:1094
@ BusLogic_OutgoingMailboxFree
Definition: BusLogic958.h:439
BusLogic_BusAddress_T CCB
Definition: BusLogic958.h:604
unsigned int CommandsAttempted
Definition: BusLogic958.h:261

Referenced by BT958HwStartIO(), and BusLogic_SendBusDeviceReset().

◆ DriverEntry()

ULONG NTAPI DriverEntry ( IN PVOID  DriverObject,
IN PVOID  Argument2 
)

Definition at line 84 of file BusLogic958.c.

95{
96 HW_INITIALIZATION_DATA hwInitializationData;
98 ULONG i;
100// static int cardNo = 0;
101
102 UCHAR VendorId[4] = { '1', '0', '4', 'b' };
103 UCHAR DeviceId[4] = { '1', '0', '4', '0' };
104
105 DebugPrint((TRACE,"\n BusLogic - Inside the DriverEntry function \n"));
106
107 // Zero out structure.
108 for (i = 0; i < sizeof(HW_INITIALIZATION_DATA); i++)
109 {
110 ((PUCHAR) & hwInitializationData)[i] = 0;
111 }
112
113 // Set size of hwInitializationData.
114 hwInitializationData.HwInitializationDataSize = sizeof(HW_INITIALIZATION_DATA);
115
116 // Set entry points.
117 hwInitializationData.HwInitialize = BT958HwInitialize;
118 hwInitializationData.HwResetBus = BT958HwResetBus;
119 hwInitializationData.HwStartIo = BT958HwStartIO;
120 hwInitializationData.HwInterrupt = BT958HwInterrupt;
121 hwInitializationData.HwAdapterControl = BT958HwAdapterControl;
122 hwInitializationData.HwFindAdapter = BT958HwFindAdapter;
123
124 // Indicate no buffer mapping but will need physical addresses
125 hwInitializationData.NeedPhysicalAddresses = TRUE;
126
127 // Indicate Auto request sense is supported
128 hwInitializationData.AutoRequestSense = TRUE;
129 hwInitializationData.MultipleRequestPerLu = TRUE;
130
131#if TAG_QUEUING
132 hwInitializationData.TaggedQueuing = TRUE;
133#else
134 hwInitializationData.TaggedQueuing = FALSE;
135#endif
136
137 hwInitializationData.AdapterInterfaceType = PCIBus;
138
139 // Fill in the vendor id and the device id
140 hwInitializationData.VendorId = &VendorId;
141 hwInitializationData.VendorIdLength = 4;
142 hwInitializationData.DeviceId = &DeviceId;
143 hwInitializationData.DeviceIdLength = 4;
144
145
146 hwInitializationData.NumberOfAccessRanges = 2;
147
148
149 // Specify size of extensions.
150 hwInitializationData.DeviceExtensionSize = sizeof(HW_DEVICE_EXTENSION);
151
152 // logical unit extension
153 hwInitializationData.SrbExtensionSize = sizeof(BusLogic_CCB_T);
154
155 HwContext = 0;
156
157 DebugPrint((TRACE,"\n BusLogic - Calling the ScsiPortInitialize Routine\n"));
158
160 Argument2,
161 &hwInitializationData,
162 &HwContext);
163
164 DebugPrint((TRACE,"\n BusLogic - Exiting the DriverEntry function \n"));
165 DebugPrint((INFO,"\n BusLogic - Status = %ul \n", Status));
166 return( Status );
167
168} // end DriverEntry()
SCSI_ADAPTER_CONTROL_STATUS NTAPI BT958HwAdapterControl(IN PVOID HwDeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, IN PVOID Parameters)
Definition: BusLogic958.c:2651
ULONG NTAPI BT958HwFindAdapter(IN PVOID HwDeviceExtension, IN PVOID Context, IN PVOID BusInformation, IN PCHAR ArgumentString, IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo, OUT PBOOLEAN Again)
Definition: BusLogic958.c:173
BOOLEAN NTAPI BT958HwStartIO(IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: BusLogic958.c:1458
BOOLEAN NTAPI BT958HwInterrupt(IN PVOID HwDeviceExtension)
Definition: BusLogic958.c:1973
struct BusLogic_CCB BusLogic_CCB_T
struct _HW_DEVICE_EXTENSION HW_DEVICE_EXTENSION
ULONG NTAPI ScsiPortInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PHW_INITIALIZATION_DATA HwInitializationData, IN PVOID HwContext OPTIONAL)
Definition: scsiport.c:1133
_In_ PVOID Argument2
Definition: classpnp.h:721
struct _HW_INITIALIZATION_DATA HW_INITIALIZATION_DATA
Status
Definition: gdiplustypes.h:25
@ PCIBus
Definition: hwresource.cpp:142
_Must_inspect_result_ _In_ PVOID _In_ struct _HW_INITIALIZATION_DATA _In_ PVOID HwContext
Definition: srb.h:907
PHW_INTERRUPT HwInterrupt
Definition: srb.h:569
PHW_ADAPTER_CONTROL HwAdapterControl
Definition: srb.h:777
BOOLEAN TaggedQueuing
Definition: srb.h:582
BOOLEAN AutoRequestSense
Definition: srb.h:583
PHW_RESET_BUS HwResetBus
Definition: srb.h:571
USHORT VendorIdLength
Definition: srb.h:586
PHW_STARTIO HwStartIo
Definition: srb.h:568
BOOLEAN MultipleRequestPerLu
Definition: srb.h:584
BOOLEAN NeedPhysicalAddresses
Definition: srb.h:581
ULONG SrbExtensionSize
Definition: srb.h:576
ULONG HwInitializationDataSize
Definition: srb.h:550
USHORT DeviceIdLength
Definition: srb.h:589
PHW_INITIALIZE HwInitialize
Definition: srb.h:567
ULONG DeviceExtensionSize
Definition: srb.h:574
INTERFACE_TYPE AdapterInterfaceType
Definition: srb.h:565
PHW_FIND_ADAPTER HwFindAdapter
Definition: srb.h:570
ULONG NumberOfAccessRanges
Definition: srb.h:577
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213