Example #1
0
acpi_status
acpi_ns_wrap_with_package(struct acpi_evaluate_info *info,
			  union acpi_operand_object *original_object,
			  union acpi_operand_object **obj_desc_ptr)
{
	union acpi_operand_object *pkg_obj_desc;

	ACPI_FUNCTION_NAME(ns_wrap_with_package);

	/*
	 * Create the new outer package and populate it. The new
	 * package will have a single element, the lone sub-object.
	 */
	pkg_obj_desc = acpi_ut_create_package_object(1);
	if (!pkg_obj_desc) {
		return (AE_NO_MEMORY);
	}

	pkg_obj_desc->package.elements[0] = original_object;

	ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
			  "%s: Wrapped %s with expected Package object\n",
			  info->full_pathname,
			  acpi_ut_get_object_type_name(original_object)));

	/* Return the new object in the object pointer */

	*obj_desc_ptr = pkg_obj_desc;
	info->return_flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
	return (AE_OK);
}
static acpi_status
acpi_ns_convert_to_package(union acpi_operand_object *original_object,
			   union acpi_operand_object **return_object)
{
	union acpi_operand_object *new_object;
	union acpi_operand_object **elements;
	u32 length;
	u8 *buffer;

	switch (original_object->common.type) {
	case ACPI_TYPE_BUFFER:

		/* Buffer-to-Package conversion */

		length = original_object->buffer.length;
		new_object = acpi_ut_create_package_object(length);
		if (!new_object) {
			return (AE_NO_MEMORY);
		}

		/* Convert each buffer byte to an integer package element */

		elements = new_object->package.elements;
		buffer = original_object->buffer.pointer;

		while (length--) {
			*elements =
			    acpi_ut_create_integer_object((u64) *buffer);
			if (!*elements) {
				acpi_ut_remove_reference(new_object);
				return (AE_NO_MEMORY);
			}
			elements++;
			buffer++;
		}
		break;

	default:
		return (AE_AML_OPERAND_TYPE);
	}

	*return_object = new_object;
	return (AE_OK);
}
Example #3
0
static acpi_status
acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
				  union acpi_operand_object **internal_object)
{
	acpi_status status = AE_OK;
	union acpi_operand_object *package_object;
	union acpi_operand_object **package_elements;
	acpi_native_uint i;

	ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);

	/* Create the package object */

	package_object =
	    acpi_ut_create_package_object(external_object->package.count);
	if (!package_object) {
		return_ACPI_STATUS(AE_NO_MEMORY);
	}

	package_elements = package_object->package.elements;

	/*
	 * Recursive implementation. Probably ok, since nested external packages
	 * as parameters should be very rare.
	 */
	for (i = 0; i < external_object->package.count; i++) {
		status =
		    acpi_ut_copy_eobject_to_iobject(&external_object->package.
						    elements[i],
						    &package_elements[i]);
		if (ACPI_FAILURE(status)) {

			/* Truncate package and delete it */

			package_object->package.count = i;
			package_elements[i] = NULL;
			acpi_ut_remove_reference(package_object);
			return_ACPI_STATUS(status);
		}
	}

	*internal_object = package_object;
	return_ACPI_STATUS(status);
}
Example #4
0
static acpi_status
acpi_ut_copy_ielement_to_ielement(u8 object_type,
				  union acpi_operand_object *source_object,
				  union acpi_generic_state *state,
				  void *context)
{
	acpi_status status = AE_OK;
	u32 this_index;
	union acpi_operand_object **this_target_ptr;
	union acpi_operand_object *target_object;

	ACPI_FUNCTION_ENTRY();

	this_index = state->pkg.index;
	this_target_ptr = (union acpi_operand_object **)
	    &state->pkg.dest_object->package.elements[this_index];

	switch (object_type) {
	case ACPI_COPY_TYPE_SIMPLE:

		/* A null source object indicates a (legal) null package element */

		if (source_object) {
			/*
			 * This is a simple object, just copy it
			 */
			target_object =
			    acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
							   (source_object));
			if (!target_object) {
				return (AE_NO_MEMORY);
			}

			status =
			    acpi_ut_copy_simple_object(source_object,
						       target_object);
			if (ACPI_FAILURE(status)) {
				goto error_exit;
			}

			*this_target_ptr = target_object;
		} else {
			/* Pass through a null element */

			*this_target_ptr = NULL;
		}
		break;

	case ACPI_COPY_TYPE_PACKAGE:

		/*
		 * This object is a package - go down another nesting level
		 * Create and build the package object
		 */
		target_object =
		    acpi_ut_create_package_object(source_object->package.count);
		if (!target_object) {
			return (AE_NO_MEMORY);
		}

		target_object->common.flags = source_object->common.flags;

		/*
		 * Pass the new package object back to the package walk routine
		 */
		state->pkg.this_target_obj = target_object;

		/*
		 * Store the object pointer in the parent package object
		 */
		*this_target_ptr = target_object;
		break;

	default:
		return (AE_BAD_PARAMETER);
	}

	return (status);

      error_exit:
	acpi_ut_remove_reference(target_object);
	return (status);
}