ReactOS 0.4.17-dev-116-ga4b6fe9
pdo.c File Reference
#include "pciidex.h"
Include dependency graph for pdo.c:

Go to the source code of this file.

Functions

static VOID PciIdeXPdoFreeDmaResources (_In_ PCHANNEL_DATA_COMMON ChanData)
 
static PDMA_ADAPTER PciIdeXPdoGetDmaAdapter (_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PCHANNEL_DATA_COMMON ChanData)
 
static BOOLEAN PciIdeXPdoInitDma (_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PCHANNEL_DATA_COMMON ChanData)
 
static NTSTATUS PciIdeXPdoStartDevice (_In_ PPDO_DEVICE_EXTENSION PdoExt, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
 
static NTSTATUS PciIdeXPdoStopDevice (_In_ PPDO_DEVICE_EXTENSION PdoExt)
 
NTSTATUS PciIdeXPdoRemoveDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp, _In_ BOOLEAN FinalRemove)
 
static NTSTATUS PciIdeXPdoQueryStopRemoveDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension)
 
static NTSTATUS PciIdeXPdoQueryTargetDeviceRelations (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXPdoQueryCapabilities (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static VOID PciIdeXMakePortResource (_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONG IoBase, _In_ ULONG Length)
 
static VOID PciIdeXMakePortRequirement (_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONG IoBase, _In_ ULONG Length)
 
static NTSTATUS PciIdeXPdoQueryResources (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXPdoQueryResourceRequirements (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static PCWSTR PciIdeXGetControllerVendorId (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 
static PCWSTR PciIdeXGetControllerDeviceId (_In_ PFDO_DEVICE_EXTENSION FdoExtension)
 
static NTSTATUS PciIdeXPdoQueryId (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXPdoQueryDeviceText (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXQueryPciIdeInterface (_In_ PPDO_DEVICE_EXTENSION PdoExt, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
 
static NTSTATUS PciIdeXPdoQueryInterface (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
 
static NTSTATUS PciIdeXPdoDispatchPnp (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI PciIdeXDispatchPnp (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 

Function Documentation

◆ PciIdeXDispatchPnp()

NTSTATUS NTAPI PciIdeXDispatchPnp ( _In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp 
)

Definition at line 1083 of file pdo.c.

1086{
1087 PAGED_CODE();
1088
1089 if (IS_FDO(DeviceObject->DeviceExtension))
1090 return PciIdeXFdoDispatchPnp(DeviceObject->DeviceExtension, Irp);
1091 else
1092 return PciIdeXPdoDispatchPnp(DeviceObject->DeviceExtension, Irp);
1093}
#define PAGED_CODE()
#define IS_FDO(p)
Definition: atapi.h:173
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS PciIdeXFdoDispatchPnp(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PIRP Irp)
Definition: fdo.c:910
static NTSTATUS PciIdeXPdoDispatchPnp(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:982
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061

Referenced by PciIdeXInitialize().

◆ PciIdeXGetControllerDeviceId()

static PCWSTR PciIdeXGetControllerDeviceId ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)
static

Definition at line 578 of file pdo.c.

580{
581 PAGED_CODE();
582
583 /* Intel */
584 if (FdoExtension->Controller.Pci.VendorID == 0x8086)
585 {
586 switch (FdoExtension->Controller.Pci.DeviceID)
587 {
588 case 0x1230:
589 return L"PIIX";
590 case 0x7010:
591 return L"PIIX3";
592 case 0x7111:
593 return L"PIIX4";
594
595 default:
596 break;
597 }
598 }
599
600 /* Only certain controllers have a non-numeric identifier */
601 return NULL;
602}
#define NULL
Definition: types.h:112
#define L(x)
Definition: resources.c:13
@ FdoExtension
Definition: precomp.h:48

Referenced by PciIdeXPdoQueryId().

◆ PciIdeXGetControllerVendorId()

static PCWSTR PciIdeXGetControllerVendorId ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)
static

Definition at line 547 of file pdo.c.

549{
550 PAGED_CODE();
551
552 switch (FdoExtension->Controller.Pci.VendorID)
553 {
554 case 0x0E11:
555 return L"Compaq";
556 case 0x1039:
557 return L"SiS";
558 case 0x1050:
559 return L"WinBond";
560 case 0x1095:
561 return L"CMD";
562 case 0x10B9:
563 return L"ALi";
564 case 0x8086:
565 return L"Intel";
566
567 default:
568 break;
569 }
570
571 /* Only certain controllers have a non-numeric identifier */
572 return NULL;
573}

Referenced by PciIdeXPdoQueryId().

◆ PciIdeXMakePortRequirement()

static VOID PciIdeXMakePortRequirement ( _Out_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ ULONG  IoBase,
_In_ ULONG  Length 
)
static

Definition at line 343 of file pdo.c.

347{
348 PAGED_CODE();
349
351 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
353 Descriptor->u.Port.Length = Length;
354 Descriptor->u.Port.Alignment = 1;
355 Descriptor->u.Port.MinimumAddress.LowPart = IoBase;
356 Descriptor->u.Port.MaximumAddress.LowPart = IoBase + Length - 1;
357}
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define CmResourceTypePort
Definition: restypes.h:104
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

Referenced by PciIdeXPdoQueryResourceRequirements().

◆ PciIdeXMakePortResource()

static VOID PciIdeXMakePortResource ( _Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Descriptor,
_In_ ULONG  IoBase,
_In_ ULONG  Length 
)
static

Definition at line 326 of file pdo.c.

330{
331 PAGED_CODE();
332
334 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
336 Descriptor->u.Port.Length = Length;
337 Descriptor->u.Port.Start.LowPart = IoBase;
338}

Referenced by PciIdeXPdoQueryResources().

◆ PciIdeXPdoDispatchPnp()

static NTSTATUS PciIdeXPdoDispatchPnp ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_Inout_ PIRP  Irp 
)
static

Definition at line 982 of file pdo.c.

985{
987 PIO_STACK_LOCATION IoStack;
988
989 PAGED_CODE();
990
991 Status = IoAcquireRemoveLock(&PdoExtension->Common.RemoveLock, Irp);
992 if (!NT_SUCCESS(Status))
993 {
994 Irp->IoStatus.Status = Status;
996
997 return Status;
998 }
999
1001 switch (IoStack->MinorFunction)
1002 {
1005 IoStack->Parameters.StartDevice.AllocatedResourcesTranslated);
1006 break;
1007
1008 case IRP_MN_STOP_DEVICE:
1010 break;
1011
1015 break;
1016
1020 break;
1021
1025 Irp,
1027
1031 else
1032 Status = Irp->IoStatus.Status;
1033 break;
1034
1037 break;
1038
1041 break;
1042
1045 break;
1046
1049 break;
1050
1051 case IRP_MN_QUERY_ID:
1053 break;
1054
1057 break;
1058
1061 break;
1062
1065 break;
1066
1067 default:
1068 Status = Irp->IoStatus.Status;
1069 break;
1070 }
1071
1072 Irp->IoStatus.Status = Status;
1074
1075 IoReleaseRemoveLock(&PdoExtension->Common.RemoveLock, Irp);
1076
1077 return Status;
1078}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
@ PdoExtension
Definition: precomp.h:49
Status
Definition: gdiplustypes.h:25
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoCompleteRequest
Definition: irp.c:1240
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
#define STATUS_SUCCESS
Definition: shellext.h:65
static NTSTATUS PciIdeXPdoQueryStopRemoveDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: pdo.c:237
static NTSTATUS PciIdeXPdoQueryResources(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:362
static NTSTATUS PciIdeXPdoQueryCapabilities(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:280
static NTSTATUS PciIdeXPdoStartDevice(_In_ PPDO_DEVICE_EXTENSION PdoExt, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
Definition: pdo.c:89
NTSTATUS PciIdeXPdoRemoveDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp, _In_ BOOLEAN FinalRemove)
Definition: pdo.c:193
static NTSTATUS PciIdeXPdoQueryDeviceText(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:795
static NTSTATUS PciIdeXPdoStopDevice(_In_ PPDO_DEVICE_EXTENSION PdoExt)
Definition: pdo.c:175
static NTSTATUS PciIdeXPdoQueryInterface(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:955
static NTSTATUS PciIdeXPdoQueryResourceRequirements(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:456
static NTSTATUS PciIdeXPdoQueryTargetDeviceRelations(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:255
static NTSTATUS PciIdeXPdoQueryId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:607
union _IO_STACK_LOCATION::@1696 Parameters
struct _IO_STACK_LOCATION::@4454::@4479 QueryDeviceRelations
struct _IO_STACK_LOCATION::@4454::@4491 StartDevice
#define IoAcquireRemoveLock(RemoveLock, Tag)
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2764
#define IRP_MN_CANCEL_STOP_DEVICE
@ TargetDeviceRelation
Definition: iotypes.h:2158
#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_RESOURCE_REQUIREMENTS
#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_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by PciIdeXDispatchPnp().

◆ PciIdeXPdoFreeDmaResources()

static VOID PciIdeXPdoFreeDmaResources ( _In_ PCHANNEL_DATA_COMMON  ChanData)
static

Definition at line 14 of file pdo.c.

16{
17 PAGED_CODE();
18
19 if (ChanData->DmaAdapter)
20 {
21 ChanData->FreeMemory(ChanData);
22
23 ChanData->DmaAdapter->DmaOperations->PutDmaAdapter(ChanData->DmaAdapter);
24 ChanData->DmaAdapter = NULL;
25 }
26}

Referenced by PciIdeXPdoInitDma(), and PciIdeXPdoStopDevice().

◆ PciIdeXPdoGetDmaAdapter()

static PDMA_ADAPTER PciIdeXPdoGetDmaAdapter ( _In_ PFDO_DEVICE_EXTENSION  FdoExt,
_In_ PCHANNEL_DATA_COMMON  ChanData 
)
static

Definition at line 31 of file pdo.c.

34{
36
37 PAGED_CODE();
38
40 DeviceDescription.Master = TRUE;
41 DeviceDescription.ScatterGather = TRUE;
42 DeviceDescription.Dma32BitAddresses = !(ChanData->ChanInfo & CHANNEL_FLAG_64_BIT_DMA);
43 DeviceDescription.InterfaceType = PCIBus;
44 DeviceDescription.MaximumLength = ChanData->MaximumTransferLength;
45
46 return IoGetDmaAdapter(FdoExt->Common.LowerDeviceObject,
48 &ChanData->MaximumPhysicalPages);
49}
#define TRUE
Definition: types.h:120
#define CHANNEL_FLAG_64_BIT_DMA
Definition: pciidex.h:266
PDMA_ADAPTER NTAPI IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_DESCRIPTION DeviceDescription, IN OUT PULONG NumberOfMapRegisters)
Definition: pnpdma.c:23
@ PCIBus
Definition: restypes.h:126
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432
#define DEVICE_DESCRIPTION_VERSION
Definition: iotypes.h:2063

Referenced by PciIdeXPdoInitDma().

◆ PciIdeXPdoInitDma()

static BOOLEAN PciIdeXPdoInitDma ( _In_ PFDO_DEVICE_EXTENSION  FdoExt,
_In_ PCHANNEL_DATA_COMMON  ChanData 
)
static

Definition at line 54 of file pdo.c.

57{
59
60 ChanData->DmaAdapter = PciIdeXPdoGetDmaAdapter(FdoExt, ChanData);
61 if (!ChanData->DmaAdapter)
62 {
63 WARN("CH %lu: Unable to get DMA adapter\n", ChanData->Channel);
64 return FALSE;
65 }
66
67 Status = ChanData->AllocateMemory(ChanData);
68 if (!NT_SUCCESS(Status))
69 {
70 WARN("CH %lu: Unable to allocate DMA memory %lx\n", ChanData->Channel, Status);
72 return FALSE;
73 }
74
75 /* See what transfer length we actually got. Round down in case we have some extra pages */
76 ChanData->Current.MaximumTransferLength = min(ChanData->Current.MaximumTransferLength,
77 ChanData->MaximumPhysicalPages << PAGE_SHIFT);
78 INFO("CH %lu: Allocated %lu PRD pages, maximum transfer length 0x%lx\n",
79 ChanData->Channel,
80 ChanData->MaximumPhysicalPages,
81 ChanData->Current.MaximumTransferLength);
82
83 return TRUE;
84}
#define WARN(fmt,...)
Definition: precomp.h:61
#define FALSE
Definition: types.h:117
#define INFO
Definition: debug.h:89
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define min(a, b)
Definition: monoChain.cc:55
static VOID PciIdeXPdoFreeDmaResources(_In_ PCHANNEL_DATA_COMMON ChanData)
Definition: pdo.c:14
static PDMA_ADAPTER PciIdeXPdoGetDmaAdapter(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PCHANNEL_DATA_COMMON ChanData)
Definition: pdo.c:31

Referenced by PciIdeXPdoStartDevice().

◆ PciIdeXPdoQueryCapabilities()

static NTSTATUS PciIdeXPdoQueryCapabilities ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp 
)
static

Definition at line 280 of file pdo.c.

283{
285 PATA_CONTROLLER Controller;
286 DEVICE_CAPABILITIES ParentCapabilities;
288 PIO_STACK_LOCATION IoStack;
290
291 PAGED_CODE();
292
293 /* Get the capabilities of the parent device */
294 RtlZeroMemory(&ParentCapabilities, sizeof(ParentCapabilities));
295 ParentCapabilities.Size = sizeof(ParentCapabilities);
296 ParentCapabilities.Version = 1;
297 ParentCapabilities.Address = MAXULONG;
298 ParentCapabilities.UINumber = MAXULONG;
299 Status = PciIdeXPnpRepeatRequest(&PdoExtension->Common, Irp, &ParentCapabilities);
300 if (!NT_SUCCESS(Status))
301 return Status;
302
304 DeviceCapabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
305 *DeviceCapabilities = ParentCapabilities;
306
307 /* Override some fields */
308 DeviceCapabilities->UniqueID = FALSE;
309 DeviceCapabilities->Address = PdoExtension->Channel;
310
311 FdoExt = PdoExtension->Common.FdoExt;
312 Controller = &FdoExt->Controller;
313 if (Controller->Flags & CTRL_FLAG_SATA_HBA_ACPI)
314 {
315 /* Convert to a root port number */
316 DeviceCapabilities->Address <<= 16;
317 DeviceCapabilities->Address |= 0xFFFF;
318 }
319
320 return STATUS_SUCCESS;
321}
_In_ PIOMMU_DEVICE_PATH _In_ PIOMMU_SVM_CAPABILITIES DeviceCapabilities
Definition: haltypes.h:1824
NTSTATUS PciIdeXPnpRepeatRequest(_In_ PCOMMON_DEVICE_EXTENSION CommonExt, _In_ PIRP Irp, _In_opt_ PDEVICE_CAPABILITIES DeviceCapabilities)
Definition: pciidex.c:156
#define CTRL_FLAG_SATA_HBA_ACPI
Definition: pciidex.h:225
ATA_CONTROLLER Controller
Definition: pciidex.h:395
struct _IO_STACK_LOCATION::@4454::@4481 DeviceCapabilities
#define MAXULONG
Definition: typedefs.h:251
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DeviceCapabilities
Definition: wingdi.h:4895
DEVICE_CAPABILITIES
Definition: iotypes.h:965
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryDeviceText()

static NTSTATUS PciIdeXPdoQueryDeviceText ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp 
)
static

Definition at line 795 of file pdo.c.

798{
799 PIO_STACK_LOCATION IoStack;
802 size_t CharCount;
803
804 PAGED_CODE();
805
807 switch (IoStack->Parameters.QueryDeviceText.DeviceTextType)
808 {
810 {
811 CharCount = sizeof("ATA Channel 99");
812
814 CharCount * sizeof(WCHAR),
816 if (!Buffer)
818
820 CharCount,
821 NULL,
822 NULL,
823 0,
824 L"ATA Channel %lu",
825 PdoExtension->Channel);
827
828 INFO("Device Description: '%S'\n", Buffer);
829 break;
830 }
831
833 {
834 CharCount = sizeof("Channel 99");
835
837 CharCount * sizeof(WCHAR),
839 if (!Buffer)
841
843 CharCount,
844 NULL,
845 NULL,
846 0,
847 L"Channel %lu",
848 PdoExtension->Channel);
850
851 INFO("Device Location: '%S'\n", Buffer);
852 break;
853 }
854
855 default:
856 return Irp->IoStatus.Status;
857 }
858
859 Irp->IoStatus.Information = (ULONG_PTR)Buffer;
860 return STATUS_SUCCESS;
861}
#define ExAllocatePoolUninitialized
Definition: bufpool.h:45
#define ULONG_PTR
Definition: config.h:101
#define PagedPool
Definition: env_spec_w32.h:308
#define ASSERT(a)
Definition: mode.c:44
NTSTRSAFEVAPI RtlStringCchPrintfExW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _Outptr_opt_result_buffer_(*pcchRemaining) NTSTRSAFE_PWSTR *ppszDestEnd, _Out_opt_ size_t *pcchRemaining, _In_ STRSAFE_DWORD dwFlags, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1246
#define TAG_PCIIDEX
Definition: pciidex.h:32
short WCHAR
Definition: pedump.c:58
struct _IO_STACK_LOCATION::@4454::@4486 QueryDeviceText
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
@ DeviceTextLocationInformation
Definition: iotypes.h:2948
@ DeviceTextDescription
Definition: iotypes.h:2947

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryId()

static NTSTATUS PciIdeXPdoQueryId ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp 
)
static

Definition at line 607 of file pdo.c.

610{
611 PIO_STACK_LOCATION IoStack;
613 PWCHAR Buffer, End;
614 size_t CharCount, Remaining;
615 static const WCHAR IdeCompatibleId[] = L"*PNP0600";
616
617 PAGED_CODE();
618
620 switch (IoStack->Parameters.QueryId.IdType)
621 {
622 case BusQueryDeviceID:
623 {
624 static const WCHAR PciIdeDeviceId[] = L"PCIIDE\\IDEChannel";
625
626 Buffer = ExAllocatePoolUninitialized(PagedPool, sizeof(PciIdeDeviceId), TAG_PCIIDEX);
627 if (!Buffer)
629
630 RtlCopyMemory(Buffer, PciIdeDeviceId, sizeof(PciIdeDeviceId));
631
632 INFO("Device ID: '%S'\n", Buffer);
633 break;
634 }
635
637 {
639 PWCHAR IdStart;
640
642
643 /* Maximum string length */
644 CharCount = sizeof("WinBond-1234") +
645 sizeof("Internal_IDE_Channel") +
646 RTL_NUMBER_OF(IdeCompatibleId) +
647 sizeof(ANSI_NULL); /* multi-string */
648
650 CharCount * sizeof(WCHAR),
652 if (!Buffer)
654
655 INFO("HardwareIDs:\n");
656
657 FdoExtension = PdoExtension->Common.FdoExt;
658 End = Buffer;
659 Remaining = CharCount;
660
661 if (!(FdoExtension->Controller.Flags & CTRL_FLAG_NON_PNP))
662 {
664
665 /* ID 1 */
666 if (VendorString)
667 {
669
670 if (DeviceString)
671 {
673 Remaining,
674 &End,
675 &Remaining,
676 0,
677 L"%ls-%ls",
678 VendorString,
679 DeviceString);
680 }
681 else
682 {
684 Remaining,
685 &End,
686 &Remaining,
687 0,
688 L"%ls-%04x",
689 VendorString,
690 FdoExtension->Controller.Pci.DeviceID);
691 }
692 }
693 else
694 {
696 Remaining,
697 &End,
698 &Remaining,
699 0,
700 L"%04x-%04x",
701 FdoExtension->Controller.Pci.VendorID,
702 FdoExtension->Controller.Pci.DeviceID);
703 }
705
706 INFO(" '%S'\n", Buffer);
707
708 ++End;
709 --Remaining;
710 }
711
712 /* ID 2 */
713 IdStart = End;
715 Remaining,
716 &End,
717 &Remaining,
718 0,
719 L"%hs",
720 "Internal_IDE_Channel");
722
723 INFO(" '%S'\n", IdStart);
724
725 ++End;
726 --Remaining;
727
728 /* ID 3 */
729 IdStart = End;
731 Remaining,
732 &End,
733 &Remaining,
734 0,
735 L"%ls",
736 IdeCompatibleId);
738
739 INFO(" '%S'\n", IdStart);
740
741 *++End = UNICODE_NULL; /* multi-string */
742 break;
743 }
744
746 {
748 sizeof(IdeCompatibleId) + sizeof(UNICODE_NULL),
750 if (!Buffer)
752
753 RtlCopyMemory(Buffer, IdeCompatibleId, sizeof(IdeCompatibleId));
754
755 Buffer[sizeof(IdeCompatibleId) / sizeof(WCHAR)] = UNICODE_NULL; /* multi-string */
756
757 INFO("Compatible ID: '%S'\n", Buffer);
758 break;
759 }
760
762 {
763 CharCount = sizeof("00");
764
766 CharCount * sizeof(WCHAR),
768 if (!Buffer)
770
772 CharCount,
773 NULL,
774 NULL,
775 0,
776 L"%lu",
777 PdoExtension->Channel);
779
780 INFO("Instance ID: '%S'\n", Buffer);
781 break;
782 }
783
784 default:
785 return Irp->IoStatus.Status;
786 }
787
788 Irp->IoStatus.Information = (ULONG_PTR)Buffer;
789 return STATUS_SUCCESS;
790}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:331
#define UNICODE_NULL
#define ANSI_NULL
#define CTRL_FLAG_NON_PNP
Definition: pciidex.h:228
static PCWSTR PciIdeXGetControllerVendorId(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: pdo.c:547
static PCWSTR PciIdeXGetControllerDeviceId(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: pdo.c:578
struct _IO_STACK_LOCATION::@4454::@4485 QueryId
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
@ BusQueryCompatibleIDs
Definition: iotypes.h:2940
@ BusQueryInstanceID
Definition: iotypes.h:2941
@ BusQueryDeviceID
Definition: iotypes.h:2938
@ BusQueryHardwareIDs
Definition: iotypes.h:2939

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryInterface()

static NTSTATUS PciIdeXPdoQueryInterface ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_Inout_ PIRP  Irp 
)
static

Definition at line 955 of file pdo.c.

958{
960 PIO_STACK_LOCATION IoStack;
961
962 PAGED_CODE();
963
965
966 if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
967 &GUID_PCIIDE_INTERFACE_ROS))
968 {
970 }
971 else
972 {
973 Status = Irp->IoStatus.Status;
974 }
975
976 return Status;
977}
static NTSTATUS PciIdeXQueryPciIdeInterface(_In_ PPDO_DEVICE_EXTENSION PdoExt, _In_ PIRP Irp, _In_ PIO_STACK_LOCATION IoStack)
Definition: pdo.c:866
struct _IO_STACK_LOCATION::@4454::@4480 QueryInterface
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryResourceRequirements()

static NTSTATUS PciIdeXPdoQueryResourceRequirements ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp 
)
static

