ReactOS 0.4.15-dev-8339-g4028de8
pdo.c File Reference
#include "pciidex.h"
#include <debug.h>
Include dependency graph for pdo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS PciIdeXPdoStartDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PCM_RESOURCE_LIST ResourceList)
 
static NTSTATUS PciIdeXPdoStopDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension)
 
static NTSTATUS PciIdeXPdoRemoveDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ BOOLEAN FinalRemove)
 
static NTSTATUS PciIdeXPdoQueryStopRemoveDevice (_In_ PPDO_DEVICE_EXTENSION PdoExtension)
 
static NTSTATUS PciIdeXPdoQueryTargetDeviceRelations (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS NTAPI PciIdeXOnRepeaterCompletion (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_reads_opt_(_Inexpressible_("varies")) PVOID Context)
 
static NTSTATUS PciIdeXPdoRepeatRequest (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp, _In_opt_ PDEVICE_CAPABILITIES DeviceCapabilities)
 
static NTSTATUS PciIdeXPdoQueryCapabilities (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXPdoQueryPnpDeviceState (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
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 PciIdeXPdoQueryDeviceUsageNotification (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
 
static NTSTATUS PciIdeXPdoDispatchPnp (_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
 
NTSTATUS NTAPI PciIdeXDispatchPnp (_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
 

Variables

static IO_COMPLETION_ROUTINE PciIdeXOnRepeaterCompletion
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file pdo.c.

Function Documentation

◆ PciIdeXDispatchPnp()

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

Definition at line 840 of file pdo.c.

843{
844 PAGED_CODE();
845
846 if (IS_FDO(DeviceObject->DeviceExtension))
847 return PciIdeXFdoDispatchPnp(DeviceObject->DeviceExtension, Irp);
848 else
849 return PciIdeXPdoDispatchPnp(DeviceObject->DeviceExtension, Irp);
850}
#define PAGED_CODE()
_In_ PIRP Irp
Definition: csq.h:116
#define IS_FDO(p)
Definition: pciidex.h:21
NTSTATUS PciIdeXFdoDispatchPnp(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _Inout_ PIRP Irp)
Definition: fdo.c:422
static NTSTATUS PciIdeXPdoDispatchPnp(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _Inout_ PIRP Irp)
Definition: pdo.c:754
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by PciIdeXInitialize().

◆ PciIdeXGetControllerDeviceId()

static PCWSTR PciIdeXGetControllerDeviceId ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)
static

Definition at line 452 of file pdo.c.

454{
455 PAGED_CODE();
456
457 /* Intel */
458 if (FdoExtension->VendorId == 0x8086)
459 {
460 switch (FdoExtension->DeviceId)
461 {
462 case 0x1230:
463 return L"PIIX";
464 case 0x7010:
465 return L"PIIX3";
466 case 0x7111:
467 return L"PIIX4";
468
469 default:
470 break;
471 }
472 }
473
474 return NULL;
475}
#define NULL
Definition: types.h:112
@ FdoExtension
Definition: precomp.h:48
#define L(x)
Definition: ntvdm.h:50

Referenced by PciIdeXPdoQueryId().

◆ PciIdeXGetControllerVendorId()

static PCWSTR PciIdeXGetControllerVendorId ( _In_ PFDO_DEVICE_EXTENSION  FdoExtension)
static

Definition at line 421 of file pdo.c.

423{
424 PAGED_CODE();
425
426 switch (FdoExtension->VendorId)
427 {
428 case 0x0E11:
429 return L"Compaq";
430 case 0x1039:
431 return L"SiS";
432 case 0x1050:
433 return L"WinBond";
434 case 0x1095:
435 return L"CMD";
436 case 0x10B9:
437 return L"ALi";
438 case 0x8086:
439 return L"Intel";
440
441 default:
442 break;
443 }
444
445 /* Only certain controllers have a non-numeric identifier */
446 return NULL;
447}

Referenced by PciIdeXPdoQueryId().

◆ PciIdeXOnRepeaterCompletion()

static NTSTATUS NTAPI PciIdeXOnRepeaterCompletion ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_reads_opt_(_Inexpressible_("varies")) PVOID  Context 
)
static

Definition at line 127 of file pdo.c.

131{
133
134 if (Irp->PendingReturned)
136
138}
#define FALSE
Definition: types.h:117
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ PciIdeXPdoDispatchPnp()

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

Definition at line 754 of file pdo.c.

757{
759 PIO_STACK_LOCATION IoStack;
760
761 PAGED_CODE();
762
764 switch (IoStack->MinorFunction)
765 {
768 IoStack->Parameters.StartDevice.AllocatedResources);
769 break;
770
773 break;
774
778 break;
779
783 break;
784
789 break;
790
794 else
795 Status = Irp->IoStatus.Status;
796 break;
797
800 break;
801
804 break;
805
808 break;
809
812 break;
813
814 case IRP_MN_QUERY_ID:
816 break;
817
820 break;
821
824 break;
825
826 default:
827 Status = Irp->IoStatus.Status;
828 break;
829 }
830
831 Irp->IoStatus.Status = Status;
833
834 return Status;
835}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
@ 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
#define STATUS_SUCCESS
Definition: shellext.h:65
static NTSTATUS PciIdeXPdoQueryStopRemoveDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: pdo.c:82
static NTSTATUS PciIdeXPdoQueryDeviceUsageNotification(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:712
static NTSTATUS PciIdeXPdoRemoveDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ BOOLEAN FinalRemove)
Definition: pdo.c:49
static NTSTATUS PciIdeXPdoQueryResources(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:255
static NTSTATUS PciIdeXPdoQueryCapabilities(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:201
static NTSTATUS PciIdeXPdoStartDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PCM_RESOURCE_LIST ResourceList)
Definition: pdo.c:17
static NTSTATUS PciIdeXPdoQueryDeviceText(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:665
static NTSTATUS PciIdeXPdoQueryResourceRequirements(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:335
static NTSTATUS PciIdeXPdoQueryTargetDeviceRelations(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:100
static NTSTATUS PciIdeXPdoQueryPnpDeviceState(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:236
static NTSTATUS PciIdeXPdoQueryId(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp)
Definition: pdo.c:480
static NTSTATUS PciIdeXPdoStopDevice(_In_ PPDO_DEVICE_EXTENSION PdoExtension)
Definition: pdo.c:38
union _IO_STACK_LOCATION::@1574 Parameters
struct _IO_STACK_LOCATION::@3992::@4029 StartDevice
struct _IO_STACK_LOCATION::@3992::@4017 QueryDeviceRelations
#define IRP_MN_CANCEL_STOP_DEVICE
@ TargetDeviceRelation
Definition: iotypes.h:2156
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#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().

◆ PciIdeXPdoQueryCapabilities()

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

Definition at line 201 of file pdo.c.

204{
205 DEVICE_CAPABILITIES ParentCapabilities;
207 PIO_STACK_LOCATION IoStack;
209
210 PAGED_CODE();
211
212 /* Get the capabilities of the parent device */
213 RtlZeroMemory(&ParentCapabilities, sizeof(ParentCapabilities));
214 ParentCapabilities.Size = sizeof(ParentCapabilities);
215 ParentCapabilities.Version = 1;
216 ParentCapabilities.Address = MAXULONG;
217 ParentCapabilities.UINumber = MAXULONG;
218 Status = PciIdeXPdoRepeatRequest(PdoExtension, Irp, &ParentCapabilities);
219 if (!NT_SUCCESS(Status))
220 return Status;
221
223 DeviceCapabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
224 *DeviceCapabilities = ParentCapabilities;
225
226 /* Override some fields */
227 DeviceCapabilities->UniqueID = FALSE;
228 DeviceCapabilities->Address = PdoExtension->Channel;
229
230 return STATUS_SUCCESS;
231}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static NTSTATUS PciIdeXPdoRepeatRequest(_In_ PPDO_DEVICE_EXTENSION PdoExtension, _In_ PIRP Irp, _In_opt_ PDEVICE_CAPABILITIES DeviceCapabilities)
Definition: pdo.c:143
struct _IO_STACK_LOCATION::@3992::@4019 DeviceCapabilities
#define MAXULONG
Definition: typedefs.h:251
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define DeviceCapabilities
Definition: wingdi.h:4449
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 665 of file pdo.c.

668{
669 PIO_STACK_LOCATION IoStack;
671 ULONG Size;
672
673 PAGED_CODE();
674
676 switch (IoStack->Parameters.QueryDeviceText.DeviceTextType)
677 {
679 {
680 static const WCHAR PrimaryChannelText[] = L"Primary channel";
681 static const WCHAR SecondaryChannelText[] = L"Secondary channel";
682
684 Size = sizeof(PrimaryChannelText);
685 else
686 Size = sizeof(SecondaryChannelText);
687
689 if (!Buffer)
691
694 PrimaryChannelText : SecondaryChannelText,
695 Size);
696
697 DPRINT("Device ID: '%S'\n", Buffer);
698 break;
699 }
700
701 default:
702 return Irp->IoStatus.Status;
703 }
704
705 Irp->IoStatus.Information = (ULONG_PTR)Buffer;
706 return STATUS_SUCCESS;
707}
Definition: bufpool.h:45
#define ULONG_PTR
Definition: config.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define IS_PRIMARY_CHANNEL(PdoExtension)
Definition: pciidex.h:23
#define TAG_PCIIDEX
Definition: pciidex.h:19
#define DPRINT
Definition: sndvol32.h:73
struct _IO_STACK_LOCATION::@3992::@4024 QueryDeviceText
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
@ DeviceTextLocationInformation
Definition: iotypes.h:2946
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryDeviceUsageNotification()

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

Definition at line 712 of file pdo.c.

715{
716 PIO_STACK_LOCATION IoStack;
718 volatile LONG* Counter;
719
720 PAGED_CODE();
721
723 if (!NT_SUCCESS(Status))
724 return Status;
725
727 switch (IoStack->Parameters.UsageNotification.Type)
728 {
730 Counter = &PdoExtension->Common.PageFiles;
731 break;
732
734 Counter = &PdoExtension->Common.HibernateFiles;
735 break;
736
738 Counter = &PdoExtension->Common.DumpFiles;
739 break;
740
741 default:
742 return Status;
743 }
744
747
748 return STATUS_SUCCESS;
749}
long LONG
Definition: pedump.c:60
VOID NTAPI IoInvalidateDeviceState(IN PDEVICE_OBJECT DeviceObject)
Definition: pnpmgr.c:1848
struct _IO_STACK_LOCATION::@3992::@4025 UsageNotification
static LARGE_INTEGER Counter
Definition: clock.c:43
#define IoAdjustPagingPathCount(_Count, _Increment)
@ DeviceUsageTypeHibernation
Definition: iotypes.h:1171
@ DeviceUsageTypeDumpFile
Definition: iotypes.h:1172
@ DeviceUsageTypePaging
Definition: iotypes.h:1170

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryId()

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

Definition at line 480 of file pdo.c.

483{
484 PIO_STACK_LOCATION IoStack;
486 PWCHAR Buffer, End;
487 size_t CharCount, Remaining;
488 static const WCHAR IdeCompatibleId[] = L"*PNP0600";
489
490 PAGED_CODE();
491
493 switch (IoStack->Parameters.QueryId.IdType)
494 {
495 case BusQueryDeviceID:
496 {
497 static const WCHAR PciIdeDeviceId[] = L"PCIIDE\\IDEChannel";
498
499 Buffer = ExAllocatePoolWithTag(PagedPool, sizeof(PciIdeDeviceId), TAG_PCIIDEX);
500 if (!Buffer)
502
503 RtlCopyMemory(Buffer, PciIdeDeviceId, sizeof(PciIdeDeviceId));
504
505 DPRINT("Device ID: '%S'\n", Buffer);
506 break;
507 }
508
510 {
512 PCWSTR VendorString;
513 PWCHAR IdStart;
514
516
517 /* Maximum string length */
518 CharCount = sizeof("WinBond-1234") +
519 sizeof("Secondary_IDE_Channel") +
520 sizeof(IdeCompatibleId) +
521 sizeof(ANSI_NULL); /* multi-string */
522
524 CharCount * sizeof(WCHAR),
526 if (!Buffer)
528
529 FdoExtension = PdoExtension->ParentController;
531
532 DPRINT("HardwareIDs:\n");
533
534 /* ID 1 */
535 if (VendorString)
536 {
538
539 if (DeviceString)
540 {
542 CharCount,
543 &End,
544 &Remaining,
545 0,
546 L"%ls-%ls",
547 VendorString,
548 DeviceString);
549 }
550 else
551 {
553 CharCount,
554 &End,
555 &Remaining,
556 0,
557 L"%ls-%04x",
558 VendorString,
559 FdoExtension->DeviceId);
560 }
561 }
562 else
563 {
565 CharCount,
566 &End,
567 &Remaining,
568 0,
569 L"%04x-%04x",
570 FdoExtension->VendorId,
571 FdoExtension->DeviceId);
572 }
574
575 DPRINT(" '%S'\n", Buffer);
576
577 ++End;
578 --Remaining;
579
580 /* ID 2 */
581 IdStart = End;
583 Remaining,
584 &End,
585 &Remaining,
586 0,
587 L"%ls",
589 L"Primary_IDE_Channel" :
590 L"Secondary_IDE_Channel");
592
593 DPRINT(" '%S'\n", IdStart);
594
595 ++End;
596 --Remaining;
597
598 /* ID 3 */
599 IdStart = End;
601 Remaining,
602 &End,
603 &Remaining,
604 0,
605 L"%ls",
606 IdeCompatibleId);
608
609 DPRINT(" '%S'\n", IdStart);
610
611 *++End = UNICODE_NULL; /* multi-string */
612 break;
613 }
614
616 {
618 sizeof(IdeCompatibleId) + sizeof(UNICODE_NULL),
620 if (!Buffer)
622
623 RtlCopyMemory(Buffer, IdeCompatibleId, sizeof(IdeCompatibleId));
624
625 Buffer[sizeof(IdeCompatibleId) / sizeof(WCHAR)] = UNICODE_NULL; /* multi-string */
626
627 DPRINT("Compatible ID: '%S'\n", Buffer);
628 break;
629 }
630
632 {
633 CharCount = sizeof("0");
634
636 CharCount * sizeof(WCHAR),
638 if (!Buffer)
640
642 CharCount,
643 NULL,
644 NULL,
645 0,
646 L"%lu",
647 PdoExtension->Channel);
649
650 DPRINT("Instance ID: '%S'\n", Buffer);
651 break;
652 }
653
654 default:
655 return Irp->IoStatus.Status;
656 }
657
658 Irp->IoStatus.Information = (ULONG_PTR)Buffer;
659 return STATUS_SUCCESS;
660}
#define ASSERT(a)
Definition: mode.c:44
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
#define UNICODE_NULL
#define ANSI_NULL
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
static PCWSTR PciIdeXGetControllerVendorId(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: pdo.c:421
static PCWSTR PciIdeXGetControllerDeviceId(_In_ PFDO_DEVICE_EXTENSION FdoExtension)
Definition: pdo.c:452
struct _IO_STACK_LOCATION::@3992::@4023 QueryId
const uint16_t * PCWSTR
Definition: typedefs.h:57
@ BusQueryCompatibleIDs
Definition: iotypes.h:2938
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryPnpDeviceState()

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

Definition at line 236 of file pdo.c.

239{
240 PAGED_CODE();
241
242 if (PdoExtension->Common.PageFiles ||
243 PdoExtension->Common.HibernateFiles ||
244 PdoExtension->Common.DumpFiles)
245 {
246 Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
247 }
248
249 return STATUS_SUCCESS;
250}
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryResourceRequirements()

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

Definition at line 335 of file pdo.c.

338{
342 IDE_CHANNEL_STATE ChannelState;
343 ULONG CommandPortBase, ControlPortBase, InterruptVector;
344 ULONG ListSize;
345
346 PAGED_CODE();
347
348 FdoExtension = PdoExtension->ParentController;
349 if (FdoExtension->InNativeMode)
350 return Irp->IoStatus.Status;
351
352 ChannelState = PciIdeXChannelState(FdoExtension, PdoExtension->Channel);
353 if (ChannelState == ChannelDisabled)
354 return Irp->IoStatus.Status;
355
356 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) +
358 RequirementsList = ExAllocatePoolZero(PagedPool, ListSize, TAG_PCIIDEX);
359 if (!RequirementsList)
361
362 /* Legacy mode resources */
363 RequirementsList->InterfaceType = Isa;
364 RequirementsList->ListSize = ListSize;
365 RequirementsList->AlternativeLists = 1;
366 RequirementsList->List[0].Version = 1;
367 RequirementsList->List[0].Revision = 1;
369
371 {
372 CommandPortBase = PCIIDE_LEGACY_PRIMARY_COMMAND_BASE;
373 ControlPortBase = PCIIDE_LEGACY_PRIMARY_CONTROL_BASE;
374 InterruptVector = PCIIDE_LEGACY_PRIMARY_IRQ;
375 }
376 else
377 {
378 CommandPortBase = PCIIDE_LEGACY_SECONDARY_COMMAND_BASE;
379 ControlPortBase = PCIIDE_LEGACY_SECONDARY_CONTROL_BASE;
380 InterruptVector = PCIIDE_LEGACY_SECONDARY_IRQ;
381 }
382
383 Descriptor = &RequirementsList->List[0].Descriptors[0];
384
385 /* Command port base */
387 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
390 Descriptor->u.Port.Alignment = 1;
391 Descriptor->u.Port.MinimumAddress.LowPart = CommandPortBase;
392 Descriptor->u.Port.MaximumAddress.LowPart = CommandPortBase +
394 ++Descriptor;
395
396 /* Control port base */
398 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
401 Descriptor->u.Port.Alignment = 1;
402 Descriptor->u.Port.MinimumAddress.LowPart = ControlPortBase;
403 Descriptor->u.Port.MaximumAddress.LowPart = ControlPortBase +
405 ++Descriptor;
406
407 /* Interrupt */
409 Descriptor->ShareDisposition = CmResourceShareShared;
411 Descriptor->u.Interrupt.MinimumVector = InterruptVector;
412 Descriptor->u.Interrupt.MaximumVector = InterruptVector;
413
414 Irp->IoStatus.Information = (ULONG_PTR)RequirementsList;
415 return STATUS_SUCCESS;
416}
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
@ Isa
Definition: hwresource.cpp:138
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
IDE_CHANNEL_STATE
Definition: ide.h:196
@ ChannelDisabled
Definition: ide.h:197
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
#define PCIIDE_LEGACY_PRIMARY_CONTROL_BASE
Definition: pciidex.h:32
#define PCIIDE_LEGACY_SECONDARY_COMMAND_BASE
Definition: pciidex.h:34
#define PCIIDE_LEGACY_SECONDARY_CONTROL_BASE
Definition: pciidex.h:35
#define PCIIDE_LEGACY_PRIMARY_IRQ
Definition: pciidex.h:33
#define PCIIDE_LEGACY_COMMAND_IO_RANGE_LENGTH
Definition: pciidex.h:29
#define PCIIDE_LEGACY_RESOURCE_COUNT
Definition: pciidex.h:28
#define PCIIDE_LEGACY_CONTROL_IO_RANGE_LENGTH
Definition: pciidex.h:30
#define PCIIDE_LEGACY_SECONDARY_IRQ
Definition: pciidex.h:36
#define PCIIDE_LEGACY_PRIMARY_COMMAND_BASE
Definition: pciidex.h:31
IDE_CHANNEL_STATE PciIdeXChannelState(_In_ PFDO_DEVICE_EXTENSION FdoExtension, _In_ ULONG Channel)
Definition: miniport.c:48
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoQueryResources()

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

Definition at line 255 of file pdo.c.

258{
260 IDE_CHANNEL_STATE ChannelState;
263 ULONG CommandPortBase, ControlPortBase, InterruptVector;
264 ULONG ListSize;
265
266 PAGED_CODE();
267
268 FdoExtension = PdoExtension->ParentController;
269 if (FdoExtension->InNativeMode)
270 return Irp->IoStatus.Status;
271
272 ChannelState = PciIdeXChannelState(FdoExtension, PdoExtension->Channel);
273 if (ChannelState == ChannelDisabled)
274 return Irp->IoStatus.Status;
275
276 ListSize = sizeof(CM_RESOURCE_LIST) +
278 ResourceList = ExAllocatePoolZero(PagedPool, ListSize, TAG_PCIIDEX);
279 if (!ResourceList)
281
282 /* Legacy mode resources */
283 ResourceList->Count = 1;
284 ResourceList->List[0].InterfaceType = Isa;
285 ResourceList->List[0].PartialResourceList.Version = 1;
286 ResourceList->List[0].PartialResourceList.Revision = 1;
287 ResourceList->List[0].PartialResourceList.Count = PCIIDE_LEGACY_RESOURCE_COUNT;
288
290 {
291 CommandPortBase = PCIIDE_LEGACY_PRIMARY_COMMAND_BASE;
292 ControlPortBase = PCIIDE_LEGACY_PRIMARY_CONTROL_BASE;
293 InterruptVector = PCIIDE_LEGACY_PRIMARY_IRQ;
294 }
295 else
296 {
297 CommandPortBase = PCIIDE_LEGACY_SECONDARY_COMMAND_BASE;
298 ControlPortBase = PCIIDE_LEGACY_SECONDARY_CONTROL_BASE;
299 InterruptVector = PCIIDE_LEGACY_SECONDARY_IRQ;
300 }
301
302 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[0];
303
304 /* Command port base */
306 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
309 Descriptor->u.Port.Start.LowPart = CommandPortBase;
310 ++Descriptor;
311
312 /* Control port base */
314 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
317 Descriptor->u.Port.Start.LowPart = ControlPortBase;
318 ++Descriptor;
319
320 /* Interrupt */
322 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
324 Descriptor->u.Interrupt.Level = InterruptVector;
325 Descriptor->u.Interrupt.Vector = InterruptVector;
326 Descriptor->u.Interrupt.Affinity = (KAFFINITY)-1;
327
328 Irp->IoStatus.Information = (ULONG_PTR)ResourceList;
329 return STATUS_SUCCESS;
330}
ULONG_PTR KAFFINITY
Definition: compat.h:85
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
_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 82 of file pdo.c.

84{
85 PAGED_CODE();
86
87 if (PdoExtension->Common.PageFiles ||
88 PdoExtension->Common.HibernateFiles ||
89 PdoExtension->Common.DumpFiles)
90 {
91 return STATUS_DEVICE_BUSY;
92 }
93
94 return STATUS_SUCCESS;
95}
#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 100 of file pdo.c.

103{
104 PDEVICE_RELATIONS DeviceRelations;
105
106 PAGED_CODE();
107
108 DeviceRelations = ExAllocatePoolWithTag(PagedPool,
109 sizeof(DEVICE_RELATIONS),
111 if (!DeviceRelations)
113
114 DeviceRelations->Count = 1;
115 DeviceRelations->Objects[0] = PdoExtension->Common.Self;
116 ObReferenceObject(PdoExtension->Common.Self);
117
118 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
119 return STATUS_SUCCESS;
120}
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoRemoveDevice()

static NTSTATUS PciIdeXPdoRemoveDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ BOOLEAN  FinalRemove 
)
static

Definition at line 49 of file pdo.c.

52{
54 ULONG i;
55
56 PAGED_CODE();
57
58 if (FinalRemove && PdoExtension->ReportedMissing)
59 {
60 ExAcquireFastMutex(&FdoExtension->DeviceSyncMutex);
61
62 for (i = 0; i < MAX_IDE_CHANNEL; ++i)
63 {
64 if (FdoExtension->Channels[i] == PdoExtension)
65 {
66 FdoExtension->Channels[i] = NULL;
67 break;
68 }
69 }
70
71 ExReleaseFastMutex(&FdoExtension->DeviceSyncMutex);
72
73 IoDeleteDevice(PdoExtension->Common.Self);
74 }
75
76 return STATUS_SUCCESS;
77}
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 FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define MAX_IDE_CHANNEL
Definition: ide.h:30
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoRepeatRequest()

static NTSTATUS PciIdeXPdoRepeatRequest ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PIRP  Irp,
_In_opt_ PDEVICE_CAPABILITIES  DeviceCapabilities 
)
static

