ReactOS 0.4.17-dev-1190-g4c812f4
fdo.c File Reference
#include "pciidex.h"
Include dependency graph for fdo.c:

Go to the source code of this file.

Functions

static DECLSPEC_NOINLINE_FROM_PAGED VOID AtaCtrlCallStartController (_In_ PATA_CONTROLLER Controller)
 
static DECLSPEC_NOINLINE_FROM_PAGED VOID AtaCtrlCallStopController (_In_ PATA_CONTROLLER Controller)
 
VOID DumpTestMiniport (_Inout_ PFDO_DEVICE_EXTENSION FdoExt)
 
NTSTATUS AtaCtrlAttachChannel (_In_ PVOID ChannelContext, _In_ BOOLEAN Attach)
 
DECLSPEC_NOINLINE_FROM_PAGED VOID AtaChanEnableInterruptsSync (_In_ PVOID ChannelContext, _In_ BOOLEAN Enable)
 
VOID AtaCtrlSetTransferMode (_In_ PVOID ChannelContext, _In_reads_(ATA_MAX_DEVICE) PCHANNEL_DEVICE_CONFIG *DeviceList)
 
VOID AtaCtrlSetDeviceData (_In_ PVOID ChannelContext, _In_ PDEVICE_OBJECT DeviceObject, _In_ PIDENTIFY_DEVICE_DATA IdentifyDeviceData)
 
PVOID AtaCtrlGetInitTaskFile (_In_ PVOID ChannelContext, _In_ PDEVICE_OBJECT DeviceObject)
 
BOOLEAN AtaCtrlDowngradeInterfaceSpeed (_In_ PVOID ChannelContext)
 
VOID AtaCtrlAbortChannel (_In_ PVOID ChannelContext, _In_ BOOLEAN DisableInterrupts)
 
PVOID AtaCtrlPciMapBar (_In_ PATA_CONTROLLER Controller, _In_range_(0, PCI_TYPE0_ADDRESSES) ULONG Index, _In_ ULONG MinimumIoLength)
 
static BOOLEAN AtaCtrlPciGetNextBarIndex (_In_ PPCI_COMMON_HEADER PciData, _Inout_ PULONG Bar)
 
static VOID AtaCtrlPciAssignResources (_In_ PATA_CONTROLLER Controller, _In_ PCM_RESOURCE_LIST ResourcesTranslated, _In_ PPCI_COMMON_HEADER PciData)
 
static VOID AtaCtrlPciSaveData (_Out_ PATA_CONTROLLER Controller, _In_ PPCI_COMMON_HEADER PciData)
 
