ReactOS 0.4.17-dev-116-ga4b6fe9
pciidex.h File Reference
#include <ntddk.h>
#include <ntstrsafe.h>
#include <ntintsafe.h>
#include <initguid.h>
#include <wdmguid.h>
#include <ata.h>
#include <ide.h>
#include <scsi.h>
#include <reactos/drivers/ata/ata_shared.h>
#include <reactos/drivers/ata/ata_user.h>
#include "debug.h"
#include "ahci.h"
#include <debug/driverdbg.h>
#include "pata.h"
Include dependency graph for pciidex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ATA_PCI_ENABLE_BITS
 
struct  _ATA_CONTROLLER
 
struct  _CHANNEL_DATA_COMMON
 
struct  _CHANNEL_DATA_PATA
 
struct  _CHANNEL_INFO_AHCI
 
struct  _CHANNEL_DATA_AHCI
 
struct  _PCIIDEX_DRIVER_EXTENSION
 
struct  _COMMON_DEVICE_EXTENSION
 
struct  _FDO_DEVICE_EXTENSION
 
struct  _PDO_DEVICE_EXTENSION
 

Macros

#define TAG_PCIIDEX   'XedI'
 
#define ASSUME(cond)
 
#define IS_FDO(p)    ((((PCOMMON_DEVICE_EXTENSION)(p))->Flags & DO_IS_FDO) != 0)
 
#define IS_PRIMARY_CHANNEL(PdoExtension)   (PdoExtension->Channel == 0)
 
#define PCIIDEX_PAGED_DATA   DATA_SEG("PAGECONS")
 
#define MAX_CHANNELS   32
 
#define PORT_TIMER_TICK_MS   10
 
#define DEV_NUMBER(Device)   ((Device)->TransportFlags & DEVICE_NUMBER_MASK)
 
#define RANGE_IS_VALID   0x01
 
#define RANGE_IS_MEMORY   0x02
 
#define RANGE_IS_MAPPED   0x04
 
#define CTRL_FLAG_NATIVE_PCI   0x00000001
 
#define CTRL_FLAG_IS_SIMPLEX   0x00000002
 
#define CTRL_FLAG_SATA_HBA_ACPI   0x00000002
 
#define CTRL_FLAG_USE_TEST_FUNCTION   0x00000004
 
#define CTRL_FLAG_IS_AHCI   0x00000008
 
#define CTRL_FLAG_NON_PNP   0x00000010
 
#define CTRL_FLAG_MANUAL_RES   0x00000020
 
#define CTRL_FLAG_DMA_INTERRUPT   0x00000040
 
#define CHANNEL_FLAG_IO32   0x00000001
 
#define CHANNEL_FLAG_DRIVE0_DMA_CAPABLE   0x00000002
 
#define CHANNEL_FLAG_DRIVE1_DMA_CAPABLE   0x00000004
 
#define CHANNEL_FLAG_CONTROL_PORT_BASE_MAPPED   0x00000008
 
#define CHANNEL_FLAG_COMMAND_PORT_BASE_MAPPED   0x00000010
 
#define CHANNEL_FLAG_DMA_PORT_BASE_MAPPED   0x00000020
 
#define CHANNEL_FLAG_64_BIT_DMA   0x00000040
 
#define CHANNEL_FLAG_PRIMARY_ADDRESS_CLAIMED   0x00000080
 
#define CHANNEL_FLAG_SECONDARY_ADDRESS_CLAIMED   0x00000100
 
#define CHANNEL_FLAG_PIO_VIA_DMA   0x00000200
 
#define CHANNEL_FLAG_NO_SLAVE   0x00000400
 
#define CHANNEL_FLAG_IS_EXTERNAL   0x00000800
 
#define CHANNEL_FLAG_IS_PMP   0x00001000
 
#define CHANNEL_FLAG_HAS_FBS   0x00002000
 
#define CHANNEL_FLAG_FBS_ENABLED   0x00004000
 
#define CHANNEL_FLAG_HAS_ACPI_GTM   0x00008000
 
#define CHANNEL_FLAG_HAS_NCQ   0x00010000
 
#define CHANNEL_FLAG_PIO_FOR_LBA48_XFER   0x00020000
 
#define CHANNEL_FLAG_NO_ATAPI_DMA   0x00040000
 
#define CHANNEL_FLAG_DMA_BEFORE_CMD   0x00080000
 
#define CHANNEL_FLAG_MRES_TF   0x00100000
 
#define CHANNEL_FLAG_MRES_DMA   0x00200000
 
#define CHANNEL_FLAG_MRES_CTRL   0x00400000
 
#define CHANNEL_FLAG_CBUS   0x80000000
 
#define DO_IS_FDO   0x80000000
 
#define PDO_FLAG_NOT_PRESENT   0x00000001
 
#define PDO_FLAG_REPORTED_MISSING   0x00000002
 

Typedefs

typedef struct _CHANNEL_DATA_PATA CHANNEL_DATA_PATA
 
typedef struct _CHANNEL_DATA_PATAPCHANNEL_DATA_PATA
 
typedef struct _CHANNEL_DATA_COMMON CHANNEL_DATA_COMMON
 
typedef struct _CHANNEL_DATA_COMMONPCHANNEL_DATA_COMMON
 
typedef struct _PCIIDE_PRD_TABLE_ENTRY PCIIDE_PRD_TABLE_ENTRY
 
typedef struct _PCIIDE_PRD_TABLE_ENTRYPPCIIDE_PRD_TABLE_ENTRY
 
typedef struct _PDO_DEVICE_EXTENSION PDO_DEVICE_EXTENSION
 
typedef struct _PDO_DEVICE_EXTENSIONPPDO_DEVICE_EXTENSION
 
typedef struct _ATA_CONTROLLER ATA_CONTROLLER
 
typedef struct _ATA_CONTROLLERPATA_CONTROLLER
 
typedef ATA_PCI_MATCH_FN * PATA_PCI_MATCH_FN
 
typedef CONTROLLER_CHANNEL_ENABLED * PCONTROLLER_CHANNEL_ENABLED
 
typedef CONTROLLER_START * PCONTROLLER_START
 
typedef CONTROLLER_STOP * PCONTROLLER_STOP
 
typedef VOID() CONTROLLER_FREE_RESOURCES(_In_ PATA_CONTROLLER Controller)
 
typedef CONTROLLER_FREE_RESOURCESPCONTROLLER_FREE_RESOURCES
 
typedef NTSTATUS() CONTROLLER_ATTACH_CHANNEL_EX(_In_ PVOID ChannelContext, _In_ BOOLEAN Attach)
 
typedef CONTROLLER_ATTACH_CHANNEL_EXPCONTROLLER_ATTACH_CHANNEL_EX
 
typedef CHANNEL_SET_MODE_EX * PCHANNEL_SET_MODE_EX
 
typedef NTSTATUS() CHANNEL_ALLOCATE_MEMORY(_In_ PVOID ChannelContext)
 
typedef CHANNEL_ALLOCATE_MEMORYPCHANNEL_ALLOCATE_MEMORY
 
typedef VOID() CHANNEL_FREE_MEMORY(_In_ PVOID ChannelContext)
 
typedef CHANNEL_FREE_MEMORYPCHANNEL_FREE_MEMORY
 
typedef VOID() CHANNEL_ENABLE_INTERRUPTS(_In_ PVOID ChannelContext, _In_ BOOLEAN Enable)
 
typedef CHANNEL_ENABLE_INTERRUPTSPCHANNEL_ENABLE_INTERRUPTS
 
typedef BOOLEAN() CHANNEL_CHECK_INTERRUPT(_In_ PCHANNEL_DATA_PATA ChanData)
 
typedef CHANNEL_CHECK_INTERRUPTPCHANNEL_CHECK_INTERRUPT
 
typedef VOID() CHANNEL_LOAD_TASK_FILE(_In_ PCHANNEL_DATA_PATA ChanData, _In_ PATA_DEVICE_REQUEST Request)
 
typedef CHANNEL_LOAD_TASK_FILEPCHANNEL_LOAD_TASK_FILE
 
typedef VOID() CHANNEL_SAVE_TASK_FILE(_In_ PCHANNEL_DATA_PATA ChanData, _Inout_ PATA_DEVICE_REQUEST Request)
 
typedef CHANNEL_SAVE_TASK_FILEPCHANNEL_SAVE_TASK_FILE
 
typedef UCHAR() CHANNEL_READ_STATUS(_In_ PCHANNEL_DATA_PATA ChanData)
 
typedef CHANNEL_READ_STATUSPCHANNEL_READ_STATUS
 
typedef BOOLEAN() CHANNEL_READ_SCR(_In_ PCHANNEL_DATA_PATA ChanData, _In_ SATA_SCR_REGISTER Register, _In_ ULONG PortNumber, _In_ PULONG Result)
 
typedef CHANNEL_READ_SCRPCHANNEL_READ_SCR
 
typedef BOOLEAN() CHANNEL_WRITE_SCR(_In_ PCHANNEL_DATA_PATA ChanData, _In_ SATA_SCR_REGISTER Register, _In_ ULONG PortNumber, _In_ ULONG Value)
 
typedef CHANNEL_WRITE_SCRPCHANNEL_WRITE_SCR
 
typedef struct _ATA_PCI_ENABLE_BITS ATA_PCI_ENABLE_BITS
 
typedef struct _ATA_PCI_ENABLE_BITSPATA_PCI_ENABLE_BITS
 
typedef struct _CHANNEL_INFO_AHCI CHANNEL_INFO_AHCI
 
typedef struct _CHANNEL_INFO_AHCIPCHANNEL_INFO_AHCI
 
typedef struct _CHANNEL_DATA_AHCI CHANNEL_DATA_AHCI
 
typedef struct _CHANNEL_DATA_AHCIPCHANNEL_DATA_AHCI
 
typedef struct _PCIIDEX_DRIVER_EXTENSION PCIIDEX_DRIVER_EXTENSION
 
typedef struct _PCIIDEX_DRIVER_EXTENSIONPPCIIDEX_DRIVER_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSION COMMON_DEVICE_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSIONPCOMMON_DEVICE_EXTENSION
 
typedef struct _FDO_DEVICE_EXTENSION FDO_DEVICE_EXTENSION
 
typedef struct _FDO_DEVICE_EXTENSIONPFDO_DEVICE_EXTENSION
 