Definition at line 456 of file pdo.c.

459{
461 PATA_CONTROLLER Controller = &FdoExtension->Controller;
464 IDE_CHANNEL_STATE ChannelState;
465 ULONG CommandPortBase, ControlPortBase, InterruptVector, ListSize;
466 BOOLEAN AppendSecondaryResources;
467
468 PAGED_CODE();
469
470 if (Controller->Flags & (CTRL_FLAG_NATIVE_PCI | CTRL_FLAG_NON_PNP))
471 return Irp->IoStatus.Status;
472
473 ChannelState = PciIdeXGetChannelState(Controller, PdoExtension->Channel);
474 if (ChannelState == ChannelDisabled)
475 return Irp->IoStatus.Status;
476
477 AppendSecondaryResources = (Controller->MaxChannels == 1);
478
479 ListSize = FIELD_OFFSET(IO_RESOURCE_REQUIREMENTS_LIST, List[0].Descriptors) +
481 if (AppendSecondaryResources)
482 ListSize += sizeof(IO_RESOURCE_DESCRIPTOR) * 2;
484 if (!RequirementsList)
486
487 /* Legacy mode resources */
488 RequirementsList->InterfaceType = Isa;
489 RequirementsList->ListSize = ListSize;
490 RequirementsList->AlternativeLists = 1;
491 RequirementsList->List[0].Version = 1;
492 RequirementsList->List[0].Revision = 1;
494 if (AppendSecondaryResources)
495 RequirementsList->List[0].Count += 2;
496
498 {
499 CommandPortBase = PCIIDE_LEGACY_PRIMARY_COMMAND_BASE;
500 ControlPortBase = PCIIDE_LEGACY_PRIMARY_CONTROL_BASE;
501 InterruptVector = PCIIDE_LEGACY_PRIMARY_IRQ;
502 }
503 else
504 {
505 CommandPortBase = PCIIDE_LEGACY_SECONDARY_COMMAND_BASE;
506 ControlPortBase = PCIIDE_LEGACY_SECONDARY_CONTROL_BASE;
507 InterruptVector = PCIIDE_LEGACY_SECONDARY_IRQ;
508 }
509
510 Descriptor = &RequirementsList->List[0].Descriptors[0];
511
512 /* Command port base */
514 CommandPortBase,
516
517 /* Control port base */
519 ControlPortBase,
521
522 /* Interrupt */
524 Descriptor->ShareDisposition = CmResourceShareShared;
526 Descriptor->u.Interrupt.MinimumVector = InterruptVector;
527 Descriptor->u.Interrupt.MaximumVector = InterruptVector;
528
529 if (AppendSecondaryResources)
530 {
534
538 }
539
540 Irp->IoStatus.Information = (ULONG_PTR)RequirementsList;
541 return STATUS_SUCCESS;
542}
unsigned char BOOLEAN
Definition: actypes.h:127
IDE_CHANNEL_STATE
Definition: ide.h:196
@ ChannelDisabled
Definition: ide.h:197
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define PCIIDE_LEGACY_PRIMARY_CONTROL_BASE
Definition: pata.h:75
#define PCIIDE_LEGACY_SECONDARY_COMMAND_BASE
Definition: pata.h:77
#define PCIIDE_LEGACY_SECONDARY_CONTROL_BASE
Definition: pata.h:78
#define PCIIDE_LEGACY_PRIMARY_IRQ
Definition: pata.h:76
#define PCIIDE_LEGACY_COMMAND_IO_RANGE_LENGTH
Definition: pata.h:72
#define PCIIDE_LEGACY_RESOURCE_COUNT
Definition: pata.h:71
#define PCIIDE_LEGACY_CONTROL_IO_RANGE_LENGTH
Definition: pata.h:73
#define PCIIDE_LEGACY_SECONDARY_IRQ
Definition: pata.h:79
#define PCIIDE_LEGACY_PRIMARY_COMMAND_BASE
Definition: pata.h:74
#define CTRL_FLAG_NATIVE_PCI
Definition: pciidex.h:223
#define IS_PRIMARY_CHANNEL(PdoExtension)
Definition: pciidex.h:43
@ Isa
Definition: restypes.h:122
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: restypes.h:117
#define CmResourceTypeInterrupt
Definition: restypes.h:105
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
IDE_CHANNEL_STATE PciIdeXGetChannelState(_In_ PATA_CONTROLLER Controller, _In_ ULONG Channel)
Definition: fdo.c:678
static VOID PciIdeXMakePortRequirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONG IoBase, _In_ ULONG Length)
Definition: pdo.c:343
ULONG MaxChannels
Definition: pciidex.h:213
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryResources()

