--- D:/ReactOS/trunk/reactos/drivers/storage/ide/pciidex/pdo.c	Ñá ÿíâ 31 02:35:00 2015
+++ D:/reactos_67875/drivers/storage/ide/pciidex/pdo.c	Ñá èþë 11 15:25:56 2015
@@ -257,10 +257,10 @@ PciIdeXPdoQueryResourceRequirements(
 	Descriptor->Flags = CM_RESOURCE_PORT_IO |
 	                    CM_RESOURCE_PORT_16_BIT_DECODE |
 	                    CM_RESOURCE_PORT_POSITIVE_DECODE;
-	Descriptor->u.Port.Length = 7;
+	Descriptor->u.Port.Length = 8;
 	Descriptor->u.Port.Alignment = 1;
 	Descriptor->u.Port.MinimumAddress.QuadPart = (ULONGLONG)CommandPortBase;
-	Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(CommandPortBase + 7 - 1);
+	Descriptor->u.Port.MaximumAddress.QuadPart = (ULONGLONG)(CommandPortBase + 8 - 1);
 	Descriptor++;
 
 	/* Control port base */
@@ -289,6 +289,66 @@ PciIdeXPdoQueryResourceRequirements(
 }
 
 static NTSTATUS
+PciIdeXPdoQueryResource(
+	IN PDEVICE_OBJECT DeviceObject,
+	IN PIRP Irp,
+	OUT ULONG_PTR* Information)
+{
+	ULONG Channel;
+        ULONG BaseIoAddress1, BaseIoAddress2, InterruptLevel;
+	ULONG ListSize;
+	PCM_RESOURCE_LIST List;
+	PCM_PARTIAL_RESOURCE_LIST PartialList;
+
+	Channel = ((PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Channel;
+
+	ListSize = sizeof(CM_RESOURCE_LIST) + 2 * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+	List = ExAllocatePool(PagedPool, ListSize);
+	if (!List) return STATUS_INSUFFICIENT_RESOURCES;
+	RtlZeroMemory(List, ListSize);
+
+        List->Count = 1;
+        List->List[0].PartialResourceList.Count = 3;
+
+        PartialList = &List->List[0].PartialResourceList;
+
+        if ( Channel == PRIMARY_CHANNEL_NUMBER )
+        {
+          BaseIoAddress1 = 0x1F0;
+          BaseIoAddress2 = 0x3F6;
+          InterruptLevel = 14;
+        }
+        else
+        {
+          BaseIoAddress1 = 0x170;
+          BaseIoAddress2 = 0x376;
+          InterruptLevel = 15;
+        }
+      
+        PartialList->PartialDescriptors[0].Type = CmResourceTypePort;
+        PartialList->PartialDescriptors[0].ShareDisposition = CmResourceShareDeviceExclusive;
+        PartialList->PartialDescriptors[0].Flags = CM_RESOURCE_PORT_IO | CM_RESOURCE_PORT_16_BIT_DECODE;
+        PartialList->PartialDescriptors[0].u.Port.Start.QuadPart = (ULONGLONG)BaseIoAddress1;
+        PartialList->PartialDescriptors[0].u.Port.Length = 8;
+
+        PartialList->PartialDescriptors[1].Type = CmResourceTypePort;
+        PartialList->PartialDescriptors[1].ShareDisposition = CmResourceShareDeviceExclusive;
+        PartialList->PartialDescriptors[1].Flags = CM_RESOURCE_PORT_IO | CM_RESOURCE_PORT_16_BIT_DECODE;
+        PartialList->PartialDescriptors[1].u.Port.Start.QuadPart = (ULONGLONG)BaseIoAddress2;
+        PartialList->PartialDescriptors[1].u.Port.Length = 1;
+
+        PartialList->PartialDescriptors[2].Type = CmResourceTypeInterrupt;
+        PartialList->PartialDescriptors[2].ShareDisposition = CmResourceShareDeviceExclusive;
+        PartialList->PartialDescriptors[2].Flags = CM_RESOURCE_INTERRUPT_LATCHED;
+        PartialList->PartialDescriptors[2].u.Interrupt.Level = InterruptLevel;
+        PartialList->PartialDescriptors[2].u.Interrupt.Vector = InterruptLevel;
+        PartialList->PartialDescriptors[2].u.Interrupt.Affinity = 1;
+
+	*Information = (ULONG_PTR)List;
+	return STATUS_SUCCESS;
+}
+
+static NTSTATUS
 PciIdeXPdoQueryDeviceText(
 	IN PDEVICE_OBJECT DeviceObject,
 	IN PIRP Irp,
@@ -428,8 +488,9 @@ PciIdeXPdoPnpDispatch(
 				{
 					DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown type 0x%lx\n",
 						Stack->Parameters.QueryDeviceRelations.Type);
-					ASSERT(FALSE);
-					Status = STATUS_NOT_SUPPORTED;
+					//ASSERT(FALSE);
+					//Status = STATUS_NOT_SUPPORTED;
+					Status = Irp->IoStatus.Status;
 					break;
 				}
 			}
@@ -465,9 +526,8 @@ PciIdeXPdoPnpDispatch(
 		}
 		case IRP_MN_QUERY_RESOURCES: /* 0x0a */
 		{
-			/* This IRP is optional; do nothing */
-			Information = Irp->IoStatus.Information;
-			Status = Irp->IoStatus.Status;
+			DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_RESOURCE\n");
+			Status = PciIdeXPdoQueryResource(DeviceObject, Irp, &Information);
 			break;
 		}
 		case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: /* 0x0b */
@@ -526,7 +586,7 @@ PciIdeXPdoPnpDispatch(
 			/* We can't forward request to the lower driver, because
 			 * we are a Pdo, so we don't have lower driver... */
 			DPRINT1("IRP_MJ_PNP / Unknown minor function 0x%lx\n", MinorFunction);
-			ASSERT(FALSE);
+			//ASSERT(FALSE);
 			Information = Irp->IoStatus.Information;
 			Status = Irp->IoStatus.Status;
 		}