Functions

 _IRQL_requires_max_ (APC_LEVEL) typedef BOOLEAN(ATA_PCI_MATCH_FN)(_In_ PVOID Context
 
 _IRQL_requires_max_ (DISPATCH_LEVEL) typedef VOID(CONTROLLER_START)(_In_ PATA_CONTROLLER Controller)
 
 _IRQL_requires_ (DISPATCH_LEVEL) typedef VOID(CHANNEL_SET_MODE_EX)(_In_ PATA_CONTROLLER Controller
 
_In_ ULONG _In_reads_ (MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
 
VOID AtaWritePortUchar (_In_ PUCHAR Port, _In_ UCHAR Value, _In_ ULONG MmioFlags)
 
BOOLEAN AtaAcpiGetTimingMode (_In_ PDEVICE_OBJECT DeviceObject, _Out_ PIDE_ACPI_TIMING_MODE_BLOCK TimingMode)
 
NTSTATUS AtaAcpiSetTimingMode (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIDE_ACPI_TIMING_MODE_BLOCK TimingMode, _In_opt_ PIDENTIFY_DEVICE_DATA IdBlock1, _In_opt_ PIDENTIFY_DEVICE_DATA IdBlock2)
 
PVOID AtaAcpiGetTaskFile (_In_ PDEVICE_OBJECT DeviceObject)
 
VOID AtaAcpiSetDeviceData (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIDENTIFY_DEVICE_DATA IdBlock)
 
DECLSPEC_NOINLINE_FROM_PAGED VOID AtaChanEnableInterruptsSync (_In_ PVOID ChannelContext, _In_ BOOLEAN Enable)
 
PVOID AtaCtrlPciMapBar (_In_ PATA_CONTROLLER Controller, _In_range_(0, PCI_TYPE0_ADDRESSES) ULONG Index, _In_ ULONG MinimumIoLength)
 
IDE_CHANNEL_STATE PciIdeXGetChannelState (_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
 
NTSTATUS PciIdeXFdoDispatchPnp (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PIRP Irp)
 
IDE_CHANNEL_STATE PciIdeXChannelState (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Channel)
 
 _Dispatch_type_ (IRP_MJ_SYSTEM_CONTROL) DRIVER_DISPATCH_PAGED PciIdeXDispatchWmi
 
BOOLEAN PciFindDevice (_In_ __callback PATA_PCI_MATCH_FN MatchFunction, _In_ PVOID Context)
 
VOID PciRead (_In_ PATA_CONTROLLER Controller, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
 
VOID PciWrite (_In_ PATA_CONTROLLER Controller, _In_reads_bytes_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
 
VOID AtaSleep (VOID)
 
NTSTATUS PciIdeXPnpRepeatRequest (_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp, _In_opt_ PDEVICE_CAPABILITIES DeviceCapabilities)
 
NTSTATUS PciIdeXPnpQueryDeviceUsageNotification (_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp)
 
NTSTATUS PciIdeXPnpQueryPnpDeviceState (_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_PNP) DRIVER_DISPATCH_PAGED PciIdeXDispatchPnp
 
NTSTATUS PciIdeXPdoRemoveDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp, _In_ BOOLEAN FinalRemove)
 
 _Dispatch_type_ (IRP_MJ_POWER) DRIVER_DISPATCH_RAISED PciIdeXDispatchPower
 
NTSTATUS AhciGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
VOID AtaAhciStopDma (_In_ PCHANNEL_DATA_AHCI ChanData)
 
VOID AtaAhciSaveTaskFile (_In_ PCHANNEL_DATA_AHCI ChanData, _Inout_ PATA_DEVICE_REQUEST Request, _In_ BOOLEAN ProcessErrorStatus)
 
VOID AtaAhciHandleFatalError (_In_ PCHANNEL_DATA_AHCI ChanData)
 
VOID AtaAhciHandlePortStateChange (_In_ PCHANNEL_DATA_AHCI ChanData, _In_ ULONG InterruptStatus)
 
BOOLEAN AtaAhciDowngradeInterfaceSpeed (_In_ PCHANNEL_DATA_AHCI ChanData)
 
ULONG AtaAhciChannelGetMaximumDeviceCount (_In_ PVOID ChannelContext)
 
VOID AtaSelectTimings (_In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList, _Out_writes_all_(MAX_IDE_DEVICE) PATA_TIMING Timings, _In_range_(>, 0) ULONG ClockPeriodPs, _In_ ULONG Flags)
 
VOID PciIdeInitTaskFileIoResources (_In_ PCHANNEL_DATA_PATA ChanData, _In_ ULONG_PTR CommandPortBase, _In_ ULONG_PTR ControlPortBase, _In_ ULONG CommandBlockSpare)
 
IDE_CHANNEL_STATE PciIdeGetChannelState (_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
 
NTSTATUS PciIdeParseResources (_In_ PCHANNEL_DATA_PATA ChanData, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
 
VOID PciIdeFreeResources (_In_ PVOID ChannelContext)
 
NTSTATUS PciIdeConnectInterrupt (_In_ PVOID ChannelContext)
 
NTSTATUS PciIdeCreateChannelData (_In_ PATA_CONTROLLER Controller, _In_ ULONG HwExtensionSize)
 
NTSTATUS PciIdeGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
ULONG PataChannelGetMaximumDeviceCount (_In_ PVOID ChannelContext)
 
VOID AtaWriteBlock16 (_In_ PUSHORT Port, _In_ PUSHORT Buffer, _In_ ULONG Count, _In_ ULONG MmioFlags)
 
VOID AtaReadBlock16 (_In_ PUSHORT Port, _In_ PUSHORT Buffer, _In_ ULONG Count, _In_ ULONG MmioFlags)
 
VOID AtaWriteBlock32 (_In_ PULONG Port, _In_ PULONG Buffer, _In_ ULONG Count, _In_ ULONG MmioFlags)
 
VOID AtaReadBlock32 (_In_ PULONG Port, _In_ PULONG Buffer, _In_ ULONG Count, _In_ ULONG MmioFlags)
 
UCHAR AtaReadPortUchar (_In_ PUCHAR Port, _In_ ULONG MmioFlags)
 
VOID AtaWritePortUlong (_In_ PULONG Port, _In_ ULONG Value, _In_ ULONG MmioFlags)
 
VOID PciIdeDmaStop (_In_ PCHANNEL_DATA_PATA ChanData)
 
NTSTATUS AmdGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS AtiGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS CmdGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS Sil680GetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS IntelGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS PcTechGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS SvwPataGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS SvwSataGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS ToshibaGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
NTSTATUS ViaGetControllerProperties (_Inout_ PATA_CONTROLLER Controller)
 
BOOLEAN SvwHasUdmaCable (_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
 
VOID ViaClampTimings (_Inout_ PATA_TIMING Timing)
 
FORCEINLINE ULONG CountSetBits (_In_ ULONG x)
 
FORCEINLINE BOOLEAN IsPowerOfTwo (_In_ ULONG x)
 
FORCEINLINE UCHAR PciRead8 (_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
 
FORCEINLINE USHORT PciRead16 (_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
 
FORCEINLINE ULONG PciRead32 (_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
 
FORCEINLINE VOID PciWrite8 (_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset, _In_ UCHAR Value)
 
FORCEINLINE VOID PciWrite16 (_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset, _In_ USHORT Value)
 
FORCEINLINE VOID PciWrite32 (_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset, _In_ ULONG Value)
 

Variables

_In_ ULONG BusNumber
 
_In_ ULONG _In_ PCI_SLOT_NUMBER PciSlot
 
_In_ ULONG _In_ PCI_SLOT_NUMBER _In_ PPCI_COMMON_HEADER PciConfig
 
_In_ ULONG Channel
 
NTSYSAPI ULONG InitSafeBootMode
 
CONTROLLER_ATTACH_CHANNEL AtaCtrlAttachChannel
 
CHANNEL_SET_DEVICE_DATA AtaCtrlSetDeviceData
 
CHANNEL_GET_INIT_TASK_FILE AtaCtrlGetInitTaskFile
 
CHANNEL_SET_MODE AtaCtrlSetTransferMode
 
CHANNEL_DOWNGRADE_INTERFACE_SPEED AtaCtrlDowngradeInterfaceSpeed
 
CHANNEL_ABORT_CHANNEL AtaCtrlAbortChannel
 
CONTROLLER_PNP_START_DEVICE PciIdeXFdoStartDevice
 
CONTROLLER_PNP_REMOVE_DEVICE PciIdeXFdoRemoveDevice
 
DRIVER_INITIALIZE DriverEntry
 
DRIVER_UNLOAD PciIdeXUnload
 
DRIVER_ADD_DEVICE PciIdeXAddDevice
 
IO_COMPLETION_ROUTINE PciIdeXPdoCompletionRoutine
 
CHANNEL_ENABLE_INTERRUPTS AtaAhciEnableInterrupts
 
CHANNEL_ENUMERATE_CHANNEL AtaAhciEnumerateChannel
 
CHANNEL_IDENTIFY_DEVICE AtaAhciIdentifyDevice
 
CHANNEL_RESET_CHANNEL AtaAhciResetChannel
 
CHANNEL_START_IO AtaAhciStartIo
 
CHANNEL_PREPARE_IO AtaAhciPrepareIo
 
CHANNEL_PREPARE_PRD_TABLE AtaAhciPreparePrdTable
 
CHANNEL_ALLOCATE_SLOT AtaAhciAllocateSlot
 
KSERVICE_ROUTINE AtaAhciHbaIsr
 
CHANNEL_SET_MODE_EX SataSetTransferMode
 
CONTROLLER_ATTACH_CHANNEL_EX PciIdeAttachChannel
 
CHANNEL_RESET_CHANNEL PataResetChannel
 
CHANNEL_ENUMERATE_CHANNEL PataEnumerateChannel
 
CHANNEL_IDENTIFY_DEVICE PataIdentifyDevice
 
CHANNEL_ALLOCATE_SLOT PataAllocateSlot
 
CHANNEL_PREPARE_PRD_TABLE PciIdePreparePrdTable
 
CHANNEL_PREPARE_IO PataPrepareIo
 
CHANNEL_START_IO PataStartIo
 
KSERVICE_ROUTINE PataChannelIsr
 
KSERVICE_ROUTINE PciIdeChannelIsr
 
CHANNEL_CHECK_INTERRUPT PciIdeCheckInterrupt
 
CHANNEL_LOAD_TASK_FILE PataLoadTaskFile
 
CHANNEL_SAVE_TASK_FILE PataSaveTaskFile
 
CHANNEL_READ_STATUS PataReadStatus
 
KDEFERRED_ROUTINE PataPollingTimerDpc
 
CHANNEL_SET_MODE_EX SvwSetTransferMode
 

Macro Definition Documentation

◆ ASSUME

#define ASSUME (   cond)
Value:
do { \
ASSERT(cond); \
__assume(cond); \
} while (0)

Definition at line 34 of file pciidex.h.

◆ CHANNEL_FLAG_64_BIT_DMA

#define CHANNEL_FLAG_64_BIT_DMA   0x00000040

Definition at line 266 of file pciidex.h.

◆ CHANNEL_FLAG_CBUS

#define CHANNEL_FLAG_CBUS   0x80000000

Definition at line 283 of file pciidex.h.

◆ CHANNEL_FLAG_COMMAND_PORT_BASE_MAPPED

#define CHANNEL_FLAG_COMMAND_PORT_BASE_MAPPED   0x00000010

Definition at line 264 of file pciidex.h.

◆ CHANNEL_FLAG_CONTROL_PORT_BASE_MAPPED

#define CHANNEL_FLAG_CONTROL_PORT_BASE_MAPPED   0x00000008

Definition at line 263 of file pciidex.h.

◆ CHANNEL_FLAG_DMA_BEFORE_CMD

#define CHANNEL_FLAG_DMA_BEFORE_CMD   0x00080000

Definition at line 279 of file pciidex.h.

◆ CHANNEL_FLAG_DMA_PORT_BASE_MAPPED

#define CHANNEL_FLAG_DMA_PORT_BASE_MAPPED   0x00000020

Definition at line 265 of file pciidex.h.

◆ CHANNEL_FLAG_DRIVE0_DMA_CAPABLE

#define CHANNEL_FLAG_DRIVE0_DMA_CAPABLE   0x00000002

Definition at line 261 of file pciidex.h.

◆ CHANNEL_FLAG_DRIVE1_DMA_CAPABLE

#define CHANNEL_FLAG_DRIVE1_DMA_CAPABLE   0x00000004

Definition at line 262 of file pciidex.h.

◆ CHANNEL_FLAG_FBS_ENABLED

#define CHANNEL_FLAG_FBS_ENABLED   0x00004000

Definition at line 274 of file pciidex.h.

◆ CHANNEL_FLAG_HAS_ACPI_GTM

#define CHANNEL_FLAG_HAS_ACPI_GTM   0x00008000

Definition at line 275 of file pciidex.h.

◆ CHANNEL_FLAG_HAS_FBS

#define CHANNEL_FLAG_HAS_FBS   0x00002000

Definition at line 273 of file pciidex.h.

◆ CHANNEL_FLAG_HAS_NCQ

#define CHANNEL_FLAG_HAS_NCQ   0x00010000

Definition at line 276 of file pciidex.h.

◆ CHANNEL_FLAG_IO32

#define CHANNEL_FLAG_IO32   0x00000001

Definition at line 260 of file pciidex.h.

◆ CHANNEL_FLAG_IS_EXTERNAL

#define CHANNEL_FLAG_IS_EXTERNAL   0x00000800

Definition at line 271 of file pciidex.h.

◆ CHANNEL_FLAG_IS_PMP

#define CHANNEL_FLAG_IS_PMP   0x00001000

Definition at line 272 of file pciidex.h.

◆ CHANNEL_FLAG_MRES_CTRL

#define CHANNEL_FLAG_MRES_CTRL   0x00400000

Definition at line 282 of file pciidex.h.

◆ CHANNEL_FLAG_MRES_DMA

#define CHANNEL_FLAG_MRES_DMA   0x00200000

Definition at line 281 of file pciidex.h.

◆ CHANNEL_FLAG_MRES_TF

#define CHANNEL_FLAG_MRES_TF   0x00100000

Definition at line 280 of file pciidex.h.

◆ CHANNEL_FLAG_NO_ATAPI_DMA

#define CHANNEL_FLAG_NO_ATAPI_DMA   0x00040000

Definition at line 278 of file pciidex.h.

◆ CHANNEL_FLAG_NO_SLAVE

#define CHANNEL_FLAG_NO_SLAVE   0x00000400

Definition at line 270 of file pciidex.h.

◆ CHANNEL_FLAG_PIO_FOR_LBA48_XFER

#define CHANNEL_FLAG_PIO_FOR_LBA48_XFER   0x00020000

Definition at line 277 of file pciidex.h.

◆ CHANNEL_FLAG_PIO_VIA_DMA

#define CHANNEL_FLAG_PIO_VIA_DMA   0x00000200

Definition at line 269 of file pciidex.h.

◆ CHANNEL_FLAG_PRIMARY_ADDRESS_CLAIMED

#define CHANNEL_FLAG_PRIMARY_ADDRESS_CLAIMED   0x00000080

Definition at line 267 of file pciidex.h.

◆ CHANNEL_FLAG_SECONDARY_ADDRESS_CLAIMED

#define CHANNEL_FLAG_SECONDARY_ADDRESS_CLAIMED   0x00000100

Definition at line 268 of file pciidex.h.

◆ CTRL_FLAG_DMA_INTERRUPT

#define CTRL_FLAG_DMA_INTERRUPT   0x00000040

Definition at line 230 of file pciidex.h.

◆ CTRL_FLAG_IS_AHCI

#define CTRL_FLAG_IS_AHCI   0x00000008

Definition at line 227 of file pciidex.h.

◆ CTRL_FLAG_IS_SIMPLEX

#define CTRL_FLAG_IS_SIMPLEX   0x00000002

Definition at line 224 of file pciidex.h.

◆ CTRL_FLAG_MANUAL_RES

#define CTRL_FLAG_MANUAL_RES   0x00000020

Definition at line 229 of file pciidex.h.

◆ CTRL_FLAG_NATIVE_PCI

#define CTRL_FLAG_NATIVE_PCI   0x00000001

Definition at line 223 of file pciidex.h.

◆ CTRL_FLAG_NON_PNP

#define CTRL_FLAG_NON_PNP   0x00000010

Definition at line 228 of file pciidex.h.

◆ CTRL_FLAG_SATA_HBA_ACPI

#define CTRL_FLAG_SATA_HBA_ACPI   0x00000002

Definition at line 225 of file pciidex.h.

◆ CTRL_FLAG_USE_TEST_FUNCTION

#define CTRL_FLAG_USE_TEST_FUNCTION   0x00000004

Definition at line 226 of file pciidex.h.

◆ DEV_NUMBER

#define DEV_NUMBER (   Device)    ((Device)->TransportFlags & DEVICE_NUMBER_MASK)

Definition at line 56 of file pciidex.h.

◆ DO_IS_FDO

#define DO_IS_FDO   0x80000000

Definition at line 379 of file pciidex.h.

◆ IS_FDO

#define IS_FDO (   p)     ((((PCOMMON_DEVICE_EXTENSION)(p))->Flags & DO_IS_FDO) != 0)

Definition at line 40 of file pciidex.h.

◆ IS_PRIMARY_CHANNEL

#define IS_PRIMARY_CHANNEL (   PdoExtension)    (PdoExtension->Channel == 0)

Definition at line 43 of file pciidex.h.

◆ MAX_CHANNELS

#define MAX_CHANNELS   32

Definition at line 52 of file pciidex.h.

◆ PCIIDEX_PAGED_DATA

#define PCIIDEX_PAGED_DATA   DATA_SEG("PAGECONS")

Pageable read-only data

Definition at line 50 of file pciidex.h.

◆ PDO_FLAG_NOT_PRESENT

#define PDO_FLAG_NOT_PRESENT   0x00000001

Definition at line 409 of file pciidex.h.

◆ PDO_FLAG_REPORTED_MISSING

#define PDO_FLAG_REPORTED_MISSING   0x00000002

Definition at line 410 of file pciidex.h.

◆ PORT_TIMER_TICK_MS

#define PORT_TIMER_TICK_MS   10

Definition at line 54 of file pciidex.h.

◆ RANGE_IS_MAPPED

#define RANGE_IS_MAPPED   0x04

Definition at line 192 of file pciidex.h.

◆ RANGE_IS_MEMORY

#define RANGE_IS_MEMORY   0x02

Definition at line 191 of file pciidex.h.

◆ RANGE_IS_VALID

#define RANGE_IS_VALID   0x01

Definition at line 190 of file pciidex.h.

◆ TAG_PCIIDEX

#define TAG_PCIIDEX   'XedI'

Definition at line 32 of file pciidex.h.

Typedef Documentation

◆ ATA_CONTROLLER

Definition at line 59 of file pciidex.h.

◆ ATA_PCI_ENABLE_BITS

◆ CHANNEL_ALLOCATE_MEMORY

typedef NTSTATUS() CHANNEL_ALLOCATE_MEMORY(_In_ PVOID ChannelContext)

Definition at line 108 of file pciidex.h.

◆ CHANNEL_CHECK_INTERRUPT

typedef BOOLEAN() CHANNEL_CHECK_INTERRUPT(_In_ PCHANNEL_DATA_PATA ChanData)

Definition at line 124 of file pciidex.h.

◆ CHANNEL_DATA_AHCI

◆ CHANNEL_DATA_COMMON

Definition at line 29 of file pciidex.h.

◆ CHANNEL_DATA_PATA

Definition at line 28 of file pciidex.h.

◆ CHANNEL_ENABLE_INTERRUPTS

typedef VOID() CHANNEL_ENABLE_INTERRUPTS(_In_ PVOID ChannelContext, _In_ BOOLEAN Enable)

Definition at line 118 of file pciidex.h.

◆ CHANNEL_FREE_MEMORY

typedef VOID() CHANNEL_FREE_MEMORY(_In_ PVOID ChannelContext)

Definition at line 113 of file pciidex.h.

◆ CHANNEL_INFO_AHCI

◆ CHANNEL_LOAD_TASK_FILE

typedef VOID() CHANNEL_LOAD_TASK_FILE(_In_ PCHANNEL_DATA_PATA ChanData, _In_ PATA_DEVICE_REQUEST Request)

Definition at line 129 of file pciidex.h.

◆ CHANNEL_READ_SCR

Definition at line 146 of file pciidex.h.

◆ CHANNEL_READ_STATUS

typedef UCHAR() CHANNEL_READ_STATUS(_In_ PCHANNEL_DATA_PATA ChanData)

Definition at line 141 of file pciidex.h.

◆ CHANNEL_SAVE_TASK_FILE

typedef VOID() CHANNEL_SAVE_TASK_FILE(_In_ PCHANNEL_DATA_PATA ChanData, _Inout_ PATA_DEVICE_REQUEST Request)

Definition at line 135 of file pciidex.h.

◆ CHANNEL_WRITE_SCR

Definition at line 154 of file pciidex.h.

◆ COMMON_DEVICE_EXTENSION

◆ CONTROLLER_ATTACH_CHANNEL_EX

typedef NTSTATUS() CONTROLLER_ATTACH_CHANNEL_EX(_In_ PVOID ChannelContext, _In_ BOOLEAN Attach)

Definition at line 94 of file pciidex.h.

◆ CONTROLLER_FREE_RESOURCES

typedef VOID() CONTROLLER_FREE_RESOURCES(_In_ PATA_CONTROLLER Controller)

Definition at line 89 of file pciidex.h.

◆ FDO_DEVICE_EXTENSION

◆ PATA_CONTROLLER

Definition at line 59 of file pciidex.h.

◆ PATA_PCI_ENABLE_BITS

◆ PATA_PCI_MATCH_FN

typedef ATA_PCI_MATCH_FN* PATA_PCI_MATCH_FN

Definition at line 68 of file pciidex.h.

◆ PCHANNEL_ALLOCATE_MEMORY

Definition at line 111 of file pciidex.h.

◆ PCHANNEL_CHECK_INTERRUPT

Definition at line 127 of file pciidex.h.

◆ PCHANNEL_DATA_AHCI

◆ PCHANNEL_DATA_COMMON

Definition at line 29 of file pciidex.h.

◆ PCHANNEL_DATA_PATA

Definition at line 28 of file pciidex.h.

◆ PCHANNEL_ENABLE_INTERRUPTS

Definition at line 122 of file pciidex.h.

◆ PCHANNEL_FREE_MEMORY

Definition at line 116 of file pciidex.h.

◆ PCHANNEL_INFO_AHCI

◆ PCHANNEL_LOAD_TASK_FILE

Definition at line 133 of file pciidex.h.

◆ PCHANNEL_READ_SCR

Definition at line 152 of file pciidex.h.

◆ PCHANNEL_READ_STATUS

Definition at line 144 of file pciidex.h.

◆ PCHANNEL_SAVE_TASK_FILE

Definition at line 139 of file pciidex.h.

◆ PCHANNEL_SET_MODE_EX

typedef CHANNEL_SET_MODE_EX* PCHANNEL_SET_MODE_EX

Definition at line 106 of file pciidex.h.

◆ PCHANNEL_WRITE_SCR

Definition at line 160 of file pciidex.h.

◆ PCIIDE_PRD_TABLE_ENTRY

Definition at line 30 of file pciidex.h.

◆ PCIIDEX_DRIVER_EXTENSION

◆ PCOMMON_DEVICE_EXTENSION

◆ PCONTROLLER_ATTACH_CHANNEL_EX

◆ PCONTROLLER_CHANNEL_ENABLED

typedef CONTROLLER_CHANNEL_ENABLED* PCONTROLLER_CHANNEL_ENABLED

Definition at line 75 of file pciidex.h.

◆ PCONTROLLER_FREE_RESOURCES

Definition at line 92 of file pciidex.h.

◆ PCONTROLLER_START

typedef CONTROLLER_START* PCONTROLLER_START

Definition at line 81 of file pciidex.h.

◆ PCONTROLLER_STOP

typedef CONTROLLER_STOP* PCONTROLLER_STOP

Definition at line 87 of file pciidex.h.

◆ PDO_DEVICE_EXTENSION

Definition at line 58 of file pciidex.h.

◆ PFDO_DEVICE_EXTENSION

◆ PPCIIDE_PRD_TABLE_ENTRY

Definition at line 30 of file pciidex.h.

◆ PPCIIDEX_DRIVER_EXTENSION

◆ PPDO_DEVICE_EXTENSION

Definition at line 58 of file pciidex.h.

Function Documentation

◆ _Dispatch_type_() [1/3]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 1331 of file isapnp.c.

1341{
1343 PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1344
1345 PAGED_CODE();
1346
1347 if (DevExt->Signature == IsaPnpBus)
1348 return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt, Irp, IrpSp);
1349 else
1350 return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt, Irp, IrpSp);
1351}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
NTSTATUS IsaFdoPnp(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:123
_In_ PIRP Irp
Definition: csq.h:116
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4138
@ IsaPnpBus
Definition: isapnp.h:36
NTSTATUS IsaPdoPnp(_In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:867
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:43
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061

◆ _Dispatch_type_() [2/3]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 1293 of file isapnp.c.

1302{
1303 PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1305
1306 if (DevExt->Signature != IsaPnpBus)
1307 {
1309 {
1310 case IRP_MN_SET_POWER:
1311 case IRP_MN_QUERY_POWER:
1313 Irp->IoStatus.Status = Status;
1314 break;
1315
1316 default:
1317 Status = Irp->IoStatus.Status;
1318 break;
1319 }
1320
1323 return Status;
1324 }
1325
1328 return PoCallDriver(((PISAPNP_FDO_EXTENSION)DevExt)->Ldo, Irp);
1329}
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1705
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER

◆ _Dispatch_type_() [3/3]

_Dispatch_type_ ( IRP_MJ_SYSTEM_CONTROL  )

Definition at line 5748 of file btrfs.c.

5750 {
5752 device_extension* Vcb = DeviceObject->DeviceExtension;
5753 bool top_level;
5754
5756
5757 top_level = is_top_level(Irp);
5758
5759 Irp->IoStatus.Information = 0;
5760
5761 if (Vcb && Vcb->type == VCB_TYPE_VOLUME) {
5762 volume_device_extension* vde = DeviceObject->DeviceExtension;
5763
5765
5767
5768 goto exit;
5769 } else if (Vcb && Vcb->type == VCB_TYPE_FS) {
5771
5772 Status = IoCallDriver(Vcb->Vpb->RealDevice, Irp);
5773
5774 goto exit;
5775 } else if (Vcb && Vcb->type == VCB_TYPE_BUS) {
5776 bus_device_extension* bde = DeviceObject->DeviceExtension;
5777
5779
5781
5782 goto exit;
5783 }
5784
5785 Status = Irp->IoStatus.Status;
5787
5788exit:
5789 if (top_level)
5791
5793
5794 return Status;
5795}
#define VCB_TYPE_VOLUME
Definition: btrfs_drv.h:689
#define VCB_TYPE_FS
Definition: btrfs_drv.h:687
#define VCB_TYPE_BUS
Definition: btrfs_drv.h:691
#define NULL
Definition: types.h:112
InsertTailList & Vcb
Definition: btrfs.c:3044
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:278
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
#define exit(n)
Definition: config.h:202
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:880
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:849

◆ _In_reads_()

_In_ ULONG _In_reads_ ( MAX_IDE_DEVICE  )

◆ _IRQL_requires_()

_IRQL_requires_ ( DISPATCH_LEVEL  )

◆ _IRQL_requires_max_() [1/2]

_IRQL_requires_max_ ( APC_LEVEL  )

Definition at line 37 of file cddata.c.

254{
255 THREAD_CONTEXT ThreadContext = {0};
256 PIRP_CONTEXT IrpContext = NULL;
258
259#ifdef CD_SANITY
260 PVOID PreviousTopLevel;
261#endif
262
264
265#if DBG
266
267 KIRQL SaveIrql = KeGetCurrentIrql();
268
269#endif
270
272
274
276
277#ifdef CD_SANITY
278 PreviousTopLevel = IoGetTopLevelIrp();
279#endif
280
281 //
282 // Loop until this request has been completed or posted.
283 //
284
285 do {
286
287 //
288 // Use a try-except to handle the exception cases.
289 //
290
291 _SEH2_TRY {
292
293 //
294 // If the IrpContext is NULL then this is the first pass through
295 // this loop.
296 //
297
298 if (IrpContext == NULL) {
299
300 //
301 // Decide if this request is waitable an allocate the IrpContext.
302 // If the file object in the stack location is NULL then this
303 // is a mount which is always waitable. Otherwise we look at
304 // the file object flags.
305 //
306
308
309 Wait = TRUE;
310
311 } else {
312
313 Wait = CanFsdWait( Irp );
314 }
315
316 IrpContext = CdCreateIrpContext( Irp, Wait );
317
318 //
319 // Update the thread context information.
320 //
321
322 CdSetThreadContext( IrpContext, &ThreadContext );
323
324#ifdef CD_SANITY
325 NT_ASSERT( !CdTestTopLevel ||
326 SafeNodeType( IrpContext->TopLevel ) == CDFS_NTC_IRP_CONTEXT );
327#endif
328
329 //
330 // Otherwise cleanup the IrpContext for the retry.
331 //
332
333 } else {
334
335 //
336 // Set the MORE_PROCESSING flag to make sure the IrpContext
337 // isn't inadvertently deleted here. Then cleanup the
338 // IrpContext to perform the retry.
339 //
340
341 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_MORE_PROCESSING );
342 CdCleanupIrpContext( IrpContext, FALSE );
343 }
344
345 //
346 // Case on the major irp code.
347 //
348
349 switch (IrpContext->MajorFunction) {
350
351 case IRP_MJ_CREATE :
352
353 Status = CdCommonCreate( IrpContext, Irp );
354 break;
355
356 case IRP_MJ_CLOSE :
357
358 Status = CdCommonClose( IrpContext, Irp );
359 break;
360
361 case IRP_MJ_READ :
362
363 //
364 // If this is an Mdl complete request, don't go through
365 // common read.
366 //
367
368 if (FlagOn( IrpContext->MinorFunction, IRP_MN_COMPLETE )) {
369
370 Status = CdCompleteMdl( IrpContext, Irp );
371
372 } else {
373
374 Status = CdCommonRead( IrpContext, Irp );
375 }
376
377 break;
378
379 case IRP_MJ_WRITE :
380
381 Status = CdCommonWrite( IrpContext, Irp );
382 break;
383
385
386 Status = CdCommonQueryInfo( IrpContext, Irp );
387 break;
388
390
391 Status = CdCommonSetInfo( IrpContext, Irp );
392 break;
393
395
396 Status = CdCommonQueryVolInfo( IrpContext, Irp );
397 break;
398
400
401 Status = CdCommonDirControl( IrpContext, Irp );
402 break;
403
405
406 Status = CdCommonFsControl( IrpContext, Irp );
407 break;
408
410
411 Status = CdCommonDevControl( IrpContext, Irp );
412 break;
413
415
416 Status = CdCommonLockControl( IrpContext, Irp );
417 break;
418
419 case IRP_MJ_CLEANUP :
420
421 Status = CdCommonCleanup( IrpContext, Irp );
422 break;
423
424 case IRP_MJ_PNP :
425
426 Status = CdCommonPnp( IrpContext, Irp );
427 break;
428
429 case IRP_MJ_SHUTDOWN :
430
431 Status = CdCommonShutdown( IrpContext, Irp );
432 break;
433
434 default :
435
437 CdCompleteRequest( IrpContext, Irp, Status );
438 }
439
441
442 Status = CdProcessException( IrpContext, Irp, _SEH2_GetExceptionCode() );
443 } _SEH2_END;
444
445 } while (Status == STATUS_CANT_WAIT);
446
447#ifdef CD_SANITY
448 NT_ASSERT( !CdTestTopLevel ||
449 (PreviousTopLevel == IoGetTopLevelIrp()) );
450#endif
451
453
454 NT_ASSERT( SaveIrql == KeGetCurrentIrql( ));
455
456 return Status;
457}
unsigned char BOOLEAN
Definition: actypes.h:127
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
LONG CdExceptionFilter(_Inout_ PIRP_CONTEXT IrpContext, _In_ PEXCEPTION_POINTERS ExceptionPointer)
Definition: cddata.c:525
VOID CdSetThreadContext(_Inout_ PIRP_CONTEXT IrpContext, _In_ PTHREAD_CONTEXT ThreadContext)
Definition: cddata.c:981
#define ASSERT_OPTIONAL_IRP(I)
Definition: cddata.h:251
NTSTATUS CdCompleteMdl(_In_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: cachesup.c:411
VOID CdCleanupIrpContext(_In_ PIRP_CONTEXT IrpContext, _In_ BOOLEAN Post)
Definition: strucsup.c:1733
#define CanFsdWait(I)
Definition: cdprocs.h:2001
NTSTATUS CdCommonLockControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: lockctrl.c:35
NTSTATUS CdCommonDevControl(_Inout_ PIRP_CONTEXT IrpContext, _Inout_ PIRP Irp)
Definition: devctrl.c:46
_Ret_valid_ PIRP_CONTEXT CdCreateIrpContext(_In_ PIRP Irp, _In_ BOOLEAN Wait)
Definition: strucsup.c:1573
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define IRP_CONTEXT_FLAG_MORE_PROCESSING
Definition: cdstruc.h:1214
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDFS_NTC_IRP_CONTEXT
Definition: nodetype.h:34
#define SafeNodeType(Ptr)
Definition: nodetype.h:54
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
#define STATUS_CANT_WAIT
Definition: ntstatus.h:546
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:204
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:203
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
#define IRP_MJ_LOCK_CONTROL
Definition: rdpdr.c:53
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_SET_INFORMATION
Definition: rdpdr.c:49
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define IRP_MN_COMPLETE
Definition: iotypes.h:4423
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define IRP_MJ_SHUTDOWN
#define IRP_MJ_CLEANUP
#define NT_ASSERT
Definition: rtlfuncs.h:3327

◆ _IRQL_requires_max_() [2/2]

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 3557 of file common.c.

3587{
3589 BOOLEAN requestSent = FALSE;
3590
3591 BOOLEAN shouldRetry = TRUE;
3592 PCDB cdb = (PCDB)DeviceExtension->PowerContext.Srb.Cdb;
3593 ULONG timeoutValue = DeviceExtension->TimeOutValue;
3594 ULONG retryCount = 1;
3595
3596 // reset some fields.
3597 DeviceExtension->PowerContext.RetryIntervalIn100ns = 0;
3598 status = PowerContextReuseRequest(DeviceExtension);
3599 RequestClearSendTime(DeviceExtension->PowerContext.PowerRequest);
3600
3601 if (!NT_SUCCESS(status))
3602 {
3603 return status;
3604 }
3605
3606 // set proper timeout value and max retry count.
3607 switch(DeviceExtension->PowerContext.PowerChangeState.PowerDown)
3608 {
3612 break;
3613
3615 // Case of issuing SYNC CACHE command. Do not use power irp timeout remaining time in this case
3616 // as we want to give best try on SYNC CACHE command.
3617 retryCount = MAXIMUM_RETRIES;
3618 timeoutValue = DeviceExtension->TimeOutValue;
3619 break;
3620
3622 {
3623 // Case of issuing STOP UNIT command
3624 // As "Imme" bit is set to '1', this command should be completed in short time.
3625 // This command is at low importance, failure of this command has very small impact.
3626 ULONG secondsRemaining = 0;
3627
3628#if (WINVER >= 0x0601)
3629 // this API is introduced in Windows7
3630 PoQueryWatchdogTime(DeviceExtension->LowerPdo, &secondsRemaining);
3631#endif
3632
3633 if (secondsRemaining == 0)
3634 {
3635 // not able to retrieve remaining time from PoQueryWatchdogTime API, use default values.
3636 retryCount = MAXIMUM_RETRIES;
3637 timeoutValue = SCSI_CDROM_TIMEOUT;
3638 }
3639 else
3640 {
3641 // plan to leave about 30 seconds to lower level drivers if possible.
3642 if (secondsRemaining >= 32)
3643 {
3644 retryCount = (secondsRemaining - 30)/SCSI_CDROM_TIMEOUT + 1;
3645 timeoutValue = SCSI_CDROM_TIMEOUT;
3646
3647 if (retryCount > MAXIMUM_RETRIES)
3648 {
3649 retryCount = MAXIMUM_RETRIES;
3650 }
3651
3652 if (retryCount == 1)
3653 {
3654 timeoutValue = secondsRemaining - 30;
3655 }
3656 }
3657 else
3658 {
3659 // issue the command with minimal timeout value and do not retry on it.
3660 retryCount = 1;
3661 timeoutValue = 2;
3662 }
3663 }
3664 }
3665 break;
3666 default:
3667 NT_ASSERT( FALSE );
3669 return status;
3670 }
3671
3672 DeviceExtension->PowerContext.RetryCount = retryCount;
3673
3674 // issue command.
3675 while (shouldRetry)
3676 {
3677
3678 // set SRB fields.
3679 DeviceExtension->PowerContext.Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
3684
3685 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
3686 DeviceExtension->PowerContext.Srb.TimeOutValue = timeoutValue;
3687
3688 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceInitial)
3689 {
3690 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_LOCK_QUEUE;
3691 }
3692 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceLocked)
3693 {
3694 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_QUIESCE_DEVICE;
3695 }
3696 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3697 {
3698 // Case of issuing SYNC CACHE command.
3699 DeviceExtension->PowerContext.Srb.CdbLength = 10;
3700 cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
3701 }
3702 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceFlushed)
3703 {
3704 // Case of issuing STOP UNIT command.
3705 DeviceExtension->PowerContext.Srb.CdbLength = 6;
3706 cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
3707 cdb->START_STOP.Start = 0;
3708 cdb->START_STOP.Immediate = 1;
3709 }
3710 else if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceStopped)
3711 {
3712 DeviceExtension->PowerContext.Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
3713 }
3714
3715 // Set up completion routine and context if requested
3717 {
3718 WdfRequestSetCompletionRoutine(DeviceExtension->PowerContext.PowerRequest,
3720 Context);
3721 }
3722
3723 status = RequestSend(DeviceExtension,
3724 DeviceExtension->PowerContext.PowerRequest,
3725 DeviceExtension->IoTarget,
3727 &requestSent);
3728
3729 if (requestSent)
3730 {
3731 if ((CompletionRoutine == NULL) &&
3732 (SRB_STATUS(DeviceExtension->PowerContext.Srb.SrbStatus) != SRB_STATUS_SUCCESS))
3733 {
3734 TracePrint((TRACE_LEVEL_ERROR,
3735 TRACE_FLAG_POWER,
3736 "%p\tError occured when issuing %s command to device. Srb %p, Status %x\n",
3737 DeviceExtension->PowerContext.PowerRequest,
3738 (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced) ? "SYNC CACHE" : "STOP UNIT",
3739 &DeviceExtension->PowerContext.Srb,
3740 DeviceExtension->PowerContext.Srb.SrbStatus));
3741
3742 NT_ASSERT(!(TEST_FLAG(DeviceExtension->PowerContext.Srb.SrbStatus, SRB_STATUS_QUEUE_FROZEN)));
3743
3744 shouldRetry = RequestSenseInfoInterpret(DeviceExtension,
3745 DeviceExtension->PowerContext.PowerRequest,
3746 &(DeviceExtension->PowerContext.Srb),
3747 retryCount - DeviceExtension->PowerContext.RetryCount,
3748 &status,
3749 &(DeviceExtension->PowerContext.RetryIntervalIn100ns));
3750
3751 if (shouldRetry && (DeviceExtension->PowerContext.RetryCount-- == 0))
3752 {
3753 shouldRetry = FALSE;
3754 }
3755 }
3756 else
3757 {
3758 // succeeded, do not need to retry.
3759 shouldRetry = FALSE;
3760 }
3761
3762 }
3763 else
3764 {
3765 // request failed to be sent
3766 shouldRetry = FALSE;
3767 }
3768
3769 if (shouldRetry)
3770 {
3772 t.QuadPart = -DeviceExtension->PowerContext.RetryIntervalIn100ns;
3774
3775 status = PowerContextReuseRequest(DeviceExtension);
3776 if (!NT_SUCCESS(status))
3777 {
3778 shouldRetry = FALSE;
3779 }
3780 }
3781 }
3782
3783 if (DeviceExtension->PowerContext.PowerChangeState.PowerDown == PowerDownDeviceQuiesced)
3784 {
3785 // record SYNC CACHE command completion time stamp.
3786 KeQueryTickCount(&DeviceExtension->PowerContext.Step1CompleteTime);
3787 }
3788
3789 return status;
3790}
#define MAXIMUM_RETRIES
Definition: cdrom.h:124
#define SCSI_CDROM_TIMEOUT
Definition: cdrom.h:680
BOOLEAN RequestSenseInfoInterpret(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ PSCSI_REQUEST_BLOCK Srb, _In_ ULONG RetriedCount, _Out_ NTSTATUS *Status, _Out_opt_ _Deref_out_range_(0, MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS) LONGLONG *RetryIntervalIn100ns)
Definition: sense.c:2467
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
@ PowerDownDeviceStopped
Definition: cdrom.h:412
@ PowerDownDeviceQuiesced
Definition: cdrom.h:410
@ PowerDownDeviceInitial
Definition: cdrom.h:408
@ PowerDownDeviceLocked
Definition: cdrom.h:409
@ PowerDownDeviceFlushed
Definition: cdrom.h:411
union _CDB * PCDB
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS RequestSend(_In_ PCDROM_DEVICE_EXTENSION DeviceExtension, _In_ WDFREQUEST Request, _In_ WDFIOTARGET IoTarget, _In_ ULONG Flags, _Out_opt_ PBOOLEAN RequestSent)
Definition: common.c:3793
VOID RequestClearSendTime(_In_ WDFREQUEST Request)
Definition: common.c:111
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:315
#define SRB_FLAGS_NO_DATA_TRANSFER
Definition: srb.h:402
#define SRB_FUNCTION_LOCK_QUEUE
Definition: srb.h:332
#define SRB_FUNCTION_UNLOCK_QUEUE
Definition: srb.h:333
#define SRB_FLAGS_BYPASS_LOCKED_QUEUE
Definition: srb.h:410
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:397
#define SRB_STATUS(Status)
Definition: srb.h:389
#define SRB_STATUS_QUEUE_FROZEN
Definition: srb.h:386
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:404
#define SRB_STATUS_SUCCESS
Definition: srb.h:341
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
GLdouble GLdouble t
Definition: gl.h:2047
#define KernelMode
Definition: asm.h:38
#define SRB_FLAGS_D3_PROCESSING
Definition: srb.h:165
#define SRB_FUNCTION_QUIESCE_DEVICE
Definition: srb.h:99
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
_In_ PVOID Context
Definition: storport.h:2269
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
Definition: cdrw_hw.h:28
struct _CDB::_START_STOP START_STOP
struct _CDB::_SYNCHRONIZE_CACHE10 SYNCHRONIZE_CACHE10
@ WDF_REQUEST_SEND_OPTION_SYNCHRONOUS
Definition: wdfrequest.h:109
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
Definition: wdfrequest.h:895

◆ AhciGetControllerProperties()

NTSTATUS AhciGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 625 of file ahci_generic.c.

627{
628 PCM_PARTIAL_RESOURCE_DESCRIPTOR InterruptDesc = &Controller->InterruptDesc;
629 ULONG i, GlobalControl;
631
632 PAGED_CODE();
633
634 if (!AhciMatchController(Controller))
635 return STATUS_NO_MATCH;
636
637 if (Controller->InterruptDesc.Type != CmResourceTypeInterrupt)
638 {
639 ERR("No interrupt resource\n");
641 }
642
643 Controller->IoBase = AtaAhciGetAbar(Controller);
644 if (!Controller->IoBase)
645 return STATUS_NO_MATCH; // Try IDE/RAID
646
647 Controller->Flags = CTRL_FLAG_IS_AHCI | CTRL_FLAG_SATA_HBA_ACPI;
648 Controller->Start = AtaAhciHbaStart;
649 Controller->Stop = AtaAhciHbaStop;
650 Controller->FreeResources = AtaAhciHbaFreeResouces;
651 Controller->AttachChannel = AtaAhciAttachChannel;
652
653 /* Set AE before accessing other AHCI registers */
654 GlobalControl = AHCI_HBA_READ(Controller->IoBase, HbaGlobalControl);
655 GlobalControl |= AHCI_GHC_AE;
656 AHCI_HBA_WRITE(Controller->IoBase, HbaGlobalControl, GlobalControl);
657
658 Controller->AhciCapabilities = AHCI_HBA_READ(Controller->IoBase, HbaCapabilities);
659 Controller->ChannelBitmap = AHCI_HBA_READ(Controller->IoBase, HbaPortBitmap);
660 Controller->MaxChannels = CountSetBits(Controller->ChannelBitmap);
661 if (Controller->MaxChannels == 0)
662 {
663 ASSERT(Controller->MaxChannels == 0);
665 }
666
667 Controller->AhciVersion = AHCI_HBA_READ(Controller->IoBase, HbaAhciVersion);
668 if (Controller->AhciVersion >= AHCI_VERSION_1_2)
669 {
670 Controller->AhciCapabilitiesEx = AHCI_HBA_READ(Controller->IoBase, HbaCapabilitiesEx);
671
672 if (Controller->AhciCapabilitiesEx & AHCI_CAP2_BOH)
673 AtaAhciHbaRequestOsOwnership(Controller->IoBase);
674 }
675
676 /* Reset the HBA into a consistent state */
677 GlobalControl = AHCI_HBA_READ(Controller->IoBase, HbaGlobalControl);
678 GlobalControl |= AHCI_GHC_HR;
679 AHCI_HBA_WRITE(Controller->IoBase, HbaGlobalControl, GlobalControl);
680
681 /* HBA reset may take up to 1 second */
682 for (i = 100000; i > 0; i--)
683 {
684 GlobalControl = AHCI_HBA_READ(Controller->IoBase, HbaGlobalControl);
685 if (!(GlobalControl & AHCI_GHC_HR))
686 break;
687
689 }
690 if (i == 0)
691 {
692 ERR("HBA reset failed %08lx\n", GlobalControl);
693 return STATUS_IO_TIMEOUT;
694 }
695
696 /* Re-enable AE */
697 GlobalControl |= AHCI_GHC_AE;
698 AHCI_HBA_WRITE(Controller->IoBase, HbaGlobalControl, GlobalControl);
699
700 /* Disable interrupts */
701 GlobalControl = AHCI_HBA_READ(Controller->IoBase, HbaGlobalControl);
702 if (GlobalControl & AHCI_GHC_IE)
703 {
704 GlobalControl &= ~AHCI_GHC_IE;
705 AHCI_HBA_WRITE(Controller->IoBase, HbaGlobalControl, GlobalControl);
706 }
707
708#if DBG
709 /* On virtual machines, this will allow us to test the PMP support code */
710 if (AtaAhciIsVbox())
711 Controller->AhciCapabilities |= AHCI_CAP_SPM;
712#endif
713
714 Status = AtaAhciCreateChannelData(Controller);
715 if (!NT_SUCCESS(Status))
716 return Status;
717
718 Controller->QueueDepth = ((Controller->AhciCapabilities & AHCI_CAP_NCS) >> 8) + 1;
719
720 INFO("%04X:%04X.%02X: Ver %08lX, PI %08lX, CAP %08lX, CAP2 %08lX\n",
721 Controller->Pci.VendorID,
722 Controller->Pci.DeviceID,
723 Controller->Pci.RevisionID,
724 Controller->AhciVersion,
725 Controller->ChannelBitmap,
726 Controller->AhciCapabilities,
727 Controller->AhciCapabilitiesEx);
728
729 /* Clear HBA interrupts */
730 AHCI_HBA_WRITE(Controller->IoBase, HbaInterruptStatus, 0xFFFFFFFF);
731
732 Status = IoConnectInterrupt(&Controller->InterruptObject,
734 Controller,
735 NULL,
736 InterruptDesc->u.Interrupt.Vector,
737 InterruptDesc->u.Interrupt.Level,
738 InterruptDesc->u.Interrupt.Level,
739 (InterruptDesc->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
741 (InterruptDesc->ShareDisposition == CmResourceShareShared),
742 InterruptDesc->u.Interrupt.Affinity,
743 FALSE);
744 if (!NT_SUCCESS(Status))
745 {
746 ERR("Could not connect to interrupt %lu, status 0x%lx\n",
747 InterruptDesc->u.Interrupt.Vector, Status);
748 return Status;
749 }
750
751 return STATUS_SUCCESS;
752}
#define AHCI_CAP2_BOH
Definition: ahci.h:340
#define AHCI_CAP_SPM
Definition: ahci.h:324
#define AHCI_CAP_NCS
Definition: ahci.h:319
#define AHCI_GHC_HR
Definition: ahci.h:307
#define AHCI_GHC_AE
Definition: ahci.h:310
#define AHCI_VERSION_1_2
Definition: ahci.h:300
FORCEINLINE ULONG AHCI_HBA_READ(_In_ PVOID HbaIoBase, _In_ AHCI_HOST_BUS_ADAPTER_REGISTER Register)
Definition: ahci.h:529
#define AHCI_GHC_IE
Definition: ahci.h:308
FORCEINLINE VOID AHCI_HBA_WRITE(_In_ PVOID HbaIoBase, _In_ AHCI_HOST_BUS_ADAPTER_REGISTER Register, _In_ ULONG Value)
Definition: ahci.h:538
@ HbaCapabilities
Definition: ahci.h:83
@ HbaCapabilitiesEx
Definition: ahci.h:92
@ HbaPortBitmap
Definition: ahci.h:86
@ HbaGlobalControl
Definition: ahci.h:84
@ HbaAhciVersion
Definition: ahci.h:87
@ HbaInterruptStatus
Definition: ahci.h:85
static PVOID AtaAhciGetAbar(_Inout_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:431
static NTSTATUS AtaAhciAttachChannel(_In_ PVOID ChannelContext, _In_ BOOLEAN Attach)
Definition: ahci_generic.c:474
static VOID AtaAhciHbaStop(_In_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:520
static BOOLEAN AhciMatchController(_In_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:583
static VOID AtaAhciHbaFreeResouces(_In_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:546
static NTSTATUS AtaAhciCreateChannelData(_In_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:348
static VOID AtaAhciHbaRequestOsOwnership(_In_ PVOID IoBase)
Definition: ahci_generic.c:291
static VOID AtaAhciHbaStart(_In_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:497
#define ERR(fmt,...)
Definition: precomp.h:57
#define INFO
Definition: debug.h:89
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
#define ASSERT(a)
Definition: mode.c:44
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:23
#define STATUS_NO_MATCH
Definition: ntstatus.h:873
#define STATUS_DEVICE_HARDWARE_ERROR
Definition: ntstatus.h:1169
#define CTRL_FLAG_SATA_HBA_ACPI
Definition: pciidex.h:225
#define CTRL_FLAG_IS_AHCI
Definition: pciidex.h:227
FORCEINLINE ULONG CountSetBits(_In_ ULONG x)
Definition: pciidex.h:827
KSERVICE_ROUTINE AtaAhciHbaIsr
Definition: pciidex.h:629
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: restypes.h:117
#define CmResourceTypeInterrupt
Definition: restypes.h:105
@ Latched
Definition: miniport.h:81
@ LevelSensitive
Definition: miniport.h:80
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384::@387 Interrupt
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384 u
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by PciIdeXFdoStartDevice().

◆ AmdGetControllerProperties()

NTSTATUS AmdGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 329 of file amd.c.

331{
333 ULONG i, HwFlags, SupportedMode;
334
335 PAGED_CODE();
336 ASSERT(Controller->Pci.VendorID == PCI_VEN_AMD || Controller->Pci.VendorID == PCI_VEN_NVIDIA);
337
338 for (i = 0; i < RTL_NUMBER_OF(AmdControllerList); ++i)
339 {
340 HwFlags = AmdControllerList[i].Flags;
341
342 if ((Controller->Pci.VendorID == AmdControllerList[i].VendorID) &&
343 (Controller->Pci.DeviceID == AmdControllerList[i].DeviceID))
344 {
345 break;
346 }
347 }
349 return STATUS_NO_MATCH;
350
351 Status = PciIdeCreateChannelData(Controller, 0);
352 if (!NT_SUCCESS(Status))
353 return Status;
354
355 if (HwFlags & HW_FLAGS_SATA)
356 {
357 SupportedMode = SATA_ALL;
358 }
359 else
360 {
361 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_ALL;
362
363 if (HwFlags & HW_FLAGS_CHECK_SYSBOARD)
364 {
365 if (Controller->Pci.SubSystemID == PCI_SUBSYSTEM_AMD_SERENADE)
366 SupportedMode &= ~UDMA_MODE6;
367 }
368 else
369 {
370 if (HwFlags & HW_FLAGS_UDMA5)
371 SupportedMode &= ~UDMA_MODE6;
372 else if (HwFlags & HW_FLAGS_UDMA4)
373 SupportedMode &= ~UDMA_MODES(5, 6);
374 }
375
376 if (Controller->Pci.VendorID == PCI_VEN_AMD)
377 {
378 Controller->ChannelEnableBits = AmdEnableBits;
379 Controller->Start = AmdControllerStart;
380 }
381 else
382 {
383 Controller->ChannelEnableBits = NvEnableBits;
384 }
385 }
386
387 for (i = 0; i < Controller->MaxChannels; ++i)
388 {
389 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
390
391 ChanData->HwFlags = HwFlags;
392 ChanData->TransferModeSupported = SupportedMode;
393
394 if (HwFlags & HW_FLAGS_SATA)
395 {
396 ChanData->ChanInfo |= CHANNEL_FLAG_NO_SLAVE;
397 ChanData->SetTransferMode = SataSetTransferMode;
398 }
399 else
400 {
401 ChanData->SetTransferMode = AmdSetTransferMode;
402
403 /* Check for 80-conductor cable */
404 if (Controller->Pci.VendorID == PCI_VEN_AMD)
405 {
406 UCHAR ConfigReg = PciRead8(Controller, AMD_REG_CONFIG_CR(AMD_CONFIG_BASE));
407
408 if (!(ConfigReg & AMD_REG_CONFIG_CR(i)))
409 {
410 INFO("CH %lu: BIOS detected 40-conductor cable\n", i);
411 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
412 }
413 }
414 else
415 {
416 USHORT UdmaTimReg = PciRead16(Controller, AMD_REG_UDMA(NV_CONFIG_BASE, i));
417
418 if (!NvHasUdmaCable(UdmaTimReg, 0) && !NvHasUdmaCable(UdmaTimReg, 1))
419 {
420 INFO("CH %lu: BIOS hasn't selected mode faster than UDMA 2, "
421 "assume 40-conductor cable\n",
422 ChanData->Channel);
423 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
424 }
425 }
426 }
427 }
428
429 return STATUS_SUCCESS;
430}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define HW_FLAGS_UDMA5
Definition: amd.c:80
#define NV_CONFIG_BASE
Definition: amd.c:55
#define AMD_CONFIG_BASE
Definition: amd.c:54
#define HW_FLAGS_SATA
Definition: amd.c:83
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS NvEnableBits[MAX_IDE_CHANNEL]
Definition: amd.c:160
#define HW_FLAGS_UDMA4
Definition: amd.c:79
#define PCI_SUBSYSTEM_AMD_SERENADE
Definition: amd.c:52
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS AmdEnableBits[MAX_IDE_CHANNEL]
Definition: amd.c:153
#define AMD_REG_UDMA(IoBase, Channel)
Definition: amd.c:63
#define AMD_REG_CONFIG_CR(IoBase)
Definition: amd.c:60
static PCIIDEX_PAGED_DATA const struct @1172 AmdControllerList[]
static VOID AmdControllerStart(_In_ PATA_CONTROLLER Controller)
Definition: amd.c:297
static BOOLEAN NvHasUdmaCable(_In_ USHORT UdmaTimReg, _In_ ULONG Drive)
Definition: amd.c:313
static VOID AmdSetTransferMode(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
Definition: amd.c:217
#define HW_FLAGS_CHECK_SYSBOARD
Definition: amd.c:81
#define UDMA_ALL
Definition: ata_user.h:31
#define MWDMA_ALL
Definition: ata_user.h:27
#define PIO_ALL
Definition: ata_user.h:19
#define SATA_ALL
Definition: pata.h:37
#define PCI_VEN_NVIDIA
Definition: pata.h:12
#define PCI_VEN_AMD
Definition: pata.h:11
NTSTATUS PciIdeCreateChannelData(_In_ PATA_CONTROLLER Controller, _In_ ULONG HwExtensionSize)
FORCEINLINE UCHAR PciRead8(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
Definition: pciidex.h:847
#define CHANNEL_FLAG_NO_SLAVE
Definition: pciidex.h:270
FORCEINLINE USHORT PciRead16(_In_ PATA_CONTROLLER Controller, _In_ ULONG ConfigDataOffset)
Definition: pciidex.h:859
CHANNEL_SET_MODE_EX SataSetTransferMode
Definition: pciidex.h:633
unsigned short USHORT
Definition: pedump.c:61
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by PciIdeGetControllerProperties().

◆ AtaAcpiGetTaskFile()

PVOID AtaAcpiGetTaskFile ( _In_ PDEVICE_OBJECT  DeviceObject)

Definition at line 212 of file acpi.c.

214{
217 ULONG RetryCount, OutputSize;
219
220 PAGED_CODE();
221 /*
222 * We invoke this routine within the PnP START handler only,
223 * and thus specify that the code is in a pageable section.
224 */
226
227 InputBuffer.MethodNameAsUlong = 'FTG_'; // _GTF
229
230 /*
231 * The output buffer must be large enough to hold the list of ATA commands to the drive.
232 * We assume that 10 commands is the common case.
233 */
234 OutputSize = FIELD_OFFSET(ACPI_EVAL_OUTPUT_BUFFER, Argument) +
236
237 for (RetryCount = 0; RetryCount < 2; ++RetryCount)
238 {
240 if (!OutputBuffer)
241 {
242 ERR("Failed to allocate memory of size %lu\n", OutputSize);
243 return NULL;
244 }
245
246 /* Evaluate the _GTF method */
247 Status = AtaAcpiEvaluateObject(DeviceObject,
249 sizeof(InputBuffer),
251 OutputSize);
252
253 /* Increase the allocation size if it's too small */
255 {
256 OutputSize = OutputBuffer->Length;
257
259 continue;
260 }
261
262 break;
263 }
264
265 if (!NT_SUCCESS(Status))
266 goto Cleanup;
267
268 if (OutputBuffer->Argument[0].Type != ACPI_METHOD_ARGUMENT_BUFFER)
269 {
270 ERR("Unexpected method type %u\n", OutputBuffer->Argument[0].Type);
271 goto Cleanup;
272 }
273
274 if (OutputBuffer->Argument[0].DataLength % sizeof(ATA_ACPI_TASK_FILE))
275 {
276 ERR("Incorrect command stream length %u\n", OutputBuffer->Argument[0].DataLength);
277 goto Cleanup;
278 }
279
280 if (OutputBuffer->Argument[0].DataLength == 0)
281 {
282 WARN("Empty command list\n");
283 goto Cleanup;
284 }
285
286 return OutputBuffer;
287
288Cleanup:
290
291 return NULL;
292}
#define ACPI_METHOD_ARGUMENT_LENGTH(DataLength)
Definition: acpiioct.h:153
#define ACPI_EVAL_INPUT_BUFFER_SIGNATURE
Definition: acpiioct.h:12
#define ACPI_METHOD_ARGUMENT_BUFFER
Definition: acpiioct.h:32
ACPI_EVAL_OUTPUT_BUFFER UNALIGNED * PACPI_EVAL_OUTPUT_BUFFER
Definition: acpiioct.h:99
#define WARN(fmt,...)
Definition: precomp.h:61
static const WCHAR Cleanup[]
Definition: register.c:80
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define TAG_PCIIDEX
Definition: pciidex.h:32
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by AtaCtrlGetInitTaskFile().

◆ AtaAcpiGetTimingMode()

BOOLEAN AtaAcpiGetTimingMode ( _In_ PDEVICE_OBJECT  DeviceObject,
_Out_ PIDE_ACPI_TIMING_MODE_BLOCK  TimingMode 
)

Definition at line 98 of file acpi.c.

101{
103 ACPI_METHOD_ARGUMENT_LENGTH(sizeof(*TimingMode))];
107
108 RtlZeroMemory(Buffer, sizeof(Buffer));
109
110 InputBuffer.MethodNameAsUlong = 'MTG_'; // _GTM
112
113 /* Evaluate the _GTM method */
114 Status = AtaAcpiEvaluateObject(DeviceObject,
116 sizeof(InputBuffer),
118 sizeof(Buffer));
119
120 if (!NT_SUCCESS(Status))
121 {
123
124 TRACE("Failed to evaluate the _GTM method, status 0x%lx\n", Status);
125 return FALSE;
126 }
127
128 if (OutputBuffer->Argument[0].DataLength < sizeof(*TimingMode))
129 {
130 ERR("Buffer too small, size %u/%u\n",
131 OutputBuffer->Argument[0].DataLength, sizeof(*TimingMode));
132 return FALSE;
133 }
134
135 if (OutputBuffer->Argument[0].Type != ACPI_METHOD_ARGUMENT_BUFFER)
136 {
137 ERR("Unexpected method type %u\n", OutputBuffer->Argument[0].Type);
138 return FALSE;
139 }
140
141 RtlCopyMemory(TimingMode, OutputBuffer->Argument[0].Data, sizeof(*TimingMode));
142
143 return TRUE;
144}
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by PciIdeAcpiSetTransferMode(), and PciIdeXPdoStartDevice().

◆ AtaAcpiSetDeviceData()

VOID AtaAcpiSetDeviceData ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIDENTIFY_DEVICE_DATA  IdBlock 
)

Definition at line 296 of file acpi.c.

299{
301 PACPI_METHOD_ARGUMENT Argument;
303 ULONG InputSize;
304
305 PAGED_CODE();
307
308 InputSize = FIELD_OFFSET(ACPI_EVAL_INPUT_BUFFER_COMPLEX, Argument) +
309 ACPI_METHOD_ARGUMENT_LENGTH(sizeof(*IdBlock));
310
312 if (!InputBuffer)
313 {
314 ERR("Failed to allocate memory\n");
315 return;
316 }
317 InputBuffer->MethodNameAsUlong = 'DDS_'; // _SDD
319 InputBuffer->ArgumentCount = 1;
320 InputBuffer->Size = InputSize;
321
322 /* Argument 1: The ATA drive ID block */
323 Argument = InputBuffer->Argument;
324 ACPI_METHOD_SET_ARGUMENT_BUFFER(Argument, IdBlock, sizeof(*IdBlock));
325
326 /* Evaluate the _SDD method */
327 Status = AtaAcpiEvaluateObject(DeviceObject, InputBuffer, InputSize, NULL, 0);
328 if (!NT_SUCCESS(Status))
329 {
331 TRACE("Failed to set device data, status 0x%lx\n", Status);
332 else
333 WARN("Failed to set device data, status 0x%lx\n", Status);
334 }
335
337}
#define ExAllocatePoolUninitialized
#define ACPI_EVAL_INPUT_BUFFER_COMPLEX_SIGNATURE
Definition: acpiioct.h:15
ACPI_METHOD_ARGUMENT UNALIGNED * PACPI_METHOD_ARGUMENT
Definition: acpiioct.h:80
#define ACPI_METHOD_SET_ARGUMENT_BUFFER(Argument, BuffData, BuffLength)
Definition: acpiioct.h:174
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by AtaCtrlSetDeviceData().

◆ AtaAcpiSetTimingMode()

NTSTATUS AtaAcpiSetTimingMode ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIDE_ACPI_TIMING_MODE_BLOCK  TimingMode,
_In_opt_ PIDENTIFY_DEVICE_DATA  IdBlock1,
_In_opt_ PIDENTIFY_DEVICE_DATA  IdBlock2 
)

Definition at line 147 of file acpi.c.

152{
154 PACPI_METHOD_ARGUMENT Argument;
156 ULONG InputSize;
157
158 InputSize = FIELD_OFFSET(ACPI_EVAL_INPUT_BUFFER_COMPLEX, Argument) +
159 ACPI_METHOD_ARGUMENT_LENGTH(sizeof(*TimingMode)) +
160 ACPI_METHOD_ARGUMENT_LENGTH(sizeof(*IdBlock1)) +
161 ACPI_METHOD_ARGUMENT_LENGTH(sizeof(*IdBlock2));
162
164 if (!InputBuffer)
165 {
166 ERR("Failed to allocate memory\n");
168 }
169 InputBuffer->MethodNameAsUlong = 'MTS_'; // _STM
171 InputBuffer->ArgumentCount = 3;
172 InputBuffer->Size = InputSize;
173
174 /* Argument 1: The channel timing information block */
175 Argument = InputBuffer->Argument;
176 ACPI_METHOD_SET_ARGUMENT_BUFFER(Argument, TimingMode, sizeof(*TimingMode));
177
178 /* Argument 2: The ATA drive ID block */
179 Argument = ACPI_METHOD_NEXT_ARGUMENT(Argument);
180 Argument->Type = ACPI_METHOD_ARGUMENT_BUFFER;
181 Argument->DataLength = sizeof(*IdBlock1);
182 if (IdBlock1)
183 RtlCopyMemory(Argument->Data, IdBlock1, sizeof(*IdBlock1));
184 else
185 RtlZeroMemory(Argument->Data, sizeof(*IdBlock1));
186
187 /* Argument 3: The ATA drive ID block */
188 Argument = ACPI_METHOD_NEXT_ARGUMENT(Argument);
189 Argument->Type = ACPI_METHOD_ARGUMENT_BUFFER;
190 Argument->DataLength = sizeof(*IdBlock2);
191 if (IdBlock2)
192 RtlCopyMemory(Argument->Data, IdBlock2, sizeof(*IdBlock2));
193 else
194 RtlZeroMemory(Argument->Data, sizeof(*IdBlock2));
195
196 /* Evaluate the _STM method */
197 Status = AtaAcpiEvaluateObject(DeviceObject, InputBuffer, InputSize, NULL, 0);
198 if (!NT_SUCCESS(Status))
199 {
201 INFO("Failed to set transfer timings, status 0x%lx\n", Status);
202 else
203 ERR("Failed to set transfer timings, status 0x%lx\n", Status);
204 }
205
207 return Status;
208}
#define ACPI_METHOD_NEXT_ARGUMENT(Argument)
Definition: acpiioct.h:159

Referenced by AtaCtrlSetTransferMode(), and PciIdeAcpiSetTransferMode().

◆ AtaAhciChannelGetMaximumDeviceCount()

ULONG AtaAhciChannelGetMaximumDeviceCount ( _In_ PVOID  ChannelContext)

Definition at line 1569 of file ahci_hw.c.

1571{
1572 PCHANNEL_DATA_AHCI ChanData = ChannelContext;
1573 PATA_CONTROLLER Controller = ChanData->Controller;
1574
1575 if (Controller->AhciCapabilities & AHCI_CAP_SPM)
1576 return AHCI_MAX_PMP_DEVICES;
1577
1578 return AHCI_MAX_PORT_DEVICES;
1579}
#define AHCI_MAX_PMP_DEVICES
Definition: ahci.h:12
#define AHCI_MAX_PORT_DEVICES
Definition: ahci.h:11
ULONG AhciCapabilities
Definition: pciidex.h:218

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaAhciDowngradeInterfaceSpeed()

BOOLEAN AtaAhciDowngradeInterfaceSpeed ( _In_ PCHANNEL_DATA_AHCI  ChanData)

Definition at line 1542 of file ahci_hw.c.

1544{
1545 ULONG SataSpeed, SataControl;
1546
1547 SataSpeed = AHCI_PORT_READ(ChanData->IoBase, PxSataStatus) & AHCI_PXSSTS_SPD_MASK;
1548 if (SataSpeed != AHCI_PXSSTS_SPD_SATA1)
1549 {
1550 SataControl = AHCI_PORT_READ(ChanData->IoBase, PxSataControl);
1551
1552 if ((SataControl & AHCI_PXCTL_SPD_MASK) != AHCI_PXCTL_SPD_LIMIT_NONE)
1553 {
1554 SataControl &= ~AHCI_PXCTL_SPD_MASK;
1555 SataControl |= SataSpeed - AHCI_PXCTL_SPD_LIMIT_LEVEL;
1556
1557 WARN("CH %lu: Downgrading interface speed to %08lx\n", ChanData->Channel, SataControl);
1558
1559 AHCI_PORT_WRITE(ChanData->IoBase, PxSataControl, SataControl);
1560 return TRUE;
1561 }
1562 }
1563
1564 INFO("CH %lu: Unable to downgrade interface speed %08lx\n", ChanData->Channel, SataSpeed);
1565 return FALSE;
1566}
FORCEINLINE VOID AHCI_PORT_WRITE(_In_ PVOID PortIoBase, _In_ AHCI_PORT_REGISTER Register, _In_ ULONG Value)
Definition: ahci.h:557
#define AHCI_PXSSTS_SPD_SATA1
Definition: ahci.h:219
#define AHCI_PXCTL_SPD_MASK
Definition: ahci.h:233
FORCEINLINE ULONG AHCI_PORT_READ(_In_ PVOID PortIoBase, _In_ AHCI_PORT_REGISTER Register)
Definition: ahci.h:548
#define AHCI_PXSSTS_SPD_MASK
Definition: ahci.h:210
@ PxSataStatus
Definition: ahci.h:107
@ PxSataControl
Definition: ahci.h:108
#define AHCI_PXCTL_SPD_LIMIT_NONE
Definition: ahci.h:240
#define AHCI_PXCTL_SPD_LIMIT_LEVEL
Definition: ahci.h:245

Referenced by AtaCtrlDowngradeInterfaceSpeed().

◆ AtaAhciHandleFatalError()

VOID AtaAhciHandleFatalError ( _In_ PCHANNEL_DATA_AHCI  ChanData)

Definition at line 1397 of file ahci_hw.c.

1399{
1400 ULONG CurrentCommandSlot, TaskFileData;
1401 ULONG i, CmdStatus, SlotsBitmap, FailedSlot;
1403
1404 Request = NULL;
1405 CurrentCommandSlot = AHCI_PXCMD_CCS(AHCI_PORT_READ(ChanData->IoBase, PxCmdStatus));
1406
1407 /* Clear the ST bit. This also clears PxCI, PxSACT, and PxCMD.CCS */
1409
1410 if (AtaAhciIsHbaHotRemoved(ChanData))
1411 goto Done;
1412
1413 /* Wait for 500ms */
1414 for (i = 50000; i > 0; i--)
1415 {
1416 CmdStatus = AHCI_PORT_READ(ChanData->IoBase, PxCmdStatus);
1417 if (!(CmdStatus & AHCI_PXCMD_CR))
1418 break;
1419
1421 }
1422 if (i == 0)
1423 {
1424 /* The interface is hung */
1425 ERR("CH %lu: Failed to stop the command list DMA engine %08lx\n",
1426 ChanData->Channel,
1427 CmdStatus);
1428 goto Done;
1429 }
1430
1431 TaskFileData = AHCI_PORT_READ(ChanData->IoBase, PxTaskFileData);
1432 if (TaskFileData & (IDE_STATUS_BUSY | IDE_STATUS_DRQ))
1433 {
1434 /* Put the device to the idle state */
1435 ERR("CH %lu: Busy TFD %08lx\n", ChanData->Channel, TaskFileData);
1436 goto Done;
1437 }
1438
1439 /* Clear errors */
1440 AHCI_PORT_WRITE(ChanData->IoBase, PxSataError,
1441 AHCI_PORT_READ(ChanData->IoBase, PxSataError));
1442
1443 /* NCQ recovery is needed */
1444 if (ChanData->ActiveQueuedSlotsBitmap != 0)
1445 {
1447
1448 /* Find some active command */
1449 NT_VERIFY(_BitScanForward(&FailedSlot, ChanData->ActiveQueuedSlotsBitmap) != 0);
1450
1451 Request = ChanData->Slots[FailedSlot];
1452 ASSERT(Request);
1453 ASSERT(Request->Slot == FailedSlot);
1455 goto Done;
1456 }
1457
1458 if (IsPowerOfTwo(ChanData->ActiveSlotsBitmap))
1459 {
1460 /* We have exactly one slot is outstanding */
1461 SlotsBitmap = ChanData->ActiveSlotsBitmap;
1462 }
1463 else if (ChanData->ActiveSlotsBitmap & (1 << CurrentCommandSlot))
1464 {
1465 SlotsBitmap = 1 << CurrentCommandSlot;
1466 }
1467 else
1468 {
1469 /* Indicates that the error bit is spurious *or* the exact slot is not known */
1470 if (ChanData->ActiveSlotsBitmap != 0)
1471 {
1472 ERR("CH %lu: Invalid slot received from the HBA %08lX --> %08lX\n",
1473 ChanData->Channel,
1474 ChanData->ActiveSlotsBitmap,
1475 1 << CurrentCommandSlot);
1476 }
1477 else
1478 {
1479 WARN("CH %lu: Spurious error interrupt %08lX\n",
1480 ChanData->Channel,
1481 AHCI_PORT_READ(ChanData->IoBase, PxInterruptStatus));
1482 }
1483 goto Done;
1484 }
1485
1487
1488 NT_VERIFY(_BitScanForward(&FailedSlot, SlotsBitmap) != 0);
1489
1490 Request = ChanData->Slots[FailedSlot];
1491 ASSERT(Request);
1492 ASSERT(Request->Slot == FailedSlot);
1493
1494 /* Save the error */
1495 Request->SrbStatus = SRB_STATUS_ERROR;
1496 Request->Output.Status = (TaskFileData & AHCI_PXTFD_STATUS_MASK);
1497 Request->Output.Error = (TaskFileData & AHCI_PXTFD_ERROR_MASK) >> AHCI_PXTFD_ERROR_SHIFT;
1498
1499 /* Save the current task file for the "ATA LBA field" (SAT-6 11.7) */
1500 if (!(Request->Device->TransportFlags & DEVICE_IS_ATAPI) ||
1502 {
1503 AtaAhciSaveTaskFile(ChanData, Request, TRUE);
1504 }
1505
1506Done:
1507 /* Request arbitration from the port worker */
1508 ChanData->PortNotification(AtaRequestFailed, ChanData->PortContext, Request);
1509}
#define AHCI_PXTFD_STATUS_MASK
Definition: ahci.h:188
#define AHCI_PXCMD_CCS(Value)
Definition: ahci.h:183
#define AHCI_PXTFD_ERROR_MASK
Definition: ahci.h:189
#define AHCI_PXCMD_CR
Definition: ahci.h:158
@ PxCmdStatus
Definition: ahci.h:104
@ PxTaskFileData
Definition: ahci.h:105
@ PxSataError
Definition: ahci.h:109
@ PxInterruptStatus
Definition: ahci.h:102
#define AHCI_PXTFD_ERROR_SHIFT
Definition: ahci.h:191
static VOID AtaAhciStopCommandListProcess(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:122
static VOID AtaAhciStartCommandListProcess(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:137
static BOOLEAN AtaAhciIsHbaHotRemoved(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:74
VOID AtaAhciSaveTaskFile(_In_ PCHANNEL_DATA_AHCI ChanData, _Inout_ PATA_DEVICE_REQUEST Request, _In_ BOOLEAN ProcessErrorStatus)
Definition: ahci_hw.c:1325
#define REQUEST_FLAG_NCQ
Definition: ata_shared.h:284
#define REQUEST_FLAG_SAVE_TASK_FILE
Definition: ata_shared.h:309
#define DEVICE_IS_ATAPI
Definition: ata_shared.h:165
@ AtaRequestFailed
Definition: ata_shared.h:77
FORCEINLINE BOOLEAN IsPowerOfTwo(_In_ ULONG x)
Definition: atapi.h:604
#define IDE_STATUS_BUSY
Definition: atapi.h:132
#define IDE_STATUS_DRQ
Definition: atapi.h:128
#define SRB_STATUS_ERROR
Definition: srb.h:344
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:57
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3304

Referenced by AtaAhciPortHandleInterrupt().

◆ AtaAhciHandlePortStateChange()

VOID AtaAhciHandlePortStateChange ( _In_ PCHANNEL_DATA_AHCI  ChanData,
_In_ ULONG  InterruptStatus 
)

Definition at line 1512 of file ahci_hw.c.

1515{
1516 ULONG SataStatus;
1517
1518 if (InterruptStatus & AHCI_PXIRQ_DMPS)
1519 {
1520 ULONG CmdStatus = AHCI_PORT_READ(ChanData->IoBase, PxCmdStatus);
1521
1522 if (CmdStatus & AHCI_PXCMD_MPSP)
1523 {
1524 WARN("CH %lu: Mechanical presence switch has changed %08lx\n",
1525 ChanData->Channel, CmdStatus);
1526 goto Notify;
1527 }
1528 }
1529
1530 SataStatus = AHCI_PORT_READ(ChanData->IoBase, PxSataStatus) & AHCI_PXSSTS_DET_MASK;
1531 if (SataStatus == AHCI_PXSSTS_DET_PHY_OK)
1532 INFO("CH %lu: Device hot plug detected %08lx\n", ChanData->Channel, SataStatus);
1533 else
1534 INFO("CH %lu: Device removal detected %08lx\n", ChanData->Channel, SataStatus);
1535
1536Notify:
1537 /* Schedule a port reset */
1538 ChanData->PortNotification(AtaBusChangeDetected, ChanData->PortContext);
1539}
#define AHCI_PXSSTS_DET_PHY_OK
Definition: ahci.h:215
#define AHCI_PXIRQ_DMPS
Definition: ahci.h:127
#define AHCI_PXSSTS_DET_MASK
Definition: ahci.h:209
#define AHCI_PXCMD_MPSP
Definition: ahci.h:162
@ AtaBusChangeDetected
Definition: ata_shared.h:76
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)

Referenced by AtaAhciPortHandleInterrupt().

◆ AtaAhciSaveTaskFile()

VOID AtaAhciSaveTaskFile ( _In_ PCHANNEL_DATA_AHCI  ChanData,
_Inout_ PATA_DEVICE_REQUEST  Request,
_In_ BOOLEAN  ProcessErrorStatus 
)

Definition at line 1325 of file ahci_hw.c.

1329{
1330 union
1331 {
1332 PAHCI_FIS_PIO_SETUP PioSetup;
1333 PAHCI_FIS_DEVICE_TO_HOST DeviceToHost;
1334 } Fis;
1335 PAHCI_RECEIVED_FIS ReceivedFis;
1336
1337 ReceivedFis = ChanData->ReceivedFis;
1338
1339 if (ChanData->ChanInfo & CHANNEL_FLAG_FBS_ENABLED)
1340 ReceivedFis += DEV_NUMBER(Request->Device);
1341
1343
1344 if (ProcessErrorStatus)
1345 {
1346 /*
1347 * Device to Host FIS on failed commands.
1348 * The Request->Output.Status and Request->Output.Error fields should have saved earlier.
1349 */
1350 Fis.DeviceToHost = &ReceivedFis->DeviceToHostFis;
1351 }
1352 else
1353 {
1354 /* Check for successful queued commands (see SATA 3.5 specification 11.14) */
1355 if (Request->Flags & REQUEST_FLAG_NCQ)
1356 {
1357 PAHCI_FIS_SET_DEVICE_BITS SetDeviceBitsFis;
1358
1359 /*
1360 * The SDB FIS was received and we do not have enough information
1361 * for the rest of the registers. Emulate the content of the task file registers.
1362 */
1363 RtlCopyMemory(&Request->Output, &Request->TaskFile, sizeof(Request->TaskFile));
1364
1365 SetDeviceBitsFis = &ReceivedFis->SetDeviceBitsFis;
1366 Request->Output.Status = SetDeviceBitsFis->Status;
1367 Request->Output.Error = SetDeviceBitsFis->Error;
1368 return;
1369 }
1370 /* Check for successful PIO Data-In commands (see SATA 3.5 specification 11.8) */
1371 else if (!(Request->Flags & REQUEST_FLAG_DMA) && (Request->Flags & REQUEST_FLAG_DATA_IN))
1372 {
1373 /* In this case we have received a PIO Setup FIS */
1374 Fis.PioSetup = &ReceivedFis->PioSetupFis;
1375
1376 Request->Output.Status = Fis.PioSetup->EStatus;
1377 Request->Output.Error = Fis.PioSetup->Error;
1378 }
1379 else
1380 {
1381 ULONG TaskFileData;
1382
1383 /* Otherwise, we have received a Device to Host FIS */
1384 Fis.DeviceToHost = &ReceivedFis->DeviceToHostFis;
1385
1386 TaskFileData = AHCI_PORT_READ(ChanData->IoBase, PxTaskFileData);
1387 Request->Output.Status = (TaskFileData & AHCI_PXTFD_STATUS_MASK);
1388 Request->Output.Error =
1390 }
1391 }
1392
1393 AtaAhciSaveReceivedFisArea(Fis.DeviceToHost, Request);
1394}
static VOID AtaAhciSaveReceivedFisArea(_In_ AHCI_FIS_DEVICE_TO_HOST *__restrict Fis, _Inout_ ATA_DEVICE_REQUEST *__restrict Request)
Captures and saves a dump of the AHCI task file registers, except the values in the Fis->Status and F...
Definition: ahci_hw.c:1302
#define REQUEST_FLAG_DATA_IN
Definition: ata_shared.h:287
#define REQUEST_FLAG_DMA
Definition: ata_shared.h:278
#define REQUEST_FLAG_HAS_TASK_FILE
Definition: ata_shared.h:312
#define CHANNEL_FLAG_FBS_ENABLED
Definition: pciidex.h:274
#define DEV_NUMBER(Device)
Definition: pciidex.h:56
AHCI_FIS_DEVICE_TO_HOST DeviceToHostFis
Definition: ahci.h:454
AHCI_FIS_SET_DEVICE_BITS SetDeviceBitsFis
Definition: ahci.h:457
AHCI_FIS_PIO_SETUP PioSetupFis
Definition: ahci.h:451

Referenced by AtaAhciHandleFatalError(), and AtaAhciPortCompleteCommands().

◆ AtaAhciStopDma()

VOID AtaAhciStopDma ( _In_ PCHANNEL_DATA_AHCI  ChanData)

Definition at line 1280 of file ahci_hw.c.

1282{
1286}
static BOOLEAN AtaAhciPerformCommandListOverride(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:267
static BOOLEAN AtaAhciStopCommandListProcessAndWait(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:163
static BOOLEAN AtaAhciStopFisReceiveProcessAndWait(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:207

Referenced by AtaAhciAttachChannel().

◆ AtaChanEnableInterruptsSync()

DECLSPEC_NOINLINE_FROM_PAGED VOID AtaChanEnableInterruptsSync ( _In_ PVOID  ChannelContext,
_In_ BOOLEAN  Enable 
)

Definition at line 62 of file fdo.c.

65{
66 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
67 PATA_CONTROLLER Controller = ChanData->Controller;
70
71 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
72 InterruptObject = Controller->InterruptObject;
73 else
76
78 ChanData->EnableInterrupts(ChanData, Enable);
80}
@ InterruptObject
Definition: ketypes.h:428
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
Definition: spinlock.c:154
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
Definition: spinlock.c:171
PKINTERRUPT InterruptObject
Definition: pciidex.h:172
PKINTERRUPT InterruptObject
Definition: pciidex.h:240
PATA_CONTROLLER Controller
Definition: pciidex.h:248
PCHANNEL_ENABLE_INTERRUPTS EnableInterrupts
Definition: pciidex.h:247
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by AtaAhciAttachChannel(), AtaAhciEnumerateChannel(), PataResetChannel(), PciIdeAttachChannel(), and PciIdeFreeResources().

◆ AtaCtrlPciMapBar()

PVOID AtaCtrlPciMapBar ( _In_ PATA_CONTROLLER  Controller,
_In_range_(0, PCI_TYPE0_ADDRESSES) ULONG  Index,
_In_ ULONG  MinimumIoLength 
)

Definition at line 249 of file fdo.c.

253{
254 PAGED_CODE();
255
256 if (!(Controller->AccessRange[Index].Flags & RANGE_IS_VALID))
257 return NULL;
258
259 /* Validate the BAR length */
260 if (MinimumIoLength != 0)
261 {
262 if (Controller->AccessRange[Index].Length < MinimumIoLength)
263 {
264 ERR("%04X:%04X.%02X: Unexpected PCI BAR #%lu length 0x%lx, minimum required 0x%lx\n",
265 Controller->Pci.VendorID,
266 Controller->Pci.DeviceID,
267 Controller->Pci.RevisionID,
268 Index,
269 Controller->AccessRange[Index].Length,
270 MinimumIoLength);
271 return NULL;
272 }
273 }
274
275 if ((Controller->AccessRange[Index].Flags & RANGE_IS_MEMORY) &&
276 !(Controller->AccessRange[Index].Flags & RANGE_IS_MAPPED))
277 {
279
280 Controller->AccessRange[Index].Flags |= RANGE_IS_MAPPED;
281
282 PhysicalAddress.QuadPart = (ULONG_PTR)Controller->AccessRange[Index].IoBase;
283 Controller->AccessRange[Index].IoBase = MmMapIoSpace(PhysicalAddress,
284 Controller->AccessRange[Index].Length,
286 }
287
288 return Controller->AccessRange[Index].IoBase;
289}
#define ULONG_PTR
Definition: config.h:101
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
#define RANGE_IS_MAPPED
Definition: pciidex.h:192
#define RANGE_IS_MEMORY
Definition: pciidex.h:191
#define RANGE_IS_VALID
Definition: pciidex.h:190
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
@ MmNonCached
Definition: mmtypes.h:129

Referenced by AtaAhciGetAbar(), PciIdeAssignNativeResources(), PciIdeControllerInitDma(), SvwSataGetControllerProperties(), and Via6421ParseResources().

◆ AtaReadBlock16()

VOID AtaReadBlock16 ( _In_ PUSHORT  Port,
_In_ PUSHORT  Buffer,
_In_ ULONG  Count,
_In_ ULONG  MmioFlags 
)

Definition at line 31 of file pata_io.c.

36{
37 ASSERT(Buffer != NULL);
38 ASSERT(Count != 0);
39
40 if (MmioFlags)
42 else
44}
#define READ_PORT_BUFFER_USHORT(port, buffer, count)
Definition: hardware.h:31
CPPORT Port[4]
Definition: headless.c:38
int Count
Definition: noreturn.cpp:7
NTKERNELAPI VOID NTAPI READ_REGISTER_BUFFER_USHORT(IN PUSHORT Register, IN PUSHORT Buffer, IN ULONG Count)

◆ AtaReadBlock32()

VOID AtaReadBlock32 ( _In_ PULONG  Port,
_In_ PULONG  Buffer,
_In_ ULONG  Count,
_In_ ULONG  MmioFlags 
)

Definition at line 63 of file pata_io.c.

68{
69 ASSERT(Buffer != NULL);
70 ASSERT(Count != 0);
71
72 if (MmioFlags)
74 else
76}
#define READ_PORT_BUFFER_ULONG(port, buffer, count)
Definition: hardware.h:32
NTKERNELAPI VOID NTAPI READ_REGISTER_BUFFER_ULONG(IN PULONG Register, IN PULONG Buffer, IN ULONG Count)

◆ AtaReadPortUchar()

UCHAR AtaReadPortUchar ( _In_ PUCHAR  Port,
_In_ ULONG  MmioFlags 
)

Definition at line 79 of file pata_io.c.

82{
83 if (MmioFlags)
85 else
86 return READ_PORT_UCHAR(Port);
87}
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22
NTKERNELAPI UCHAR NTAPI READ_REGISTER_UCHAR(IN PUCHAR Register)

◆ AtaSelectTimings()

VOID AtaSelectTimings ( _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG DeviceList,
_Out_writes_all_(MAX_IDE_DEVICE) PATA_TIMING  Timings,
_In_range_(>, 0) ULONG  ClockPeriodPs,
_In_ ULONG  Flags 
)

Definition at line 116 of file pata_generic.c.

121{
122 ULONG i;
123
124 for (i = 0; i < MAX_IDE_DEVICE; ++i)
125 {
127 PATA_TIMING Timing = &Timings[i];
128 ATA_TIMING DmaTiming;
129
130 if (!Device)
131 {
132 RtlZeroMemory(Timing, sizeof(*Timing));
133 continue;
134 }
135
136 /* PIO mode */
137 AtaCalculateTimings(Device, Timing, Device->PioMode, ClockPeriodPs);
138
139 /* UDMA works independently of any PIO mode */
140 if (Device->DmaMode == PIO_MODE(0) || Device->DmaMode >= UDMA_MODE(0))
141 continue;
142
143 /* DMA mode */
144 AtaCalculateTimings(Device, &DmaTiming, Device->DmaMode, ClockPeriodPs);
145
146 /*
147 * Typically, the ATA port driver uses PIO commands along with DMA ones.
148 * Given that we program the chipset only once after device enumeration,
149 * we want to make sure the PIO commands would always work.
150 */
151 Timing->AddressSetup = max(Timing->AddressSetup, DmaTiming.AddressSetup);
152 Timing->CmdActive = max(Timing->CmdActive, DmaTiming.CmdActive);
153 Timing->CmdRecovery = max(Timing->CmdRecovery, DmaTiming.CmdRecovery);
154 Timing->DataActive = max(Timing->DataActive, DmaTiming.DataActive);
155 Timing->DataRecovery = max(Timing->DataRecovery, DmaTiming.DataRecovery);
156 }
157
158 /* Merge timings shared between both drives */
160 {
161 Timings[0].AddressSetup = max(Timings[0].AddressSetup, Timings[1].AddressSetup);
162
163 Timings[1].AddressSetup = Timings[0].AddressSetup;
164 }
166 {
167 Timings[0].CmdActive = max(Timings[0].CmdActive, Timings[1].CmdActive);
168 Timings[0].CmdRecovery = max(Timings[0].CmdRecovery, Timings[1].CmdRecovery);
169
170 Timings[1].CmdActive = Timings[0].CmdActive;
171 Timings[1].CmdRecovery = Timings[0].CmdRecovery;
172 }
174 {
175 Timings[0].DataActive = max(Timings[0].DataActive, Timings[1].DataActive);
176 Timings[0].DataRecovery = max(Timings[0].DataRecovery, Timings[1].DataRecovery);
177
178 Timings[1].DataActive = Timings[0].DataActive;
179 Timings[1].DataRecovery = Timings[0].DataRecovery;
180 }
181}
#define PIO_MODE(n)
Definition: ata_user.h:36
#define UDMA_MODE(n)
Definition: ata_user.h:39
PDEVICE_LIST DeviceList
Definition: utils.c:27
#define MAX_IDE_DEVICE
Definition: ide.h:32
#define SHARED_DATA_TIMINGS
Definition: pata.h:231
#define SHARED_CMD_TIMINGS
Definition: pata.h:230
#define SHARED_ADDR_TIMINGS
Definition: pata.h:232
static VOID AtaCalculateTimings(_In_ PCHANNEL_DEVICE_CONFIG Device, _Out_ PATA_TIMING Timing, _In_ ULONG Mode, _In_ ULONG ClockPeriodPs)
Definition: pata_generic.c:62
ATATIM CmdRecovery
Definition: pata.h:224
ATATIM CmdActive
Definition: pata.h:223
ATATIM DataRecovery
Definition: pata.h:227
ATATIM AddressSetup
Definition: pata.h:221
ATATIM DataActive
Definition: pata.h:226
#define max(a, b)
Definition: svc.c:63
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by AmdSetTransferMode(), CmdSetTransferMode(), Via6421SetTransferMode(), and ViaSetTransferMode().

◆ AtaSleep()

VOID AtaSleep ( VOID  )

Definition at line 100 of file pciidex.c.

101{
104
106
107 DueTime.QuadPart = PORT_TIMER_TICK_MS * -10000LL;
108
112}
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define PORT_TIMER_TICK_MS
Definition: pciidex.h:54
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:282
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190
@ Executive
Definition: ketypes.h:467

Referenced by AtaAhciPhyCheckDevicePresence(), AtaAhciPmpPhyCheckDevicePresence(), AtaAhciPmpPhyWaitForReady(), AtaAhciPollRegister(), AtaAhciWaitForDeviceReady(), and PataResetChannel().

◆ AtaWriteBlock16()

VOID AtaWriteBlock16 ( _In_ PUSHORT  Port,
_In_ PUSHORT  Buffer,
_In_ ULONG  Count,
_In_ ULONG  MmioFlags 
)

Definition at line 15 of file pata_io.c.

20{
21 ASSERT(Buffer != NULL);
22 ASSERT(Count != 0);
23
24 if (MmioFlags)
26 else
28}
#define WRITE_PORT_BUFFER_USHORT(port, buffer, count)
Definition: hardware.h:34
NTKERNELAPI VOID NTAPI WRITE_REGISTER_BUFFER_USHORT(IN PUSHORT Register, IN PUSHORT Buffer, IN ULONG Count)

◆ AtaWriteBlock32()

VOID AtaWriteBlock32 ( _In_ PULONG  Port,
_In_ PULONG  Buffer,
_In_ ULONG  Count,
_In_ ULONG  MmioFlags 
)

Definition at line 47 of file pata_io.c.

52{
53 ASSERT(Buffer != NULL);
54 ASSERT(Count != 0);
55
56 if (MmioFlags)
58 else
60}
#define WRITE_PORT_BUFFER_ULONG(port, buffer, count)
Definition: hardware.h:35
NTKERNELAPI VOID NTAPI WRITE_REGISTER_BUFFER_ULONG(IN PULONG Register, IN PULONG Buffer, IN ULONG Count)

◆ AtaWritePortUchar()

VOID AtaWritePortUchar ( _In_ PUCHAR  Port,
_In_ UCHAR  Value,
_In_ ULONG  MmioFlags 
)

Definition at line 90 of file pata_io.c.

94{
95 if (MmioFlags)
97 else
99}
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
NTKERNELAPI VOID NTAPI WRITE_REGISTER_UCHAR(IN PUCHAR Register, IN UCHAR Value)

◆ AtaWritePortUlong()

VOID AtaWritePortUlong ( _In_ PULONG  Port,
_In_ ULONG  Value,
_In_ ULONG  MmioFlags 
)

Definition at line 102 of file pata_io.c.

106{
107 if (MmioFlags)
109 else
111}
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:11
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123

◆ AtiGetControllerProperties()

NTSTATUS AtiGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 36 of file ati.c.

38{
40 ULONG i;
41
42 PAGED_CODE();
43 ASSERT(Controller->Pci.VendorID == PCI_VEN_ATI);
44
45 if (Controller->Pci.DeviceID != PCI_DEV_IXP200_IDE &&
46 Controller->Pci.DeviceID != PCI_DEV_IXP300_IDE &&
47 Controller->Pci.DeviceID != PCI_DEV_IXP400_IDE &&
48 Controller->Pci.DeviceID != PCI_DEV_IXP600_IDE &&
49 Controller->Pci.DeviceID != PCI_DEV_IXP700_IDE)
50 {
51 return STATUS_NO_MATCH;
52 }
53
54 Controller->ChannelEnableBits = AtiEnableBits;
55
56 if (Controller->Pci.DeviceID == PCI_DEV_IXP600_IDE)
57 Controller->MaxChannels = 1;
58
59 Status = PciIdeCreateChannelData(Controller, 0);
60 if (!NT_SUCCESS(Status))
61 return Status;
62
63 for (i = 0; i < Controller->MaxChannels; ++i)
64 {
65 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
66
67 ChanData->SetTransferMode = SvwSetTransferMode;
68 ChanData->TransferModeSupported = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 5);
69
70 if (Controller->Pci.DeviceID == PCI_DEV_IXP200_IDE)
71 ChanData->TransferModeSupported &= ~UDMA_MODE5;
72
73 if (!SvwHasUdmaCable(Controller, i))
74 {
75 INFO("CH %lu: BIOS hasn't selected mode faster than UDMA 2, "
76 "assume 40-conductor cable\n",
77 ChanData->Channel);
78 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
79 }
80 }
81
82 return STATUS_SUCCESS;
83}
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS AtiEnableBits[MAX_IDE_CHANNEL]
Definition: ati.c:26
#define PCI_DEV_IXP200_IDE
Definition: ati.c:19
#define PCI_DEV_IXP700_IDE
Definition: ati.c:23
#define PCI_DEV_IXP600_IDE
Definition: ati.c:22
#define PCI_DEV_IXP400_IDE
Definition: ati.c:21
#define PCI_DEV_IXP300_IDE
Definition: ati.c:20
#define PCI_VEN_ATI
Definition: pata.h:10
#define UDMA_MODES(MinMode, MaxMode)
Definition: pata.h:49
CHANNEL_SET_MODE_EX SvwSetTransferMode
Definition: pciidex.h:813
BOOLEAN SvwHasUdmaCable(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
Definition: svw_pata.c:213

Referenced by PciIdeGetControllerProperties().

◆ CmdGetControllerProperties()

NTSTATUS CmdGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 460 of file cmd.c.

462{
464 ULONG i, SupportedMode, HwFlags = 0;
466
467 PAGED_CODE();
468 ASSERT(Controller->Pci.VendorID == PCI_VEN_CMD);
469
470 switch (Controller->Pci.DeviceID)
471 {
472 case PCI_DEV_PCI0640:
473 /*
474 * Errata: The CMD-640 has one set of task file registers per controller
475 * and thus the two channels cannot be used simultaneously.
476 * https://www.mindprod.com/jgloss/eideflaw.html
477 */
478 Controller->Flags |= CTRL_FLAG_IS_SIMPLEX;
479
480 SupportedMode = PIO_ALL;
482 break;
483
484 case PCI_DEV_PCI0643:
485 SupportedMode = PIO_ALL | SWDMA_ALL | MWDMA_ALL;
486
487 if (Controller->Pci.RevisionID < 6)
488 HwFlags |= HW_FLAGS_PRIMARY_ENABLED;
489 break;
490
491 case PCI_DEV_PCI0646:
492 SupportedMode = PIO_ALL | SWDMA_ALL | MWDMA_ALL;
493 HwFlags |= HW_FLAGS_HAS_UDMA_REG;
494
495 if (Controller->Pci.RevisionID < 3)
496 HwFlags |= HW_FLAGS_PRIMARY_ENABLED;
497 else
498 CheckInterrupt = CmdCheckInterruptMrdMode;
499
500 if (Controller->Pci.RevisionID == 5 || Controller->Pci.RevisionID == 6)
501 {
502 /*
503 * Early 646U2 revisions can support UDMA2 only at a PCI bus speed of 33MHz.
504 * When it runs at 25 MHz or 30 MHZ, the transfer speed must be limited to UDMA1.
505 */
506 SupportedMode |= UDMA_MODES(0, 1);
507 }
508 else if (Controller->Pci.RevisionID > 6)
509 {
510 SupportedMode |= UDMA_MODES(0, 2);
511 }
512 break;
513
514 case PCI_DEV_PCI0648:
515 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 4);
516 /* Prefetch bits have different meaning on this controller */
518 CheckInterrupt = CmdCheckInterruptMrdMode;
519 break;
520
521 case PCI_DEV_CMD0649:
522 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 5);
523 HwFlags |= HW_FLAGS_HAS_UDMA_REG;
524
525 if (Controller->Pci.RevisionID == 2)
526 HwFlags |= HW_FLAGS_NEED_PIO_FIX;
527
528 CheckInterrupt = CmdCheckInterruptMrdMode;
529 break;
530
531 default:
532 return STATUS_NO_MATCH;
533 }
534
535 Controller->Start = CmdControllerStart;
536
537 Controller->Flags |= CTRL_FLAG_USE_TEST_FUNCTION;
538 Controller->ChannelEnabledTest = CmdChannelEnabledTest;
539
540 Status = PciIdeCreateChannelData(Controller, 0);
541 if (!NT_SUCCESS(Status))
542 return Status;
543
544 Controller->HwExt = ExAllocatePoolZero(NonPagedPool, sizeof(CMD_HW_EXTENSION), TAG_PCIIDEX);
545 if (!Controller->HwExt)
547
548 for (i = 0; i < Controller->MaxChannels; ++i)
549 {
550 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
551
552 ChanData->HwFlags = HwFlags;
553 ChanData->CheckInterrupt = CheckInterrupt;
554 ChanData->SetTransferMode = CmdSetTransferMode;
555 ChanData->TransferModeSupported = SupportedMode;
556
557 if (Controller->Pci.DeviceID == PCI_DEV_PCI0640)
558 {
559 ChanData->ChanInfo &= ~CHANNEL_FLAG_IO32;
560 }
561 else
562 {
563 /* Check for 80-conductor cable */
564 if (ChanData->TransferModeSupported & UDMA_80C_ALL)
565 {
566 UCHAR BmControl = PciRead8(Controller, CMD_REG_BMIDECSR);
567 if (!(BmControl & CMD_BMIDECSR_CR(i)))
568 {
569 INFO("CH %lu: BIOS detected 40-conductor cable\n", ChanData->Channel);
570 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
571 }
572 }
573 }
574 }
575
576 return STATUS_SUCCESS;
577}
#define SWDMA_ALL
Definition: ata_user.h:23
static VOID CmdSetTransferMode(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
Definition: cmd.c:243
static BOOLEAN CmdCheckInterruptPci(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: cmd.c:407
#define CMD_BMIDECSR_CR(Channel)
Definition: cmd.c:57
#define PCI_DEV_PCI0640
Definition: cmd.c:18
static IDE_CHANNEL_STATE CmdChannelEnabledTest(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
Definition: cmd.c:356
#define HW_FLAGS_HAS_UDMA_REG
Definition: cmd.c:25
#define PCI_DEV_PCI0643
Definition: cmd.c:19
#define HW_FLAGS_NEED_PIO_FIX
Definition: cmd.c:26
static BOOLEAN CmdCheckInterruptMrdMode(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: cmd.c:376
#define CMD_REG_BMIDECSR
Definition: cmd.c:43
static VOID CmdControllerStart(_In_ PATA_CONTROLLER Controller)
Definition: cmd.c:424
#define HW_FLAGS_PRIMARY_ENABLED
Definition: cmd.c:24
#define PCI_DEV_PCI0648
Definition: cmd.c:21
#define PCI_DEV_CMD0649
Definition: cmd.c:22
#define PCI_DEV_PCI0646
Definition: cmd.c:20
#define HW_FLAGS_NO_PREFETCH
Definition: cmd.c:27
#define PCI_VEN_CMD
Definition: pata.h:14
#define UDMA_80C_ALL
Definition: pata.h:41
#define CTRL_FLAG_USE_TEST_FUNCTION
Definition: pciidex.h:226
CHANNEL_CHECK_INTERRUPT * PCHANNEL_CHECK_INTERRUPT
Definition: pciidex.h:127
#define CTRL_FLAG_IS_SIMPLEX
Definition: pciidex.h:224
PCHANNEL_CHECK_INTERRUPT CheckInterrupt
Definition: pciidex.h:303

Referenced by PciIdeGetControllerProperties().

◆ CountSetBits()

FORCEINLINE ULONG CountSetBits ( _In_ ULONG  x)

Definition at line 827 of file pciidex.h.

829{
830 x -= x >> 1 & 0x55555555;
831 x = (x & 0x33333333) + (x >> 2 & 0x33333333);
832
833 return ((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101 >> 24;
834}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by AhciGetControllerProperties().

◆ IntelGetControllerProperties()

NTSTATUS IntelGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 969 of file intel.c.

971{
972 const INTEL_CONTROLLER_INFO* ControllerInfo;
973 ULONG i, ExtensionSize, HwFlags;
975
976 PAGED_CODE();
977 ASSERT(Controller->Pci.VendorID == PCI_VEN_INTEL);
978
979 for (i = 0; i < RTL_NUMBER_OF(IntelControllerList); ++i)
980 {
981 ControllerInfo = &IntelControllerList[i];
982
983 if (Controller->Pci.DeviceID == ControllerInfo->DeviceID)
984 break;
985 }
987 return STATUS_NO_MATCH;
988
989 Controller->Flags |= CTRL_FLAG_DMA_INTERRUPT;
990
991 if (ControllerInfo->Type == TYPE_SCH)
992 Controller->MaxChannels = 1;
993
994 if (ControllerInfo->Type == TYPE_PIIX || ControllerInfo->Type == TYPE_MPIIX)
996 else
997 ExtensionSize = 0;
998
1000 if (!NT_SUCCESS(Status))
1001 return Status;
1002
1003 switch (ControllerInfo->Type)
1004 {
1005 case TYPE_MPIIX:
1006 /*
1007 * This is a bridge device and there are no PCI BAR resources allocated,
1008 * so mark the controller as a legacy device.
1009 */
1010 Controller->Flags &= ~CTRL_FLAG_NATIVE_PCI;
1011 Controller->ChannelEnableBits = IntelMpiixEnableBits;
1012 break;
1013
1014 case TYPE_PIIX:
1015 case TYPE_PIIX3:
1016 case TYPE_PIIX4:
1017 case TYPE_ICH:
1018 Controller->ChannelEnableBits = IntelPiixEnableBits;
1019 break;
1020
1021 case TYPE_SATA:
1022 // TODO: Implement the map support
1023 //Controller->ChannelEnabledTest = IntelCombinedEnabledTest;
1024 //HwFlags = TYPE_ICH;
1025 break;
1026
1027 default:
1028 break;
1029 }
1030 HwFlags = ControllerInfo->Type;
1031
1033 HwFlags |= HW_FLAGS_DISABLE_DMA;
1034
1035 for (i = 0; i < Controller->MaxChannels; ++i)
1036 {
1037 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
1038
1039 ChanData->HwFlags = HwFlags;
1040
1041 IntelInitChannel(Controller, ControllerInfo, ChanData);
1042
1043 if (HwFlags & HW_FLAGS_DISABLE_DMA)
1044 ChanData->TransferModeSupported &= PIO_ALL;
1045 }
1046
1047 return STATUS_SUCCESS;
1048}
static VOID IntelInitChannel(_In_ PATA_CONTROLLER Controller, _In_ const INTEL_CONTROLLER_INFO *ControllerInfo, _In_ PCHANNEL_DATA_PATA ChanData)
Definition: intel.c:836
static BOOLEAN IntelPciBridgeErrataMatch(_In_ PVOID Context, _In_ ULONG BusNumber, _In_ PCI_SLOT_NUMBER PciSlot, _In_ PPCI_COMMON_HEADER PciConfig)
Definition: intel.c:772
#define TYPE_PIIX4
Definition: intel.c:256
#define TYPE_SCH
Definition: intel.c:259
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS IntelPiixEnableBits[MAX_IDE_CHANNEL]
Definition: intel.c:366
#define TYPE_PIIX
Definition: intel.c:254
static PCIIDEX_PAGED_DATA const ATA_PCI_ENABLE_BITS IntelMpiixEnableBits[MAX_IDE_CHANNEL]
Definition: intel.c:373
#define TYPE_ICH
Definition: intel.c:257
#define TYPE_MPIIX
Definition: intel.c:253
#define HW_FLAGS_DISABLE_DMA
Definition: intel.c:245
#define TYPE_PIIX3
Definition: intel.c:255
static PCIIDEX_PAGED_DATA const INTEL_CONTROLLER_INFO IntelControllerList[]
Definition: intel.c:273
#define TYPE_SATA
Definition: intel.c:258
struct _INTEL_HW_EXTENSION INTEL_HW_EXTENSION
#define PCI_VEN_INTEL
Definition: pata.h:19
BOOLEAN PciFindDevice(_In_ __callback PATA_PCI_MATCH_FN MatchFunction, _In_ PVOID Context)
Definition: pciidex.c:13
#define CTRL_FLAG_DMA_INTERRUPT
Definition: pciidex.h:230
WORD ExtensionSize
Definition: apisets.c:17

Referenced by PciIdeGetControllerProperties().

◆ IsPowerOfTwo()

FORCEINLINE BOOLEAN IsPowerOfTwo ( _In_ ULONG  x)

Definition at line 838 of file pciidex.h.

840{
841 /* Also exclude zero numbers */
842 return (x != 0) && ((x & (x - 1)) == 0);
843}

◆ PataChannelGetMaximumDeviceCount()

ULONG PataChannelGetMaximumDeviceCount ( _In_ PVOID  ChannelContext)

Definition at line 87 of file pata_hw.c.

89{
90 PCHANNEL_DATA_PATA ChanData = ChannelContext;
91
92#if defined(_M_IX86)
93 if (ChanData->ChanInfo & CHANNEL_FLAG_CBUS)
94 return 4;
95#endif
96
97 return (ChanData->ChanInfo & CHANNEL_FLAG_NO_SLAVE) ? 1 : 2;
98}
#define CHANNEL_FLAG_CBUS
Definition: pciidex.h:283

Referenced by PataEnumerateChannel(), PataResetChannel(), and PciIdeXQueryPciIdeInterface().

◆ PciFindDevice()

BOOLEAN PciFindDevice ( _In_ __callback PATA_PCI_MATCH_FN  MatchFunction,
_In_ PVOID  Context 
)

Definition at line 13 of file pciidex.c.

16{
17 ULONG BusNumber, DeviceNumber, FunctionNumber;
18
19 for (BusNumber = 0; BusNumber < 0xFF; ++BusNumber)
20 {
22 {
23 for (FunctionNumber = 0; FunctionNumber < PCI_MAX_FUNCTION; ++FunctionNumber)
24 {
29
30 PciSlot.u.AsULONG = 0;
31 PciSlot.u.bits.DeviceNumber = DeviceNumber;
32 PciSlot.u.bits.FunctionNumber = FunctionNumber;
33
37 &Buffer,
38 0,
39 sizeof(Buffer));
40 if (BytesRead != sizeof(Buffer) ||
41 PciConfig->VendorID == PCI_INVALID_VENDORID ||
42 PciConfig->VendorID == 0)
43 {
44 if (FunctionNumber == 0)
45 {
46 /* This slot has no single- or a multi-function device */
47 break;
48 }
49 else
50 {
51 /* Continue scanning the functions */
52 continue;
53 }
54 }
55
56 if (MatchFunction(Context, BusNumber, PciSlot, PciConfig))
57 return TRUE;
58
60 {
61 /* The device is a single function device */
62 break;
63 }
64 }
65 }
66 }
67
68 return FALSE;
69}
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bus.c:73
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
_In_ ULONG _In_ PCI_SLOT_NUMBER PciSlot
Definition: pciidex.h:66
_In_ ULONG BusNumber
Definition: pciidex.h:65
_In_ ULONG _In_ PCI_SLOT_NUMBER _In_ PPCI_COMMON_HEADER PciConfig
Definition: pciidex.h:67
@ PCIConfiguration
Definition: miniport.h:93
struct _PCI_SLOT_NUMBER::@4498::@4499 bits
union _PCI_SLOT_NUMBER::@4498 u
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3603
#define PCI_MAX_FUNCTION
Definition: iotypes.h:3601
struct _PCI_COMMON_HEADER * PPCI_COMMON_HEADER
#define PCI_MAX_DEVICES
Definition: iotypes.h:3600
_In_ USHORT _In_ UCHAR RevisionID
Definition: iotypes.h:893
#define PCI_MULTIFUNCTION_DEVICE(PciData)
Definition: iotypes.h:3614

Referenced by IntelGetControllerProperties(), SvwPataControllerStart(), and ViaPataGetControllerProperties().

◆ PciIdeConnectInterrupt()

NTSTATUS PciIdeConnectInterrupt ( _In_ PVOID  ChannelContext)

Definition at line 1012 of file pata_generic.c.

1014{
1015 PCHANNEL_DATA_PATA ChanData = ChannelContext;
1016 PATA_CONTROLLER Controller = ChanData->Controller;
1017 PCM_PARTIAL_RESOURCE_DESCRIPTOR InterruptDesc;
1018 PKSERVICE_ROUTINE IsrHandler;
1020
1021 PAGED_CODE();
1022
1023 if (Controller->Flags & CTRL_FLAG_NATIVE_PCI)
1024 InterruptDesc = &Controller->InterruptDesc;
1025 else
1026 InterruptDesc = &ChanData->InterruptDesc;
1027 ASSERT(InterruptDesc);
1028
1029 if (ChanData->Regs.Dma != NULL)
1030 IsrHandler = PciIdeChannelIsr;
1031 else
1032 IsrHandler = PataChannelIsr;
1033 Status = IoConnectInterrupt(&ChanData->InterruptObject,
1034 IsrHandler,
1035 ChanData,
1036 NULL,
1037 InterruptDesc->u.Interrupt.Vector,
1038 InterruptDesc->u.Interrupt.Level,
1039 InterruptDesc->u.Interrupt.Level,
1040 (InterruptDesc->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
1042 (InterruptDesc->ShareDisposition == CmResourceShareShared),
1043 InterruptDesc->u.Interrupt.Affinity,
1044 FALSE);
1045 if (!NT_SUCCESS(Status))
1046 {
1047 ERR("Could not connect to interrupt %lu, status 0x%lx\n",
1048 InterruptDesc->u.Interrupt.Vector, Status);
1049 return Status;
1050 }
1051
1052 return STATUS_SUCCESS;
1053}
#define CTRL_FLAG_NATIVE_PCI
Definition: pciidex.h:223
KSERVICE_ROUTINE PciIdeChannelIsr
Definition: pciidex.h:703
KSERVICE_ROUTINE PataChannelIsr
Definition: pciidex.h:702
CM_PARTIAL_RESOURCE_DESCRIPTOR InterruptDesc
Definition: pciidex.h:171
IDE_REGISTERS Regs
Definition: pciidex.h:302
KSERVICE_ROUTINE * PKSERVICE_ROUTINE
Definition: ketypes.h:564

Referenced by PciIdeXPdoStartDevice().

◆ PciIdeCreateChannelData()

NTSTATUS PciIdeCreateChannelData ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  HwExtensionSize 
)

Definition at line 1072 of file pata_generic.c.

1075{
1076 PCHANNEL_DATA_PATA ChanData;
1077 ULONG i, Size;
1078
1079 PAGED_CODE();
1080 ASSERT(Controller->MaxChannels != 0);
1081
1082 Size = FIELD_OFFSET(CHANNEL_DATA_PATA, HwExt) + HwExtensionSize;
1083 ChanData = ExAllocatePoolZero(NonPagedPool, Size * Controller->MaxChannels, TAG_PCIIDEX);
1084 if (!ChanData)
1086
1087 Controller->ChanDataBlock = ChanData;
1088 Controller->ChannelBitmap = NUM_TO_BITMAP(Controller->MaxChannels);
1089
1090 for (i = 0; i < Controller->MaxChannels; ++i)
1091 {
1092 Controller->Channels[i] = ChanData;
1093
1094 ChanData->Channel = i;
1095 ChanData->Controller = Controller;
1096
1097 /* Set default values */
1098 ChanData->ChanInfo = CHANNEL_FLAG_IO32;
1099 ChanData->AllocateMemory = PciIdeAllocateMemory;
1100 ChanData->FreeMemory = PciIdeFreeMemory;
1101 ChanData->EnableInterrupts = PataEnableInterrupts;
1102 ChanData->PreparePrdTable = PciIdePreparePrdTable;
1103 ChanData->PrepareIo = PataPrepareIo;
1104 ChanData->StartIo = PataStartIo;
1105 ChanData->LoadTaskFile = PataLoadTaskFile;
1106 ChanData->SaveTaskFile = PataSaveTaskFile;
1107 ChanData->ReadStatus = PataReadStatus;
1108 ChanData->SetTransferMode = PciIdeGenericSetTransferMode;
1109 ChanData->TransferModeSupported = PIO_ALL | SWDMA_ALL | MWDMA_ALL | UDMA_ALL;
1110
1112
1113 ChanData = (PVOID)((ULONG_PTR)ChanData + Size);
1114 }
1115
1116 return STATUS_SUCCESS;
1117}
#define NUM_TO_BITMAP(num)
Definition: atapi.h:179
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
static VOID PciIdeGenericSetTransferMode(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
Definition: pata_generic.c:416
static NTSTATUS PciIdeAllocateMemory(_In_ PVOID ChannelContext)
Definition: pata_generic.c:511
static VOID PciIdeFreeMemory(_In_ PVOID ChannelContext)
Definition: pata_generic.c:485
static VOID PataEnableInterrupts(_In_ PVOID ChannelContext, _In_ BOOLEAN Enable)
Definition: pata_generic.c:965
CHANNEL_PREPARE_IO PataPrepareIo
Definition: pciidex.h:700
CHANNEL_LOAD_TASK_FILE PataLoadTaskFile
Definition: pciidex.h:705
KDEFERRED_ROUTINE PataPollingTimerDpc
Definition: pciidex.h:708
CHANNEL_START_IO PataStartIo
Definition: pciidex.h:701
#define CHANNEL_FLAG_IO32
Definition: pciidex.h:260
CHANNEL_SAVE_TASK_FILE PataSaveTaskFile
Definition: pciidex.h:706
CHANNEL_READ_STATUS PataReadStatus
Definition: pciidex.h:707
CHANNEL_PREPARE_PRD_TABLE PciIdePreparePrdTable
Definition: pciidex.h:699
PCHANNEL_READ_STATUS ReadStatus
Definition: pciidex.h:299
KDPC PollingTimerDpc
Definition: pciidex.h:312
PCHANNEL_SAVE_TASK_FILE SaveTaskFile
Definition: pciidex.h:298
PCHANNEL_LOAD_TASK_FILE LoadTaskFile
Definition: pciidex.h:297
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

Referenced by AmdGetControllerProperties(), AtiGetControllerProperties(), CmdGetControllerProperties(), IntelGetControllerProperties(), PataGetControllerProperties(), PciIdeGetControllerProperties(), PcTechGetControllerProperties(), Sil680GetControllerProperties(), SvwPataGetControllerProperties(), SvwSataGetControllerProperties(), ToshibaGetControllerProperties(), Via6421GetControllerProperties(), ViaCx700GetControllerProperties(), and ViaGetControllerProperties().

◆ PciIdeDmaStop()

VOID PciIdeDmaStop ( _In_ PCHANNEL_DATA_PATA  ChanData)

Definition at line 247 of file pata_io.c.

249{
250 PUCHAR IoBase = ChanData->Regs.Dma;
251
252 /* Wait one PIO transfer cycle */
253 (VOID)ATA_READ(IoBase + PCIIDE_DMA_STATUS, ChanData, MRES_DMA);
254
255 /* Clear the interrupt bit in the status register */
256 ATA_WRITE(IoBase + PCIIDE_DMA_COMMAND, PCIIDE_DMA_COMMAND_STOP, ChanData, MRES_DMA);
257 ATA_WRITE(IoBase + PCIIDE_DMA_STATUS, PCIIDE_DMA_STATUS_INTERRUPT, ChanData, MRES_DMA);
258}
#define VOID
Definition: acefi.h:82
#define ATA_WRITE(Port, Value)
Definition: hwidep.h:80
#define ATA_READ(Port)
Definition: hwidep.h:89
#define PCIIDE_DMA_STATUS
Definition: pata.h:107
#define PCIIDE_DMA_STATUS_INTERRUPT
Definition: pata.h:127
#define PCIIDE_DMA_COMMAND
Definition: pata.h:106
#define PCIIDE_DMA_COMMAND_STOP
Definition: pata.h:115
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by PataResetChannel(), and PciIdeChannelIsr().

◆ PciIdeFreeResources()

VOID PciIdeFreeResources ( _In_ PVOID  ChannelContext)

Definition at line 877 of file pata_generic.c.

879{
880 PCHANNEL_DATA_PATA ChanData = ChannelContext;
881
882 PAGED_CODE();
883
884 if (ChanData->InterruptObject)
885 {
887
888 IoDisconnectInterrupt(ChanData->InterruptObject);
889 ChanData->InterruptObject = NULL;
890 }
891
892 ChanData->Regs.Dma = NULL;
893
894 ChanData->ChanInfo &= ~(CHANNEL_FLAG_DRIVE0_DMA_CAPABLE |
896
898}
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:142
static VOID PataReleaseLegacyAddressRanges(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: pata_generic.c:433
#define CHANNEL_FLAG_DRIVE0_DMA_CAPABLE
Definition: pciidex.h:261
#define CHANNEL_FLAG_DRIVE1_DMA_CAPABLE
Definition: pciidex.h:262
DECLSPEC_NOINLINE_FROM_PAGED VOID AtaChanEnableInterruptsSync(_In_ PVOID ChannelContext, _In_ BOOLEAN Enable)
Definition: fdo.c:62

Referenced by PciIdeXPdoStopDevice().

◆ PciIdeGetChannelState()

IDE_CHANNEL_STATE PciIdeGetChannelState ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  Channel 
)

Definition at line 902 of file pata_generic.c.

905{
906 PAGED_CODE();
907
908 /* SFF-8038i compliant hardware */
909 if (Controller->Flags & CTRL_FLAG_NATIVE_PCI)
910 {
911 /*
912 * If any native PCI IDE channel is enabled,
913 * its PCI I/O resources should be allocated as well:
914 *
915 * [BAR 0] I/O ports at FFC0 [size=8] Channel 0 task file registers
916 * [BAR 1] I/O ports at FF8C [size=4] Channel 0 device control
917 * [BAR 2] I/O ports at FF80 [size=8] Channel 1 task file registers
918 * [BAR 3] I/O ports at FF88 [size=4] Channel 1 device control
919 * [BAR 4] I/O ports at FFA0 [size=16] Bus Mastering registers
920 * [BAR 5] Memory at FE780000 Aux registers
921 */
922 if (!(Controller->Flags & CTRL_FLAG_MANUAL_RES))
923 {
924 const ULONG BarIndex = Channel * 2;
925
926 ASSERT(Channel < 2);
927
928 /* Check task file registers */
929 if (!(Controller->AccessRange[BarIndex].Flags & RANGE_IS_VALID))
930 return ChannelDisabled;
931
932 /* Check device control */
933 if (!(Controller->AccessRange[BarIndex + 1].Flags & RANGE_IS_VALID))
934 return ChannelDisabled;
935 }
936 }
937
938 if (Controller->ChannelEnableBits)
939 {
940 if (Controller->Flags & CTRL_FLAG_USE_TEST_FUNCTION)
941 {
942 /* Device-specific test */
943 return Controller->ChannelEnabledTest(Controller, Channel);
944 }
945 else
946 {
947 const ATA_PCI_ENABLE_BITS* EnableBits = &Controller->ChannelEnableBits[Channel];
948 UCHAR RegisterValue;
949
950 /* Test PCI bits */
951 RegisterValue = PciRead8(Controller, EnableBits->Register);
952 if ((RegisterValue & EnableBits->Mask) == EnableBits->ValueEnabled)
953 return ChannelEnabled;
954 else
955 return ChannelDisabled;
956 }
957 }
958
959 /* This channel is always enabled */
960 return ChannelStateUnknown;
961}
@ ChannelDisabled
Definition: ide.h:197
@ ChannelStateUnknown
Definition: ide.h:199
@ ChannelEnabled
Definition: ide.h:198
_In_ ULONG Channel
Definition: pciidex.h:74
#define CTRL_FLAG_MANUAL_RES
Definition: pciidex.h:229

Referenced by PciIdeXGetChannelState().

◆ PciIdeGetControllerProperties()

NTSTATUS PciIdeGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 1121 of file pata_generic.c.

1123{
1125 ULONG i;
1126
1127 PAGED_CODE();
1128
1129 Controller->MaxChannels = MAX_IDE_CHANNEL;
1130
1131 /* Match the controller through the PCI ID */
1132 switch (Controller->Pci.VendorID)
1133 {
1134 case PCI_VEN_ATI:
1135 Status = AtiGetControllerProperties(Controller);
1136 break;
1137 case PCI_VEN_AMD:
1138 case PCI_VEN_NVIDIA:
1139 Status = AmdGetControllerProperties(Controller);
1140 break;
1141 case PCI_VEN_CMD:
1142 Status = CmdGetControllerProperties(Controller);
1143 if (Status == STATUS_NO_MATCH)
1145 break;
1146 case PCI_VEN_INTEL:
1148 break;
1149 case PCI_VEN_PC_TECH:
1151 break;
1154 if (Status == STATUS_NO_MATCH)
1156 break;
1157 case PCI_VEN_TOSHIBA:
1159 break;
1160 case PCI_VEN_VIA:
1161 Status = ViaGetControllerProperties(Controller);
1162 break;
1163
1164 default:
1166 break;
1167 }
1168
1169 /* Try to use the generic PCI IDE minidriver */
1170 if (Status == STATUS_NO_MATCH)
1171 {
1172 if ((Controller->Pci.BaseClass != PCI_CLASS_MASS_STORAGE_CTLR) ||
1173 ((Controller->Pci.SubClass != PCI_SUBCLASS_MSC_IDE_CTLR) &&
1174 (Controller->Pci.SubClass != PCI_SUBCLASS_MSC_RAID_CTLR)))
1175 {
1176 ERR("Unsupported controller\n");
1177 return Status;
1178 }
1179
1180 WARN("%04X:%04X.%02X: Using generic PCI IDE minidriver\n",
1181 Controller->Pci.VendorID,
1182 Controller->Pci.DeviceID,
1183 Controller->Pci.RevisionID);
1184
1185 Status = PciIdeCreateChannelData(Controller, 0);
1186 if (!NT_SUCCESS(Status))
1187 return Status;
1188
1189 /* Disable 32-bit I/O for unknown controllers */
1190 for (i = 0; i < Controller->MaxChannels; ++i)
1191 {
1192 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
1193
1194 ChanData->ChanInfo &= ~CHANNEL_FLAG_IO32;
1195 }
1196 }
1197
1198 if (!NT_SUCCESS(Status))
1199 return Status;
1200
1201 /*
1202 * Check for a legacy PCI IDE device.
1203 * NOTE: NT architecture does not support switching only one IDE channel to native mode.
1204 */
1205 if ((Controller->Pci.BaseClass == PCI_CLASS_MASS_STORAGE_CTLR) &&
1206 (Controller->Pci.SubClass == PCI_SUBCLASS_MSC_IDE_CTLR))
1207 {
1208 if (!(Controller->Pci.ProgIf & PCIIDE_PROGIF_PRIMARY_CHANNEL_NATIVE_MODE) ||
1209 !(Controller->Pci.ProgIf & PCIIDE_PROGIF_SECONDARY_CHANNEL_NATIVE_MODE))
1210 {
1211 Controller->Flags &= ~CTRL_FLAG_NATIVE_PCI;
1212 }
1213 }
1214
1215 if (Controller->Flags & CTRL_FLAG_NATIVE_PCI)
1216 {
1217 if (Controller->InterruptDesc.Type != CmResourceTypeInterrupt)
1218 {
1219 ERR("No interrupt resource\n");
1221 }
1222 }
1223
1224 if (!PciIdeControllerInitDma(Controller))
1225 {
1226 for (i = 0; i < Controller->MaxChannels; ++i)
1227 {
1228 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
1229
1230 ChanData->TransferModeSupported &= PIO_ALL;
1231 }
1232 }
1233
1234 if (Controller->Flags & CTRL_FLAG_IS_SIMPLEX)
1235 {
1236 WARN("Sync access for hardware is required\n");
1237
1238 Controller->HwSyncObject = IoCreateController(0);
1239 if (!Controller->HwSyncObject)
1241 }
1242
1243 return STATUS_SUCCESS;
1244}
NTSTATUS AmdGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: amd.c:329
NTSTATUS AtiGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: ati.c:36
PCONTROLLER_OBJECT NTAPI IoCreateController(IN ULONG Size)
Definition: controller.c:57
NTSTATUS CmdGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: cmd.c:460
#define MAX_IDE_CHANNEL
Definition: ide.h:30
NTSTATUS IntelGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: intel.c:969
#define PCIIDE_PROGIF_SECONDARY_CHANNEL_NATIVE_MODE
Definition: pata.h:97
#define PCI_VEN_TOSHIBA
Definition: pata.h:17
#define PCI_VEN_VIA
Definition: pata.h:15
#define PCI_VEN_PC_TECH
Definition: pata.h:13
#define PCIIDE_PROGIF_PRIMARY_CHANNEL_NATIVE_MODE
Definition: pata.h:95
#define PCI_VEN_SERVERWORKS
Definition: pata.h:16
static BOOLEAN PciIdeControllerInitDma(_In_ PATA_CONTROLLER Controller)
Definition: pata_generic.c:565
NTSTATUS PcTechGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: pctech.c:41
NTSTATUS Sil680GetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: sil680.c:214
NTSTATUS SvwPataGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: svw_pata.c:288
NTSTATUS SvwSataGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: svw_sata.c:215
NTSTATUS ToshibaGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: toshiba.c:102
NTSTATUS ViaGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: via.c:859
#define PCI_CLASS_MASS_STORAGE_CTLR
Definition: iotypes.h:4106
#define PCI_SUBCLASS_MSC_IDE_CTLR
Definition: iotypes.h:4131
#define PCI_SUBCLASS_MSC_RAID_CTLR
Definition: iotypes.h:4134

◆ PciIdeInitTaskFileIoResources()

VOID PciIdeInitTaskFileIoResources ( _In_ PCHANNEL_DATA_PATA  ChanData,
_In_ ULONG_PTR  CommandPortBase,
_In_ ULONG_PTR  ControlPortBase,
_In_ ULONG  CommandBlockSpare 
)

Definition at line 663 of file pata_generic.c.

668{
669 PIDE_REGISTERS Registers = &ChanData->Regs;
670
671 PAGED_CODE();
672
673 /* Standard PATA register layout */
674 Registers->Data = (PVOID)(CommandPortBase + 0 * CommandBlockSpare);
675 Registers->Error = (PVOID)(CommandPortBase + 1 * CommandBlockSpare);
676 Registers->SectorCount = (PVOID)(CommandPortBase + 2 * CommandBlockSpare);
677 Registers->LbaLow = (PVOID)(CommandPortBase + 3 * CommandBlockSpare);
678 Registers->LbaMid = (PVOID)(CommandPortBase + 4 * CommandBlockSpare);
679 Registers->LbaHigh = (PVOID)(CommandPortBase + 5 * CommandBlockSpare);
680 Registers->Device = (PVOID)(CommandPortBase + 6 * CommandBlockSpare);
681 Registers->Status = (PVOID)(CommandPortBase + 7 * CommandBlockSpare);
682
683 Registers->Control = (PVOID)ControlPortBase;
684}
IDE_REG Error
Definition: hwidep.h:111
IDE_REG Control
Definition: hwidep.h:139
IDE_REG LbaLow
LBA bits 0-7, 24-31.
Definition: hwidep.h:118
IDE_REG LbaMid
LBA bits 8-15, 32-39.
Definition: hwidep.h:121
IDE_REG Data
Definition: hwidep.h:107
IDE_REG Status
Definition: hwidep.h:135
IDE_REG LbaHigh
LBA bits 16-23, 40-47.
Definition: hwidep.h:127
IDE_REG Device
Definition: hwidep.h:131
IDE_REG SectorCount
Definition: hwidep.h:115

Referenced by PciIdeAssignLegacyResources(), PciIdeAssignNativeResources(), SvwSataParseResources(), and Via6421ParseResources().

◆ PciIdeParseResources()

NTSTATUS PciIdeParseResources ( _In_ PCHANNEL_DATA_PATA  ChanData,
_In_ PCM_RESOURCE_LIST  ResourcesTranslated 
)

Definition at line 849 of file pata_generic.c.

852{
853 PATA_CONTROLLER Controller = ChanData->Controller;
855
856 PAGED_CODE();
857
858 ASSERT(ChanData->Channel < 2);
859
860 if (Controller->Flags & CTRL_FLAG_NATIVE_PCI)
861 Status = PciIdeAssignNativeResources(Controller, ChanData);
862 else
864 if (!NT_SUCCESS(Status))
865 {
866 ERR("CH %lu: Failed to assign I/O resources 0x%lx\n", ChanData->Channel, Status);
867 return Status;
868 }
869
871
872 return STATUS_SUCCESS;
873}
static VOID PataClaimLegacyAddressRanges(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: pata_generic.c:452
static NTSTATUS PciIdeAssignNativeResources(_In_ PATA_CONTROLLER Controller, _In_ PCHANNEL_DATA_PATA ChanData)
Definition: pata_generic.c:689
static NTSTATUS PciIdeAssignLegacyResources(_In_ PCHANNEL_DATA_PATA ChanData, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
Definition: pata_generic.c:723
_In_ WDFCMRESLIST _In_ WDFCMRESLIST ResourcesTranslated
Definition: wdfdevice.h:891

Referenced by PataGetControllerProperties(), and PciIdeXPdoStartDevice().

◆ PciIdeXChannelState()

IDE_CHANNEL_STATE PciIdeXChannelState ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  Channel 
)

Definition at line 15 of file miniport.c.

18{
19 PCIIDE_CHANNEL_ENABLED MiniportChannelEnabled;
20
21 PAGED_CODE();
22
23 MiniportChannelEnabled = FdoExtension->Properties.PciIdeChannelEnabled;
24 if (MiniportChannelEnabled)
25 return MiniportChannelEnabled(FdoExtension->MiniControllerExtension, Channel);
26
28}
@ FdoExtension
Definition: precomp.h:48
IDE_CHANNEL_STATE(NTAPI * PCIIDE_CHANNEL_ENABLED)(_In_ PVOID DeviceExtension, _In_ ULONG Channel)
Definition: ide.h:203

◆ PciIdeXFdoDispatchPnp()

NTSTATUS PciIdeXFdoDispatchPnp ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_Inout_ PIRP  Irp 
)

Definition at line 910 of file fdo.c.

913{
914 PIO_STACK_LOCATION IoStack;
916
917 PAGED_CODE();
918
919 Status = IoAcquireRemoveLock(&FdoExtension->Common.RemoveLock, Irp);
920 if (!NT_SUCCESS(Status))
921 {
922 Irp->IoStatus.Status = Status;
924
925 return Status;
926 }
927
929 switch (IoStack->MinorFunction)
930 {
932 {
933 if (!NT_VERIFY(IoForwardIrpSynchronously(FdoExtension->Common.LowerDeviceObject, Irp)))
934 {
936 goto CompleteIrp;
937 }
938 Status = Irp->IoStatus.Status;
939 if (!NT_SUCCESS(Status))
940 goto CompleteIrp;
941
943 IoStack->Parameters.
944 StartDevice.AllocatedResourcesTranslated);
945 goto CompleteIrp;
946 }
947
949 {
951 break;
952 }
953
955 {
956 IoReleaseRemoveLockAndWait(&FdoExtension->Common.RemoveLock, Irp);
957
959
960 Irp->IoStatus.Status = STATUS_SUCCESS;
962 Status = IoCallDriver(FdoExtension->Common.LowerDeviceObject, Irp);
963
964 IoDetachDevice(FdoExtension->Common.LowerDeviceObject);
965 IoDeleteDevice(FdoExtension->Common.Self);
966 return Status;
967 }
968
970 {
972 break;
973 }
974
976 {
977 if (IoStack->Parameters.QueryDeviceRelations.Type != BusRelations)
978 break;
979
981 if (!NT_SUCCESS(Status))
982 goto CompleteIrp;
983
984 Irp->IoStatus.Status = Status;
985 break;
986 }
987
989 {
991 break;
992 }
993
995 {
998 break;
999
1000 Irp->IoStatus.Status = Status;
1001 break;
1002 }
1003
1009 Irp->IoStatus.Status = STATUS_SUCCESS;
1010 break;
1011
1012 case IRP_MN_QUERY_ID:
1013 return PciIdeXFdoQueryId(FdoExtension, Irp, IoStack);
1014
1015 default:
1016 break;
1017 }
1018
1020 Status = IoCallDriver(FdoExtension->Common.LowerDeviceObject, Irp);
1021
1022 IoReleaseRemoveLock(&FdoExtension->Common.RemoveLock, Irp);
1023 return Status;
1024
1026 Irp->IoStatus.Status = Status;
1028
1029 IoReleaseRemoveLock(&FdoExtension->Common.RemoveLock, Irp);
1030 return Status;
1031}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
static BOOL StartDevice(IN HDEVINFO DeviceInfoSet, IN PSP_DEVINFO_DATA DevInfoData OPTIONAL, IN BOOL bEnable, IN DWORD HardwareProfile OPTIONAL, OUT BOOL *bNeedReboot OPTIONAL)
Definition: wizard.c:173
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1297
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1252
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1625
NTSTATUS PciIdeXPnpQueryDeviceUsageNotification(_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp)
Definition: pciidex.c:214
NTSTATUS PciIdeXPnpQueryPnpDeviceState(_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp)
Definition: pciidex.c:266
CONTROLLER_PNP_START_DEVICE PciIdeXFdoStartDevice
Definition: pciidex.h:468
CONTROLLER_PNP_REMOVE_DEVICE PciIdeXFdoRemoveDevice
Definition: pciidex.h:471
static NTSTATUS PciIdeXFdoQueryBusRelations(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PIRP Irp)
Definition: fdo.c:693
static NTSTATUS PciIdeXFdoQueryInterface(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PIO_STACK_LOCATION IoStack)
Definition: fdo.c:803
static NTSTATUS PciIdeXFdoQueryId(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
Definition: fdo.c:845
static NTSTATUS PciIdeXFdoStopDevice(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: fdo.c:574
union _IO_STACK_LOCATION::@1696 Parameters
struct _IO_STACK_LOCATION::@4454::@4479 QueryDeviceRelations
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IoAcquireRemoveLock(RemoveLock, Tag)
#define IoReleaseRemoveLockAndWait(_RemoveLock, _Tag)
Definition: iofuncs.h:2774
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2764
#define IRP_MN_CANCEL_STOP_DEVICE
@ BusRelations
Definition: iotypes.h:2154
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_START_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define IRP_MN_QUERY_ID
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by PciIdeXDispatchPnp().

◆ PciIdeXGetChannelState()

IDE_CHANNEL_STATE PciIdeXGetChannelState ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  Channel 
)

Definition at line 678 of file fdo.c.

681{
682 PAGED_CODE();
683
684 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
685 return ChannelStateUnknown;
686
687 return PciIdeGetChannelState(Controller, Channel);
688}
IDE_CHANNEL_STATE PciIdeGetChannelState(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
Definition: pata_generic.c:902

Referenced by PciIdeXFdoQueryBusRelations(), PciIdeXPdoQueryResourceRequirements(), and PciIdeXPdoQueryResources().

◆ PciIdeXPdoRemoveDevice()

NTSTATUS PciIdeXPdoRemoveDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp,
_In_ BOOLEAN  FinalRemove 
)

Definition at line 193 of file pdo.c.

197{
200 BOOLEAN WasRemoved = FALSE;
201
202 PAGED_CODE();
203
205
206 if (FinalRemove && (PdoExtension->Flags & PDO_FLAG_REPORTED_MISSING))
207 {
208 IoReleaseRemoveLockAndWait(&PdoExtension->Common.RemoveLock, Irp);
209
210 if (Irp)
211 ExAcquireFastMutex(&FdoExtension->PdoListSyncMutex);
212
213 RemoveEntryList(&PdoExtension->ListEntry);
214
215 if (Irp)
216 ExReleaseFastMutex(&FdoExtension->PdoListSyncMutex);
217
218 IoDeleteDevice(PdoExtension->Common.Self);
219 WasRemoved = TRUE;
220 }
221
223 if (Irp)
224 {
225 Irp->IoStatus.Status = Status;
227 }
228
229 if (!WasRemoved)
230 IoReleaseRemoveLock(&PdoExtension->Common.RemoveLock, Irp);
231 return Status;
232}
@ PdoExtension
Definition: precomp.h:49
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define PDO_FLAG_REPORTED_MISSING
Definition: pciidex.h:410
static NTSTATUS PciIdeXPdoStopDevice(_In_ PPDO_DEVICE_EXTENSION PdoExt)
Definition: pdo.c:175

Referenced by PciIdeXFdoRemoveDevice(), and PciIdeXPdoDispatchPnp().

◆ PciIdeXPnpQueryDeviceUsageNotification()

NTSTATUS PciIdeXPnpQueryDeviceUsageNotification ( _In_ PCOMMON_DEVICE_EXTENSION  CommonExt,
_In_ PIRP  Irp 
)

Definition at line 214 of file pciidex.c.

217{
218 PIO_STACK_LOCATION IoStack;
220 volatile LONG* Counter;
221
222 PAGED_CODE();
223
224 if (!IS_FDO(CommonExt))
225 {
226 Status = PciIdeXPnpRepeatRequest(CommonExt, Irp, NULL);
227 }
228 else
229 {
230 if (!NT_VERIFY(IoForwardIrpSynchronously(CommonExt->LowerDeviceObject, Irp)))
231 return STATUS_UNSUCCESSFUL;
232 Status = Irp->IoStatus.Status;
233 }
234 if (!NT_SUCCESS(Status))
235 return Status;
236
238 switch (IoStack->Parameters.UsageNotification.Type)
239 {
241 Counter = &CommonExt->PageFiles;
242 break;
243
245 Counter = &CommonExt->HibernateFiles;
246 break;
247
249 Counter = &CommonExt->DumpFiles;
250 break;
251
252 default:
253 return Status;
254 }
255
257
258 if (!IS_FDO(CommonExt))
259 IoInvalidateDeviceState(CommonExt->Self);
260
261 return STATUS_SUCCESS;
262}
#define IS_FDO(p)
Definition: atapi.h:173
NTSTATUS PciIdeXPnpRepeatRequest(_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp, _In_opt_ PDEVICE_CAPABILITIES DeviceCapabilities)
Definition: pciidex.c:156
long LONG
Definition: pedump.c:60
VOID NTAPI IoInvalidateDeviceState(IN PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:1847
struct _IO_STACK_LOCATION::@4454::@4487 UsageNotification
static LARGE_INTEGER Counter
Definition: clock.c:43
#define IoAdjustPagingPathCount(_Count, _Increment)
@ DeviceUsageTypeHibernation
Definition: iotypes.h:1171
@ DeviceUsageTypeDumpFile
Definition: iotypes.h:1172
@ DeviceUsageTypePaging
Definition: iotypes.h:1170

Referenced by PciIdeXFdoDispatchPnp(), and PciIdeXPdoDispatchPnp().

◆ PciIdeXPnpQueryPnpDeviceState()

NTSTATUS PciIdeXPnpQueryPnpDeviceState ( _In_ PCOMMON_DEVICE_EXTENSION  CommonExt,
_In_ PIRP  Irp 
)

Definition at line 266 of file pciidex.c.

269{
270 PAGED_CODE();
271
272 if (CommonExt->PageFiles || CommonExt->HibernateFiles || CommonExt->DumpFiles)
273 Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
274
275 if (IS_FDO(CommonExt))
276 Irp->IoStatus.Status = STATUS_SUCCESS;
277
278 return STATUS_SUCCESS;
279}
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006

Referenced by PciIdeXFdoDispatchPnp(), and PciIdeXPdoDispatchPnp().

◆ PciIdeXPnpRepeatRequest()

NTSTATUS PciIdeXPnpRepeatRequest ( _In_ PCOMMON_DEVICE_EXTENSION  CommonExt,
_In_ PIRP  Irp,
_In_opt_ PDEVICE_CAPABILITIES  DeviceCapabilities 
)

Definition at line 156 of file pciidex.c.

160{
161 PCOMMON_DEVICE_EXTENSION FdoExt = CommonExt->FdoExt;
162 PDEVICE_OBJECT TopDeviceObject;
163 PIO_STACK_LOCATION IoStack, SubStack;
164 PIRP SubIrp;
167
168 PAGED_CODE();
169 ASSERT(!IS_FDO(CommonExt));
170
171 TopDeviceObject = IoGetAttachedDeviceReference(FdoExt->Self);
172
173 SubIrp = IoAllocateIrp(TopDeviceObject->StackSize, FALSE);
174 if (!SubIrp)
175 {
176 ObDereferenceObject(TopDeviceObject);
178 }
179
181
183 SubStack = IoGetNextIrpStackLocation(SubIrp);
184 RtlCopyMemory(SubStack, IoStack, sizeof(*SubStack));
185
187 SubStack->Parameters.DeviceCapabilities.Capabilities = DeviceCapabilities;
188
191 &Event,
192 TRUE,
193 TRUE,
194 TRUE);
195
197
198 Status = IoCallDriver(TopDeviceObject, SubIrp);
199 if (Status == STATUS_PENDING)
200 {
202 }
203
204 ObDereferenceObject(TopDeviceObject);
205
206 Status = SubIrp->IoStatus.Status;
207 IoFreeIrp(SubIrp);
208
209 return Status;
210}
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
_In_ PIOMMU_DEVICE_PATH _In_ PIOMMU_SVM_CAPABILITIES DeviceCapabilities
Definition: haltypes.h:1824
@ NotificationEvent
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1407
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
IO_COMPLETION_ROUTINE PciIdeXPdoCompletionRoutine
Definition: pciidex.h:521
PDEVICE_OBJECT Self
Definition: pciidex.h:376
struct _IO_STACK_LOCATION::@4454::@4481 DeviceCapabilities
IO_STATUS_BLOCK IoStatus
#define STATUS_PENDING
Definition: telnetd.h:14
#define DeviceCapabilities
Definition: wingdi.h:4895
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PciIdeXPdoQueryCapabilities(), and PciIdeXPnpQueryDeviceUsageNotification().

◆ PciRead()

VOID PciRead ( _In_ PATA_CONTROLLER  Controller,
_Out_writes_bytes_all_(BufferLength) PVOID  Buffer,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  BufferLength 
)

Definition at line 72 of file pciidex.c.

77{
78 Controller->GetBusData(Controller->BusInterfaceContext,
80 Buffer,
81 ConfigDataOffset,
83}
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
#define PCI_WHICHSPACE_CONFIG
Definition: iotypes.h:3646

Referenced by IntelInitChannel(), PciRead16(), PciRead32(), and PciRead8().

◆ PciRead16()

FORCEINLINE USHORT PciRead16 ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  ConfigDataOffset 
)

Definition at line 859 of file pciidex.h.

862{
864
865 PciRead(Controller, &Result, ConfigDataOffset, sizeof(Result));
866 return Result;
867}
VOID PciRead(_In_ PATA_CONTROLLER Controller, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: pciidex.c:72
_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 AmdGetControllerProperties(), IntelInitChannel(), IntelPiixLegacySetTransferMode(), IntelPiixSetTransferMode(), PcTechControllerStart(), Sil680SetTransferMode(), and SvwSetTransferMode().

◆ PciRead32()

FORCEINLINE ULONG PciRead32 ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  ConfigDataOffset 
)

◆ PciRead8()

◆ PciWrite()

VOID PciWrite ( _In_ PATA_CONTROLLER  Controller,
_In_reads_bytes_(BufferLength) PVOID  Buffer,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  BufferLength 
)

Definition at line 86 of file pciidex.c.

91{
92 Controller->SetBusData(Controller->BusInterfaceContext,
94 Buffer,
95 ConfigDataOffset,
97}

Referenced by PciWrite16(), PciWrite32(), and PciWrite8().

◆ PciWrite16()

FORCEINLINE VOID PciWrite16 ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  ConfigDataOffset,
_In_ USHORT  Value 
)

Definition at line 893 of file pciidex.h.

897{
898 PciWrite(Controller, &Value, ConfigDataOffset, sizeof(Value));
899}
VOID PciWrite(_In_ PATA_CONTROLLER Controller, _In_reads_bytes_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: pciidex.c:86

Referenced by IntelPiixLegacyPrepareIo(), IntelPiixLegacySetTransferMode(), IntelPiixSetTransferMode(), PcTechControllerStart(), Sil680SetTransferMode(), and SvwSetTransferMode().

◆ PciWrite32()

FORCEINLINE VOID PciWrite32 ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  Value 
)

Definition at line 903 of file pciidex.h.

907{
908 PciWrite(Controller, &Value, ConfigDataOffset, sizeof(Value));
909}

Referenced by AmdSetTransferMode(), IntelSchSetTransferMode(), Sil680SetTransferMode(), SvwSetTransferMode(), ToshibaSetTransferMode(), ViaScrWritePci(), and ViaSetTransferMode().

◆ PciWrite8()

◆ PcTechGetControllerProperties()

NTSTATUS PcTechGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 41 of file pctech.c.

43{
45 ULONG i;
46
47 PAGED_CODE();
48 ASSERT(Controller->Pci.VendorID == PCI_VEN_PC_TECH);
49
50 if (Controller->Pci.DeviceID != PCI_DEV_RZ1000 && Controller->Pci.DeviceID != PCI_DEV_RZ1001)
51 return STATUS_NO_MATCH;
52
53 Status = PciIdeCreateChannelData(Controller, 0);
54 if (!NT_SUCCESS(Status))
55 return Status;
56
57 Controller->Start = PcTechControllerStart;
58
59 for (i = 0; i < Controller->MaxChannels; ++i)
60 {
61 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
62
63 ChanData->ChanInfo &= ~CHANNEL_FLAG_IO32;
64 }
65
66 return STATUS_SUCCESS;
67}
#define PCI_DEV_RZ1001
Definition: pctech.c:15
static VOID PcTechControllerStart(_In_ PATA_CONTROLLER Controller)
Definition: pctech.c:29
#define PCI_DEV_RZ1000
Definition: pctech.c:14

Referenced by PciIdeGetControllerProperties().

◆ Sil680GetControllerProperties()

NTSTATUS Sil680GetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 214 of file sil680.c.

216{
218 ULONG i;
219
220 PAGED_CODE();
221 ASSERT(Controller->Pci.VendorID == PCI_VEN_CMD);
222
223 if (Controller->Pci.VendorID != PCI_DEV_SIL0680)
224 return STATUS_NO_MATCH;
225
226 Status = PciIdeCreateChannelData(Controller, 0);
227 if (!NT_SUCCESS(Status))
228 return Status;
229
230 for (i = 0; i < Controller->MaxChannels; ++i)
231 {
232 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
234
236 ChanData->SetTransferMode = Sil680SetTransferMode;
237 ChanData->TransferModeSupported = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 6);
238
239 /* Check for 80-conductor cable */
240 Config = PciRead8(Controller, SIL_REG_CFG(i));
241 if (!(Config & SIL_CFG_CABLE_80))
242 {
243 INFO("CH %lu: BIOS detected 40-conductor cable\n", ChanData->Channel);
244 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
245 }
246 }
247
249}
#define SIL_CFG_CABLE_80
Definition: sil680.c:25
#define SIL_REG_CFG(Channel)
Definition: sil680.c:18
static BOOLEAN Sil680CheckInterrupt(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: sil680.c:202
static VOID Sil680SetTransferMode(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
Definition: sil680.c:71
#define PCI_DEV_SIL0680
Definition: sil680.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476

Referenced by PciIdeGetControllerProperties().

◆ SvwHasUdmaCable()

BOOLEAN SvwHasUdmaCable ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  Channel 
)

Definition at line 213 of file svw_pata.c.

216{
217 UCHAR UdmaModeReg;
218
219 PAGED_CODE();
220
221 UdmaModeReg = PciRead8(Controller, SVW_REG_UDMA_MODE + Channel);
222
223 /* Check mode settings, see if UDMA3 or higher mode is active */
224 return ((UdmaModeReg & 0x07) > 2) || ((UdmaModeReg & 0x70) > 0x20);
225}
#define SVW_REG_UDMA_MODE
Definition: svw_pata.c:31

Referenced by AtiGetControllerProperties(), and SvwPataGetControllerProperties().

◆ SvwPataGetControllerProperties()

NTSTATUS SvwPataGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 288 of file svw_pata.c.

290{
292 ULONG i, SupportedMode;
293 BOOLEAN No64KDma = FALSE;
294
295 PAGED_CODE();
296 ASSERT(Controller->Pci.VendorID == PCI_VEN_SERVERWORKS);
297
298 switch (Controller->Pci.DeviceID)
299 {
300 case PCI_DEV_OSB4_IDE:
301 /* UDMA is supported but its use is discouraged */
302 SupportedMode = PIO_ALL | MWDMA_ALL;
303
304 No64KDma = TRUE;
305 break;
306
307 case PCI_DEV_CSB5_IDE:
308 if (Controller->Pci.RevisionID < 0x92)
309 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 4);
310 else
311 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 5);
312 Controller->Flags |= CTRL_FLAG_DMA_INTERRUPT;
313 break;
314
316 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 4);
317 Controller->MaxChannels = 1;
318 break;
319
320 case PCI_DEV_CSB6_IDE:
321 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 5);
322 break;
323
325 SupportedMode = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 5);
326 Controller->MaxChannels = 1;
327 No64KDma = TRUE;
328 break;
329
330 default:
331 return STATUS_NO_MATCH;
332 }
333
334 Status = PciIdeCreateChannelData(Controller, 0);
335 if (!NT_SUCCESS(Status))
336 return Status;
337
338 Controller->Start = SvwPataControllerStart;
339
340 for (i = 0; i < Controller->MaxChannels; ++i)
341 {
342 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
343
344 if (No64KDma)
345 ChanData->MaximumTransferLength = PCIIDE_PRD_LIMIT - 0x4000;
346
347 ChanData->SetTransferMode = SvwSetTransferMode;
348 ChanData->TransferModeSupported = SupportedMode;
349
350 /* Check for 80-conductor cable */
351 if ((ChanData->TransferModeSupported & UDMA_80C_ALL) && !SvwHasUdmaCable(Controller, i))
352 {
353 INFO("CH %lu: BIOS hasn't selected mode faster than UDMA 2, "
354 "assume 40-conductor cable\n",
355 ChanData->Channel);
356 ChanData->TransferModeSupported &= ~UDMA_80C_ALL;
357 }
358 }
359
360 return STATUS_SUCCESS;
361}
#define PCIIDE_PRD_LIMIT
Definition: pata.h:215
#define PCI_DEV_CSB5_IDE
Definition: svw_pata.c:20
#define PCI_DEV_HT1000_IDE
Definition: svw_pata.c:23
#define PCI_DEV_CSB6_IDE
Definition: svw_pata.c:21
static VOID SvwPataControllerStart(_In_ PATA_CONTROLLER Controller)
Definition: svw_pata.c:264
#define PCI_DEV_OSB4_IDE
Definition: svw_pata.c:19
#define PCI_DEV_CSB6_IDE_THIRD
Definition: svw_pata.c:22

Referenced by PciIdeGetControllerProperties().

◆ SvwSataGetControllerProperties()

NTSTATUS SvwSataGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 215 of file svw_sata.c.

217{
219 ULONG i, HwFlags;
220 PUCHAR IoBase;
221
222 PAGED_CODE();
223 ASSERT(Controller->Pci.VendorID == PCI_VEN_SERVERWORKS);
224
225 for (i = 0; i < RTL_NUMBER_OF(SvwSataControllerList); ++i)
226 {
227 HwFlags = SvwSataControllerList[i].Flags;
228
229 if (Controller->Pci.DeviceID == SvwSataControllerList[i].DeviceID)
230 break;
231 }
233 return STATUS_NO_MATCH;
234
235 if (HwFlags & HW_FLAGS_8_PORTS)
236 Controller->MaxChannels = 8;
237 else
238 Controller->MaxChannels = 4;
239
240 Controller->Flags |= CTRL_FLAG_MANUAL_RES;
241
242 Status = PciIdeCreateChannelData(Controller, 0);
243 if (!NT_SUCCESS(Status))
244 return Status;
245
246 IoBase = AtaCtrlPciMapBar(Controller, SvwSataGetIoBarIndex(Controller), 0);
247 if (!IoBase)
249
250 /*
251 * Errata: Set SICR registers to turn off waiting for a status message
252 * before sending FIS, fixes some issues with Seagate hard drives.
253 */
254 WRITE_REGISTER_ULONG((PULONG)(IoBase + 0x80),
255 READ_REGISTER_ULONG((PULONG)(IoBase + 0x80)) & ~0x00040000);
256
257 /* Clear interrupts */
258 WRITE_REGISTER_ULONG((PULONG)(IoBase + 0x44), 0xFFFFFFFF);
259 WRITE_REGISTER_ULONG((PULONG)(IoBase + 0x88), 0);
260
261 for (i = 0; i < Controller->MaxChannels; ++i)
262 {
263 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
264
265 ChanData->TransferModeSupported = SATA_ALL;
266 ChanData->SetTransferMode = SataSetTransferMode;
267
268 if (HwFlags & HW_FLAGS_NO_ATAPI_DMA)
269 ChanData->ChanInfo |= CHANNEL_FLAG_NO_ATAPI_DMA;
270
271 /*
272 * Errata: Enable the DMA engine before sending the drive command
273 * to avoid data corruption.
274 */
275 ChanData->ChanInfo |= CHANNEL_FLAG_DMA_BEFORE_CMD;
276
277 ChanData->ChanInfo |= CHANNEL_FLAG_NO_SLAVE;
278 ChanData->ReadStatus = SvwSataReadStatus;
282 ChanData->ScrRead = SvwSataScrRead;
283 ChanData->ScrWrite = SvwSataScrWrite;
284
285 SvwSataParseResources(ChanData, IoBase, i);
286 }
287
288 return STATUS_SUCCESS;
289}
#define READ_REGISTER_ULONG(r)
Definition: arm.h:10
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:713
#define CHANNEL_FLAG_NO_ATAPI_DMA
Definition: pciidex.h:278
#define CHANNEL_FLAG_DMA_BEFORE_CMD
Definition: pciidex.h:279
PVOID AtaCtrlPciMapBar(_In_ PATA_CONTROLLER Controller, _In_range_(0, PCI_TYPE0_ADDRESSES) ULONG Index, _In_ ULONG MinimumIoLength)
Definition: fdo.c:249
PCHANNEL_WRITE_SCR ScrWrite
Definition: pciidex.h:314
PCHANNEL_READ_SCR ScrRead
Definition: pciidex.h:313
static VOID SvwSataSaveTaskFile(_In_ PCHANNEL_DATA_PATA ChanData, _Inout_ PATA_DEVICE_REQUEST Request)
Definition: svw_sata.c:158
static VOID SvwSataLoadTaskFile(_In_ PCHANNEL_DATA_PATA ChanData, _In_ PATA_DEVICE_REQUEST Request)
Definition: svw_sata.c:124
static VOID SvwSataParseResources(_Inout_ PCHANNEL_DATA_PATA ChanData, _In_ PUCHAR IoBase, _In_ ULONG PortIndex)
Definition: svw_sata.c:193
static PCIIDEX_PAGED_DATA const struct @1176 SvwSataControllerList[]
static BOOLEAN SvwSataScrWrite(_In_ PCHANNEL_DATA_PATA ChanData, _In_ SATA_SCR_REGISTER Register, _In_ ULONG PortNumber, _In_ ULONG Value)
Definition: svw_sata.c:73
static BOOLEAN SvwSataScrRead(_In_ PCHANNEL_DATA_PATA ChanData, _In_ SATA_SCR_REGISTER Register, _In_ ULONG PortNumber, _In_ PULONG Result)
Definition: svw_sata.c:56
#define HW_FLAGS_NO_ATAPI_DMA
Definition: svw_sata.c:34
static UCHAR SvwSataReadStatus(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: svw_sata.c:112
#define HW_FLAGS_8_PORTS
Definition: svw_sata.c:33
static ULONG SvwSataGetIoBarIndex(_In_ PATA_CONTROLLER Controller)
Definition: svw_sata.c:91
static BOOLEAN SvwSataCheckInterrupt(_In_ PCHANNEL_DATA_PATA ChanData)
Definition: svw_sata.c:99
uint32_t * PULONG
Definition: typedefs.h:59

Referenced by PciIdeGetControllerProperties().

◆ ToshibaGetControllerProperties()

NTSTATUS ToshibaGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 102 of file toshiba.c.

104{
106 ULONG i;
107
108 PAGED_CODE();
109 ASSERT(Controller->Pci.VendorID == PCI_VEN_TOSHIBA);
110
111 if (Controller->Pci.DeviceID != PCI_DEV_PICCOLO_1 &&
112 Controller->Pci.DeviceID != PCI_DEV_PICCOLO_2 &&
113 Controller->Pci.DeviceID != PCI_DEV_PICCOLO_3 &&
114 Controller->Pci.DeviceID != PCI_DEV_PICCOLO_5)
115 {
116 return STATUS_NO_MATCH;
117 }
118
119 Controller->MaxChannels = 1;
120
121 Status = PciIdeCreateChannelData(Controller, 0);
122 if (!NT_SUCCESS(Status))
123 return Status;
124
125 for (i = 0; i < Controller->MaxChannels; ++i)
126 {
127 PCHANNEL_DATA_PATA ChanData = Controller->Channels[i];
128
129 ChanData->TransferModeSupported = PIO_ALL | MWDMA_ALL | UDMA_MODES(0, 2);
130 ChanData->SetTransferMode = ToshibaSetTransferMode;
131 }
132
133 return STATUS_SUCCESS;
134}
#define PCI_DEV_PICCOLO_3
Definition: toshiba.c:21
#define PCI_DEV_PICCOLO_5
Definition: toshiba.c:22
#define PCI_DEV_PICCOLO_1
Definition: toshiba.c:19
static VOID ToshibaSetTransferMode(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel, _In_reads_(MAX_IDE_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
Definition: toshiba.c:58
#define PCI_DEV_PICCOLO_2
Definition: toshiba.c:20

Referenced by PciIdeGetControllerProperties().

◆ ViaClampTimings()

VOID ViaClampTimings ( _Inout_ PATA_TIMING  Timing)

Definition at line 165 of file via.c.

167{
168 Timing->AddressSetup = CLAMP_TIMING(Timing->AddressSetup, 1, 4) - 1;
169 Timing->CmdRecovery = CLAMP_TIMING(Timing->CmdRecovery, 1, 16) - 1;
170 Timing->CmdActive = CLAMP_TIMING(Timing->CmdActive, 1, 16) - 1;
171 Timing->DataRecovery = CLAMP_TIMING(Timing->DataRecovery, 1, 16) - 1;
172 Timing->DataActive = CLAMP_TIMING(Timing->DataActive, 1, 16) - 1;
173}
FORCEINLINE ATATIM CLAMP_TIMING(_In_ ATATIM Value, _In_ ATATIM Minimum, _In_ ATATIM Maximum)
Definition: pata.h:236

Referenced by AmdSetTransferMode(), Via6421SetTransferMode(), and ViaSetTransferMode().

◆ ViaGetControllerProperties()

NTSTATUS ViaGetControllerProperties ( _Inout_ PATA_CONTROLLER  Controller)

Definition at line 859 of file via.c.

861{
863 ULONG i, HwFlags;
864
865 PAGED_CODE();
866 ASSERT(Controller->Pci.VendorID == PCI_VEN_VIA);
867
868 if (Controller->Pci.DeviceID == PCI_DEV_VT6421A_RAID)
869 {
870 return Via6421GetControllerProperties(Controller);
871 }
872 else if ((Controller->Pci.DeviceID == PCI_DEV_CX700M2_IDE_SATA) ||
873 (Controller->Pci.DeviceID == PCI_DEV_CX700M2_IDE_SATA_RAID))
874 {
875 return ViaCx700GetControllerProperties(Controller);
876 }
877
878 for (i = 0; i < RTL_NUMBER_OF(ViaControllerList); ++i)
879 {
880 HwFlags = ViaControllerList[i].Flags;
881
882 if (Controller->Pci.DeviceID == ViaControllerList[i].DeviceID)
883 break;
884 }
886 return STATUS_NO_MATCH;
887
888 if (HwFlags & HW_FLAGS_SINGLE_CHAN)
889 Controller->MaxChannels = 1;
890
891 Status = PciIdeCreateChannelData(Controller, 0);
892 if (!NT_SUCCESS(Status))
893 return Status;
894
895 if (GET_TYPE(HwFlags) == TYPE_SATA)
896 return ViaSataGetControllerProperties(Controller, HwFlags);
897
898 return ViaPataGetControllerProperties(Controller, HwFlags);
899}
static NTSTATUS Via6421GetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: via.c:536
static NTSTATUS ViaCx700GetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: via.c:592
#define PCI_DEV_CX700M2_IDE_SATA_RAID
Definition: via.c:26
#define PCI_DEV_CX700M2_IDE_SATA
Definition: via.c:25
static NTSTATUS ViaPataGetControllerProperties(_Inout_ PATA_CONTROLLER Controller, _In_ ULONG HwFlags)
Definition: via.c:721
#define GET_TYPE(Flags)
Definition: via.c:69
#define PCI_DEV_VT6421A_RAID
Definition: via.c:24
#define HW_FLAGS_SINGLE_CHAN
Definition: via.c:58
static NTSTATUS ViaSataGetControllerProperties(_Inout_ PATA_CONTROLLER Controller, _In_ ULONG HwFlags)
Definition: via.c:826
static PCIIDEX_PAGED_DATA const struct @1177 ViaControllerList[]
#define TYPE_SATA
Definition: via.c:67

Referenced by PciIdeGetControllerProperties().

Variable Documentation

◆ AtaAhciAllocateSlot

CHANNEL_ALLOCATE_SLOT AtaAhciAllocateSlot

Definition at line 628 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaAhciEnableInterrupts

CHANNEL_ENABLE_INTERRUPTS AtaAhciEnableInterrupts

Definition at line 591 of file pciidex.h.

Referenced by AtaAhciCreateChannelData().

◆ AtaAhciEnumerateChannel

CHANNEL_ENUMERATE_CHANNEL AtaAhciEnumerateChannel

Definition at line 592 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaAhciHbaIsr

KSERVICE_ROUTINE AtaAhciHbaIsr

Definition at line 629 of file pciidex.h.

Referenced by AhciGetControllerProperties().

◆ AtaAhciIdentifyDevice

CHANNEL_IDENTIFY_DEVICE AtaAhciIdentifyDevice

Definition at line 593 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaAhciPrepareIo

CHANNEL_PREPARE_IO AtaAhciPrepareIo

Definition at line 626 of file pciidex.h.

Referenced by AtaAhciCreateChannelData().

◆ AtaAhciPreparePrdTable

CHANNEL_PREPARE_PRD_TABLE AtaAhciPreparePrdTable

Definition at line 627 of file pciidex.h.

Referenced by AtaAhciCreateChannelData().

◆ AtaAhciResetChannel

CHANNEL_RESET_CHANNEL AtaAhciResetChannel

Definition at line 594 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaAhciStartIo

CHANNEL_START_IO AtaAhciStartIo

Definition at line 625 of file pciidex.h.

Referenced by AtaAhciCreateChannelData().

◆ AtaCtrlAbortChannel

CHANNEL_ABORT_CHANNEL AtaCtrlAbortChannel

Definition at line 465 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaCtrlAttachChannel

CONTROLLER_ATTACH_CHANNEL AtaCtrlAttachChannel

Definition at line 455 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaCtrlDowngradeInterfaceSpeed

CHANNEL_DOWNGRADE_INTERFACE_SPEED AtaCtrlDowngradeInterfaceSpeed

Definition at line 464 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaCtrlGetInitTaskFile

CHANNEL_GET_INIT_TASK_FILE AtaCtrlGetInitTaskFile

Definition at line 461 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaCtrlSetDeviceData

CHANNEL_SET_DEVICE_DATA AtaCtrlSetDeviceData

Definition at line 458 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ AtaCtrlSetTransferMode

CHANNEL_SET_MODE AtaCtrlSetTransferMode

Definition at line 463 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ BusNumber

_In_ ULONG BusNumber

Definition at line 65 of file pciidex.h.

Referenced by AcpiHwGetPciDeviceInfo(), AcpiHwProcessPciList(), AddControllers(), AllocateAddressMapping(), AtapiFindDev(), AtapiFindListedDev(), BootTranslateBusAddress(), Bus_PDO_QueryResources(), CmpInitializeRegistryNode(), CmpSetupConfigurationTree(), CODE_SEG(), ConfigCallback(), FindBootDisplay(), FindBootDisplayFromLoaderARCTree(), FindBrokenController(), GetArcComponentInterface(), HalAssignSlotResources(), HalGetBusData(), HalGetBusDataByOffset(), HalGetInterruptVector(), HaliHandlerForBus(), HaliHandlerForConfigSpace(), HaliPciInterfaceReadConfig(), HaliReferenceHandlerForBus(), HaliReferenceHandlerForConfigSpace(), HaliRegisterBusHandler(), HaliTranslateBusAddress(), HalpAllocateBusHandler(), HalpAssignSlotResources(), HalpFindMatchingDebuggingDevice(), HalpGetCmosData(), HalpSetCmosData(), HalSetBusData(), HalSetBusDataByOffset(), HalTranslateBusAddress(), InitializeConfiguration(), IntelPciBridgeErrataMatch(), IntVideoPortEnumBusCallback(), IntVideoPortEnumBuses(), IntVideoPortFindAdapter(), IoQueryDeviceDescription(), IoTranslateBusAddress(), KdpSysReadBusData(), KdpSysReadIoSpace(), KdpSysWriteBusData(), KdpSysWriteIoSpace(), NdisOverrideBusNumber(), OslIsPciDevicePresent(), Pc98HwDetect(), PcHwDetect(), PciAllocateCmResourceList(), PciAllocateIoRequirementsList(), PciAssignSlotResources(), PciCacheLegacyDeviceRouting(), PciFindDevice(), PciFindPdoByLocation(), PciIdeXFdoQueryInterface(), PciIsDebuggingDevice(), PciLocateKdDevices(), PciTranslateBusAddress(), RegistryInitAdapterKey(), ScsiPortGetBusDataByOffset(), SpiGetPciConfigData(), SvwOsb4PciBridgeInit(), UefiHwDetect(), ViaQuerySouthBridgeInformation(), VidInitialize(), and XboxHwDetect().

◆ Channel

_In_ ULONG Channel

Definition at line 74 of file pciidex.h.

Referenced by AmdEnablePostedWriteBuffer(), AmdSetTransferMode(), AtapiCheckInterrupt__(), AtapiDmaDone(), AtapiDmaInit(), AtapiDmaStart(), AtapiInterrupt__(), AtapiResetController__(), BlasterCleanup(), ChanMgrChannelDestroy(), ChanMgrCloseChannel(), ChanMgrCloseChannelsWithFileObject(), ChanMgrCreateChannel(), ChanMgrGetByHandle(), ChanMgrGetChannelByName(), ChanMgrGetChannelCount(), ChanMgrGetChannelIndex(), ChanMgrIsUniqueName(), ChanMgrReleaseChannel(), ChannelClearRedrawEvent(), ChannelClose(), ChannelCreate(), ChannelDereferenceHandles(), ChannelDestroy(), ChannelGetApplicationType(), ChannelGetDescription(), ChannelGetFlags(), ChannelGetIndex(), ChannelGetName(), ChannelGetStatus(), ChannelHasNewIBufferData(), ChannelHasNewOBufferData(), ChannelHasRedrawEvent(), ChannelIBufferLength(), ChannelInitializeVTable(), ChannelIRead(), ChannelIReadLast(), ChannelIsActive(), ChannelIsClosed(), ChannelIsEqual(), ChannelIWrite(), ChannelOFlush(), ChannelOWrite(), ChannelSetDescription(), ChannelSetLockEvent(), ChannelSetName(), ChannelSetRedrawEvent(), ChannelSetStatus(), CmdChannelEnabledTest(), CmdSetTransferMode(), ConMgrAdvanceCurrentChannel(), ConMgrChannelClose(), ConMgrIsSacChannel(), ConMgrIsWriteEnabled(), ConMgrResetCurrentChannel(), ConMgrSetCurrentChannel(), DmaRequest(), EventDescCreate(), EventDescSetChannel(), FindDevices(), FindDmaDescriptor(), IdeMediaStatus(), IntelPiixChooseDeviceSpeed(), IntelPiixLegacySetTransferMode(), IntelPiixSetTransferMode(), IopFindDmaResource(), IsaConvertDmaRequirement(), IssueIdentify(), MMixerGetChannelCountLegacy(), MMixerSetGetControlDetails(), MMixerSetGetVolumeControlDetails(), MPU401Cleanup(), PciIdeChannelEnabled(), PciIdeGenericSetTransferMode(), PciIdeGetChannelState(), PciIdeXChannelState(), PciIdeXFdoQueryBusRelations(), PciIdeXGetChannelState(), PitDecrementCount(), PitGetReloadValue(), PitInitCounter(), PitLatchChannelCount(), PitLatchChannelStatus(), PitReadData(), PitSetGate(), PitSetOut(), PitSetOutFunction(), PitWriteCommand(), PitWriteData(), RawChannelCreate(), RawChannelDestroy(), RawChannelGetIBufferIndex(), RawChannelIBufferIsFull(), RawChannelIBufferLength(), RawChannelIRead(), RawChannelIReadLast(), RawChannelIWrite(), RawChannelOEcho(), RawChannelOFlush(), RawChannelORead(), RawChannelOWrite(), RawChannelOWrite2(), RawChannelSetIBufferIndex(), SataSetTransferMode(), SetDriveParameters(), Sil680SetTransferMode(), SvwChooseDeviceSpeed(), SvwHasUdmaCable(), SvwSetTransferMode(), ToshibaSetTransferMode(), UniataAhciStatus(), VDDQueryDMA(), VDDSetDMA(), Via6421SetTransferMode(), ViaSataSetTransferMode(), ViaSetTransferMode(), VTUTF8ChannelAnsiDispatch(), VTUTF8ChannelAssertCursor(), VTUTF8ChannelConsumeEscapeSequence(), VTUTF8ChannelCreate(), VTUTF8ChannelDestroy(), VTUTF8ChannelGetIBufferIndex(), VTUTF8ChannelIBufferIsFull(), VTUTF8ChannelIBufferLength(), VTUTF8ChannelIRead(), VTUTF8ChannelIReadLast(), VTUTF8ChannelIWrite(), VTUTF8ChannelOEcho(), VTUTF8ChannelOFlush(), VTUTF8ChannelOInit(), VTUTF8ChannelOWrite(), VTUTF8ChannelOWrite2(), VTUTF8ChannelProcessAttributes(), and VTUTF8ChannelSetIBufferIndex().

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 509 of file pciidex.h.

◆ InitSafeBootMode

NTSYSAPI ULONG InitSafeBootMode
extern

Definition at line 71 of file init.c.

◆ PataAllocateSlot

CHANNEL_ALLOCATE_SLOT PataAllocateSlot

Definition at line 698 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ PataChannelIsr

KSERVICE_ROUTINE PataChannelIsr

Definition at line 702 of file pciidex.h.

Referenced by PciIdeConnectInterrupt().

◆ PataEnumerateChannel

CHANNEL_ENUMERATE_CHANNEL PataEnumerateChannel

Definition at line 689 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ PataIdentifyDevice

CHANNEL_IDENTIFY_DEVICE PataIdentifyDevice

Definition at line 690 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ PataLoadTaskFile

CHANNEL_LOAD_TASK_FILE PataLoadTaskFile

Definition at line 705 of file pciidex.h.

Referenced by PciIdeCreateChannelData().

◆ PataPollingTimerDpc

KDEFERRED_ROUTINE PataPollingTimerDpc

Definition at line 708 of file pciidex.h.

Referenced by PciIdeCreateChannelData().

◆ PataPrepareIo

CHANNEL_PREPARE_IO PataPrepareIo

Definition at line 700 of file pciidex.h.

Referenced by IntelPiixLegacyPrepareIo(), and PciIdeCreateChannelData().

◆ PataReadStatus

CHANNEL_READ_STATUS PataReadStatus

Definition at line 707 of file pciidex.h.

Referenced by PciIdeCreateChannelData().

◆ PataResetChannel

CHANNEL_RESET_CHANNEL PataResetChannel

Definition at line 688 of file pciidex.h.

Referenced by PciIdeXQueryPciIdeInterface().

◆ PataSaveTaskFile

CHANNEL_SAVE_TASK_FILE PataSaveTaskFile

Definition at line 706 of file pciidex.h.

Referenced by PciIdeCreateChannelData().

◆ PataStartIo

CHANNEL_START_IO PataStartIo

Definition at line 701 of file pciidex.h.

Referenced by PciIdeCreateChannelData().

◆ PciConfig

◆ PciIdeAttachChannel

CONTROLLER_ATTACH_CHANNEL_EX PciIdeAttachChannel

Definition at line 636 of file pciidex.h.

Referenced by PciIdeXFdoStartDevice().

◆ PciIdeChannelIsr

KSERVICE_ROUTINE PciIdeChannelIsr

Definition at line 703 of file pciidex.h.

Referenced by PciIdeConnectInterrupt().

◆ PciIdeCheckInterrupt

CHANNEL_CHECK_INTERRUPT PciIdeCheckInterrupt

Definition at line 704 of file pciidex.h.

Referenced by PciIdeControllerInitDma().

◆ PciIdePreparePrdTable

CHANNEL_PREPARE_PRD_TABLE PciIdePreparePrdTable

Definition at line 699 of file pciidex.h.

Referenced by PciIdeCreateChannelData().

◆ PciIdeXAddDevice

DRIVER_ADD_DEVICE PciIdeXAddDevice

Definition at line 515 of file pciidex.h.

Referenced by PciIdeXInitialize().

◆ PciIdeXFdoRemoveDevice

CONTROLLER_PNP_REMOVE_DEVICE PciIdeXFdoRemoveDevice

Definition at line 471 of file pciidex.h.

Referenced by PciIdeXFdoDispatchPnp(), and PciIdeXInitialize().

◆ PciIdeXFdoStartDevice

CONTROLLER_PNP_START_DEVICE PciIdeXFdoStartDevice

Definition at line 468 of file pciidex.h.

Referenced by PciIdeXFdoDispatchPnp(), and PciIdeXInitialize().

◆ PciIdeXPdoCompletionRoutine

IO_COMPLETION_ROUTINE PciIdeXPdoCompletionRoutine

Definition at line 521 of file pciidex.h.

Referenced by _IRQL_requires_max_(), and PciIdeXPnpRepeatRequest().

◆ PciIdeXUnload

DRIVER_UNLOAD PciIdeXUnload

Definition at line 512 of file pciidex.h.

Referenced by PciIdeXInitialize().

◆ PciSlot

◆ SataSetTransferMode

◆ SvwSetTransferMode

CHANNEL_SET_MODE_EX SvwSetTransferMode

Definition at line 813 of file pciidex.h.

Referenced by AtiGetControllerProperties(), and SvwPataGetControllerProperties().