static NTSTATUS PciIdeXPdoQueryResources ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp 
)
static

Definition at line 362 of file pdo.c.

365{
367 PATA_CONTROLLER Controller = &FdoExtension->Controller;
368 IDE_CHANNEL_STATE ChannelState;
371 ULONG CommandPortBase, ControlPortBase, InterruptVector, ListSize;
372 BOOLEAN AppendSecondaryResources;
373
374 PAGED_CODE();
375
376 if (Controller->Flags & (CTRL_FLAG_NATIVE_PCI | CTRL_FLAG_NON_PNP))
377 return Irp->IoStatus.Status;
378
379 ChannelState = PciIdeXGetChannelState(Controller, PdoExtension->Channel);
380 if (ChannelState == ChannelDisabled)
381 return Irp->IoStatus.Status;
382
383 /*
384 * There are single-channel IDE controllers that only support the primary channel
385 * (e.g. Intel SCH or VIA VT6415). In that case,
386 * some secondary channels may still decode its hardware resources.
387 * To handle all cases, append a dummy resource block to the primary channel
388 * so that the PnP manager does not allocate this I/O range to other devices in the system.
389 */
390 AppendSecondaryResources = (Controller->MaxChannels == 1);
391
392 ListSize = FIELD_OFFSET(CM_RESOURCE_LIST, List[0].PartialResourceList.PartialDescriptors) +
394 if (AppendSecondaryResources)
395 ListSize += sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * 2;
397 if (!ResourceList)
399
400 /* Legacy mode resources */
401 ResourceList->Count = 1;
402 ResourceList->List[0].InterfaceType = Isa;
403 ResourceList->List[0].PartialResourceList.Version = 1;
404 ResourceList->List[0].PartialResourceList.Revision = 1;
405 ResourceList->List[0].PartialResourceList.Count = PCIIDE_LEGACY_RESOURCE_COUNT;
406 if (AppendSecondaryResources)
407 ResourceList->List[0].PartialResourceList.Count += 2;
408
410 {
411 CommandPortBase = PCIIDE_LEGACY_PRIMARY_COMMAND_BASE;
412 ControlPortBase = PCIIDE_LEGACY_PRIMARY_CONTROL_BASE;
413 InterruptVector = PCIIDE_LEGACY_PRIMARY_IRQ;
414 }
415 else
416 {
417 CommandPortBase = PCIIDE_LEGACY_SECONDARY_COMMAND_BASE;
418 ControlPortBase = PCIIDE_LEGACY_SECONDARY_CONTROL_BASE;
419 InterruptVector = PCIIDE_LEGACY_SECONDARY_IRQ;
420 }
421
422 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[0];
423
424 /* Command port base */
426
427 /* Control port base */
429
430 /* Interrupt */
432 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
434 Descriptor->u.Interrupt.Level = InterruptVector;
435 Descriptor->u.Interrupt.Vector = InterruptVector;
436 Descriptor->u.Interrupt.Affinity = (KAFFINITY)-1;
437
438 if (AppendSecondaryResources)
439 {
443
447 }
448
449 Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
450 return STATUS_SUCCESS;
451}
ULONG_PTR KAFFINITY
Definition: compat.h:85
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
static VOID PciIdeXMakePortResource(_Out_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ ULONG IoBase, _In_ ULONG Length)
Definition: pdo.c:326
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryStopRemoveDevice()

