Exemple #1
0
static acpi_status
acpi_ut_get_package_object_size(union acpi_operand_object *internal_object,
				acpi_size * obj_length)
{
	acpi_status status;
	struct acpi_pkg_info info;

	ACPI_FUNCTION_TRACE_PTR(ut_get_package_object_size, internal_object);

	info.length = 0;
	info.object_space = 0;
	info.num_packages = 1;

	status = acpi_ut_walk_package_tree(internal_object, NULL,
					   acpi_ut_get_element_length, &info);
	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

	
	info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) *
	    (acpi_size) info.num_packages;

	

	*obj_length = info.length;
	return_ACPI_STATUS(status);
}
Exemple #2
0
acpi_status
acpi_ns_init_one_package(acpi_handle obj_handle,
			 u32 level, void *context, void **return_value)
{
	acpi_status status;
	union acpi_operand_object *obj_desc;
	struct acpi_namespace_node *node =
	    (struct acpi_namespace_node *)obj_handle;

	obj_desc = acpi_ns_get_attached_object(node);
	if (!obj_desc) {
		return (AE_OK);
	}

	/* Exit if package is already initialized */

	if (obj_desc->package.flags & AOPOBJ_DATA_VALID) {
		return (AE_OK);
	}

	status = acpi_ds_get_package_arguments(obj_desc);
	if (ACPI_FAILURE(status)) {
		return (AE_OK);
	}

	status =
	    acpi_ut_walk_package_tree(obj_desc, NULL,
				      acpi_ds_init_package_element, NULL);
	if (ACPI_FAILURE(status)) {
		return (AE_OK);
	}

	obj_desc->package.flags |= AOPOBJ_DATA_VALID;
	return (AE_OK);
}
Exemple #3
0
static acpi_status
acpi_ut_get_package_object_size(union acpi_operand_object *internal_object,
				acpi_size * obj_length)
{
	acpi_status status;
	struct acpi_pkg_info info;

	ACPI_FUNCTION_TRACE_PTR(ut_get_package_object_size, internal_object);

	info.length = 0;
	info.object_space = 0;
	info.num_packages = 1;

	status = acpi_ut_walk_package_tree(internal_object, NULL,
					   acpi_ut_get_element_length, &info);
	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

	/*
	 * We have handled all of the objects in all levels of the package.
	 * just add the length of the package objects themselves.
	 * Round up to the next machine word.
	 */
	info.length += ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object)) *
	    (acpi_size) info.num_packages;

	/* Return the total package length */

	*obj_length = info.length;
	return_ACPI_STATUS(status);
}
acpi_status
acpi_ut_copy_ipackage_to_ipackage (
	acpi_operand_object     *source_obj,
	acpi_operand_object     *dest_obj,
	acpi_walk_state         *walk_state)
{
	acpi_status             status = AE_OK;


	FUNCTION_TRACE ("Ut_copy_ipackage_to_ipackage");


	dest_obj->common.type   = source_obj->common.type;
	dest_obj->package.count = source_obj->package.count;


	/*
	 * Create the object array and walk the source package tree
	 */
	dest_obj->package.elements = ACPI_MEM_CALLOCATE ((source_obj->package.count + 1) *
			 sizeof (void *));
	dest_obj->package.next_element = dest_obj->package.elements;

	if (!dest_obj->package.elements) {
		REPORT_ERROR (
			("Aml_build_copy_internal_package_object: Package allocation failure\n"));
		return_ACPI_STATUS (AE_NO_MEMORY);
	}


	status = acpi_ut_walk_package_tree (source_obj, dest_obj,
			 acpi_ut_copy_ielement_to_ielement, walk_state);

	return_ACPI_STATUS (status);
}
static acpi_status
acpi_ut_copy_ipackage_to_epackage (
	acpi_operand_object     *internal_object,
	u8                      *buffer,
	u32                     *space_used)
{
	acpi_object             *external_object;
	acpi_status             status;
	acpi_pkg_info           info;


	FUNCTION_TRACE ("Ut_copy_ipackage_to_epackage");


	/*
	 * First package at head of the buffer
	 */
	external_object = (acpi_object *) buffer;

	/*
	 * Free space begins right after the first package
	 */
	info.length      = 0;
	info.object_space = 0;
	info.num_packages = 1;
	info.free_space  = buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));


	external_object->type              = internal_object->common.type;
	external_object->package.count     = internal_object->package.count;
	external_object->package.elements  = (acpi_object *) info.free_space;


	/*
	 * Build an array of ACPI_OBJECTS in the buffer
	 * and move the free space past it
	 */
	info.free_space += external_object->package.count *
			  ROUND_UP_TO_NATIVE_WORD (sizeof (acpi_object));


	status = acpi_ut_walk_package_tree (internal_object, external_object,
			 acpi_ut_copy_ielement_to_eelement, &info);

	*space_used = info.length;

	return_ACPI_STATUS (status);

}
Exemple #6
0
static acpi_status
acpi_ut_copy_ipackage_to_epackage (
	union acpi_operand_object       *internal_object,
	u8                              *buffer,
	acpi_size                       *space_used)
{
	union acpi_object               *external_object;
	acpi_status                     status;
	struct acpi_pkg_info            info;


	ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage");


	/*
	 * First package at head of the buffer
	 */
	external_object = ACPI_CAST_PTR (union acpi_object, buffer);

	/*
	 * Free space begins right after the first package
	 */
	info.length      = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
	info.free_space  = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
	info.object_space = 0;
	info.num_packages = 1;

	external_object->type            = ACPI_GET_OBJECT_TYPE (internal_object);
	external_object->package.count   = internal_object->package.count;
	external_object->package.elements = ACPI_CAST_PTR (union acpi_object, info.free_space);

	/*
	 * Leave room for an array of ACPI_OBJECTS in the buffer
	 * and move the free space past it
	 */
	info.length    += (acpi_size) external_object->package.count *
			 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));
	info.free_space += external_object->package.count *
			 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object));

	status = acpi_ut_walk_package_tree (internal_object, external_object,
			 acpi_ut_copy_ielement_to_eelement, &info);

	*space_used = info.length;
	return_ACPI_STATUS (status);
}
Exemple #7
0
acpi_status
acpi_ut_copy_ipackage_to_ipackage (
	union acpi_operand_object       *source_obj,
	union acpi_operand_object       *dest_obj,
	struct acpi_walk_state          *walk_state)
{
	acpi_status                     status = AE_OK;


	ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage");


