From ddab6d36442cfeeb35ee47cbca11519b0173b9f2 Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 21 Jun 2011 19:29:27 +0000 Subject: Use AcpiWalkResources() to parse the resource list from _CRS rather than using a home-rolled loop. While here, add support for 64-bit address range resources. Silence on: acpi@ (older version) --- sys/dev/acpica/acpi_resource.c | 596 +++++++++++++++++++---------------------- sys/dev/acpica/acpivar.h | 22 +- 2 files changed, 282 insertions(+), 336 deletions(-) (limited to 'sys/dev/acpica') diff --git a/sys/dev/acpica/acpi_resource.c b/sys/dev/acpica/acpi_resource.c index c83b679..5c103df 100644 --- a/sys/dev/acpica/acpi_resource.c +++ b/sys/dev/acpica/acpi_resource.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -139,332 +140,277 @@ acpi_config_intr(device_t dev, ACPI_RESOURCE *res) INTR_POLARITY_HIGH : INTR_POLARITY_LOW); } -/* - * Fetch a device's resources and associate them with the device. - * - * Note that it might be nice to also locate ACPI-specific resource items, such - * as GPE bits. - * - * We really need to split the resource-fetching code out from the - * resource-parsing code, since we may want to use the parsing - * code for _PRS someday. - */ -ACPI_STATUS -acpi_parse_resources(device_t dev, ACPI_HANDLE handle, - struct acpi_parse_resource_set *set, void *arg) -{ - ACPI_BUFFER buf; - ACPI_RESOURCE *res; - char *curr, *last; - ACPI_STATUS status; - void *context; +struct acpi_resource_context { + struct acpi_parse_resource_set *set; + device_t dev; + void *context; +}; - ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); +#ifdef ACPI_DEBUG_OUTPUT +static const char * +acpi_address_range_name(UINT8 ResourceType) +{ + static char buf[16]; + + switch (ResourceType) { + case ACPI_MEMORY_RANGE: + return ("Memory"); + case ACPI_IO_RANGE: + return ("IO"); + case ACPI_BUS_NUMBER_RANGE: + return ("Bus Number"); + default: + snprintf(buf, sizeof(buf), "type %u", ResourceType); + return (buf); + } +} +#endif + +static ACPI_STATUS +acpi_parse_resource(ACPI_RESOURCE *res, void *context) +{ + struct acpi_parse_resource_set *set; + struct acpi_resource_context *arc; + UINT64 min, max, length, gran; + const char *name; + device_t dev; - /* - * Special-case some devices that abuse _PRS/_CRS to mean - * something other than "I consume this resource". - * - * XXX do we really need this? It's only relevant once - * we start always-allocating these resources, and even - * then, the only special-cased device is likely to be - * the PCI interrupt link. - */ + arc = context; + dev = arc->dev; + set = arc->set; - /* Fetch the device's current resources. */ - buf.Length = ACPI_ALLOCATE_BUFFER; - if (ACPI_FAILURE((status = AcpiGetCurrentResources(handle, &buf)))) { - if (status != AE_NOT_FOUND && status != AE_TYPE) - printf("can't fetch resources for %s - %s\n", - acpi_name(handle), AcpiFormatException(status)); - return_ACPI_STATUS (status); - } - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s - got %ld bytes of resources\n", - acpi_name(handle), (long)buf.Length)); - set->set_init(dev, arg, &context); - - /* Iterate through the resources */ - curr = buf.Pointer; - last = (char *)buf.Pointer + buf.Length; - while (curr < last) { - res = (ACPI_RESOURCE *)curr; - curr += res->Length; - - /* Handle the individual resource types */ - switch(res->Type) { - case ACPI_RESOURCE_TYPE_END_TAG: - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n")); - curr = last; + switch (res->Type) { + case ACPI_RESOURCE_TYPE_END_TAG: + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n")); + break; + case ACPI_RESOURCE_TYPE_FIXED_IO: + if (res->Data.FixedIo.AddressLength <= 0) break; - case ACPI_RESOURCE_TYPE_FIXED_IO: - if (res->Data.FixedIo.AddressLength <= 0) - break; - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedIo 0x%x/%d\n", - res->Data.FixedIo.Address, - res->Data.FixedIo.AddressLength)); - set->set_ioport(dev, context, - res->Data.FixedIo.Address, - res->Data.FixedIo.AddressLength); + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedIo 0x%x/%d\n", + res->Data.FixedIo.Address, res->Data.FixedIo.AddressLength)); + set->set_ioport(dev, arc->context, res->Data.FixedIo.Address, + res->Data.FixedIo.AddressLength); + break; + case ACPI_RESOURCE_TYPE_IO: + if (res->Data.Io.AddressLength <= 0) break; - case ACPI_RESOURCE_TYPE_IO: - if (res->Data.Io.AddressLength <= 0) - break; - if (res->Data.Io.Minimum == res->Data.Io.Maximum) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x/%d\n", - res->Data.Io.Minimum, - res->Data.Io.AddressLength)); - set->set_ioport(dev, context, - res->Data.Io.Minimum, - res->Data.Io.AddressLength); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x-0x%x/%d\n", - res->Data.Io.Minimum, - res->Data.Io.Maximum, - res->Data.Io.AddressLength)); - set->set_iorange(dev, context, - res->Data.Io.Minimum, - res->Data.Io.Maximum, - res->Data.Io.AddressLength, - res->Data.Io.Alignment); - } + if (res->Data.Io.Minimum == res->Data.Io.Maximum) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x/%d\n", + res->Data.Io.Minimum, res->Data.Io.AddressLength)); + set->set_ioport(dev, arc->context, res->Data.Io.Minimum, + res->Data.Io.AddressLength); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Io 0x%x-0x%x/%d\n", + res->Data.Io.Minimum, res->Data.Io.Maximum, + res->Data.Io.AddressLength)); + set->set_iorange(dev, arc->context, res->Data.Io.Minimum, + res->Data.Io.Maximum, res->Data.Io.AddressLength, + res->Data.Io.Alignment); + } + break; + case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: + if (res->Data.FixedMemory32.AddressLength <= 0) break; - case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: - if (res->Data.FixedMemory32.AddressLength <= 0) - break; - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedMemory32 0x%x/%d\n", - res->Data.FixedMemory32.Address, - res->Data.FixedMemory32.AddressLength)); - set->set_memory(dev, context, - res->Data.FixedMemory32.Address, - res->Data.FixedMemory32.AddressLength); + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "FixedMemory32 0x%x/%d\n", + res->Data.FixedMemory32.Address, + res->Data.FixedMemory32.AddressLength)); + set->set_memory(dev, arc->context, res->Data.FixedMemory32.Address, + res->Data.FixedMemory32.AddressLength); + break; + case ACPI_RESOURCE_TYPE_MEMORY32: + if (res->Data.Memory32.AddressLength <= 0) break; - case ACPI_RESOURCE_TYPE_MEMORY32: - if (res->Data.Memory32.AddressLength <= 0) - break; - if (res->Data.Memory32.Minimum == - res->Data.Memory32.Maximum) { - - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x/%d\n", - res->Data.Memory32.Minimum, - res->Data.Memory32.AddressLength)); - set->set_memory(dev, context, - res->Data.Memory32.Minimum, - res->Data.Memory32.AddressLength); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x-0x%x/%d\n", - res->Data.Memory32.Minimum, - res->Data.Memory32.Maximum, - res->Data.Memory32.AddressLength)); - set->set_memoryrange(dev, context, - res->Data.Memory32.Minimum, - res->Data.Memory32.Maximum, - res->Data.Memory32.AddressLength, - res->Data.Memory32.Alignment); - } + if (res->Data.Memory32.Minimum == res->Data.Memory32.Maximum) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x/%d\n", + res->Data.Memory32.Minimum, res->Data.Memory32.AddressLength)); + set->set_memory(dev, arc->context, res->Data.Memory32.Minimum, + res->Data.Memory32.AddressLength); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory32 0x%x-0x%x/%d\n", + res->Data.Memory32.Minimum, res->Data.Memory32.Maximum, + res->Data.Memory32.AddressLength)); + set->set_memoryrange(dev, arc->context, res->Data.Memory32.Minimum, + res->Data.Memory32.Maximum, res->Data.Memory32.AddressLength, + res->Data.Memory32.Alignment); + } + break; + case ACPI_RESOURCE_TYPE_MEMORY24: + if (res->Data.Memory24.AddressLength <= 0) break; - case ACPI_RESOURCE_TYPE_MEMORY24: - if (res->Data.Memory24.AddressLength <= 0) - break; - if (res->Data.Memory24.Minimum == - res->Data.Memory24.Maximum) { - - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x/%d\n", - res->Data.Memory24.Minimum, - res->Data.Memory24.AddressLength)); - set->set_memory(dev, context, res->Data.Memory24.Minimum, - res->Data.Memory24.AddressLength); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x-0x%x/%d\n", - res->Data.Memory24.Minimum, - res->Data.Memory24.Maximum, - res->Data.Memory24.AddressLength)); - set->set_memoryrange(dev, context, - res->Data.Memory24.Minimum, - res->Data.Memory24.Maximum, - res->Data.Memory24.AddressLength, - res->Data.Memory24.Alignment); - } + if (res->Data.Memory24.Minimum == res->Data.Memory24.Maximum) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x/%d\n", + res->Data.Memory24.Minimum, res->Data.Memory24.AddressLength)); + set->set_memory(dev, arc->context, res->Data.Memory24.Minimum, + res->Data.Memory24.AddressLength); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "Memory24 0x%x-0x%x/%d\n", + res->Data.Memory24.Minimum, res->Data.Memory24.Maximum, + res->Data.Memory24.AddressLength)); + set->set_memoryrange(dev, arc->context, res->Data.Memory24.Minimum, + res->Data.Memory24.Maximum, res->Data.Memory24.AddressLength, + res->Data.Memory24.Alignment); + } + break; + case ACPI_RESOURCE_TYPE_IRQ: + /* + * from 1.0b 6.4.2 + * "This structure is repeated for each separate interrupt + * required" + */ + set->set_irq(dev, arc->context, res->Data.Irq.Interrupts, + res->Data.Irq.InterruptCount, res->Data.Irq.Triggering, + res->Data.Irq.Polarity); + break; + case ACPI_RESOURCE_TYPE_DMA: + /* + * from 1.0b 6.4.3 + * "This structure is repeated for each separate DMA channel + * required" + */ + set->set_drq(dev, arc->context, res->Data.Dma.Channels, + res->Data.Dma.ChannelCount); + break; + case ACPI_RESOURCE_TYPE_START_DEPENDENT: + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "start dependent functions\n")); + set->set_start_dependent(dev, arc->context, + res->Data.StartDpf.CompatibilityPriority); + break; + case ACPI_RESOURCE_TYPE_END_DEPENDENT: + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependent functions\n")); + set->set_end_dependent(dev, arc->context); + break; + case ACPI_RESOURCE_TYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + switch (res->Type) { + case ACPI_RESOURCE_TYPE_ADDRESS16: + gran = res->Data.Address16.Granularity; + min = res->Data.Address16.Minimum; + max = res->Data.Address16.Maximum; + length = res->Data.Address16.AddressLength; + name = "Address16"; + break; + case ACPI_RESOURCE_TYPE_ADDRESS32: + gran = res->Data.Address32.Granularity; + min = res->Data.Address32.Minimum; + max = res->Data.Address32.Maximum; + length = res->Data.Address32.AddressLength; + name = "Address32"; + break; + case ACPI_RESOURCE_TYPE_ADDRESS64: + gran = res->Data.Address64.Granularity; + min = res->Data.Address64.Minimum; + max = res->Data.Address64.Maximum; + length = res->Data.Address64.AddressLength; + name = "Address64"; break; - case ACPI_RESOURCE_TYPE_IRQ: - /* - * from 1.0b 6.4.2 - * "This structure is repeated for each separate interrupt - * required" - */ - set->set_irq(dev, context, res->Data.Irq.Interrupts, - res->Data.Irq.InterruptCount, res->Data.Irq.Triggering, - res->Data.Irq.Polarity); + default: + KASSERT(res->Type == ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ("should never happen")); + gran = res->Data.ExtAddress64.Granularity; + min = res->Data.ExtAddress64.Minimum; + max = res->Data.ExtAddress64.Maximum; + length = res->Data.ExtAddress64.AddressLength; + name = "ExtAddress64"; break; - case ACPI_RESOURCE_TYPE_DMA: - /* - * from 1.0b 6.4.3 - * "This structure is repeated for each separate dma channel - * required" - */ - set->set_drq(dev, context, res->Data.Dma.Channels, - res->Data.Dma.ChannelCount); + } + if (length <= 0) break; - case ACPI_RESOURCE_TYPE_START_DEPENDENT: - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "start dependent functions\n")); - set->set_start_dependent(dev, context, - res->Data.StartDpf.CompatibilityPriority); + if (res->Data.Address.ProducerConsumer != ACPI_CONSUMER) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, + "ignored %s %s producer\n", name, + acpi_address_range_name(res->Data.Address.ResourceType))); break; - case ACPI_RESOURCE_TYPE_END_DEPENDENT: - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "end dependent functions\n")); - set->set_end_dependent(dev, context); + } + if (res->Data.Address.ResourceType != ACPI_MEMORY_RANGE && + res->Data.Address.ResourceType != ACPI_IO_RANGE) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, + "ignored %s for non-memory, non-I/O\n", name)); break; - case ACPI_RESOURCE_TYPE_ADDRESS32: - if (res->Data.Address32.AddressLength <= 0) - break; - if (res->Data.Address32.ProducerConsumer != ACPI_CONSUMER) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "ignored Address32 %s producer\n", - res->Data.Address32.ResourceType == ACPI_IO_RANGE ? - "IO" : "Memory")); - break; - } - if (res->Data.Address32.ResourceType != ACPI_MEMORY_RANGE && - res->Data.Address32.ResourceType != ACPI_IO_RANGE) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "ignored Address32 for non-memory, non-I/O\n")); - break; - } + } - if (res->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED && - res->Data.Address32.MaxAddressFixed == ACPI_ADDRESS_FIXED) { - - if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address32/Memory 0x%x/%d\n", - res->Data.Address32.Minimum, - res->Data.Address32.AddressLength)); - set->set_memory(dev, context, - res->Data.Address32.Minimum, - res->Data.Address32.AddressLength); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address32/IO 0x%x/%d\n", - res->Data.Address32.Minimum, - res->Data.Address32.AddressLength)); - set->set_ioport(dev, context, - res->Data.Address32.Minimum, - res->Data.Address32.AddressLength); - } - } else { - if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address32/Memory 0x%x-0x%x/%d\n", - res->Data.Address32.Minimum, - res->Data.Address32.Maximum, - res->Data.Address32.AddressLength)); - set->set_memoryrange(dev, context, - res->Data.Address32.Minimum, - res->Data.Address32.Maximum, - res->Data.Address32.AddressLength, - res->Data.Address32.Granularity); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address32/IO 0x%x-0x%x/%d\n", - res->Data.Address32.Minimum, - res->Data.Address32.Maximum, - res->Data.Address32.AddressLength)); - set->set_iorange(dev, context, - res->Data.Address32.Minimum, - res->Data.Address32.Maximum, - res->Data.Address32.AddressLength, - res->Data.Address32.Granularity); - } - } +#ifdef __i386__ + if (min > ULONG_MAX || (res->Data.Address.MaxAddressFixed && max > + ULONG_MAX)) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored %s above 4G\n", + name)); break; - case ACPI_RESOURCE_TYPE_ADDRESS16: - if (res->Data.Address16.AddressLength <= 0) - break; - if (res->Data.Address16.ProducerConsumer != ACPI_CONSUMER) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "ignored Address16 %s producer\n", - res->Data.Address16.ResourceType == ACPI_IO_RANGE ? - "IO" : "Memory")); - break; - } - if (res->Data.Address16.ResourceType != ACPI_MEMORY_RANGE && - res->Data.Address16.ResourceType != ACPI_IO_RANGE) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "ignored Address16 for non-memory, non-I/O\n")); - break; + } + if (max > ULONG_MAX) + max = ULONG_MAX; +#endif + if (res->Data.Address.MinAddressFixed == ACPI_ADDRESS_FIXED && + res->Data.Address.MaxAddressFixed == ACPI_ADDRESS_FIXED) { + if (res->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/Memory 0x%x/%d\n", + name, min, length)); + set->set_memory(dev, arc->context, min, length); + } else { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/IO 0x%x/%d\n", name, + min, length)); + set->set_ioport(dev, arc->context, min, length); } - - if (res->Data.Address16.MinAddressFixed == ACPI_ADDRESS_FIXED && - res->Data.Address16.MaxAddressFixed == ACPI_ADDRESS_FIXED) { - - if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address16/Memory 0x%x/%d\n", - res->Data.Address16.Minimum, - res->Data.Address16.AddressLength)); - set->set_memory(dev, context, - res->Data.Address16.Minimum, - res->Data.Address16.AddressLength); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address16/IO 0x%x/%d\n", - res->Data.Address16.Minimum, - res->Data.Address16.AddressLength)); - set->set_ioport(dev, context, - res->Data.Address16.Minimum, - res->Data.Address16.AddressLength); - } + } else { + if (res->Data.Address32.ResourceType == ACPI_MEMORY_RANGE) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/Memory 0x%x-0x%x/%d\n", + name, min, max, length)); + set->set_memoryrange(dev, arc->context, min, max, length, gran); } else { - if (res->Data.Address16.ResourceType == ACPI_MEMORY_RANGE) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address16/Memory 0x%x-0x%x/%d\n", - res->Data.Address16.Minimum, - res->Data.Address16.Maximum, - res->Data.Address16.AddressLength)); - set->set_memoryrange(dev, context, - res->Data.Address16.Minimum, - res->Data.Address16.Maximum, - res->Data.Address16.AddressLength, - res->Data.Address16.Granularity); - } else { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "Address16/IO 0x%x-0x%x/%d\n", - res->Data.Address16.Minimum, - res->Data.Address16.Maximum, - res->Data.Address16.AddressLength)); - set->set_iorange(dev, context, - res->Data.Address16.Minimum, - res->Data.Address16.Maximum, - res->Data.Address16.AddressLength, - res->Data.Address16.Granularity); - } - } - break; - case ACPI_RESOURCE_TYPE_ADDRESS64: - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "unimplemented Address64 resource\n")); - break; - case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - if (res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) { - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "ignored ExtIRQ producer\n")); - break; + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "%s/IO 0x%x-0x%x/%d\n", + name, min, max, length)); + set->set_iorange(dev, arc->context, min, max, length, gran); } - set->set_ext_irq(dev, context, res->Data.ExtendedIrq.Interrupts, - res->Data.ExtendedIrq.InterruptCount, - res->Data.ExtendedIrq.Triggering, - res->Data.ExtendedIrq.Polarity); - break; - case ACPI_RESOURCE_TYPE_VENDOR: - ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, - "unimplemented VendorSpecific resource\n")); - break; - default: + } + break; + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + if (res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) { + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored ExtIRQ producer\n")); break; } - } + set->set_ext_irq(dev, arc->context, res->Data.ExtendedIrq.Interrupts, + res->Data.ExtendedIrq.InterruptCount, + res->Data.ExtendedIrq.Triggering, res->Data.ExtendedIrq.Polarity); + break; + case ACPI_RESOURCE_TYPE_VENDOR: + ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, + "unimplemented VendorSpecific resource\n")); + break; + default: + break; + } + return (AE_OK); +} - AcpiOsFree(buf.Pointer); - set->set_done(dev, context); +/* + * Fetch a device's resources and associate them with the device. + * + * Note that it might be nice to also locate ACPI-specific resource items, such + * as GPE bits. + * + * We really need to split the resource-fetching code out from the + * resource-parsing code, since we may want to use the parsing + * code for _PRS someday. + */ +ACPI_STATUS +acpi_parse_resources(device_t dev, ACPI_HANDLE handle, + struct acpi_parse_resource_set *set, void *arg) +{ + struct acpi_resource_context arc; + ACPI_STATUS status; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + set->set_init(dev, arg, &arc.context); + arc.set = set; + arc.dev = dev; + status = AcpiWalkResources(handle, "_CRS", acpi_parse_resource, &arc); + if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { + printf("can't fetch resources for %s - %s\n", + acpi_name(handle), AcpiFormatException(status)); + return_ACPI_STATUS (status); + } + set->set_done(dev, arc.context); return_ACPI_STATUS (AE_OK); } @@ -475,20 +421,20 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, static void acpi_res_set_init(device_t dev, void *arg, void **context); static void acpi_res_set_done(device_t dev, void *context); static void acpi_res_set_ioport(device_t dev, void *context, - u_int32_t base, u_int32_t length); + uint64_t base, uint64_t length); static void acpi_res_set_iorange(device_t dev, void *context, - u_int32_t low, u_int32_t high, - u_int32_t length, u_int32_t align); + uint64_t low, uint64_t high, + uint64_t length, uint64_t align); static void acpi_res_set_memory(device_t dev, void *context, - u_int32_t base, u_int32_t length); + uint64_t base, uint64_t length); static void acpi_res_set_memoryrange(device_t dev, void *context, - u_int32_t low, u_int32_t high, - u_int32_t length, u_int32_t align); -static void acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq, + uint64_t low, uint64_t high, + uint64_t length, uint64_t align); +static void acpi_res_set_irq(device_t dev, void *context, uint8_t *irq, int count, int trig, int pol); static void acpi_res_set_ext_irq(device_t dev, void *context, - u_int32_t *irq, int count, int trig, int pol); -static void acpi_res_set_drq(device_t dev, void *context, u_int8_t *drq, + uint32_t *irq, int count, int trig, int pol); +static void acpi_res_set_drq(device_t dev, void *context, uint8_t *drq, int count); static void acpi_res_set_start_dependent(device_t dev, void *context, int preference); @@ -539,8 +485,8 @@ acpi_res_set_done(device_t dev, void *context) } static void -acpi_res_set_ioport(device_t dev, void *context, u_int32_t base, - u_int32_t length) +acpi_res_set_ioport(device_t dev, void *context, uint64_t base, + uint64_t length) { struct acpi_res_context *cp = (struct acpi_res_context *)context; @@ -550,8 +496,8 @@ acpi_res_set_ioport(device_t dev, void *context, u_int32_t base, } static void -acpi_res_set_iorange(device_t dev, void *context, u_int32_t low, - u_int32_t high, u_int32_t length, u_int32_t align) +acpi_res_set_iorange(device_t dev, void *context, uint64_t low, + uint64_t high, uint64_t length, uint64_t align) { struct acpi_res_context *cp = (struct acpi_res_context *)context; @@ -561,8 +507,8 @@ acpi_res_set_iorange(device_t dev, void *context, u_int32_t low, } static void -acpi_res_set_memory(device_t dev, void *context, u_int32_t base, - u_int32_t length) +acpi_res_set_memory(device_t dev, void *context, uint64_t base, + uint64_t length) { struct acpi_res_context *cp = (struct acpi_res_context *)context; @@ -573,8 +519,8 @@ acpi_res_set_memory(device_t dev, void *context, u_int32_t base, } static void -acpi_res_set_memoryrange(device_t dev, void *context, u_int32_t low, - u_int32_t high, u_int32_t length, u_int32_t align) +acpi_res_set_memoryrange(device_t dev, void *context, uint64_t low, + uint64_t high, uint64_t length, uint64_t align) { struct acpi_res_context *cp = (struct acpi_res_context *)context; @@ -584,7 +530,7 @@ acpi_res_set_memoryrange(device_t dev, void *context, u_int32_t low, } static void -acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq, int count, +acpi_res_set_irq(device_t dev, void *context, uint8_t *irq, int count, int trig, int pol) { struct acpi_res_context *cp = (struct acpi_res_context *)context; @@ -600,7 +546,7 @@ acpi_res_set_irq(device_t dev, void *context, u_int8_t *irq, int count, } static void -acpi_res_set_ext_irq(device_t dev, void *context, u_int32_t *irq, int count, +acpi_res_set_ext_irq(device_t dev, void *context, uint32_t *irq, int count, int trig, int pol) { struct acpi_res_context *cp = (struct acpi_res_context *)context; @@ -616,7 +562,7 @@ acpi_res_set_ext_irq(device_t dev, void *context, u_int32_t *irq, int count, } static void -acpi_res_set_drq(device_t dev, void *context, u_int8_t *drq, int count) +acpi_res_set_drq(device_t dev, void *context, uint8_t *drq, int count) { struct acpi_res_context *cp = (struct acpi_res_context *)context; diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index a74cd75..8735776 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -355,19 +355,19 @@ BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid); struct acpi_parse_resource_set { void (*set_init)(device_t dev, void *arg, void **context); void (*set_done)(device_t dev, void *context); - void (*set_ioport)(device_t dev, void *context, uint32_t base, - uint32_t length); - void (*set_iorange)(device_t dev, void *context, uint32_t low, - uint32_t high, uint32_t length, uint32_t align); - void (*set_memory)(device_t dev, void *context, uint32_t base, - uint32_t length); - void (*set_memoryrange)(device_t dev, void *context, uint32_t low, - uint32_t high, uint32_t length, uint32_t align); - void (*set_irq)(device_t dev, void *context, u_int8_t *irq, + void (*set_ioport)(device_t dev, void *context, uint64_t base, + uint64_t length); + void (*set_iorange)(device_t dev, void *context, uint64_t low, + uint64_t high, uint64_t length, uint64_t align); + void (*set_memory)(device_t dev, void *context, uint64_t base, + uint64_t length); + void (*set_memoryrange)(device_t dev, void *context, uint64_t low, + uint64_t high, uint64_t length, uint64_t align); + void (*set_irq)(device_t dev, void *context, uint8_t *irq, int count, int trig, int pol); - void (*set_ext_irq)(device_t dev, void *context, u_int32_t *irq, + void (*set_ext_irq)(device_t dev, void *context, uint32_t *irq, int count, int trig, int pol); - void (*set_drq)(device_t dev, void *context, u_int8_t *drq, + void (*set_drq)(device_t dev, void *context, uint8_t *drq, int count); void (*set_start_dependent)(device_t dev, void *context, int preference); -- cgit v1.1