static NTSTATUS PciIdeXPdoQueryStopRemoveDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension)
static

Definition at line 237 of file pdo.c.

239{
240 PAGED_CODE();
241
242 if (PdoExtension->Common.PageFiles ||
243 PdoExtension->Common.HibernateFiles ||
244 PdoExtension->Common.DumpFiles)
245 {
246 return STATUS_DEVICE_BUSY;
247 }
248
249 return STATUS_SUCCESS;
250}
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryTargetDeviceRelations()

static NTSTATUS PciIdeXPdoQueryTargetDeviceRelations ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp 
)
static

Definition at line 255 of file pdo.c.

258{
259 PDEVICE_RELATIONS DeviceRelations;
260
261 PAGED_CODE();
262
263 DeviceRelations = ExAllocatePoolUninitialized(PagedPool,
264 sizeof(*DeviceRelations),
266 if (!DeviceRelations)
268
269 DeviceRelations->Count = 1;
270 DeviceRelations->Objects[0] = PdoExtension->Common.Self;
271 ObReferenceObject(PdoExtension->Common.Self);
272
273 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
274 return STATUS_SUCCESS;
275}
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2165
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by PciIdeXPdoDispatchPnp().

◆ 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}
#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
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1252
#define PDO_FLAG_REPORTED_MISSING
Definition: pciidex.h:410
#define IoReleaseRemoveLockAndWait(_RemoveLock, _Tag)
Definition: iofuncs.h:2774