	dest_obj->common.type   = ACPI_GET_OBJECT_TYPE (source_obj);
	dest_obj->common.flags  = source_obj->common.flags;
	dest_obj->package.count = source_obj->package.count;

	/*
	 * Create the object array and walk the source package tree
	 */
	dest_obj->package.elements = ACPI_MEM_CALLOCATE (
			   ((acpi_size) source_obj->package.count + 1) *
			   sizeof (void *));
	if (!dest_obj->package.elements) {
		ACPI_REPORT_ERROR (
			("aml_build_copy_internal_package_object: Package allocation failure\n"));
		return_ACPI_STATUS (AE_NO_MEMORY);
	}

	/*
	 * Copy the package element-by-element by walking the package "tree".
	 * This handles nested packages of arbitrary depth.
	 */
	status = acpi_ut_walk_package_tree (source_obj, dest_obj,
			 acpi_ut_copy_ielement_to_ielement, walk_state);
	if (ACPI_FAILURE (status)) {
		/* On failure, delete the destination package object */

		acpi_ut_remove_reference (dest_obj);
	}

	return_ACPI_STATUS (status);
}
Exemple #8
0
static acpi_status
acpi_ns_init_one_object(acpi_handle obj_handle,
			u32 level, void *context, void **return_value)
{
	acpi_object_type type;
	acpi_status status = AE_OK;
	struct acpi_init_walk_info *info =
	    (struct acpi_init_walk_info *)context;
	struct acpi_namespace_node *node =
	    (struct acpi_namespace_node *)obj_handle;
	union acpi_operand_object *obj_desc;

	ACPI_FUNCTION_NAME(ns_init_one_object);

	info->object_count++;

	/* And even then, we are only interested in a few object types */

	type = acpi_ns_get_type(obj_handle);
	obj_desc = acpi_ns_get_attached_object(node);
	if (!obj_desc) {
		return (AE_OK);
	}

	/* Increment counters for object types we are looking for */

	switch (type) {
	case ACPI_TYPE_REGION:

		info->op_region_count++;
		break;

	case ACPI_TYPE_BUFFER_FIELD:

		info->field_count++;
		break;

	case ACPI_TYPE_LOCAL_BANK_FIELD:

		info->field_count++;
		break;

	case ACPI_TYPE_BUFFER:

		info->buffer_count++;
		break;

	case ACPI_TYPE_PACKAGE:

		info->package_count++;
		break;

	default:

		/* No init required, just exit now */

		return (AE_OK);
	}

	/* If the object is already initialized, nothing else to do */

	if (obj_desc->common.flags & AOPOBJ_DATA_VALID) {
		return (AE_OK);
	}

	/* Must lock the interpreter before executing AML code */

	acpi_ex_enter_interpreter();

	/*
	 * Each of these types can contain executable AML code within the
	 * declaration.
	 */
	switch (type) {
	case ACPI_TYPE_REGION:

		info->op_region_init++;
		status = acpi_ds_get_region_arguments(obj_desc);
		break;

	case ACPI_TYPE_BUFFER_FIELD:

		info->field_init++;
		status = acpi_ds_get_buffer_field_arguments(obj_desc);
		break;

	case ACPI_TYPE_LOCAL_BANK_FIELD:

		info->field_init++;
		status = acpi_ds_get_bank_field_arguments(obj_desc);
		break;

	case ACPI_TYPE_BUFFER:

		info->buffer_init++;
		status = acpi_ds_get_buffer_arguments(obj_desc);
		break;

	case ACPI_TYPE_PACKAGE:

		info->package_init++;
		status = acpi_ds_get_package_arguments(obj_desc);
		if (ACPI_FAILURE(status)) {
			break;
		}

		/*
		 * Resolve all named references in package objects (and all
		 * sub-packages). This action has been deferred until the entire
		 * namespace has been loaded, in order to support external and
		 * forward references from individual package elements (05/2017).
		 */
		status = acpi_ut_walk_package_tree(obj_desc, NULL,
						   acpi_ds_init_package_element,
						   NULL);
		obj_desc->package.flags |= AOPOBJ_DATA_VALID;
		break;

	default:

		/* No other types can get here */

		break;
	}

	if (ACPI_FAILURE(status)) {
		ACPI_EXCEPTION((AE_INFO, status,
				"Could not execute arguments for [%4.4s] (%s)",
				acpi_ut_get_node_name(node),
				acpi_ut_get_type_name(type)));
	}

	/*
	 * We ignore errors from above, and always return OK, since we don't want
	 * to abort the walk on any single error.
	 */
	acpi_ex_exit_interpreter();
	return (AE_OK);
}