[HALACPI]: Implement querying HALACPI resource requirements. If it exists, the SCI...
authorSir Richard <sir_richard@svn.reactos.org>
Fri, 2 Apr 2010 06:28:43 +0000 (06:28 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Fri, 2 Apr 2010 06:28:43 +0000 (06:28 +0000)
svn path=/trunk/; revision=46663

reactos/hal/halx86/generic/acpi/halacpi.c
reactos/hal/halx86/generic/acpi/halpnpdd.c
reactos/hal/halx86/include/halp.h

index 9b025a7..1efee79 100644 (file)
@@ -37,6 +37,8 @@ LIST_ENTRY HalpAcpiTableMatchList;
 
 ULONG HalpInvalidAcpiTable;
 
+ULONG HalpPicVectorRedirect[] = {0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15};
+
 /* This determines the HAL type */
 BOOLEAN HalDisableFirmwareMapper = TRUE;
 PWCHAR HalHardwareIdString = L"acpipic_up";
@@ -900,6 +902,98 @@ HalpIs16BitPortDecodeSupported(VOID)
     return CM_RESOURCE_PORT_16_BIT_DECODE;
 }
 
+VOID
+NTAPI
+HalpAcpiDetectResourceListSize(OUT PULONG ListSize)
+{
+    PAGED_CODE();
+    
+    /* One element if there is a SCI */
+    *ListSize = HalpFixedAcpiDescTable.sci_int_vector ? 1: 0;
+}
+
+NTSTATUS
+NTAPI
+HalpBuildAcpiResourceList(IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceList)
+{
+    ULONG Interrupt;
+    PAGED_CODE();
+    ASSERT(ResourceList != NULL);
+
+    /* Initialize the list */
+    ResourceList->BusNumber = -1;
+    ResourceList->AlternativeLists = 1;
+    ResourceList->InterfaceType = PNPBus;
+    ResourceList->List[0].Version = 1;
+    ResourceList->List[0].Revision = 1;
+    
+    /* Is there a SCI? */
+    if (HalpFixedAcpiDescTable.sci_int_vector)
+    {
+        /* Fill out the entry for it */
+        ResourceList->List[0].Descriptors[0].Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
+        ResourceList->List[0].Descriptors[0].Type = CmResourceTypeInterrupt;
+        ResourceList->List[0].Descriptors[0].ShareDisposition = CmResourceShareShared;
+        
+        /* Get the interrupt number */
+        Interrupt = HalpPicVectorRedirect[HalpFixedAcpiDescTable.sci_int_vector];
+        ResourceList->List[0].Descriptors[0].u.Interrupt.MinimumVector = Interrupt;
+        ResourceList->List[0].Descriptors[0].u.Interrupt.MaximumVector = Interrupt;
+        
+        /* One more */
+        ++ResourceList->List[0].Count;
+    }
+    
+    /* All good */
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+HalpQueryAcpiResourceRequirements(OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
+{
+    PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
+    ULONG Count = 0, ListSize;
+    NTSTATUS Status;
+    PAGED_CODE();
+  
+    /* Get ACPI resources */
+    HalpAcpiDetectResourceListSize(&Count);
+    
+    /* Compute size of the list and allocate it */
+    ListSize = sizeof(IO_RESOURCE_LIST) * (Count - 1) +
+               sizeof(IO_RESOURCE_REQUIREMENTS_LIST);
+    RequirementsList = ExAllocatePoolWithTag(PagedPool, ListSize, ' laH');
+    if (RequirementsList)
+    {
+        /* Initialize it */
+        RtlZeroMemory(RequirementsList, ListSize);
+        RequirementsList->ListSize = ListSize;
+        
+        /* Build it */
+        Status = HalpBuildAcpiResourceList(RequirementsList);
+        if (NT_SUCCESS(Status))
+        {
+            /* It worked, return it */
+            *Requirements = RequirementsList;
+        }
+        else
+        {
+            /* Fail */
+            ExFreePoolWithTag(RequirementsList, 0);
+            Status = STATUS_NO_SUCH_DEVICE;
+        }
+    }
+    else
+    {
+        /* Not enough memory */
+        Status = STATUS_INSUFFICIENT_RESOURCES;
+    }
+    
+    /* Return the status */
+    return Status;
+}
+
 /*
  * @implemented
  */
index a293cf6..26276f7 100644 (file)
@@ -341,9 +341,29 @@ NTAPI
 HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject,
                               OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements)
 {
-    UNIMPLEMENTED;
-    while (TRUE);
-    return STATUS_NO_SUCH_DEVICE;
+    PPDO_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
+    NTSTATUS Status;
+    PAGED_CODE();
+    
+    /* Only the ACPI PDO has requirements */
+    if (DeviceExtension->PdoType == AcpiPdo)
+    {
+        /* Query ACPI requirements */
+        Status = HalpQueryAcpiResourceRequirements(Requirements);
+    }
+    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
index 8940589..6edb855 100644 (file)
@@ -751,6 +751,12 @@ HalpIs16BitPortDecodeSupported(
     VOID
 );
 
+NTSTATUS
+NTAPI
+HalpQueryAcpiResourceRequirements(
+    OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements
+);
+
 VOID
 FASTCALL
 KeUpdateSystemTime(