Referenced by PciIdeXFdoRemoveDevice(), and PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoStartDevice()

static NTSTATUS PciIdeXPdoStartDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExt,
_In_ PCM_RESOURCE_LIST  ResourcesTranslated 
)
static

Definition at line 89 of file pdo.c.

92{
94 PATA_CONTROLLER Controller = &FdoExt->Controller;
95 PCHANNEL_DATA_COMMON ChanData = PdoExt->ChanData;
97
98 PAGED_CODE();
99
100 /* Init default values */
101 if (ChanData->MaximumTransferLength == 0)
103 ChanData->Current.MaximumTransferLength = ChanData->MaximumTransferLength;
104 ChanData->Current.TransferModeSupported = ChanData->TransferModeSupported;
105
106 if (!(Controller->Flags & CTRL_FLAG_IS_AHCI))
107 {
108 PCHANNEL_DATA_PATA PataData = (PCHANNEL_DATA_PATA)ChanData;
109
110 if (!(Controller->Flags & CTRL_FLAG_MANUAL_RES))
111 {
113 if (!NT_SUCCESS(Status))
114 {
115 ERR("CH %lu: Failed to parse resources 0x%lx\n", ChanData->Channel, Status);
116 return Status;
117 }
118 }
119
120 /* Query the first _GTM data */
121 if (!(Controller->Flags & CTRL_FLAG_SATA_HBA_ACPI) &&
122 !(ChanData->ChanInfo & CHANNEL_FLAG_HAS_ACPI_GTM))
123 {
125 {
126 INFO("CH %lu: ACPI available\n", ChanData->Channel);
128 }
129 }
130 }
131
132 /* Allocate DMA resources */
133 if (ChanData->Current.TransferModeSupported & ~PIO_ALL)
134 {
135 if (!PciIdeXPdoInitDma(FdoExt, ChanData))
136 {
137 /* Fall back to PIO */
138 ChanData->Current.TransferModeSupported &= PIO_ALL;
139 INFO("CH %lu: Non DMA channel\n", ChanData->Channel);
140 }
141 }
142
143 if (!ChanData->DmaAdapter)
144 {
145 /* Check for ATA controllers that do not support PIO operations */
146 if (ChanData->ChanInfo & CHANNEL_FLAG_PIO_VIA_DMA)
147 {
148 ERR("CH %lu: Unable to fall back to PIO mode\n", ChanData->Channel);
150 }
151
152 /* Get maximum physical pages for non DMA channel */
153 ChanData->MaximumPhysicalPages = BYTES_TO_PAGES(ChanData->Current.MaximumTransferLength);
154 }
155
156 if (!(Controller->Flags & CTRL_FLAG_IS_AHCI))
157 {
158 Status = PciIdeConnectInterrupt(ChanData);
159 if (!NT_SUCCESS(Status))
160 {
161 ERR("CH %lu: Could not connect to interrupt\n", ChanData->Channel, Status);
162 return Status;
163 }
164
165 if (!(ChanData->ChanInfo & CHANNEL_FLAG_IO32))
166 INFO("CH %lu: 32-bit I/O not supported\n", ChanData->Channel);
167 }
168
169 return STATUS_SUCCESS;
170}
BOOLEAN AtaAcpiGetTimingMode(_In_ PDEVICE_OBJECT DeviceObject, _Out_ PIDE_ACPI_TIMING_MODE_BLOCK TimingMode)
Definition: acpi.c:98
#define ATA_MAX_TRANSFER_LENGTH
Definition: ata_shared.h:26
#define PIO_ALL
Definition: ata_user.h:19
#define ERR(fmt,...)
Definition: precomp.h:57
NTSTATUS PciIdeParseResources(_In_ PCHANNEL_DATA_PATA ChanData, _In_ PCM_RESOURCE_LIST ResourcesTranslated)
Definition: pata_generic.c:849
NTSTATUS PciIdeConnectInterrupt(_In_ PVOID ChannelContext)
#define CHANNEL_FLAG_IO32
Definition: pciidex.h:260
#define CTRL_FLAG_MANUAL_RES
Definition: pciidex.h:229
#define CHANNEL_FLAG_PIO_VIA_DMA
Definition: pciidex.h:269
#define CTRL_FLAG_IS_AHCI
Definition: pciidex.h:227
struct _CHANNEL_DATA_PATA * PCHANNEL_DATA_PATA
Definition: pciidex.h:28
#define CHANNEL_FLAG_HAS_ACPI_GTM
Definition: pciidex.h:275
static BOOLEAN PciIdeXPdoInitDma(_In_ PFDO_DEVICE_EXTENSION FdoExt, _In_ PCHANNEL_DATA_COMMON ChanData)
Definition: pdo.c:54
ULONG TransferModeSupported
Definition: pciidex.h:250
struct _CHANNEL_DATA_COMMON::@1183 Current
PDMA_ADAPTER DmaAdapter
Definition: pciidex.h:249
ULONG MaximumPhysicalPages
Definition: pciidex.h:258
ULONG MaximumTransferLength
Definition: pciidex.h:251
IDE_ACPI_TIMING_MODE_BLOCK CurrentTimingMode
Definition: pciidex.h:315
PDEVICE_OBJECT Self
Definition: pciidex.h:376
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133
_In_ WDFCMRESLIST _In_ WDFCMRESLIST ResourcesTranslated
Definition: wdfdevice.h:891
#define BYTES_TO_PAGES(Size)

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoStopDevice()

