ReactOS 0.4.17-dev-116-ga4b6fe9
ide.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for ide.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _IDENTIFY_DATA
 
struct  _EXTENDED_IDENTIFY_DATA
 
struct  _PCIIDE_TRANSFER_MODE_SELECT
 
struct  _IDE_CONTROLLER_PROPERTIES
 

Macros

#define MAX_IDE_CHANNEL   2
 
#define MAX_IDE_LINE   2
 
#define MAX_IDE_DEVICE   2
 
#define PIO_MODE0   (1 << 0)
 
#define PIO_MODE1   (1 << 1)
 
#define PIO_MODE2   (1 << 2)
 
#define PIO_MODE3   (1 << 3)
 
#define PIO_MODE4   (1 << 4)
 
#define SWDMA_MODE0   (1 << 5)
 
#define SWDMA_MODE1   (1 << 6)
 
#define SWDMA_MODE2   (1 << 7)
 
#define MWDMA_MODE0   (1 << 8)
 
#define MWDMA_MODE1   (1 << 9)
 
#define MWDMA_MODE2   (1 << 10)
 
#define UDMA_MODE0   (1 << 11)
 
#define UDMA_MODE1   (1 << 12)
 
#define UDMA_MODE2   (1 << 13)
 
#define UDMA_MODE3   (1 << 14)
 
#define UDMA_MODE4   (1 << 15)
 
#define UDMA_MODE5   (1 << 16)
 
#define UDMA_MODE6   (1 << 17)
 

Typedefs

typedef struct _IDENTIFY_DATA IDENTIFY_DATA
 
typedef struct _IDENTIFY_DATAPIDENTIFY_DATA
 
typedef struct _EXTENDED_IDENTIFY_DATA EXTENDED_IDENTIFY_DATA
 
typedef struct _EXTENDED_IDENTIFY_DATAPEXTENDED_IDENTIFY_DATA
 
typedef struct _PCIIDE_TRANSFER_MODE_SELECT PCIIDE_TRANSFER_MODE_SELECT
 
typedef struct _PCIIDE_TRANSFER_MODE_SELECTPPCIIDE_TRANSFER_MODE_SELECT
 
typedef IDE_CHANNEL_STATE(NTAPIPCIIDE_CHANNEL_ENABLED) (_In_ PVOID DeviceExtension, _In_ ULONG Channel)
 
typedef BOOLEAN(NTAPIPCIIDE_SYNC_ACCESS_REQUIRED) (_In_ PVOID DeviceExtension)
 
typedef NTSTATUS(NTAPIPCIIDE_TRANSFER_MODE_SELECT_FUNC) (_In_ PVOID DeviceExtension, _Inout_ PPCIIDE_TRANSFER_MODE_SELECT XferMode)
 
typedef ULONG(NTAPIPCIIDE_USEDMA_FUNC) (_In_ PVOID DeviceExtension, _In_ PUCHAR CdbCommand, _In_ PUCHAR Slave)
 
typedef NTSTATUS(NTAPIPCIIDE_UDMA_MODES_SUPPORTED) (_In_ IDENTIFY_DATA IdentifyData, _Out_ PULONG BestXferMode, _Out_ PULONG CurrentXferMode)
 
typedef struct _IDE_CONTROLLER_PROPERTIES IDE_CONTROLLER_PROPERTIES
 
typedef struct _IDE_CONTROLLER_PROPERTIESPIDE_CONTROLLER_PROPERTIES
 
typedef NTSTATUS(NTAPIPCONTROLLER_PROPERTIES) (_In_ PVOID DeviceExtension, _In_ PIDE_CONTROLLER_PROPERTIES ControllerProperties)
 

Enumerations

enum  IDE_CHANNEL_STATE { ChannelDisabled = 0 , ChannelEnabled , ChannelStateUnknown }
 

Functions

NTSTATUS NTAPI PciIdeXInitialize (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath, _In_ PCONTROLLER_PROPERTIES HwGetControllerProperties, _In_ ULONG ExtensionSize)
 