Definition at line 143 of file pdo.c.

147{
148 PDEVICE_OBJECT Fdo, TopDeviceObject;
149 PIO_STACK_LOCATION IoStack, SubStack;
150 PIRP SubIrp;
153
154 PAGED_CODE();
155
156 Fdo = PdoExtension->ParentController->Common.Self;
157 TopDeviceObject = IoGetAttachedDeviceReference(Fdo);
158
159 SubIrp = IoAllocateIrp(TopDeviceObject->StackSize, FALSE);
160 if (!SubIrp)
161 {
162 ObDereferenceObject(TopDeviceObject);
164 }
165
167
169 SubStack = IoGetNextIrpStackLocation(SubIrp);
170 RtlCopyMemory(SubStack, IoStack, sizeof(IO_STACK_LOCATION));
171
173 SubStack->Parameters.DeviceCapabilities.Capabilities = DeviceCapabilities;
174
177 &Event,
178 TRUE,
179 TRUE,
180 TRUE);
181
183
184 Status = IoCallDriver(TopDeviceObject, SubIrp);
185 if (Status == STATUS_PENDING)
186 {
188 }
189
190 ObDereferenceObject(TopDeviceObject);
191
192 Status = SubIrp->IoStatus.Status;
193 IoFreeIrp(SubIrp);
194
195 return Status;
196}
#define TRUE
Definition: types.h:120
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
#define KernelMode
Definition: asm.h:34
@ NotificationEvent
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
#define IoCallDriver
Definition: irp.c:1225
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
static IO_COMPLETION_ROUTINE PciIdeXOnRepeaterCompletion
Definition: pdo.c:122
IO_STATUS_BLOCK IoStatus
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
@ Executive
Definition: ketypes.h:415
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by PciIdeXPdoQueryCapabilities(), and PciIdeXPdoQueryDeviceUsageNotification().

