ACPI_STATUS AcpiInstallAddressSpaceHandler ( ACPI_HANDLE Device, ACPI_ADR_SPACE_TYPE SpaceId, ACPI_ADR_SPACE_HANDLER Handler, ACPI_ADR_SPACE_SETUP Setup, void *Context) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler); /* Parameter validation */ if (!Device) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Convert and validate the device handle */ Node = AcpiNsValidateHandle (Device); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Install the handler for all Regions for this Space ID */ Status = AcpiEvInstallSpaceHandler ( Node, SpaceId, Handler, Setup, Context); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } /* Run all _REG methods for this address space */ AcpiEvExecuteRegMethods (Node, SpaceId, ACPI_REG_CONNECT); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiInstallAddressSpaceHandler ( ACPI_HANDLE Device, ACPI_ADR_SPACE_TYPE SpaceId, ACPI_ADR_SPACE_HANDLER Handler, ACPI_ADR_SPACE_SETUP Setup, void *Context) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler); /* Parameter validation */ if (!Device) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Convert and validate the device handle */ Node = AcpiNsValidateHandle (Device); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Install the handler for all Regions for this Space ID */ Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } /* * For the default SpaceIDs, (the IDs for which there are default region handlers * installed) Only execute the _REG methods if the global initialization _REG * methods have already been run (via AcpiInitializeObjects). In other words, * we will defer the execution of the _REG methods for these SpaceIDs until * execution of AcpiInitializeObjects. This is done because we need the handlers * for the default spaces (mem/io/pci/table) to be installed before we can run * any control methods (or _REG methods). There is known BIOS code that depends * on this. * * For all other SpaceIDs, we can safely execute the _REG methods immediately. * This means that for IDs like EmbeddedController, this function should be called * only after AcpiEnableSubsystem has been called. */ switch (SpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: case ACPI_ADR_SPACE_SYSTEM_IO: case ACPI_ADR_SPACE_PCI_CONFIG: case ACPI_ADR_SPACE_DATA_TABLE: if (!AcpiGbl_RegMethodsExecuted) { /* We will defer execution of the _REG methods for this space */ goto UnlockAndExit; } break; default: break; } /* Run all _REG methods for this address space */ Status = AcpiEvExecuteRegMethods (Node, SpaceId); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); }
ACPI_STATUS AcpiEvInstallRegionHandlers ( void) { ACPI_STATUS Status; UINT32 i; ACPI_FUNCTION_TRACE (EvInstallRegionHandlers); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * All address spaces (PCI Config, EC, SMBus) are scope dependent and * registration must occur for a specific device. * * In the case of the system memory and IO address spaces there is * currently no device associated with the address space. For these we * use the root. * * We install the default PCI config space handler at the root so that * this space is immediately available even though the we have not * enumerated all the PCI Root Buses yet. This is to conform to the ACPI * specification which states that the PCI config space must be always * available -- even though we are nowhere near ready to find the PCI root * buses at this point. * * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler * has already been installed (via AcpiInstallAddressSpaceHandler). * Similar for AE_SAME_HANDLER. */ for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) { Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, AcpiGbl_DefaultAddressSpaces[i], ACPI_DEFAULT_HANDLER, NULL, NULL); switch (Status) { case AE_OK: case AE_SAME_HANDLER: case AE_ALREADY_EXISTS: /* These exceptions are all OK */ Status = AE_OK; break; default: goto UnlockAndExit; } } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); }