NTSTATUS NTAPI PciIdeXGetBusData (_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
 
NTSTATUS NTAPI PciIdeXSetBusData (_In_ PVOID DeviceExtension, _In_reads_bytes_(BufferLength) PVOID Buffer, _In_reads_bytes_(BufferLength) PVOID DataMask, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
 

Macro Definition Documentation

◆ MAX_IDE_CHANNEL

#define MAX_IDE_CHANNEL   2

Definition at line 30 of file ide.h.

◆ MAX_IDE_DEVICE

#define MAX_IDE_DEVICE   2

Definition at line 32 of file ide.h.

◆ MAX_IDE_LINE

#define MAX_IDE_LINE   2

Definition at line 31 of file ide.h.

◆ MWDMA_MODE0

#define MWDMA_MODE0   (1 << 8)

Definition at line 287 of file ide.h.

◆ MWDMA_MODE1

#define MWDMA_MODE1   (1 << 9)

Definition at line 288 of file ide.h.

◆ MWDMA_MODE2

#define MWDMA_MODE2   (1 << 10)

Definition at line 289 of file ide.h.

◆ PIO_MODE0

#define PIO_MODE0   (1 << 0)

Definition at line 277 of file ide.h.

◆ PIO_MODE1

#define PIO_MODE1   (1 << 1)

Definition at line 278 of file ide.h.

◆ PIO_MODE2

#define PIO_MODE2   (1 << 2)

Definition at line 279 of file ide.h.

◆ PIO_MODE3

#define PIO_MODE3   (1 << 3)

Definition at line 280 of file ide.h.

◆ PIO_MODE4

#define PIO_MODE4   (1 << 4)

Definition at line 281 of file ide.h.

◆ SWDMA_MODE0

#define SWDMA_MODE0   (1 << 5)

Definition at line 283 of file ide.h.

◆ SWDMA_MODE1

#define SWDMA_MODE1   (1 << 6)

Definition at line 284 of file ide.h.

◆ SWDMA_MODE2

#define SWDMA_MODE2   (1 << 7)

Definition at line 285 of file ide.h.

◆ UDMA_MODE0

#define UDMA_MODE0   (1 << 11)

Definition at line 291 of file ide.h.

◆ UDMA_MODE1

#define UDMA_MODE1   (1 << 12)

Definition at line 292 of file ide.h.

◆ UDMA_MODE2

#define UDMA_MODE2   (1 << 13)

Definition at line 293 of file ide.h.

◆ UDMA_MODE3

#define UDMA_MODE3   (1 << 14)

Definition at line 294 of file ide.h.

◆ UDMA_MODE4

#define UDMA_MODE4   (1 << 15)

Definition at line 295 of file ide.h.

◆ UDMA_MODE5

#define UDMA_MODE5   (1 << 16)

Definition at line 296 of file ide.h.

◆ UDMA_MODE6

#define UDMA_MODE6   (1 << 17)

Definition at line 297 of file ide.h.

Typedef Documentation

◆ EXTENDED_IDENTIFY_DATA

◆ IDE_CONTROLLER_PROPERTIES

◆ IDENTIFY_DATA

◆ PCIIDE_CHANNEL_ENABLED

typedef IDE_CHANNEL_STATE(NTAPI * PCIIDE_CHANNEL_ENABLED) (_In_ PVOID DeviceExtension, _In_ ULONG Channel)

Definition at line 202 of file ide.h.

◆ PCIIDE_SYNC_ACCESS_REQUIRED

typedef BOOLEAN(NTAPI * PCIIDE_SYNC_ACCESS_REQUIRED) (_In_ PVOID DeviceExtension)

Definition at line 207 of file ide.h.

◆ PCIIDE_TRANSFER_MODE_SELECT

◆ PCIIDE_TRANSFER_MODE_SELECT_FUNC

typedef NTSTATUS(NTAPI * PCIIDE_TRANSFER_MODE_SELECT_FUNC) (_In_ PVOID DeviceExtension, _Inout_ PPCIIDE_TRANSFER_MODE_SELECT XferMode)

Definition at line 211 of file ide.h.

◆ PCIIDE_UDMA_MODES_SUPPORTED

typedef NTSTATUS(NTAPI * PCIIDE_UDMA_MODES_SUPPORTED) (_In_ IDENTIFY_DATA IdentifyData, _Out_ PULONG BestXferMode, _Out_ PULONG CurrentXferMode)

Definition at line 222 of file ide.h.

◆ PCIIDE_USEDMA_FUNC

typedef ULONG(NTAPI * PCIIDE_USEDMA_FUNC) (_In_ PVOID DeviceExtension, _In_ PUCHAR CdbCommand, _In_ PUCHAR Slave)

Definition at line 216 of file ide.h.

◆ PCONTROLLER_PROPERTIES

typedef NTSTATUS(NTAPI * PCONTROLLER_PROPERTIES) (_In_ PVOID DeviceExtension, _In_ PIDE_CONTROLLER_PROPERTIES ControllerProperties)

Definition at line 244 of file ide.h.

◆ PEXTENDED_IDENTIFY_DATA

◆ PIDE_CONTROLLER_PROPERTIES

◆ PIDENTIFY_DATA

◆ PPCIIDE_TRANSFER_MODE_SELECT

Enumeration Type Documentation

◆ IDE_CHANNEL_STATE

Enumerator
ChannelDisabled 
ChannelEnabled 
ChannelStateUnknown 

Definition at line 195 of file ide.h.

196{
197 ChannelDisabled = 0,
IDE_CHANNEL_STATE
Definition: ide.h:196
@ ChannelDisabled
Definition: ide.h:197
@ ChannelStateUnknown
Definition: ide.h:199
@ ChannelEnabled
Definition: ide.h:198

Function Documentation

◆ PciIdeXGetBusData()

NTSTATUS NTAPI PciIdeXGetBusData ( _In_ PVOID  DeviceExtension,
_Out_writes_bytes_all_(BufferLength) PVOID  Buffer,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  BufferLength 
)

Definition at line 59 of file miniport.c.

64{
66 PATA_CONTROLLER Controller;
68
69 INFO("PciIdeXGetBusData(%p %p 0x%lx 0x%lx)\n",
70 DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
71
72 FdoExt = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
73 Controller = &FdoExt->Controller;
74
75 BytesRead = Controller->GetBusData(Controller->BusInterfaceContext,
77 Buffer,
78 ConfigDataOffset,
82
83 return STATUS_SUCCESS;
84}
Definition: bufpool.h:45
#define INFO
Definition: debug.h:89
#define STATUS_SUCCESS
Definition: shellext.h:65
PVOID BusInterfaceContext
Definition: pciidex.h:199
PGET_SET_DEVICE_DATA GetBusData
Definition: pciidex.h:198
ATA_CONTROLLER Controller
Definition: pciidex.h:395
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
_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_WHICHSPACE_CONFIG
Definition: iotypes.h:3646

Referenced by PciIdeGetControllerProperties(), and PciIdeXSetBusData().

◆ PciIdeXInitialize()

NTSTATUS NTAPI PciIdeXInitialize ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath,
_In_ PCONTROLLER_PROPERTIES  HwGetControllerProperties,
_In_ ULONG  ExtensionSize 
)

Definition at line 514 of file pciidex.c.

519{
522
523 PAGED_CODE();
524
525 INFO("PciIdeXInitialize(%p '%wZ' %p 0x%lx)\n",
526 DriverObject, RegistryPath, HwGetControllerProperties, ExtensionSize);
527
528 /* ReactOS-specific: Check for our legacy detection magic */
530 {
531#if defined(ATA_DETECT_LEGACY_DEVICES)
532 PPCIIDEX_LEGACY_CONTROLLER_INTERFACE ControllerInferface;
533
534 ControllerInferface = (PVOID)HwGetControllerProperties;
535 ControllerInferface->Version = PCIIDEX_INTERFACE_VERSION;
536 ControllerInferface->AddDevice = PciIdeXAddDeviceEx;
537 ControllerInferface->StartDevice = PciIdeXFdoStartDevice;
538 ControllerInferface->RemoveDevice = PciIdeXFdoRemoveDevice;
539
540 ExtensionSize = 0;
541#else
543#endif
544 }
545
548 sizeof(*DriverExtension),
550 if (!NT_SUCCESS(Status))
551 return Status;
552
554 DriverExtension->MiniControllerExtensionSize = ExtensionSize;
555 DriverExtension->HwGetControllerProperties = HwGetControllerProperties;
556
560 DriverObject->DriverExtension->AddDevice = PciIdeXAddDevice;
561 DriverObject->DriverUnload = PciIdeXUnload;
562
563 /* Create a directory to hold the driver's device objects */
565
566 return STATUS_SUCCESS;
567}
#define PAGED_CODE()
#define PCIIDEX_INTERFACE_VERSION
Definition: ata_shared.h:12
#define PCIIDEX_GET_CONTROLLER_INTERFACE_SIGNATURE
Definition: ata_shared.h:481
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSTATUS NTAPI PciIdeXDispatchPower(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: power.c:53
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI IoAllocateDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress, IN ULONG DriverObjectExtensionSize, OUT PVOID *DriverObjectExtension)
Definition: driver.c:1838
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
static NTSTATUS PciIdeXAddDeviceEx(_In_ PDRIVER_OBJECT DriverObject, _In_ PDEVICE_OBJECT PhysicalDeviceObject, _Out_ PVOID *ControllerContext)
Definition: pciidex.c:350
static VOID PciIdeXCreateIdeDirectory(VOID)
Definition: pciidex.c:483
NTSTATUS NTAPI PciIdeXDispatchWmi(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: pciidex.c:117
CONTROLLER_PNP_START_DEVICE PciIdeXFdoStartDevice
Definition: pciidex.h:468
DRIVER_UNLOAD PciIdeXUnload
Definition: pciidex.h:512
DRIVER_ADD_DEVICE PciIdeXAddDevice
Definition: pciidex.h:515
CONTROLLER_PNP_REMOVE_DEVICE PciIdeXFdoRemoveDevice
Definition: pciidex.h:471
WORD ExtensionSize
Definition: apisets.c:17
NTSTATUS NTAPI PciIdeXDispatchPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: pdo.c:1083
Legacy detection interface with the PCIIDEX driver.
Definition: ata_shared.h:489
PCONTROLLER_PNP_REMOVE_DEVICE RemoveDevice
Definition: ata_shared.h:493
PCONTROLLER_PNP_START_DEVICE StartDevice
Definition: ata_shared.h:492
PCONTROLLER_PNP_ADD_DEVICE AddDevice
Definition: ata_shared.h:491
void * PVOID
Definition: typedefs.h:50
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER

Referenced by AtaLegacyDetectChannel(), and DriverEntry().

◆ PciIdeXSetBusData()

NTSTATUS NTAPI PciIdeXSetBusData ( _In_ PVOID  DeviceExtension,
_In_reads_bytes_(BufferLength) PVOID  Buffer,
_In_reads_bytes_(BufferLength) PVOID  DataMask,
_In_ ULONG  ConfigDataOffset,
_In_ ULONG  BufferLength 
)

Definition at line 89 of file miniport.c.

95{
97 PATA_CONTROLLER Controller;
98 UCHAR LocalBuffer[4];
103
104 INFO("PciIdeXSetBusData(%p %p %p 0x%lx 0x%lx)\n",
105 DeviceExtension, Buffer, DataMask, ConfigDataOffset, BufferLength);
106
107 /* Optimize the common case (4-byte PCI access) */
108 if (BufferLength <= sizeof(LocalBuffer))
109 {
110 CurrentBuffer = LocalBuffer;
111 }
112 else
113 {
115 if (!CurrentBuffer)
117 }
118
119 FdoExt = CONTAINING_RECORD(DeviceExtension, FDO_DEVICE_EXTENSION, MiniControllerExtension);
120 Controller = &FdoExt->Controller;
121
122 /*
123 * This spinlock protects the PCI configuration space against concurrent modifications.
124 * For example, the PIIX register SIDETIM (0x44) is a byte-sized register
125 * and controls both of the IDE channels.
126 */
127 KeAcquireSpinLock(&Controller->Lock, &OldIrql);
128
129 Status = PciIdeXGetBusData(DeviceExtension, Buffer, ConfigDataOffset, BufferLength);
130 if (!NT_SUCCESS(Status))
131 goto Cleanup;
132
133 for (i = 0; i < BufferLength; i++)
134 {
135 CurrentBuffer[i] = (CurrentBuffer[i] & ~((PUCHAR)DataMask)[i]) |
136 (((PUCHAR)DataMask)[i] & ((PUCHAR)Buffer)[i]);
137 }
138
139 BytesWritten = Controller->SetBusData(Controller->BusInterfaceContext,
142 ConfigDataOffset,
146 else
148
149Cleanup:
150 KeReleaseSpinLock(&Controller->Lock, OldIrql);
151
152 if (CurrentBuffer != LocalBuffer)
154 return Status;
155}
#define ExAllocatePoolUninitialized
static ACPI_BUFFER CurrentBuffer
static const WCHAR Cleanup[]
Definition: register.c:80
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NonPagedPool
Definition: env_spec_w32.h:307
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 ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define TAG_PCIIDEX
Definition: pciidex.h:32
NTSTATUS NTAPI PciIdeXGetBusData(_In_ PVOID DeviceExtension, _Out_writes_bytes_all_(BufferLength) PVOID Buffer, _In_ ULONG ConfigDataOffset, _In_ ULONG BufferLength)
Definition: miniport.c:59
PGET_SET_DEVICE_DATA SetBusData
Definition: pciidex.h:197
KSPIN_LOCK Lock
Definition: pciidex.h:232
unsigned char UCHAR
Definition: typedefs.h:53
unsigned char * PUCHAR
Definition: typedefs.h:53
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_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 BytesWritten
Definition: wdfiotarget.h:960
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778