static NTSTATUS AtaCtrlPciCollectInformation (_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
 
NTSTATUS PciIdeXFdoStartDevice (_In_ PVOID ControllerContext, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
 
static VOID PciIdeXFdoFreeResources (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 
static NTSTATUS PciIdeXFdoStopDevice (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 
VOID PciIdeXFdoRemoveDevice (_In_ PVOID ControllerContext)
 
static PPDO_DEVICE_EXTENSION PciIdeXPdoCreateDevice (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG ChannelNumber)
 
IDE_CHANNEL_STATE PciIdeXGetChannelState (_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
 
static NTSTATUS PciIdeXFdoQueryBusRelations (_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXFdoQueryInterface (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PIO_STACK_LOCATION IoStack)
 
static NTSTATUS PciIdeXFdoQueryId (_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
 
NTSTATUS PciIdeXFdoDispatchPnp (_In_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PIRP Irp)
 

Function Documentation

◆ 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;
70
71 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
72 InterruptObject = Controller->InterruptObject;
73 else
76
78 ChanData->EnableInterrupts(ChanData, Enable);
80}
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:44
@ InterruptObject
Definition: ketypes.h:447
_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
#define CTRL_FLAG_IS_AHCI
Definition: pciidex.h:228
PKINTERRUPT InterruptObject
Definition: pciidex.h:241
PATA_CONTROLLER Controller
Definition: pciidex.h:249
PCHANNEL_ENABLE_INTERRUPTS EnableInterrupts
Definition: pciidex.h:248
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

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

◆ AtaCtrlAbortChannel()

VOID AtaCtrlAbortChannel ( _In_ PVOID  ChannelContext,
_In_ BOOLEAN  DisableInterrupts 
)

Definition at line 213 of file fdo.c.

216{
217 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
218
220
221 ChanData->ActiveSlotsBitmap = 0;
222 ChanData->ActiveQueuedSlotsBitmap = 0;
223
224 /* Disable and clear pending interrupts */
225 if (DisableInterrupts)
226 {
227 ChanData->EnableInterrupts(ChanData, FALSE);
228
229#if DBG
230 if (ChanData->Controller->Flags & CTRL_FLAG_IS_AHCI)
231 {
232 PVOID IoBase = ((PCHANNEL_DATA_AHCI)ChanData)->IoBase;
233
234 DbgPrint("PxIS 0x%08lX\n", AHCI_PORT_READ(IoBase, PxInterruptStatus));
235 DbgPrint("PxIE 0x%08lX\n", AHCI_PORT_READ(IoBase, PxInterruptEnable));
236 DbgPrint("PxCMD 0x%08lX\n", AHCI_PORT_READ(IoBase, PxCmdStatus));
237 DbgPrint("PxTFD 0x%08lX\n", AHCI_PORT_READ(IoBase, PxTaskFileData));
238 DbgPrint("PxSIG 0x%08lX\n", AHCI_PORT_READ(IoBase, PxSignature));
239 DbgPrint("PxSSTS 0x%08lX\n", AHCI_PORT_READ(IoBase, PxSataStatus));
240 DbgPrint("PxSCTL 0x%08lX\n", AHCI_PORT_READ(IoBase, PxSataControl));
241 DbgPrint("PxSERR 0x%08lX\n", AHCI_PORT_READ(IoBase, PxSataError));
242 DbgPrint("PxSACT 0x%08lX\n", AHCI_PORT_READ(IoBase, PxSataActive));
243 DbgPrint("PxCI 0x%08lX\n", AHCI_PORT_READ(IoBase, PxCommandIssue));
244 DbgPrint("PxSNTF 0x%08lX\n", AHCI_PORT_READ(IoBase, PxSataNotification));
245 DbgPrint("PxFBS 0x%08lX\n", AHCI_PORT_READ(IoBase, PxFisSwitchingControl));
246 DbgPrint("PxDEVSLP 0x%08lX\n", AHCI_PORT_READ(IoBase, PxDeviceSleep));
247 }
248#endif
249 }
250}
FORCEINLINE ULONG AHCI_PORT_READ(_In_ PVOID PortIoBase, _In_ AHCI_PORT_REGISTER Register)
Definition: ahci.h:548
@ PxCmdStatus
Definition: ahci.h:104
@ PxTaskFileData
Definition: ahci.h:105
@ PxCommandIssue
Definition: ahci.h:111
@ PxSataStatus
Definition: ahci.h:107
@ PxSataControl
Definition: ahci.h:108
@ PxInterruptEnable
Definition: ahci.h:103
@ PxSataNotification
Definition: ahci.h:112
@ PxSataError
Definition: ahci.h:109
@ PxSignature
Definition: ahci.h:106
@ PxFisSwitchingControl
Definition: ahci.h:113
@ PxInterruptStatus
Definition: ahci.h:102
@ PxDeviceSleep
Definition: ahci.h:114
@ PxSataActive
Definition: ahci.h:110
#define FALSE
Definition: types.h:117
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define DbgPrint
Definition: hal.h:12
struct _CHANNEL_DATA_AHCI * PCHANNEL_DATA_AHCI
ULONG ActiveSlotsBitmap
Definition: pciidex.h:288
ULONG ActiveQueuedSlotsBitmap
Definition: pciidex.h:289

◆ AtaCtrlAttachChannel()

NTSTATUS AtaCtrlAttachChannel ( _In_ PVOID  ChannelContext,
_In_ BOOLEAN  Attach 
)

Definition at line 48 of file fdo.c.

51{
52 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
54
55 PAGED_CODE();
56
57 return Controller->AttachChannel(ChanData, Attach);
58}
#define PAGED_CODE()

◆ AtaCtrlCallStartController()

static DECLSPEC_NOINLINE_FROM_PAGED VOID AtaCtrlCallStartController ( _In_ PATA_CONTROLLER  Controller)
static

Definition at line 18 of file fdo.c.

20{
22
24 Controller->Start(Controller);
26}
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609

Referenced by PciIdeXFdoStartDevice().

◆ AtaCtrlCallStopController()

static DECLSPEC_NOINLINE_FROM_PAGED VOID AtaCtrlCallStopController ( _In_ PATA_CONTROLLER  Controller)
static

Definition at line 31 of file fdo.c.

Referenced by PciIdeXFdoFreeResources().

◆ AtaCtrlDowngradeInterfaceSpeed()

BOOLEAN AtaCtrlDowngradeInterfaceSpeed ( _In_ PVOID  ChannelContext)

Definition at line 197 of file fdo.c.

199{
200 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
202
203 PAGED_CODE();
204
205 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
206 return AtaAhciDowngradeInterfaceSpeed(ChannelContext);
207
208 /* Optionally, implement a SATA framework at some point in the future */
209 return FALSE;
210}
BOOLEAN AtaAhciDowngradeInterfaceSpeed(_In_ PCHANNEL_DATA_AHCI ChanData)
Definition: ahci_hw.c:1542

◆ AtaCtrlGetInitTaskFile()

PVOID AtaCtrlGetInitTaskFile ( _In_ PVOID  ChannelContext,
_In_ PDEVICE_OBJECT  DeviceObject 
)

Definition at line 178 of file fdo.c.

181{
182 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
184
185 PAGED_CODE();
186
187 if ((Controller->Flags & CTRL_FLAG_SATA_HBA_ACPI) ||
189 {
191 }
192
193 return NULL;
194}
PVOID AtaAcpiGetTaskFile(_In_ PDEVICE_OBJECT DeviceObject)
Definition: acpi.c:233
#define NULL
Definition: types.h:112
#define CTRL_FLAG_SATA_HBA_ACPI
Definition: pciidex.h:226
#define CHANNEL_FLAG_HAS_ACPI_GTM
Definition: pciidex.h:276
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061

◆ AtaCtrlPciAssignResources()

static VOID AtaCtrlPciAssignResources ( _In_ PATA_CONTROLLER  Controller,
_In_ PCM_RESOURCE_LIST  ResourcesTranslated,
_In_ PPCI_COMMON_HEADER  PciData 
)
static

Definition at line 327 of file fdo.c.

331{
332 ULONG i, Bar;
333
334 PAGED_CODE();
335
337 return;
338
339 for (i = 0; i < ResourcesTranslated->List[0].PartialResourceList.Count; ++i)
340 {
342
343 Desc = &ResourcesTranslated->List[0].PartialResourceList.PartialDescriptors[i];
344 if (Desc->Type == CmResourceTypeInterrupt)
345 {
346 RtlCopyMemory(&Controller->InterruptDesc, Desc, sizeof(*Desc));
347 break;
348 }
349 }
350
351 for (i = 0, Bar = 0; i < ResourcesTranslated->List[0].PartialResourceList.Count; ++i)
352 {
354 ULONG CurrBar, NextBar;
355
356 Desc = &ResourcesTranslated->List[0].PartialResourceList.PartialDescriptors[i];
357 if ((Desc->Type != CmResourceTypePort) && (Desc->Type != CmResourceTypeMemory))
358 continue;
359
360 if (!AtaCtrlPciGetNextBarIndex(PciData, &Bar))
361 break;
362
363 CurrBar = PciData->u.type0.BaseAddresses[Bar];
364 if (Bar < (PCI_TYPE0_ADDRESSES - 1))
365 NextBar = PciData->u.type0.BaseAddresses[Bar + 1];
366 else
367 NextBar = 0;
368
369 if (CurrBar & PCI_ADDRESS_IO_SPACE)
370 {
371 if (Desc->Type != CmResourceTypePort)
372 continue;
373
374 if (Desc->u.Port.Start.QuadPart != (CurrBar & PCI_ADDRESS_IO_ADDRESS_MASK))
375 continue;
376
377 INFO("BAR[%lu]: I/O %I64X Len %lX\n",
378 Bar, Desc->u.Port.Start.QuadPart, Desc->u.Port.Length);
379 Controller->AccessRange[Bar].Flags |= RANGE_IS_VALID;
380 Controller->AccessRange[Bar].IoBase = (PVOID)(ULONG_PTR)Desc->u.Port.Start.QuadPart;
381 Controller->AccessRange[Bar].Length = Desc->u.Port.Length;
382 }
383 else
384 {
385 if (Desc->Type != CmResourceTypeMemory)
386 continue;
387
388 if (Desc->u.Memory.Start.LowPart != (CurrBar & PCI_ADDRESS_MEMORY_ADDRESS_MASK))
389 continue;
390
392 {
393 if (Desc->u.Memory.Start.HighPart != NextBar)
394 continue;
395 }
396 else
397 {
398 if (Desc->u.Memory.Start.HighPart != 0)
399 continue;
400 }
401
402 INFO("BAR[%lu]: MEM %I64X Len %lX\n",
403 Bar, Desc->u.Memory.Start.QuadPart, Desc->u.Memory.Length);
404 Controller->AccessRange[Bar].Flags |= RANGE_IS_VALID | RANGE_IS_MEMORY;
405 Controller->AccessRange[Bar].IoBase = (PVOID)(ULONG_PTR)Desc->u.Memory.Start.QuadPart;
406 Controller->AccessRange[Bar].Length = Desc->u.Memory.Length;
407 }
408
409 ++Bar;
410 }
411}
#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
void Bar(void)
Definition: terminate.cpp:70
#define RANGE_IS_MEMORY
Definition: pciidex.h:191
#define RANGE_IS_VALID
Definition: pciidex.h:190
#define CmResourceTypeMemory
Definition: restypes.h:106
#define CmResourceTypePort
Definition: restypes.h:104
#define CmResourceTypeInterrupt
Definition: restypes.h:105
static BOOLEAN AtaCtrlPciGetNextBarIndex(_In_ PPCI_COMMON_HEADER PciData, _Inout_ PULONG Bar)
Definition: fdo.c:299
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@496 Port
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@494::@499 Memory
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCMRESLIST _In_ WDFCMRESLIST ResourcesTranslated
Definition: wdfdevice.h:891
#define PCI_TYPE_64BIT
Definition: iotypes.h:4255
#define PCI_ADDRESS_IO_ADDRESS_MASK
Definition: iotypes.h:4249
#define PCI_TYPE0_ADDRESSES
Definition: iotypes.h:3515
#define PCI_ADDRESS_IO_SPACE
Definition: iotypes.h:4246
#define PCI_ADDRESS_MEMORY_ADDRESS_MASK
Definition: iotypes.h:4250
#define PCI_ADDRESS_MEMORY_TYPE_MASK
Definition: iotypes.h:4247

Referenced by AtaCtrlPciCollectInformation().

◆ AtaCtrlPciCollectInformation()

static NTSTATUS AtaCtrlPciCollectInformation ( _In_ PFDO_DEVICE_EXTENSION  FdoExt,
_In_ PCM_RESOURCE_LIST  ResourcesTranslated 
)
static

Definition at line 437 of file fdo.c.

440{
441 PATA_CONTROLLER Controller = &FdoExt->Controller;
443 PPCI_COMMON_HEADER PciData = (PPCI_COMMON_HEADER)Buffer; // Partial PCI header
445
446 PAGED_CODE();
447
448 BytesRead = Controller->GetBusData(Controller->BusInterfaceContext,
450 Buffer,
451 0,
452 sizeof(Buffer));
453 if (BytesRead != sizeof(Buffer))
455
458
459 return STATUS_SUCCESS;
460}
Definition: bufpool.h:45
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 * u
Definition: glfuncs.h:240
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:684
#define STATUS_SUCCESS
Definition: shellext.h:65
static VOID AtaCtrlPciAssignResources(_In_ PATA_CONTROLLER Controller, _In_ PCM_RESOURCE_LIST ResourcesTranslated, _In_ PPCI_COMMON_HEADER PciData)
Definition: fdo.c:327
static VOID AtaCtrlPciSaveData(_Out_ PATA_CONTROLLER Controller, _In_ PPCI_COMMON_HEADER PciData)
Definition: fdo.c:416
unsigned char UCHAR
Definition: typedefs.h:53
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
_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:3659
struct _PCI_COMMON_HEADER * PPCI_COMMON_HEADER

Referenced by PciIdeXFdoStartDevice().

◆ AtaCtrlPciGetNextBarIndex()

static BOOLEAN AtaCtrlPciGetNextBarIndex ( _In_ PPCI_COMMON_HEADER  PciData,
_Inout_ PULONG  Bar 
)
static

Definition at line 299 of file fdo.c.

302{
303 PAGED_CODE();
304
305 for (; *Bar < PCI_TYPE0_ADDRESSES; (*Bar)++)
306 {
307 ULONG IoBase = PciData->u.type0.BaseAddresses[*Bar];
308
309 if (IoBase & PCI_ADDRESS_IO_SPACE)
310 IoBase &= ~PCI_ADDRESS_IO_SPACE;
311 else
313
314 /* Look for a valid BAR */
315 if (IoBase == 0)
316 continue;
317
318 return TRUE;
319 }
320
321 return FALSE;
322}
#define TRUE
Definition: types.h:120
#define PCI_ADDRESS_MEMORY_PREFETCHABLE
Definition: iotypes.h:4248

Referenced by AtaCtrlPciAssignResources().

◆ AtaCtrlPciMapBar()

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

Definition at line 254 of file fdo.c.

258{
259 PAGED_CODE();
260
261 if (!(Controller->AccessRange[Index].Flags & RANGE_IS_VALID))
262 return NULL;
263
264 /* Validate the BAR length */
265 if (MinimumIoLength != 0)
266 {
267 if (Controller->AccessRange[Index].Length < MinimumIoLength)
268 {
269 ERR("%04X:%04X.%02X: Unexpected PCI BAR #%lu length 0x%lx, minimum required 0x%lx\n",
270 Controller->Pci.VendorID,
271 Controller->Pci.DeviceID,
272 Controller->Pci.RevisionID,
273 Index,
274 Controller->AccessRange[Index].Length,
275 MinimumIoLength);
276 return NULL;
277 }
278 }
279
280 if ((Controller->AccessRange[Index].Flags & RANGE_IS_MEMORY) &&
281 !(Controller->AccessRange[Index].Flags & RANGE_IS_MAPPED))
282 {
284
285 Controller->AccessRange[Index].Flags |= RANGE_IS_MAPPED;
286
287 PhysicalAddress.QuadPart = (ULONG_PTR)Controller->AccessRange[Index].IoBase;
288 Controller->AccessRange[Index].IoBase = MmMapIoSpace(PhysicalAddress,
289 Controller->AccessRange[Index].Length,
291 }
292
293 return Controller->AccessRange[Index].IoBase;
294}
#define ERR(fmt,...)
Definition: precomp.h:57
_In_ ULONG _In_ MEMORY_CACHING_TYPE _Out_ PPHYSICAL_ADDRESS PhysicalAddress
Definition: dispmprt.h:714
#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
_In_ WDFCOLLECTION _In_ ULONG Index
@ MmNonCached
Definition: mmtypes.h:129

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

◆ AtaCtrlPciSaveData()

static VOID AtaCtrlPciSaveData ( _Out_ PATA_CONTROLLER  Controller,
_In_ PPCI_COMMON_HEADER  PciData 
)
static

Definition at line 416 of file fdo.c.

419{
420 PAGED_CODE();
421
422 Controller->Pci.VendorID = PciData->VendorID;
423 Controller->Pci.DeviceID = PciData->DeviceID;
424 Controller->Pci.Command = PciData->Command;
425 Controller->Pci.RevisionID = PciData->RevisionID;
426 Controller->Pci.ProgIf = PciData->ProgIf;
427 Controller->Pci.SubClass = PciData->SubClass;
428 Controller->Pci.BaseClass = PciData->BaseClass;
429 Controller->Pci.CacheLineSize = PciData->CacheLineSize;
430 Controller->Pci.SubVendorID = PciData->u.type0.SubVendorID;
431 Controller->Pci.SubSystemID = PciData->u.type0.SubSystemID;
432}

Referenced by AtaCtrlPciCollectInformation().

◆ AtaCtrlSetDeviceData()

VOID AtaCtrlSetDeviceData ( _In_ PVOID  ChannelContext,
_In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIDENTIFY_DEVICE_DATA  IdentifyDeviceData 
)

Definition at line 160 of file fdo.c.

164{
165 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
167
168 PAGED_CODE();
169
170 if (!(Controller->Flags & CTRL_FLAG_SATA_HBA_ACPI))
171 return;
172
173 AtaAcpiSetDeviceData(DeviceObject, IdentifyDeviceData);
174}
VOID AtaAcpiSetDeviceData(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIDENTIFY_DEVICE_DATA IdBlock)
Definition: acpi.c:317

◆ AtaCtrlSetTransferMode()

VOID AtaCtrlSetTransferMode ( _In_ PVOID  ChannelContext,
_In_reads_(ATA_MAX_DEVICE) PCHANNEL_DEVICE_CONFIG *  DeviceList 
)

Definition at line 83 of file fdo.c.

86{
87 PCHANNEL_DATA_COMMON ChanData = ChannelContext;
90 ULONG i;
91 BOOLEAN DiscoveredNewDevice = FALSE;
92
93 for (i = 0; i < ATA_MAX_DEVICE; ++i)
94 {
96
97 if (!Device)
98 continue;
99
100 if (Device->IsNewDevice)
101 DiscoveredNewDevice = TRUE;
102
103 /* Apply the channel limit */
104 Device->SupportedModes &= ChanData->Current.TransferModeSupported;
105
106 if ((ChanData->ChanInfo & CHANNEL_FLAG_NO_ATAPI_DMA) && !Device->IsFixedDisk)
107 Device->SupportedModes &= PIO_ALL;
108
109 /*
110 * If we are booting in minimal safe mode we disable DMA for ATAPI devices
111 * to improve system stability.
112 */
113 if (InitSafeBootMode == 1)
114 {
115 if (!(ChanData->ChanInfo & CHANNEL_FLAG_PIO_VIA_DMA) && !Device->IsFixedDisk)
116 Device->SupportedModes &= PIO_ALL;
117 }
118
119 /* Set initial values for mode selection: Find the fastest supported PIO and DMA mode */
120 if (!_BitScanReverse(&Device->DmaMode, Device->SupportedModes & ~PIO_ALL))
121 Device->DmaMode = PIO_MODE(0);
122 NT_VERIFY(_BitScanReverse(&Device->PioMode, Device->SupportedModes & PIO_ALL));
123 }
124
125 /*
126 * _GTF should be executed after _STM has been evaluated,
127 * because it is expected that ACPI BIOS will use the identity data buffers
128 * to construct the list of ATA commands to the drive.
129 *
130 * Therefore for any new device we have to evaluate a dummy _STM
131 * when the whole configuration of the channel's transfer timings
132 * is done at the controller minidriver.
133 */
134 if (DiscoveredNewDevice && (ChanData->ChanInfo & CHANNEL_FLAG_HAS_ACPI_GTM))
135 {
136 PCHANNEL_DATA_PATA PataData = ChannelContext;
137
138 /* Evaluate _STM */
139 AtaAcpiSetTimingMode(PataData->PdoExt->Common.Self,
140 &PataData->CurrentTimingMode,
141 DeviceList[0] ? DeviceList[0]->IdentifyDeviceData : NULL,
142 DeviceList[1] ? DeviceList[1]->IdentifyDeviceData : NULL);
143 }
144
145 /* ACPI evaluations can pend, so they cannot run under the controller lock */
147 {
148 ChanData->SetTransferMode(Controller, ChanData->Channel, DeviceList);
149 return;
150 }
151
152 /* Set the PATA transfer timings */
154 ChanData->SetTransferMode(Controller, ChanData->Channel, DeviceList);
156}
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: acpi.c:168
unsigned char BOOLEAN
Definition: actypes.h:127
#define ATA_MAX_DEVICE
Definition: ata_shared.h:15
#define PIO_MODE(n)
Definition: ata_user.h:36
#define PIO_ALL
Definition: ata_user.h:19
PDEVICE_LIST DeviceList
Definition: utils.c:27
PULONG InitSafeBootMode
Definition: init.c:75
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
#define CHANNEL_FLAG_NO_ATAPI_DMA
Definition: pciidex.h:279
#define CHANNEL_FLAG_PIO_VIA_DMA
Definition: pciidex.h:270
CHANNEL_SET_MODE_EX PciIdeGenericSetTransferMode
Definition: pciidex.h:641
unsigned char _BitScanReverse(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:180
PCHANNEL_SET_MODE_EX SetTransferMode
Definition: pciidex.h:244
struct _CHANNEL_DATA_COMMON::@1295 Current
IDE_ACPI_TIMING_MODE_BLOCK CurrentTimingMode
Definition: pciidex.h:316
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3311

◆ DumpTestMiniport()

VOID DumpTestMiniport ( _Inout_ PFDO_DEVICE_EXTENSION  FdoExt)

◆ PciIdeXFdoDispatchPnp()

NTSTATUS PciIdeXFdoDispatchPnp ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_Inout_ PIRP  Irp 
)

Definition at line 915 of file fdo.c.

918{
919 PIO_STACK_LOCATION IoStack;
921
922 PAGED_CODE();
923
924 Status = IoAcquireRemoveLock(&FdoExtension->Common.RemoveLock, Irp);
925 if (!NT_SUCCESS(Status))
926 {
927 Irp->IoStatus.Status = Status;
929
930 return Status;
931 }
932
934 switch (IoStack->MinorFunction)
935 {
937 {
938 if (!NT_VERIFY(IoForwardIrpSynchronously(FdoExtension->Common.LowerDeviceObject, Irp)))
939 {
941 goto CompleteIrp;
942 }
943 Status = Irp->IoStatus.Status;
944 if (!NT_SUCCESS(Status))
945 goto CompleteIrp;
946
948 IoStack->Parameters.
949 StartDevice.AllocatedResourcesTranslated);
950 goto CompleteIrp;
951 }
952
954 {
956 break;
957 }
958
960 {
961 IoReleaseRemoveLockAndWait(&FdoExtension->Common.RemoveLock, Irp);
962
964
965 Irp->IoStatus.Status = STATUS_SUCCESS;
967 Status = IoCallDriver(FdoExtension->Common.LowerDeviceObject, Irp);
968
969 IoDetachDevice(FdoExtension->Common.LowerDeviceObject);
970 IoDeleteDevice(FdoExtension->Common.Self);
971 return Status;
972 }
973
975 {
977 break;
978 }
979
981 {
982 if (IoStack->Parameters.QueryDeviceRelations.Type != BusRelations)
983 break;
984
986 if (!NT_SUCCESS(Status))
987 goto CompleteIrp;
988
989 Irp->IoStatus.Status = Status;
990 break;
991 }
992
994 {
996 break;
997 }
998
1000 {
1003 break;
1004
1005 Irp->IoStatus.Status = Status;
1006 break;
1007 }
1008
1014 Irp->IoStatus.Status = STATUS_SUCCESS;
1015 break;
1016
1017 case IRP_MN_QUERY_ID:
1018 return PciIdeXFdoQueryId(FdoExtension, Irp, IoStack);
1019
1020 default:
1021 break;
1022 }
1023
1025 Status = IoCallDriver(FdoExtension->Common.LowerDeviceObject, Irp);
1026
1027 IoReleaseRemoveLock(&FdoExtension->Common.RemoveLock, Irp);
1028 return Status;
1029
1031 Irp->IoStatus.Status = Status;
1033
1034 IoReleaseRemoveLock(&FdoExtension->Common.RemoveLock, Irp);
1035 return Status;
1036}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
@ FdoExtension
Definition: precomp.h:60
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
Status
Definition: gdiplustypes.h:24
_In_ PIRP Irp
Definition: kse.h:79
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
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1306
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261
#define IoCompleteRequest
Definition: irp.c:1272
BOOLEAN NTAPI IoForwardIrpSynchronously(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1657
#define IoCallDriver
Definition: irp.c:1257
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:469
CONTROLLER_PNP_REMOVE_DEVICE PciIdeXFdoRemoveDevice
Definition: pciidex.h:472
static NTSTATUS PciIdeXFdoQueryBusRelations(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PIRP Irp)
Definition: fdo.c:698
static NTSTATUS PciIdeXFdoQueryInterface(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ PIO_STACK_LOCATION IoStack)
Definition: fdo.c:808
static NTSTATUS PciIdeXFdoQueryId(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
Definition: fdo.c:850
static NTSTATUS PciIdeXFdoStopDevice(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: fdo.c:579
struct _IO_STACK_LOCATION::@5020::@5045 QueryDeviceRelations
union _IO_STACK_LOCATION::@1814 Parameters
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define IoAcquireRemoveLock(RemoveLock, Tag)
#define IoReleaseRemoveLockAndWait(_RemoveLock, _Tag)
Definition: iofuncs.h:2781
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2771
#define IRP_MN_CANCEL_STOP_DEVICE
@ BusRelations
Definition: iotypes.h:2154
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#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().

◆ PciIdeXFdoFreeResources()

static VOID PciIdeXFdoFreeResources ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)
static

Definition at line 528 of file fdo.c.

530{
532 ULONG i;
533
534 PAGED_CODE();
535
536 if (Controller->Stop)
538
539 if (Controller->FreeResources)
540 Controller->FreeResources(Controller);
541
542 Controller->InterruptObject = NULL;
543
544 for (i = 0; i < RTL_NUMBER_OF(Controller->AccessRange); ++i)
545 {
546 if ((Controller->AccessRange[i].Flags & RANGE_IS_VALID) &&
547 (Controller->AccessRange[i].Flags & RANGE_IS_MAPPED))
548 {
549 MmUnmapIoSpace(Controller->AccessRange[i].IoBase, Controller->AccessRange[i].Length);
550 }
551
552 Controller->AccessRange[i].Flags = 0;
553 }
554
555 if (Controller->ChanDataBlock)
556 {
558 Controller->ChanDataBlock = NULL;
559 }
560
561 if (Controller->HwSyncObject)
562 {
563 IoDeleteController(Controller->HwSyncObject);
564 Controller->HwSyncObject = NULL;
565 }
566
567 if (Controller->HwExt)
568 {
570 Controller->HwExt = NULL;
571 }
572
573 Controller->InterruptDesc.Type = 0;
574}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
VOID NTAPI IoDeleteController(IN PCONTROLLER_OBJECT ControllerObject)
Definition: controller.c:117
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:192
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define TAG_PCIIDEX
Definition: pciidex.h:32
static DECLSPEC_NOINLINE_FROM_PAGED VOID AtaCtrlCallStopController(_In_ PATA_CONTROLLER Controller)
Definition: fdo.c:31

Referenced by PciIdeXFdoRemoveDevice(), and PciIdeXFdoStopDevice().

◆ PciIdeXFdoQueryBusRelations()

static NTSTATUS PciIdeXFdoQueryBusRelations ( _In_ PFDO_DEVICE_EXTENSION  FdoExt,
_In_ PIRP  Irp 
)
static

Definition at line 698 of file fdo.c.

701{
702 PATA_CONTROLLER Controller = &FdoExt->Controller;
703 PDEVICE_RELATIONS DeviceRelations;
704 PLIST_ENTRY ListEntry;
705 ULONG i, Size, ChannelBitmap = 0;
706
707 PAGED_CODE();
708
709 /*
710 * Preallocate the device relations structure we need for the QBR IRP,
711 * because we don't want to be in a state where allocation fails.
712 */
715 if (!DeviceRelations)
717
718 ExAcquireFastMutex(&FdoExt->PdoListSyncMutex);
719
720 /* Check existing ports */
721 for (ListEntry = FdoExt->PdoListHead.Flink;
722 ListEntry != &FdoExt->PdoListHead;
723 ListEntry = ListEntry->Flink)
724 {
726 IDE_CHANNEL_STATE ChannelState;
728
729 PdoExt = CONTAINING_RECORD(ListEntry, PDO_DEVICE_EXTENSION, ListEntry);
730 Channel = PdoExt->Channel;
731
732 ChannelBitmap |= 1 << Channel;
733
735 if (ChannelState == ChannelDisabled)
736 {
737 INFO("%04X:%04X.%02X: Skip disabled channel %lu\n",
738 Controller->Pci.VendorID,
739 Controller->Pci.DeviceID,
740 Controller->Pci.RevisionID,
741 Channel);
742
744 continue;
745 }
746 }
747
748 /* Enumerate the remaining ports */
749 ChannelBitmap = Controller->ChannelBitmap & ~ChannelBitmap;
750 for (i = 0; i < MAX_CHANNELS; ++i)
751 {
753 IDE_CHANNEL_STATE ChannelState;
754
755 if (!(ChannelBitmap & (1 << i)))
756 continue;
757
758 ChannelState = PciIdeXGetChannelState(Controller, i);
759 if (ChannelState == ChannelDisabled)
760 {
761 INFO("%04X:%04X.%02X: Skip disabled channel %lu\n",
762 Controller->Pci.VendorID,
763 Controller->Pci.DeviceID,
764 Controller->Pci.RevisionID,
765 i);
766 continue;
767 }
768
769 /* Need to create a PDO */
771 if (!PdoExt)
772 {
773 /* We are out of memory, trying to continue process the QBR IRP anyway */
774 continue;
775 }
776
777 InsertTailList(&FdoExt->PdoListHead, &PdoExt->ListEntry);
778 }
779
780 /* Initialize the device relations structure */
781 DeviceRelations->Count = 0;
782 for (ListEntry = FdoExt->PdoListHead.Flink;
783 ListEntry != &FdoExt->PdoListHead;
784 ListEntry = ListEntry->Flink)
785 {
787
788 PdoExt = CONTAINING_RECORD(ListEntry, PDO_DEVICE_EXTENSION, ListEntry);
789 if (PdoExt->Flags & PDO_FLAG_NOT_PRESENT)
790 {
792 continue;
793 }
794
795 DeviceRelations->Objects[DeviceRelations->Count++] = PdoExt->Common.Self;
797 }
798
799 ExReleaseFastMutex(&FdoExt->PdoListSyncMutex);
800
801 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
802 return STATUS_SUCCESS;
803}
#define ExAllocatePoolUninitialized
#define MAX_CHANNELS
Definition: channels.c:23
#define InsertTailList(ListHead, Entry)
#define PagedPool
Definition: env_spec_w32.h:308
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
IDE_CHANNEL_STATE
Definition: ide.h:196
@ ChannelDisabled
Definition: ide.h:197
#define PDO_FLAG_REPORTED_MISSING
Definition: pciidex.h:411
_In_ ULONG Channel
Definition: pciidex.h:74
#define PDO_FLAG_NOT_PRESENT
Definition: pciidex.h:410
static PPDO_DEVICE_EXTENSION PciIdeXPdoCreateDevice(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG ChannelNumber)
Definition: fdo.c:621
IDE_CHANNEL_STATE PciIdeXGetChannelState(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
Definition: fdo.c:683
PDEVICE_OBJECT Self
Definition: pciidex.h:377
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2165
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by PciIdeXFdoDispatchPnp().

◆ PciIdeXFdoQueryId()

static NTSTATUS PciIdeXFdoQueryId ( _In_ PFDO_DEVICE_EXTENSION  FdoExt,
_In_ PIRP  Irp,
_In_ PIO_STACK_LOCATION  IoStack 
)
static

Definition at line 850 of file fdo.c.

854{
856
857 PAGED_CODE();
858
859 switch (IoStack->Parameters.QueryId.IdType)
860 {
863 {
864 if (!NT_VERIFY(IoForwardIrpSynchronously(FdoExt->Common.LowerDeviceObject, Irp)))
865 {
867 break;
868 }
869 Status = Irp->IoStatus.Status;
870
871 /*
872 * We provide a generic identifier necessary to install the device
873 * in case our FDO is root-enumerated device.
874 */
876 {
877 static const WCHAR IdeGenericId[] = L"*PNP0600\0"; // multi-string
879
881 if (!Buffer)
882 {
884 break;
885 }
886 RtlCopyMemory(Buffer, IdeGenericId, sizeof(IdeGenericId));
887
888 INFO("Hardware/Compatible ID: '%S'\n", Buffer);
889
890 Irp->IoStatus.Information = (ULONG_PTR)Buffer;
892 }
893 break;
894 }
895
896 default:
897 {
899 Status = IoCallDriver(FdoExt->Common.LowerDeviceObject, Irp);
900
901 IoReleaseRemoveLock(&FdoExt->Common.RemoveLock, Irp);
902 return Status;
903 }
904 }
905
906 Irp->IoStatus.Status = Status;
908
909 IoReleaseRemoveLock(&FdoExt->Common.RemoveLock, Irp);
910 return Status;
911}
#define L(x)
Definition: resources.c:13
short WCHAR
Definition: pedump.c:58
uint16_t * PWCHAR
Definition: typedefs.h:56
@ BusQueryCompatibleIDs
Definition: iotypes.h:2953
@ BusQueryHardwareIDs
Definition: iotypes.h:2952

Referenced by PciIdeXFdoDispatchPnp().

◆ PciIdeXFdoQueryInterface()

static NTSTATUS PciIdeXFdoQueryInterface ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ PIO_STACK_LOCATION  IoStack 
)
static

Definition at line 808 of file fdo.c.

811{
812 PAGED_CODE();
813
814 if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
815 &GUID_TRANSLATOR_INTERFACE_STANDARD))
816 {
818 PTRANSLATOR_INTERFACE TranslatorInterface;
819 CM_RESOURCE_TYPE ResourceType;
821
822 /* In native mode the IDE controller does not use any legacy interrupt resources */
825
826 if (IoStack->Parameters.QueryInterface.Size < sizeof(*TranslatorInterface))
828
829 ResourceType = PtrToUlong(IoStack->Parameters.QueryInterface.InterfaceSpecificData);
830 if (ResourceType != CmResourceTypeInterrupt)
832
833 TranslatorInterface = (PTRANSLATOR_INTERFACE)IoStack->Parameters.QueryInterface.Interface;
834
836 0,
838 sizeof(*TranslatorInterface),
839 IoStack->Parameters.QueryInterface.Version,
840 TranslatorInterface,
841 &BusNumber);
842 }
843
845}
#define PtrToUlong(u)
Definition: config.h:107
#define CTRL_FLAG_NATIVE_PCI
Definition: pciidex.h:224
#define CTRL_FLAG_NON_PNP
Definition: pciidex.h:229
_In_ ULONG BusNumber
Definition: pciidex.h:65
@ InterfaceTypeUndefined
Definition: restypes.h:121
@ PCIBus
Definition: restypes.h:127
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
#define HalGetInterruptTranslator
Definition: haltypes.h:313
struct _TRANSLATOR_INTERFACE * PTRANSLATOR_INTERFACE

Referenced by PciIdeXFdoDispatchPnp().

◆ PciIdeXFdoRemoveDevice()

VOID PciIdeXFdoRemoveDevice ( _In_ PVOID  ControllerContext)

Definition at line 591 of file fdo.c.

593{
594 PFDO_DEVICE_EXTENSION FdoExt = ControllerContext;
595 PLIST_ENTRY ListEntry;
596
597 PAGED_CODE();
598
600
601 for (ListEntry = FdoExt->PdoListHead.Flink;
602 ListEntry != &FdoExt->PdoListHead;
603 ListEntry = ListEntry->Flink)
604 {
606
607 PdoExt = CONTAINING_RECORD(ListEntry, PDO_DEVICE_EXTENSION, ListEntry);
608
611 }
612
614
616}
NTSTATUS PciIdeXPdoRemoveDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp, _In_ BOOLEAN FinalRemove)
Definition: pdo.c:193
static VOID PciIdeXFdoFreeResources(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: fdo.c:528
LIST_ENTRY PdoListHead
Definition: precomp.h:256
FAST_MUTEX PdoListSyncMutex
Definition: pciidex.h:393

◆ PciIdeXFdoStartDevice()

NTSTATUS PciIdeXFdoStartDevice ( _In_ PVOID  ControllerContext,
_In_ PCM_RESOURCE_LIST  ResourcesTranslated 
)

Definition at line 464 of file fdo.c.

467{
468 PFDO_DEVICE_EXTENSION FdoExt = ControllerContext;
471
472 PAGED_CODE();
473
476 Controller->QueueDepth = 1; // PATA_CHANNEL_SLOT
477 Controller->AlignmentRequirement = ATA_MIN_BUFFER_ALIGNMENT;
478 Controller->AttachChannel = PciIdeAttachChannel;
479 Controller->FreeResources = NULL;
480 Controller->Start = NULL;
481 Controller->Stop = NULL;
482 Controller->ChannelEnableBits = NULL;
483
484#if defined(ATA_DETECT_LEGACY_DEVICES)
485 if (Controller->Flags & CTRL_FLAG_NON_PNP)
486 {
488 }
489 else
490#endif
491 {
493 if (!NT_SUCCESS(Status))
494 {
495 ERR("Failed to collect PCI information 0x%lx\n", Status);
496 return Status;
497 }
498
499 INFO("Starting controller %04X:%04X.%02X-%04X.%04X-%02X.%02X.%02X\n",
500 Controller->Pci.VendorID,
501 Controller->Pci.DeviceID,
502 Controller->Pci.RevisionID,
503 Controller->Pci.SubVendorID,
504 Controller->Pci.SubSystemID,
505 Controller->Pci.BaseClass,
506 Controller->Pci.SubClass,
507 Controller->Pci.ProgIf);
508
510 if (Status == STATUS_NO_MATCH)
512 }
513 if (!NT_SUCCESS(Status))
514 {
515 ERR("Failed to match ATA controller with status %lx\n", Status);
516 return Status;
517 }
518
519 if (Controller->Start)
521
522 return STATUS_SUCCESS;
523}
NTSTATUS AhciGetControllerProperties(_Inout_ PATA_CONTROLLER Controller)
Definition: ahci_generic.c:625
#define ATA_MIN_BUFFER_ALIGNMENT
Definition: ata_shared.h:30
#define STATUS_NO_MATCH
Definition: ntstatus.h:873
NTSTATUS PataGetControllerProperties(_Inout_ PATA_CONTROLLER Controller, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
Definition: pata_legacy.c:16
NTSTATUS NTAPI PciIdeGetControllerProperties(IN PVOID DeviceExtension, OUT PIDE_CONTROLLER_PROPERTIES ControllerProperties)
Definition: pciide.c:46
CONTROLLER_ATTACH_CHANNEL_EX PciIdeAttachChannel
Definition: pciidex.h:644
static NTSTATUS AtaCtrlPciCollectInformation(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
Definition: fdo.c:437
static DECLSPEC_NOINLINE_FROM_PAGED VOID AtaCtrlCallStartController(_In_ PATA_CONTROLLER Controller)
Definition: fdo.c:18
ATA_CONTROLLER Controller
Definition: pciidex.h:396

◆ PciIdeXFdoStopDevice()

static NTSTATUS PciIdeXFdoStopDevice ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)
static

Definition at line 579 of file fdo.c.

581{
582 PAGED_CODE();
583
585
586 return STATUS_SUCCESS;
587}

Referenced by PciIdeXFdoDispatchPnp().

◆ PciIdeXGetChannelState()

IDE_CHANNEL_STATE PciIdeXGetChannelState ( _In_ PATA_CONTROLLER  Controller,
_In_ ULONG  Channel 
)

Definition at line 683 of file fdo.c.

686{
687 PAGED_CODE();
688
689 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
690 return ChannelStateUnknown;
691
693}
@ ChannelStateUnknown
Definition: ide.h:199
IDE_CHANNEL_STATE PciIdeGetChannelState(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
Definition: pata_generic.c:912

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

◆ PciIdeXPdoCreateDevice()

static PPDO_DEVICE_EXTENSION PciIdeXPdoCreateDevice ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension,
_In_ ULONG  ChannelNumber 
)
static

Definition at line 621 of file fdo.c.

624{
627 WCHAR DeviceNameBuffer[sizeof("\\Device\\Ide\\PciIde99999Channel99-FFF")];
631 static ULONG PdoNumber = 0;
632
633 PAGED_CODE();
634
635 Status = RtlStringCbPrintfW(DeviceNameBuffer,
636 sizeof(DeviceNameBuffer),
637 L"\\Device\\Ide\\PciIde%luChannel%lu-%lx",
638 FdoExtension->ControllerNumber,
639 ChannelNumber,
640 PdoNumber++);
642 RtlInitUnicodeString(&DeviceName, DeviceNameBuffer);
643
644 Status = IoCreateDevice(FdoExtension->Common.Self->DriverObject,
645 sizeof(*PdoExtension),
646 &DeviceName,
649 FALSE,
650 &Pdo);
651 if (!NT_SUCCESS(Status))
652 {
653 ERR("Failed to create PDO 0x%lx\n", Status);
654 return NULL;
655 }
656
657 INFO("Created device object %p '%wZ'\n", Pdo, &DeviceName);
658
659 /* DMA buffers alignment */
660 Alignment = FdoExtension->Controller.AlignmentRequirement;
661 Alignment = max(Alignment, FdoExtension->Common.Self->AlignmentRequirement);
663 Pdo->AlignmentRequirement = Alignment;
664
665 PdoExtension = Pdo->DeviceExtension;
666
668 PdoExtension->Common.Self = Pdo;
669 PdoExtension->Common.FdoExt = FdoExtension;
670 IoInitializeRemoveLock(&PdoExtension->Common.RemoveLock, TAG_PCIIDEX, 0, 0);
671
672 PdoExtension->Channel = ChannelNumber;
673 PdoExtension->ChanData = FdoExtension->Controller.Channels[ChannelNumber];
674 ASSERT(PdoExtension->ChanData);
675 PdoExtension->ChanData->PdoExt = PdoExtension;
676
677 Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
678 return PdoExtension;
679}
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
@ PdoExtension
Definition: precomp.h:61
union Alignment_ Alignment
_In_ UCXUSBDEVICE _In_ PDEVICE_OBJECT Pdo
Definition: hubucx.h:280
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1038
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:49
#define max(a, b)
Definition: svc.c:63
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
#define IoInitializeRemoveLock(Lock, AllocateTag, MaxLockedMinutes, HighWatermark)
Definition: iofuncs.h:2840

Referenced by PciIdeXFdoQueryBusRelations().