Author: sir_richard
Date: Fri Apr 2 08:46:33 2010
New Revision: 46664
URL:
http://svn.reactos.org/svn/reactos?rev=46664&view=rev
Log:
[HALACPI]: Implement HalpQueryResources: We take the resource requirements, find the SCI
requirement, and convert it into a resource. The ACPI HAL should now report its resoures
once the PnP HAL driver model is enabled.
Modified:
trunk/reactos/hal/halx86/generic/acpi/halpnpdd.c
Modified: trunk/reactos/hal/halx86/generic/acpi/halpnpdd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/acpi/ha…
==============================================================================
--- trunk/reactos/hal/halx86/generic/acpi/halpnpdd.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/acpi/halpnpdd.c [iso-8859-1] Fri Apr 2 08:46:33
2010
@@ -331,9 +331,95 @@
HalpQueryResources(IN PDEVICE_OBJECT DeviceObject,
OUT PCM_RESOURCE_LIST *Resources)
{
- UNIMPLEMENTED;
- while (TRUE);
- return STATUS_NO_SUCH_DEVICE;
+ PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+ NTSTATUS Status;
+ PCM_RESOURCE_LIST ResourceList;
+ PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
+ PIO_RESOURCE_DESCRIPTOR Descriptor;
+ PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDesc;
+ ULONG i;
+ PAGED_CODE();
+
+ /* Only the ACPI PDO has requirements */
+ if (DeviceExtension->PdoType == AcpiPdo)
+ {
+ /* Query ACPI requirements */
+ Status = HalpQueryAcpiResourceRequirements(&RequirementsList);
+ ASSERT(RequirementsList->AlternativeLists == 1);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ /* Allocate the resourcel ist */
+ ResourceList = ExAllocatePoolWithTag(PagedPool,
+ sizeof(CM_RESOURCE_LIST),
+ ' laH');
+ if (!ResourceList )
+ {
+ /* Fail, no memory */
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ ExFreePoolWithTag(RequirementsList, 0);
+ return Status;
+ }
+
+ /* Initialize it */
+ RtlZeroMemory(ResourceList, sizeof(CM_RESOURCE_LIST));
+ ResourceList->Count = 1;
+
+ /* Setup the list fields */
+ ResourceList->List[0].BusNumber = -1;
+ ResourceList->List[0].InterfaceType = PNPBus;
+ ResourceList->List[0].PartialResourceList.Version = 1;
+ ResourceList->List[0].PartialResourceList.Revision = 1;
+ ResourceList->List[0].PartialResourceList.Count = 1;
+
+ /* Setup the first descriptor */
+ PartialDesc = ResourceList->List[0].PartialResourceList.PartialDescriptors;
+ PartialDesc->Type = CmResourceTypeInterrupt;
+
+ /* Find the requirement descriptor for the SCI */
+ for (i = 0; i < RequirementsList->List[0].Count; i++)
+ {
+ /* Get this descriptor */
+ Descriptor = &RequirementsList->List[0].Descriptors[i];
+ if (Descriptor->Type == CmResourceTypeInterrupt) break;
+ Descriptor = NULL;
+ }
+
+ /* Make sure we found the descriptor */
+ if (Descriptor)
+ {
+ /* Copy requirements descriptor into resource descriptor */
+ PartialDesc->ShareDisposition = Descriptor->ShareDisposition;
+ PartialDesc->Flags = Descriptor->Flags;
+ ASSERT(Descriptor->u.Interrupt.MinimumVector ==
+ Descriptor->u.Interrupt.MaximumVector);
+ PartialDesc->u.Interrupt.Vector =
Descriptor->u.Interrupt.MinimumVector;
+ PartialDesc->u.Interrupt.Level =
Descriptor->u.Interrupt.MinimumVector;
+ PartialDesc->u.Interrupt.Affinity = 0xFFFFFFFF;
+
+ /* Return resources and success */
+ *Resources = ResourceList;
+ ExFreePoolWithTag(RequirementsList, 0);
+ return STATUS_SUCCESS;
+ }
+
+ /* Free memory and fail */
+ ExFreePoolWithTag(RequirementsList, 0);
+ ExFreePoolWithTag(ResourceList, 0);
+ Status = STATUS_NOT_FOUND;
+ }
+ else if (DeviceExtension->PdoType == WdPdo)
+ {
+ /* Watchdog doesn't */
+ return STATUS_NOT_SUPPORTED;
+ }
+ else
+ {
+ /* This shouldn't happen */
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Return the status */
+ return Status;
}
NTSTATUS