static NTSTATUS PciIdeXPdoStopDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExt)
static

Definition at line 175 of file pdo.c.

177{
178 PCHANNEL_DATA_COMMON ChanData = PdoExt->ChanData;
179 PATA_CONTROLLER Controller = ChanData->Controller;
180
181 PAGED_CODE();
182
183 if (!(Controller->Flags & CTRL_FLAG_IS_AHCI))
184 PciIdeFreeResources(ChanData);
185
187
188 return STATUS_SUCCESS;
189}
VOID PciIdeFreeResources(_In_ PVOID ChannelContext)
Definition: pata_generic.c:877
PATA_CONTROLLER Controller
Definition: pciidex.h:248

Referenced by PciIdeXPdoDispatchPnp(), and PciIdeXPdoRemoveDevice().

◆ PciIdeXQueryPciIdeInterface()

static NTSTATUS PciIdeXQueryPciIdeInterface ( _In_ PPDO_DEVICE_EXTENSION  PdoExt,
_In_ PIRP  Irp,
_In_ PIO_STACK_LOCATION  IoStack 
)
static

Definition at line 866 of file pdo.c.

870{
872 PATA_CONTROLLER Controller = &FdoExt->Controller;
873 PCHANNEL_DATA_COMMON ChanData;
874 PPCIIDEX_CHANNEL_INTERFACE ChannelInterface;
875
876 PAGED_CODE();
877
878 if (IoStack->Parameters.QueryInterface.Size < sizeof(*ChannelInterface))
879 return Irp->IoStatus.Status;
880
881 if (IoStack->Parameters.QueryInterface.Version != PCIIDEX_INTERFACE_VERSION)
882 return Irp->IoStatus.Status;
883
884 ChanData = PdoExt->ChanData;
885
886 ChannelInterface = (PPCIIDEX_CHANNEL_INTERFACE)IoStack->Parameters.QueryInterface.Interface;
887 ChannelInterface->AttachChannel = AtaCtrlAttachChannel;
888 ChannelInterface->ChannelContext = ChanData;
889 ChannelInterface->Channel = ChanData->Channel;
890 ChannelInterface->MaximumTransferLength = ChanData->Current.MaximumTransferLength;
891 ChannelInterface->TransferModeSupported = ChanData->Current.TransferModeSupported;
892 ChannelInterface->SetTransferMode = AtaCtrlSetTransferMode;
893 ChannelInterface->SetDeviceData = AtaCtrlSetDeviceData;
894 ChannelInterface->GetInitTaskFile = AtaCtrlGetInitTaskFile;
896 ChannelInterface->PreparePrdTable = ChanData->PreparePrdTable;
897 ChannelInterface->PrepareIo = ChanData->PrepareIo;
898 ChannelInterface->StartIo = ChanData->StartIo;
899 ChannelInterface->MaximumPhysicalPages = ChanData->MaximumPhysicalPages;
900 ChannelInterface->QueueDepth = Controller->QueueDepth;
901 ChannelInterface->DmaAdapter = ChanData->DmaAdapter;
902 ChannelInterface->ChannelObject = PdoExt->Common.Self;
903 ChannelInterface->AbortChannel = AtaCtrlAbortChannel;
904
905 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
906 {
907 ChannelInterface->AllocateSlot = AtaAhciAllocateSlot;
908 ChannelInterface->ResetChannel = AtaAhciResetChannel;
909 ChannelInterface->EnumerateChannel = AtaAhciEnumerateChannel;
910 ChannelInterface->IdentifyDevice = AtaAhciIdentifyDevice;
911 ChannelInterface->MaxTargetId = AtaAhciChannelGetMaximumDeviceCount(ChanData);
912 }
913 else
914 {
915 ChannelInterface->AllocateSlot = PataAllocateSlot;
916 ChannelInterface->ResetChannel = PataResetChannel;
917 ChannelInterface->EnumerateChannel = PataEnumerateChannel;
918 ChannelInterface->IdentifyDevice = PataIdentifyDevice;
919 ChannelInterface->MaxTargetId = PataChannelGetMaximumDeviceCount(ChanData);
920 }
921
922 ChannelInterface->PortContext = &ChanData->PortContext;
923 ChannelInterface->PortNotification = &ChanData->PortNotification;
924 ChannelInterface->Slots = &ChanData->Slots;
925
926 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
927 ChannelInterface->InterruptObject = Controller->InterruptObject;
928 else
929 ChannelInterface->InterruptObject = ChanData->InterruptObject;
930
931 if (ChanData->ChanInfo & CHANNEL_FLAG_PIO_VIA_DMA)
932 ChannelInterface->Flags |= ATA_CHANNEL_FLAG_PIO_VIA_DMA;
933
934 if (ChanData->ChanInfo & CHANNEL_FLAG_IS_EXTERNAL)
935 ChannelInterface->Flags |= ATA_CHANNEL_FLAG_IS_EXTERNAL;
936
937 if (ChanData->ChanInfo & CHANNEL_FLAG_HAS_NCQ)
938 ChannelInterface->Flags |= ATA_CHANNEL_FLAG_NCQ;
939
940 if (Controller->Flags & CTRL_FLAG_IS_AHCI)
941 ChannelInterface->Flags |= ATA_CHANNEL_FLAG_IS_AHCI;
942
944 ChannelInterface->Flags |= ATA_CHANNEL_FLAG_PIO_FOR_LBA48_XFER;
945
946 if (Controller->Flags & CTRL_FLAG_IS_SIMPLEX)
947 ChannelInterface->HwSyncObject = Controller->HwSyncObject;
948
949 return STATUS_SUCCESS;
950}
ULONG AtaAhciChannelGetMaximumDeviceCount(_In_ PVOID ChannelContext)
Definition: ahci_hw.c:1569
#define PCIIDEX_INTERFACE_VERSION
Definition: ata_shared.h:12
#define ATA_CHANNEL_FLAG_IS_EXTERNAL
Definition: ata_shared.h:536
struct _PCIIDEX_CHANNEL_INTERFACE * PPCIIDEX_CHANNEL_INTERFACE
#define ATA_CHANNEL_FLAG_PIO_VIA_DMA
Definition: ata_shared.h:535
#define ATA_CHANNEL_FLAG_PIO_FOR_LBA48_XFER
Definition: ata_shared.h:539
#define ATA_CHANNEL_FLAG_NCQ
Definition: ata_shared.h:537
#define ATA_CHANNEL_FLAG_IS_AHCI
Definition: ata_shared.h:538
if(dx< 0)
Definition: linetemp.h:194
ULONG PataChannelGetMaximumDeviceCount(_In_ PVOID ChannelContext)
Definition: pata_hw.c:87
#define CHANNEL_FLAG_PIO_FOR_LBA48_XFER
Definition: pciidex.h:277
CONTROLLER_ATTACH_CHANNEL AtaCtrlAttachChannel
Definition: pciidex.h:455
CHANNEL_SET_MODE AtaCtrlSetTransferMode
Definition: pciidex.h:463
CHANNEL_IDENTIFY_DEVICE PataIdentifyDevice
Definition: pciidex.h:690
CHANNEL_ENUMERATE_CHANNEL PataEnumerateChannel
Definition: pciidex.h:689
CHANNEL_ALLOCATE_SLOT AtaAhciAllocateSlot
Definition: pciidex.h:628
CHANNEL_SET_DEVICE_DATA AtaCtrlSetDeviceData
Definition: pciidex.h:458
CHANNEL_IDENTIFY_DEVICE AtaAhciIdentifyDevice
Definition: pciidex.h:593
CHANNEL_ALLOCATE_SLOT PataAllocateSlot
Definition: pciidex.h:698
CHANNEL_DOWNGRADE_INTERFACE_SPEED AtaCtrlDowngradeInterfaceSpeed
Definition: pciidex.h:464
CHANNEL_RESET_CHANNEL PataResetChannel
Definition: pciidex.h:688
#define CHANNEL_FLAG_IS_EXTERNAL
Definition: pciidex.h:271
CHANNEL_ENUMERATE_CHANNEL AtaAhciEnumerateChannel
Definition: pciidex.h:592
CHANNEL_ABORT_CHANNEL AtaCtrlAbortChannel
Definition: pciidex.h:465
#define CHANNEL_FLAG_HAS_NCQ
Definition: pciidex.h:276
CHANNEL_RESET_CHANNEL AtaAhciResetChannel
Definition: pciidex.h:594
CHANNEL_GET_INIT_TASK_FILE AtaCtrlGetInitTaskFile
Definition: pciidex.h:461
#define CTRL_FLAG_IS_SIMPLEX
Definition: pciidex.h:224
PCONTROLLER_OBJECT HwSyncObject
Definition: pciidex.h:201
ULONG QueueDepth
Definition: pciidex.h:221
PKINTERRUPT InterruptObject
Definition: pciidex.h:172
PCHANNEL_PREPARE_IO PrepareIo
Definition: pciidex.h:245
PPORT_NOTIFICATION PortNotification
Definition: pciidex.h:286
PCHANNEL_PREPARE_PRD_TABLE PreparePrdTable
Definition: pciidex.h:244
PKINTERRUPT InterruptObject
Definition: pciidex.h:240
PATA_DEVICE_REQUEST * Slots
Definition: pciidex.h:289
PCHANNEL_START_IO StartIo
Definition: pciidex.h:246
Channel interface with the PCIIDEX driver.
Definition: ata_shared.h:502
PPORT_NOTIFICATION * PortNotification
Definition: ata_shared.h:542
PCHANNEL_SET_MODE SetTransferMode
Definition: ata_shared.h:526
PCHANNEL_ALLOCATE_SLOT AllocateSlot
Definition: ata_shared.h:527
PCHANNEL_RESET_CHANNEL ResetChannel
Definition: ata_shared.h:523
PCHANNEL_DOWNGRADE_INTERFACE_SPEED DowngradeInterfaceSpeed
Definition: ata_shared.h:521
PCHANNEL_IDENTIFY_DEVICE IdentifyDevice
Definition: ata_shared.h:525
PCHANNEL_GET_INIT_TASK_FILE GetInitTaskFile
Definition: ata_shared.h:520
PCHANNEL_ABORT_CHANNEL AbortChannel
Definition: ata_shared.h:522
PCHANNEL_SET_DEVICE_DATA SetDeviceData
Definition: ata_shared.h:519
PCHANNEL_START_IO StartIo
Definition: ata_shared.h:530
PCONTROLLER_OBJECT HwSyncObject
Definition: ata_shared.h:531
PCHANNEL_PREPARE_IO PrepareIo
Definition: ata_shared.h:529
PCONTROLLER_ATTACH_CHANNEL AttachChannel
Definition: ata_shared.h:511
PCHANNEL_PREPARE_PRD_TABLE PreparePrdTable
Definition: ata_shared.h:528
PATA_DEVICE_REQUEST ** Slots
Definition: ata_shared.h:543
PDEVICE_OBJECT ChannelObject
Definition: ata_shared.h:533
PCHANNEL_ENUMERATE_CHANNEL EnumerateChannel
Definition: ata_shared.h:524

Referenced by PciIdeXPdoQueryInterface().