Example #1
0
acpi_status acpi_ev_initialize_op_regions(void)
{
    acpi_status status;
    u32 i;

    ACPI_FUNCTION_TRACE(ev_initialize_op_regions);

    status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
    if (ACPI_FAILURE(status)) {
        return_ACPI_STATUS(status);
    }

    /* Run the _REG methods for op_regions in each default address space */

    for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
        /*
         * Make sure the installed handler is the DEFAULT handler. If not the
         * default, the _REG methods will have already been run (when the
         * handler was installed)
         */
        if (acpi_ev_has_default_handler(acpi_gbl_root_node,
                                        acpi_gbl_default_address_spaces
                                        [i])) {
            status =
                acpi_ev_execute_reg_methods(acpi_gbl_root_node,
                                            acpi_gbl_default_address_spaces
                                            [i]);
        }
    }

    acpi_gbl_reg_methods_executed = TRUE;

    (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
    return_ACPI_STATUS(status);
}
Example #2
0
acpi_status acpi_ev_initialize_op_regions(void)
{
	acpi_status status;
	acpi_native_uint i;

	ACPI_FUNCTION_TRACE(ev_initialize_op_regions);

	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

	/*
	 * Run the _REG methods for op_regions in each default address space
	 */
	for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {

		/* TBD: Make sure handler is the DEFAULT handler, otherwise
		 * _REG will have already been run.
		 */
		status = acpi_ev_execute_reg_methods(acpi_gbl_root_node,
						     acpi_gbl_default_address_spaces
						     [i]);
	}

	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
	return_ACPI_STATUS(status);
}
Example #3
0
/*******************************************************************************
 *
 * FUNCTION:    acpi_install_address_space_handler
 *
 * PARAMETERS:  Device          - Handle for the device
 *              space_id        - The address space ID
 *              Handler         - Address of the handler
 *              Setup           - Address of the setup function
 *              Context         - Value passed to the handler on each access
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Install a handler for all op_regions of a given space_id.
 *
 ******************************************************************************/
acpi_status
acpi_install_address_space_handler(acpi_handle device,
				   acpi_adr_space_type space_id,
				   acpi_adr_space_handler handler,
				   acpi_adr_space_setup setup, void *context)
{
	struct acpi_namespace_node *node;
	acpi_status status;

	ACPI_FUNCTION_TRACE(acpi_install_address_space_handler);

	/* Parameter validation */

	if (!device) {
		return_ACPI_STATUS(AE_BAD_PARAMETER);
	}

	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

	/* Convert and validate the device handle */

	node = acpi_ns_map_handle_to_node(device);
	if (!node) {
		status = AE_BAD_PARAMETER;
		goto unlock_and_exit;
	}

	/* Install the handler for all Regions for this Space ID */

	status =
	    acpi_ev_install_space_handler(node, space_id, handler, setup,
					  context);
	if (ACPI_FAILURE(status)) {
		goto unlock_and_exit;
	}

	/* Run all _REG methods for this address space */

	status = acpi_ev_execute_reg_methods(node, space_id);

      unlock_and_exit:
	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
	return_ACPI_STATUS(status);
}
Example #4
0
/*******************************************************************************
 *
 * FUNCTION:    acpi_install_address_space_handler
 *
 * PARAMETERS:  device          - Handle for the device
 *              space_id        - The address space ID
 *              handler         - Address of the handler
 *              setup           - Address of the setup function
 *              context         - Value passed to the handler on each access
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Install a handler for all op_regions of a given space_id.
 *
 * NOTE: This function should only be called after acpi_enable_subsystem has
 * been called. This is because any _REG methods associated with the Space ID
 * are executed here, and these methods can only be safely executed after
 * the default handlers have been installed and the hardware has been
 * initialized (via acpi_enable_subsystem.)
 *
 ******************************************************************************/
acpi_status
acpi_install_address_space_handler(acpi_handle device,
				   acpi_adr_space_type space_id,
				   acpi_adr_space_handler handler,
				   acpi_adr_space_setup setup, void *context)
{
	struct acpi_namespace_node *node;
	acpi_status status;

	ACPI_FUNCTION_TRACE(acpi_install_address_space_handler);

	/* Parameter validation */

	if (!device) {
		return_ACPI_STATUS(AE_BAD_PARAMETER);
	}

	status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

	/* Convert and validate the device handle */

	node = acpi_ns_validate_handle(device);
	if (!node) {
		status = AE_BAD_PARAMETER;
		goto unlock_and_exit;
	}

	/* Install the handler for all Regions for this Space ID */

	status =
	    acpi_ev_install_space_handler(node, space_id, handler, setup,
					  context);
	if (ACPI_FAILURE(status)) {
		goto unlock_and_exit;
	}

	/*
	 * For the default space_IDs, (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 acpi_initialize_objects). In other words,
	 * we will defer the execution of the _REG methods for these space_IDs until
	 * execution of acpi_initialize_objects. 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 space_IDs, we can safely execute the _REG methods immediately.
	 * This means that for IDs like embedded_controller, this function should be called
	 * only after acpi_enable_subsystem has been called.
	 */
	switch (space_id) {
	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 (!acpi_gbl_reg_methods_executed) {

			/* We will defer execution of the _REG methods for this space */
			goto unlock_and_exit;
		}
		break;

	default:

		break;
	}

	/* Run all _REG methods for this address space */

	status = acpi_ev_execute_reg_methods(node, space_id);

      unlock_and_exit:
	(void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
	return_ACPI_STATUS(status);
}