static void acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child) { ACPI_STATUS status; device_t child; /* * Occasionally a PCI device may show up as an ACPI device * with a _HID. (For example, the TabletPC TC1000 has a * second PCI-ISA bridge that has a _HID for an * acpi_sysresource device.) In that case, leave ACPI-CA's * device data pointing at the ACPI-enumerated device. */ child = acpi_get_device(handle); if (child != NULL) { KASSERT(device_get_parent(child) == devclass_get_device(devclass_find("acpi"), 0), ("%s: child (%s)'s parent is not acpi0", __func__, acpi_name(handle))); return; } /* * Update ACPI-CA to use the PCI enumerated device_t for this handle. */ status = AcpiAttachData(handle, acpi_fake_objhandler, pci_child); if (ACPI_FAILURE(status)) printf("WARNING: Unable to attach object data to %s - %s\n", acpi_name(handle), AcpiFormatException(status)); }
static void acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child) { ACPI_STATUS status; device_t child; /* * Lookup and remove the unused device that acpi0 creates when it walks * the namespace creating devices. */ child = acpi_get_device(handle); if (child != NULL) { if (device_is_alive(child)) { /* * The TabletPC TC1000 has a second PCI-ISA bridge * that has a _HID for an acpi_sysresource device. * In that case, leave ACPI-CA's device data pointing * at the ACPI-enumerated device. */ device_printf(child, "Conflicts with PCI device %d:%d:%d\n", pci_get_bus(pci_child), pci_get_slot(pci_child), pci_get_function(pci_child)); return; } KASSERT(device_get_parent(child) == devclass_get_device(devclass_find("acpi"), 0), ("%s: child (%s)'s parent is not acpi0", __func__, acpi_name(handle))); device_delete_child(device_get_parent(child), child); } /* * Update ACPI-CA to use the PCI enumerated device_t for this handle. */ status = AcpiDetachData(handle, acpi_fake_objhandler); if (ACPI_FAILURE(status)) kprintf("WARNING: Unable to detach object data from %s - %s\n", acpi_name(handle), AcpiFormatException(status)); status = AcpiAttachData(handle, acpi_fake_objhandler, pci_child); if (ACPI_FAILURE(status)) kprintf("WARNING: Unable to attach object data to %s - %s\n", acpi_name(handle), AcpiFormatException(status)); }
ACPI_STATUS AeInstallEarlyHandlers ( void) { ACPI_STATUS Status; UINT32 i; ACPI_HANDLE Handle; ACPI_FUNCTION_ENTRY (); Status = AcpiInstallInterfaceHandler (AeInterfaceHandler); if (ACPI_FAILURE (Status)) { printf ("Could not install interface handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallTableHandler (AeTableHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install table handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallExceptionHandler (AeExceptionHandler); if (ACPI_FAILURE (Status)) { printf ("Could not install exception handler, %s\n", AcpiFormatException (Status)); } /* Install global notify handlers */ Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, AeSystemNotifyHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a global system notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, AeDeviceNotifyHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a global notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiGetHandle (NULL, "\\_SB", &Handle); if (ACPI_SUCCESS (Status)) { Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler1, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler1); if (ACPI_FAILURE (Status)) { printf ("Could not remove a notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler1, NULL); AE_CHECK_OK (AcpiInstallNotifyHandler, Status); Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler1); AE_CHECK_OK (AcpiRemoveNotifyHandler, Status); #if 0 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler1, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a notify handler, %s\n", AcpiFormatException (Status)); } #endif /* Install two handlers for _SB_ */ Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); /* Attempt duplicate handler installation, should fail */ Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777)); Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); AE_CHECK_OK (AcpiAttachData, Status); Status = AcpiDetachData (Handle, AeAttachedDataHandler); AE_CHECK_OK (AcpiDetachData, Status); /* Test attach data at the root object */ Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler, AcpiGbl_RootNode); AE_CHECK_OK (AcpiAttachData, Status); Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2, AcpiGbl_RootNode); AE_CHECK_OK (AcpiAttachData, Status); /* Test support for multiple attaches */ Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); AE_CHECK_OK (AcpiAttachData, Status); Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle); AE_CHECK_OK (AcpiAttachData, Status); } else {
ACPI_STATUS AeInstallHandlers (void) { ACPI_STATUS Status; UINT32 i; ACPI_HANDLE Handle; ACPI_FUNCTION_ENTRY (); Status = AcpiInstallTableHandler (AeTableHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install table handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallExceptionHandler (AeExceptionHandler); if (ACPI_FAILURE (Status)) { printf ("Could not install exception handler, %s\n", AcpiFormatException (Status)); } /* Install global notify handler */ Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, AeNotifyHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a global notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, AeDeviceNotifyHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a global notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiGetHandle (NULL, "\\_SB", &Handle); if (ACPI_SUCCESS (Status)) { Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, AeNotifyHandler); if (ACPI_FAILURE (Status)) { printf ("Could not remove a notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler, NULL); Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler); Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, AeNotifyHandler, NULL); if (ACPI_FAILURE (Status)) { printf ("Could not install a notify handler, %s\n", AcpiFormatException (Status)); } Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); Status = AcpiDetachData (Handle, AeAttachedDataHandler); Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); } else { printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); } /* Set a handler for all supported operation regions */ for (i = 0; i < AEXEC_NUM_REGIONS; i++) { Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode, SpaceId[i], AeRegionHandler); /* Install handler at the root object. * TBD: all default handlers should be installed here! */ Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, SpaceId[i], AeRegionHandler, AeRegionInit, NULL); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "Could not install an OpRegion handler for %s space(%u)", AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i])); return (Status); } } /* * Initialize the global Region Handler space * MCW 3/23/00 */ AeRegions.NumberOfRegions = 0; AeRegions.RegionList = NULL; return Status; }