From cbc12bf14da60ff075a0740daf2ae96250c6f2df Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Fri, 2 Apr 2010 06:28:43 +0000 Subject: [PATCH] [HALACPI]: Implement querying HALACPI resource requirements. If it exists, the SCI Vector is added to the list as a requirement. svn path=/trunk/; revision=46663 --- reactos/hal/halx86/generic/acpi/halacpi.c | 94 ++++++++++++++++++++++ reactos/hal/halx86/generic/acpi/halpnpdd.c | 26 +++++- reactos/hal/halx86/include/halp.h | 6 ++ 3 files changed, 123 insertions(+), 3 deletions(-) diff --git a/reactos/hal/halx86/generic/acpi/halacpi.c b/reactos/hal/halx86/generic/acpi/halacpi.c index 9b025a73de7..1efee7996a4 100644 --- a/reactos/hal/halx86/generic/acpi/halacpi.c +++ b/reactos/hal/halx86/generic/acpi/halacpi.c @@ -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 */ diff --git a/reactos/hal/halx86/generic/acpi/halpnpdd.c b/reactos/hal/halx86/generic/acpi/halpnpdd.c index a293cf62c5a..26276f798ee 100644 --- a/reactos/hal/halx86/generic/acpi/halpnpdd.c +++ b/reactos/hal/halx86/generic/acpi/halpnpdd.c @@ -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 diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 8940589298b..6edb85570d7 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -751,6 +751,12 @@ HalpIs16BitPortDecodeSupported( VOID ); +NTSTATUS +NTAPI +HalpQueryAcpiResourceRequirements( + OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements +); + VOID FASTCALL KeUpdateSystemTime(