buslogic958.h
来自「一个类似windows」· C头文件 代码 · 共 1,180 行 · 第 1/3 页
H
1,180 行
typedef struct BusLogic_WmiExtendedSetupInformation
{
UCHAR BusType; // Byte 0
UCHAR BIOS_Address; // Byte 1
unsigned short ScatterGatherLimit; // Bytes 2-3
UCHAR MailboxCount; // Byte 4
BusLogic_BusAddress_T BaseMailboxAddress; // Bytes 5-8
BOOLEAN FastOnEISA; // Byte 9
BOOLEAN LevelSensitiveInterrupt; // Byte 10
UCHAR FirmwareRevision[3]; // Bytes 11-14
BOOLEAN HostWideSCSI; // Byte 15
BOOLEAN HostDifferentialSCSI; // Byte 16
BOOLEAN HostSupportsSCAM; // Byte 17
BOOLEAN HostUltraSCSI; // Byte 18
BOOLEAN HostSmartTermination; // Byte 19
}BusLogic_WmiExtendedSetupInformation_T, *PBusLogic_WmiExtendedSetupInformation_T;
#pragma pack ()
//_________________________________________________________________________________________
// function declaractions
//_________________________________________________________________________________________
ULONG
STDCALL
DriverEntry(IN PVOID DriverObject,
IN PVOID Argument2
);
ULONG
STDCALL
BT958HwFindAdapter(IN PVOID HwDeviceExtension,
IN PVOID Context,
IN PVOID BusInformation,
IN PCHAR ArgumentString,
IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
OUT PBOOLEAN Again);
BOOLEAN
STDCALL
BT958HwInitialize(IN PVOID HwDeviceExtension);
BOOLEAN
STDCALL
BT958HwStartIO(IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb
);
BOOLEAN
STDCALL
BT958HwInterrupt(IN PVOID HwDeviceExtension);
BOOLEAN
STDCALL
BT958HwResetBus(IN PVOID HwDeviceExtension,
IN ULONG PathId
);
SCSI_ADAPTER_CONTROL_STATUS
STDCALL
BT958HwAdapterControl(IN PVOID HwDeviceExtension,
IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
IN PVOID Parameters
);
#if 0
BOOLEAN
BT958WmiSrb(IN PHW_DEVICE_EXTENSION HwDeviceExtension,
IN OUT PSCSI_WMI_REQUEST_BLOCK Srb);
#endif
void
BT958WmiInitialize( IN PHW_DEVICE_EXTENSION HwDeviceExtension);
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);
int
BusLogic_QueueCommand(IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb,
IN PBuslogic_CCB_T ccb);
BOOLEAN
BusLogic_WriteOutgoingMailbox(PHW_DEVICE_EXTENSION deviceExtension ,
BusLogic_ActionCode_T ActionCode,
BusLogic_CCB_T *CCB);
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
BusLogic_SendBusDeviceReset(IN PVOID HwDeviceExtension,
PSCSI_REQUEST_BLOCK Srb);
UCHAR
ReadBusLogicPort(PUCHAR adr )
{
return ScsiPortReadPortUchar( adr );
}
VOID
WriteBusLogicPort(UCHAR data,
PUCHAR adr)
{
ScsiPortWritePortUchar(adr, data);
}
//_________________________________________________________________________________________
// Declarations for the device registers and rewading and writing to them
//_________________________________________________________________________________________
// Define the BusLogic SCSI Host Adapter I/O Register Offsets.
#define BusLogic_ControlRegisterOffset 0 // WO register
#define BusLogic_StatusRegisterOffset 0 // RO register
#define BusLogic_CommandParameterRegisterOffset 1 // WO register
#define BusLogic_DataInRegisterOffset 1 // RO register
#define BusLogic_InterruptRegisterOffset 2 // RO register
#define BusLogic_GeometryRegisterOffset 3 // RO register
// Define the structure of the write-only Control Register.
typedef union BusLogic_ControlRegister
{
UCHAR All;
struct
{
UCHAR :4; // Bits 0-3
BOOLEAN SCSIBusReset:1; // Bit 4
BOOLEAN InterruptReset:1; // Bit 5
BOOLEAN SoftReset:1; // Bit 6
BOOLEAN HardReset:1; // Bit 7
} Bits;
}BusLogic_ControlRegister_T;
// Define the structure of the read-only Status Register.
typedef union BusLogic_StatusRegister
{
UCHAR All;
struct
{
BOOLEAN CommandInvalid:1; // Bit 0
BOOLEAN Reserved:1; // Bit 1
BOOLEAN DataInRegisterReady:1; // Bit 2
BOOLEAN CommandParameterRegisterBusy:1; // Bit 3
BOOLEAN HostAdapterReady:1; // Bit 4
BOOLEAN InitializationRequired:1; // Bit 5
BOOLEAN DiagnosticFailure:1; // Bit 6
BOOLEAN DiagnosticActive:1; // Bit 7
} Bits;
}BusLogic_StatusRegister_T;
// Define the structure of the read-only Interrupt Register.
typedef union BusLogic_InterruptRegister
{
UCHAR All;
struct
{
BOOLEAN IncomingMailboxLoaded:1; // Bit 0
BOOLEAN OutgoingMailboxAvailable:1; // Bit 1
BOOLEAN CommandComplete:1; // Bit 2
BOOLEAN ExternalBusReset:1; // Bit 3
UCHAR Reserved:3; // Bits 4-6
BOOLEAN InterruptValid:1; // Bit 7
} Bits;
}BusLogic_InterruptRegister_T;
// Define the possible Host Adapter BIOS Disk Geometry Translations.
typedef enum BusLogic_BIOS_DiskGeometryTranslation
{
BusLogic_BIOS_Disk_Not_Installed = 0,
BusLogic_BIOS_Disk_Installed_64x32 = 1,
BusLogic_BIOS_Disk_Installed_128x32 = 2,
BusLogic_BIOS_Disk_Installed_255x63 = 3
}BusLogic_BIOS_DiskGeometryTranslation_T;
// Define the structure of the read-only Geometry Register
typedef union BusLogic_GeometryRegister
{
UCHAR All;
struct
{
BusLogic_BIOS_DiskGeometryTranslation_T Drive0Geometry:2; // Bits 0-1
BusLogic_BIOS_DiskGeometryTranslation_T Drive1Geometry:2; // Bits 2-3
UCHAR :3; // Bits 4-6
BOOLEAN ExtendedTranslationEnabled:1; // Bit 7
} Bits;
}
BusLogic_GeometryRegister_T;
void
BusLogic_InterruptReset(BusLogic_HostAdapter_T *HostAdapter)
{
BusLogic_ControlRegister_T ControlRegister;
ControlRegister.All = 0;
ControlRegister.Bits.InterruptReset = TRUE;
WriteBusLogicPort(ControlRegister.All,
HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}
void
BusLogic_SoftReset(BusLogic_HostAdapter_T *HostAdapter)
{
BusLogic_ControlRegister_T ControlRegister;
ControlRegister.All = 0;
ControlRegister.Bits.SoftReset = TRUE;
WriteBusLogicPort(ControlRegister.All,
HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}
void
BusLogic_HardReset(BusLogic_HostAdapter_T *HostAdapter)
{
BusLogic_ControlRegister_T ControlRegister;
ControlRegister.All = 0;
ControlRegister.Bits.HardReset = TRUE;
WriteBusLogicPort(ControlRegister.All,
HostAdapter->IO_Address + BusLogic_ControlRegisterOffset);
}
UCHAR
BusLogic_ReadStatusRegister(BusLogic_HostAdapter_T *HostAdapter)
{
return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_StatusRegisterOffset);
}
UCHAR
BusLogic_ReadInterruptRegister(BusLogic_HostAdapter_T *HostAdapter)
{
return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_InterruptRegisterOffset);
}
UCHAR
BusLogic_ReadGeometryRegister(BusLogic_HostAdapter_T *HostAdapter)
{
return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_GeometryRegisterOffset);
}
UCHAR
BusLogic_ReadDataInRegister(BusLogic_HostAdapter_T *HostAdapter)
{
return ReadBusLogicPort(HostAdapter->IO_Address + BusLogic_DataInRegisterOffset);
}
void
BusLogic_WriteCommandParameterRegister(BusLogic_HostAdapter_T *HostAdapter,
UCHAR Value)
{
WriteBusLogicPort(Value,
HostAdapter->IO_Address + BusLogic_CommandParameterRegisterOffset);
}
// BusLogic_StartMailboxCommand issues an Execute Mailbox Command, which
// notifies the Host Adapter that an entry has been made in an Outgoing
// Mailbox.
void
BusLogic_StartMailboxCommand(BusLogic_HostAdapter_T *HostAdapter)
{
BusLogic_WriteCommandParameterRegister(HostAdapter,
BusLogic_ExecuteMailboxCommand);
}
// Define the Inquire Synchronous Period reply type. For each Target Device,
// a byte is returned which represents the Synchronous Transfer Period in units
// of 10 nanoseconds.
typedef UCHAR BusLogic_SynchronousPeriod_T[BusLogic_MaxTargetDevices];
// Define the Inquire Installed Devices ID 0 to 7 and Inquire Installed
// Devices ID 8 to 15 reply type. For each Target Device, a byte is returned
// where bit 0 set indicates that Logical Unit 0 exists, bit 1 set indicates
// that Logical Unit 1 exists, and so on.
typedef UCHAR BusLogic_InstalledDevices8_T[8];
// Define the Inquire Target Devices reply type. Inquire Target Devices only
// tests Logical Unit 0 of each Target Device unlike the Inquire Installed
// Devices commands which test Logical Units 0 - 7. Two bytes are returned,
// where byte 0 bit 0 set indicates that Target Device 0 exists, and so on.
typedef unsigned short BusLogic_InstalledDevices_T;
// Define the Initialize Extended Mailbox request structure.
#pragma pack (1)
typedef struct BusLogic_ExtendedMailboxRequest
{
UCHAR MailboxCount; /* Byte 0 */
ULONG BaseMailboxAddress; /* Bytes 1-4 */
}BusLogic_ExtendedMailboxRequest_T;
#pragma pack ()
// Define the Set CCB Format request type. Extended LUN Format CCBs are
// necessary to support more than 8 Logical Units per Target Device.
typedef enum BusLogic_SetCCBFormatRequest
{
BusLogic_LegacyLUNFormatCCB = 0,
BusLogic_ExtendedLUNFormatCCB = 1
}BusLogic_SetCCBFormatRequest_T;
//______________________________________________________________________________________
// Statistics
//______________________________________________________________________________________
// BusLogic_IncrementByteCounter increments Byte Counter by Amount.
void
BusLogic_IncrementByteCounter(BusLogic_ByteCounter_T *ByteCounter,
unsigned int Amount)
{
ByteCounter->Units += Amount;
if (ByteCounter->Units > 999999999)
{
ByteCounter->Units -= 1000000000;
ByteCounter->Billions++;
}
}
// BusLogic_IncrementSizeBucket increments the Bucket for Amount.
void
BusLogic_IncrementSizeBucket(BusLogic_CommandSizeBuckets_T CommandSizeBuckets,
unsigned int Amount)
{
int Index = 0;
if (Amount < 8*1024)
{
if (Amount < 2*1024)
Index = (Amount < 1*1024 ? 0 : 1);
else
Index = (Amount < 4*1024 ? 2 : 3);
}
else if (Amount < 128*1024)
{
if (Amount < 32*1024)
Index = (Amount < 16*1024 ? 4 : 5);
else
Index = (Amount < 64*1024 ? 6 : 7);
}
else
Index = (Amount < 256*1024 ? 8 : 9);
CommandSizeBuckets[Index]++;
}
// BusLogic_IncrementErrorCounter increments Error Counter by 1, stopping at
// 65535 rather than wrapping around to 0.
void
BusLogic_IncrementErrorCounter(unsigned short *ErrorCounter)
{
if (*ErrorCounter < 65535) (*ErrorCounter)++;
}
//____________________________________________________________________________________________
#endif // _BT958_H_
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?