int pnpacpi_build_resource_template(acpi_handle handle, struct acpi_buffer *buffer) { struct acpi_resource *resource; int res_cnt = 0; acpi_status status; status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_count_resources, &res_cnt); if (ACPI_FAILURE(status)) { pnp_err("Evaluate _CRS failed"); return -EINVAL; } if (!res_cnt) return -EINVAL; buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; buffer->pointer = pnpacpi_kmalloc(buffer->length - 1, GFP_KERNEL); if (!buffer->pointer) return -ENOMEM; pnp_dbg("Res cnt %d", res_cnt); resource = (struct acpi_resource *)buffer->pointer; status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_type_resources, &resource); if (ACPI_FAILURE(status)) { kfree(buffer->pointer); pnp_err("Evaluate _CRS failed"); return -EINVAL; } /* resource will pointer the end resource now */ resource->id = ACPI_RSTYPE_END_TAG; return 0; }
int pnpacpi_build_resource_template(struct pnp_dev *dev, struct acpi_buffer *buffer) { acpi_handle handle = dev->data; struct acpi_resource *resource; int res_cnt = 0; acpi_status status; status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_count_resources, &res_cnt); if (ACPI_FAILURE(status)) { dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); return -EINVAL; } if (!res_cnt) return -EINVAL; buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1; buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL); if (!buffer->pointer) return -ENOMEM; resource = (struct acpi_resource *)buffer->pointer; status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_type_resources, &resource); if (ACPI_FAILURE(status)) { kfree(buffer->pointer); dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status); return -EINVAL; } /* resource will pointer the end resource now */ resource->type = ACPI_RESOURCE_TYPE_END_TAG; return 0; }
static void probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device, int busnum, int domain) { size_t size; sprintf(info->name, "PCI Bus %04x:%02x", domain, busnum); info->bridge = device; info->res_num = 0; acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, info); if (!info->res_num) return; size = sizeof(*info->res) * info->res_num; info->res = kzalloc(size, GFP_KERNEL); if (!info->res) { info->res_num = 0; return; } size = sizeof(*info->res_offset) * info->res_num; info->res_num = 0; info->res_offset = kzalloc(size, GFP_KERNEL); if (!info->res_offset) { kfree(info->res); info->res = NULL; return; } acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, info); }
struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int bus) { struct pci_root_info info; struct pci_controller *controller; unsigned int windows = 0; struct pci_bus *pbus; char *name; int pxm; controller = alloc_pci_controller(domain); if (!controller) goto out1; controller->acpi_handle = device->handle; pxm = acpi_get_pxm(controller->acpi_handle); #ifdef CONFIG_NUMA if (pxm >= 0) controller->node = pxm_to_node(pxm); #endif acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, &windows); if (windows) { controller->window = kmalloc_node(sizeof(*controller->window) * windows, GFP_KERNEL, controller->node); if (!controller->window) goto out2; } name = kmalloc(16, GFP_KERNEL); if (!name) goto out3; sprintf(name, "PCI Bus %04x:%02x", domain, bus); info.controller = controller; info.name = name; acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, &info); /* * See arch/x86/pci/acpi.c. * The desired pci bus might already be scanned in a quirk. We * should handle the case here, but it appears that IA64 hasn't * such quirk. So we just ignore the case now. */ pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller); if (pbus) pcibios_setup_root_windows(pbus, controller); return pbus; out3: kfree(controller->window); out2: kfree(controller); out1: return NULL; }
struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int bus) { struct pci_root_info info; struct pci_controller *controller; unsigned int windows = 0; struct pci_bus *pbus; char *name; int pxm; controller = alloc_pci_controller(domain); if (!controller) goto out1; controller->acpi_handle = device->handle; pxm = acpi_get_pxm(controller->acpi_handle); #ifdef CONFIG_NUMA if (pxm >= 0) controller->node = pxm_to_node(pxm); #endif acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, &windows); controller->window = kmalloc_node(sizeof(*controller->window) * windows, GFP_KERNEL, controller->node); if (!controller->window) goto out2; name = kmalloc(16, GFP_KERNEL); if (!name) goto out3; sprintf(name, "PCI Bus %04x:%02x", domain, bus); info.controller = controller; info.name = name; acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, &info); pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller); if (pbus) pcibios_setup_root_windows(pbus, controller); return pbus; out3: kfree(controller->window); out2: kfree(controller); out1: return NULL; }
acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res) { /* Blank the resource table values */ pnp_init_resource_table(res); return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res); }
/******************************************************************************* * * FUNCTION: acpi_get_vendor_resource * * PARAMETERS: device_handle - Handle for the parent device object * Name - Method name for the parent resource * (METHOD_NAME__CRS or METHOD_NAME__PRS) * Uuid - Pointer to the UUID to be matched. * includes both subtype and 16-byte UUID * ret_buffer - Where the vendor resource is returned * * RETURN: Status * * DESCRIPTION: Walk a resource template for the specified evice to find a * vendor-defined resource that matches the supplied UUID and * UUID subtype. Returns a struct acpi_resource of type Vendor. * ******************************************************************************/ acpi_status acpi_get_vendor_resource(acpi_handle device_handle, char *name, struct acpi_vendor_uuid * uuid, struct acpi_buffer * ret_buffer) { struct acpi_vendor_walk_info info; acpi_status status; /* Other parameters are validated by acpi_walk_resources */ if (!uuid || !ret_buffer) { return (AE_BAD_PARAMETER); } info.uuid = uuid; info.buffer = ret_buffer; info.status = AE_NOT_EXIST; /* Walk the _CRS or _PRS resource list for this device */ status = acpi_walk_resources(device_handle, name, acpi_rs_match_vendor_resource, &info); if (ACPI_FAILURE(status)) { return (status); } return (info.status); }
acpi_status acpi_get_vendor_resource(acpi_handle device_handle, char *name, struct acpi_vendor_uuid * uuid, struct acpi_buffer * ret_buffer) { struct acpi_vendor_walk_info info; acpi_status status; if (!uuid || !ret_buffer) { return (AE_BAD_PARAMETER); } info.uuid = uuid; info.buffer = ret_buffer; info.status = AE_NOT_EXIST; status = acpi_walk_resources(device_handle, name, acpi_rs_match_vendor_resource, &info); if (ACPI_FAILURE(status)) { return (status); } return (info.status); }
/** * acpi_dev_get_resources - Get current resources of a device. * @adev: ACPI device node to get the resources for. * @list: Head of the resultant list of resources (must be empty). * @preproc: The caller's preprocessing routine. * @preproc_data: Pointer passed to the caller's preprocessing routine. * * Evaluate the _CRS method for the given device node and process its output by * (1) executing the @preproc() rountine provided by the caller, passing the * resource pointer and @preproc_data to it as arguments, for each ACPI resource * returned and (2) converting all of the returned ACPI resources into struct * resource objects if possible. If the return value of @preproc() in step (1) * is different from 0, step (2) is not applied to the given ACPI resource and * if that value is negative, the whole processing is aborted and that value is * returned as the final error code. * * The resultant struct resource objects are put on the list pointed to by * @list, that must be empty initially, as members of struct resource_entry * objects. Callers of this routine should use %acpi_dev_free_resource_list() to * free that list. * * The number of resources in the output list is returned on success, an error * code reflecting the error condition is returned otherwise. */ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, int (*preproc)(struct acpi_resource *, void *), void *preproc_data) { struct res_proc_context c; acpi_status status; if (!adev || !adev->handle || !list_empty(list)) return -EINVAL; if (!acpi_has_method(adev->handle, METHOD_NAME__CRS)) return 0; c.list = list; c.preproc = preproc; c.preproc_data = preproc_data; c.count = 0; c.error = 0; status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS, acpi_dev_process_resource, &c); if (ACPI_FAILURE(status)) { acpi_dev_free_resource_list(list); return c.error ? c.error : -EIO; } return c.count; }
/** * acpi_irq_parse_one - Resolve an interrupt for a device * @handle: the device whose interrupt is to be resolved * @index: index of the interrupt to resolve * @fwspec: structure irq_fwspec filled by this function * @flags: resource flags filled by this function * * Description: * Resolves an interrupt for a device by walking its CRS resources to find * the appropriate ACPI IRQ resource and populating the given struct irq_fwspec * and flags. * * Return: * The result stored in ctx.rc by the callback, or the default -EINVAL value * if an error occurs. */ static int acpi_irq_parse_one(acpi_handle handle, unsigned int index, struct irq_fwspec *fwspec, unsigned long *flags) { struct acpi_irq_parse_one_ctx ctx = { -EINVAL, index, flags, fwspec }; acpi_walk_resources(handle, METHOD_NAME__CRS, acpi_irq_parse_one_cb, &ctx); return ctx.rc; }
static int acpi_motherboard_add(struct acpi_device *device) { if (!device) return -EINVAL; acpi_walk_resources(device->handle, METHOD_NAME__CRS, acpi_reserve_io_ranges, NULL); return 0; }
static int acpi_serial_add(struct acpi_device *device) { struct serial_private *priv; acpi_status status; struct serial_struct serial_req; int result; memset(&serial_req, 0, sizeof(serial_req)); priv = kmalloc(sizeof(struct serial_private), GFP_KERNEL); if (!priv) { result = -ENOMEM; goto fail; } memset(priv, 0, sizeof(*priv)); status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, acpi_serial_resource, &serial_req); if (ACPI_FAILURE(status)) { result = -ENODEV; goto fail; } if (serial_req.iomem_base) priv->iomem_base = serial_req.iomem_base; else if (!serial_req.port) { printk(KERN_ERR "%s: no iomem or port address in %s _CRS\n", __FUNCTION__, device->pnp.bus_id); result = -ENODEV; goto fail; } serial_req.baud_base = BASE_BAUD; serial_req.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_RESOURCES; priv->line = register_serial(&serial_req); if (priv->line < 0) { printk(KERN_WARNING "Couldn't register serial port %s: %d\n", device->pnp.bus_id, priv->line); result = -ENODEV; goto fail; } acpi_driver_data(device) = priv; return 0; fail: if (serial_req.iomem_base) iounmap(serial_req.iomem_base); kfree(priv); return result; }
static acpi_status hp_crs_locate(acpi_handle obj, u64 *base, u64 *length) { struct csr_space space = { 0, 0 }; acpi_walk_resources(obj, METHOD_NAME__CRS, find_csr_space, &space); if (!space.length) return AE_NOT_FOUND; *base = space.base; *length = space.length; return AE_OK; }
static void get_current_resources(struct acpi_device *device, int busnum, int domain, struct pci_bus *bus) { struct pci_root_info info; size_t size; if (pci_use_crs) pci_bus_remove_resources(bus); info.bridge = device; info.bus = bus; info.res_num = 0; acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, &info); if (!info.res_num) return; size = sizeof(*info.res) * info.res_num; info.res = kmalloc(size, GFP_KERNEL); if (!info.res) goto res_alloc_fail; info.name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum); if (!info.name) goto name_alloc_fail; info.res_num = 0; acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, &info); add_resources(&info); return; name_alloc_fail: kfree(info.res); res_alloc_fail: return; }
static u32 smo8800_get_irq(struct acpi_device *device) { u32 irq = 0; acpi_status status; status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, smo8800_get_resource, &irq); if (ACPI_FAILURE(status)) { dev_err(&device->dev, "acpi_walk_resources failed\n"); return 0; } return irq; }
struct pci_bus * pcibios_scan_root (void *handle, int seg, int bus) { struct pci_root_info info; struct pci_controller *controller; unsigned int windows = 0; char *name; controller = alloc_pci_controller(seg); if (!controller) goto out1; controller->acpi_handle = handle; acpi_walk_resources(handle, METHOD_NAME__CRS, count_window, &windows); controller->window = kmalloc(sizeof(*controller->window) * windows, GFP_KERNEL); if (!controller->window) goto out2; name = kmalloc(16, GFP_KERNEL); if (!name) goto out3; sprintf(name, "PCI Bus %02x:%02x", seg, bus); info.controller = controller; info.name = name; acpi_walk_resources(handle, METHOD_NAME__CRS, add_window, &info); return scan_root_bus(bus, pci_root_ops, controller); out3: kfree(controller->window); out2: kfree(controller); out1: return NULL; }
struct pci_bus * __devinit pci_acpi_scan_root (struct acpi_device *device, int domain, int bus) { struct pci_root_info info; struct pci_controller *controller; unsigned int windows = 0; char *name; controller = alloc_pci_controller(domain); if (!controller) goto out1; controller->acpi_handle = device->handle; acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, &windows); controller->window = kmalloc(sizeof(*controller->window) * windows, GFP_KERNEL); if (!controller->window) goto out2; name = kmalloc(16, GFP_KERNEL); if (!name) goto out3; sprintf(name, "PCI Bus %04x:%02x", domain, bus); info.controller = controller; info.name = name; acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, &info); return pci_scan_bus(bus, &pci_root_ops, controller); out3: kfree(controller->window); out2: kfree(controller); out1: return NULL; }
static acpi_status try_get_root_bridge_busnr(acpi_handle handle, struct resource *res) { acpi_status status; res->start = -1; status = acpi_walk_resources(handle, METHOD_NAME__CRS, get_root_bridge_busnr_callback, res); if (ACPI_FAILURE(status)) return status; if (res->start == -1) return AE_ERROR; return AE_OK; }
acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, struct pnp_dev *dev) { acpi_status status; struct acpipnp_parse_option_s parse_data; parse_data.option = pnp_register_independent_option(dev); if (!parse_data.option) return AE_ERROR; parse_data.dev = dev; status = acpi_walk_resources(handle, METHOD_NAME__PRS, pnpacpi_option_resource, &parse_data); return status; }
acpi_status acpi_find_vendor_resource(acpi_handle obj, struct acpi_vendor_descriptor *id, u8 **data, u32 *length) { struct acpi_vendor_info info; info.descriptor = id; info.data = NULL; acpi_walk_resources(obj, METHOD_NAME__CRS, acpi_vendor_resource_match, &info); if (!info.data) return AE_NOT_FOUND; *data = info.data; *length = info.length; return AE_OK; }
int pnpacpi_parse_allocated_resource(struct pnp_dev *dev) { acpi_handle handle = dev->data; acpi_status status; pnp_dbg(&dev->dev, "parse allocated resources\n"); pnp_init_resources(dev); status = acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, dev); if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) dev_err(&dev->dev, "can't evaluate _CRS: %d", status); return -EPERM; } return 0; }
static int __devinit snd_mpu401_acpi_pnp(int dev, struct acpi_device *device) { struct mpu401_resources res; acpi_status status; res.port = SNDRV_AUTO_PORT; res.irq = SNDRV_AUTO_IRQ; status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, snd_mpu401_acpi_resource, &res); if (ACPI_FAILURE(status)) return -ENODEV; if (res.port == SNDRV_AUTO_PORT || res.irq == SNDRV_AUTO_IRQ) { snd_printk(KERN_ERR "no port or irq in %s _CRS\n", acpi_device_bid(device)); return -ENODEV; } port[dev] = res.port; irq[dev] = res.irq; return 0; }
static int mei_reserver_dma_acpi(struct mei_device *dev) { struct mei_txe_hw *hw = to_txe_hw(dev); acpi_handle handle; acpi_status ret; handle = ACPI_HANDLE(&dev->pdev->dev); if (!handle) { dev_err(&dev->pdev->dev, "TXE8086 acpi NULL handle received\n"); return -ENODEV; } dev_dbg(&dev->pdev->dev, "TXE8086 acpi handle received\n"); ret = acpi_walk_resources(handle, METHOD_NAME__CRS, txei_walk_resource, dev); if (ACPI_FAILURE(ret)) { dev_err(&dev->pdev->dev, "TXE8086: acpi_walk_resources FAILURE\n"); return -ENOMEM; } if (!hw->pool_size) { dev_err(&dev->pdev->dev, "TXE8086: acpi __CRS resource not found\n"); return -ENOMEM; } dev_dbg(&dev->pdev->dev, "DMA Memory reserved memory usage: size=%zd\n", hw->pool_size); /* limit the pool_size to SATT_RANGE_MAX */ hw->pool_size = min_t(size_t, hw->pool_size, SATT_RANGE_MAX); hw->pool_vaddr = ioremap(hw->pool_paddr, hw->pool_size); /* FIXME: is this fatal ? */ if (!hw->pool_vaddr) dev_err(&dev->pdev->dev, "TXE8086: acpi __CRS cannot remap\n"); hw->pool_release = mei_release_dma_acpi; return 0; }
int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) { acpi_handle handle = dev->data; acpi_status status; struct acpipnp_parse_option_s parse_data; pnp_dbg(&dev->dev, "parse resource options\n"); parse_data.dev = dev; parse_data.option_flags = 0; status = acpi_walk_resources(handle, METHOD_NAME__PRS, pnpacpi_option_resource, &parse_data); if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) dev_err(&dev->dev, "can't evaluate _PRS: %d", status); return -EPERM; } return 0; }
static int fjes_acpi_add(struct acpi_device *device) { struct platform_device *plat_dev; acpi_status status; if (!is_extended_socket_device(device)) return -ENODEV; if (acpi_check_extended_socket_status(device)) return -ENODEV; status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, fjes_get_acpi_resource, fjes_resource); if (ACPI_FAILURE(status)) return -ENODEV; /* create platform_device */ plat_dev = platform_device_register_simple(DRV_NAME, 0, fjes_resource, ARRAY_SIZE(fjes_resource)); device->driver_data = plat_dev; return 0; }
static int fjes_acpi_add(struct acpi_device *device) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1]; struct platform_device *plat_dev; union acpi_object *str; acpi_status status; int result; status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer); if (ACPI_FAILURE(status)) return -ENODEV; str = buffer.pointer; result = utf16s_to_utf8s((wchar_t *)str->string.pointer, str->string.length, UTF16_LITTLE_ENDIAN, str_buf, sizeof(str_buf) - 1); str_buf[result] = 0; if (strncmp(FJES_ACPI_SYMBOL, str_buf, strlen(FJES_ACPI_SYMBOL)) != 0) { kfree(buffer.pointer); return -ENODEV; } kfree(buffer.pointer); status = acpi_walk_resources(device->handle, METHOD_NAME__CRS, fjes_get_acpi_resource, fjes_resource); if (ACPI_FAILURE(status)) return -ENODEV; /* create platform_device */ plat_dev = platform_device_register_simple(DRV_NAME, 0, fjes_resource, ARRAY_SIZE(fjes_resource)); device->driver_data = plat_dev; return 0; }
static acpi_status acpi_db_device_resources(acpi_handle obj_handle, u32 nesting_level, void *context, void **return_value) { struct acpi_namespace_node *node; struct acpi_namespace_node *prt_node = NULL; struct acpi_namespace_node *crs_node = NULL; struct acpi_namespace_node *prs_node = NULL; struct acpi_namespace_node *aei_node = NULL; char *parent_path; struct acpi_buffer return_buffer; acpi_status status; node = ACPI_CAST_PTR(struct acpi_namespace_node, obj_handle); parent_path = acpi_ns_get_normalized_pathname(node, TRUE); if (!parent_path) { return (AE_NO_MEMORY); } /* Get handles to the resource methods for this device */ (void)acpi_get_handle(node, METHOD_NAME__PRT, ACPI_CAST_PTR(acpi_handle, &prt_node)); (void)acpi_get_handle(node, METHOD_NAME__CRS, ACPI_CAST_PTR(acpi_handle, &crs_node)); (void)acpi_get_handle(node, METHOD_NAME__PRS, ACPI_CAST_PTR(acpi_handle, &prs_node)); (void)acpi_get_handle(node, METHOD_NAME__AEI, ACPI_CAST_PTR(acpi_handle, &aei_node)); if (!prt_node && !crs_node && !prs_node && !aei_node) { goto cleanup; /* Nothing to do */ } acpi_os_printf("\nDevice: %s\n", parent_path); /* Prepare for a return object of arbitrary size */ return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; /* _PRT */ if (prt_node) { acpi_os_printf("Evaluating _PRT\n"); status = acpi_evaluate_object(prt_node, NULL, NULL, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("Could not evaluate _PRT: %s\n", acpi_format_exception(status)); goto get_crs; } return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; status = acpi_get_irq_routing_table(node, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("GetIrqRoutingTable failed: %s\n", acpi_format_exception(status)); goto get_crs; } acpi_rs_dump_irq_list(ACPI_CAST_PTR(u8, acpi_gbl_db_buffer)); } /* _CRS */ get_crs: if (crs_node) { acpi_os_printf("Evaluating _CRS\n"); return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; status = acpi_evaluate_object(crs_node, NULL, NULL, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("Could not evaluate _CRS: %s\n", acpi_format_exception(status)); goto get_prs; } /* This code exercises the acpi_walk_resources interface */ status = acpi_walk_resources(node, METHOD_NAME__CRS, acpi_db_resource_callback, NULL); if (ACPI_FAILURE(status)) { acpi_os_printf("AcpiWalkResources failed: %s\n", acpi_format_exception(status)); goto get_prs; } /* Get the _CRS resource list (test ALLOCATE buffer) */ return_buffer.pointer = NULL; return_buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; status = acpi_get_current_resources(node, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("AcpiGetCurrentResources failed: %s\n", acpi_format_exception(status)); goto get_prs; } /* This code exercises the acpi_walk_resource_buffer interface */ status = acpi_walk_resource_buffer(&return_buffer, acpi_db_resource_callback, NULL); if (ACPI_FAILURE(status)) { acpi_os_printf("AcpiWalkResourceBuffer failed: %s\n", acpi_format_exception(status)); goto end_crs; } /* Dump the _CRS resource list */ acpi_rs_dump_resource_list(ACPI_CAST_PTR(struct acpi_resource, return_buffer. pointer)); /* * Perform comparison of original AML to newly created AML. This * tests both the AML->Resource conversion and the Resource->AML * conversion. */ (void)acpi_dm_test_resource_conversion(node, METHOD_NAME__CRS); /* Execute _SRS with the resource list */ acpi_os_printf("Evaluating _SRS\n"); status = acpi_set_current_resources(node, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("AcpiSetCurrentResources failed: %s\n", acpi_format_exception(status)); goto end_crs; } end_crs: ACPI_FREE(return_buffer.pointer); } /* _PRS */ get_prs: if (prs_node) { acpi_os_printf("Evaluating _PRS\n"); return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; status = acpi_evaluate_object(prs_node, NULL, NULL, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("Could not evaluate _PRS: %s\n", acpi_format_exception(status)); goto get_aei; } return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; status = acpi_get_possible_resources(node, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("AcpiGetPossibleResources failed: %s\n", acpi_format_exception(status)); goto get_aei; } acpi_rs_dump_resource_list(ACPI_CAST_PTR (struct acpi_resource, acpi_gbl_db_buffer)); } /* _AEI */ get_aei: if (aei_node) { acpi_os_printf("Evaluating _AEI\n"); return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; status = acpi_evaluate_object(aei_node, NULL, NULL, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("Could not evaluate _AEI: %s\n", acpi_format_exception(status)); goto cleanup; } return_buffer.pointer = acpi_gbl_db_buffer; return_buffer.length = ACPI_DEBUG_BUFFER_SIZE; status = acpi_get_event_resources(node, &return_buffer); if (ACPI_FAILURE(status)) { acpi_os_printf("AcpiGetEventResources failed: %s\n", acpi_format_exception(status)); goto cleanup; } acpi_rs_dump_resource_list(ACPI_CAST_PTR (struct acpi_resource, acpi_gbl_db_buffer)); } cleanup: ACPI_FREE(parent_path); return (AE_OK); }