◆ PciIdeXPdoStartDevice()

static NTSTATUS PciIdeXPdoStartDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension,
_In_ PCM_RESOURCE_LIST  ResourceList 
)
static

Definition at line 17 of file pdo.c.

20{
21 PUCHAR IoBase;
22
23 PAGED_CODE();
24
25 IoBase = PdoExtension->ParentController->BusMasterPortBase;
27 {
29 }
30 DPRINT("Bus Master Base %p\n", IoBase);
31
32 return STATUS_SUCCESS;
33}
#define BM_SECONDARY_CHANNEL_OFFSET
Definition: pciidex.h:47
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by PciIdeXPdoDispatchPnp().

◆ PciIdeXPdoStopDevice()

static NTSTATUS PciIdeXPdoStopDevice ( _In_ PPDO_DEVICE_EXTENSION  PdoExtension)
static

Definition at line 38 of file pdo.c.

40{
41 PAGED_CODE();
42
43 return STATUS_SUCCESS;
44}

Referenced by PciIdeXPdoDispatchPnp().

Variable Documentation

◆ PciIdeXOnRepeaterCompletion

IO_COMPLETION_ROUTINE PciIdeXOnRepeaterCompletion
static

Definition at line 122 of file pdo.c.

Referenced by PciIdeXPdoRepeatRequest().