Commit 6287ee32 authored by Bob Moore's avatar Bob Moore Committed by Len Brown

ACPICA: Support for external package objects as method arguments

Implemented support to allow Package objects to be passed as
method arguments to the acpi_evaluate_object interface. Previously,
this would return an AE_NOT_IMPLEMENTED exception.
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 8ff6f48d
...@@ -67,6 +67,10 @@ static acpi_status ...@@ -67,6 +67,10 @@ static acpi_status
acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj, acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
union acpi_operand_object **return_obj); union acpi_operand_object **return_obj);
static acpi_status
acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
union acpi_operand_object **internal_object);
static acpi_status static acpi_status
acpi_ut_copy_simple_object(union acpi_operand_object *source_desc, acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
union acpi_operand_object *dest_desc); union acpi_operand_object *dest_desc);
...@@ -518,75 +522,71 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object, ...@@ -518,75 +522,71 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
return_ACPI_STATUS(AE_NO_MEMORY); return_ACPI_STATUS(AE_NO_MEMORY);
} }
#ifdef ACPI_FUTURE_IMPLEMENTATION
/* Code to convert packages that are parameters to control methods */
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_copy_epackage_to_ipackage * FUNCTION: acpi_ut_copy_epackage_to_ipackage
* *
* PARAMETERS: *internal_object - Pointer to the object we are returning * PARAMETERS: external_object - The external object to be converted
* *Buffer - Where the object is returned * internal_object - Where the internal object is returned
* *space_used - Where the length of the object is returned
* *
* RETURN: Status * RETURN: Status
* *
* DESCRIPTION: This function is called to place a package object in a user * DESCRIPTION: Copy an external package object to an internal package.
* buffer. A package object by definition contains other objects. * Handles nested packages.
*
* The buffer is assumed to have sufficient space for the object.
* The caller must have verified the buffer length needed using the
* acpi_ut_get_object_size function before calling this function.
* *
******************************************************************************/ ******************************************************************************/
static acpi_status static acpi_status
acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object, acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
u8 * buffer, u32 * space_used) union acpi_operand_object **internal_object)
{ {
u8 *free_space; acpi_status status = AE_OK;
union acpi_object *external_object; union acpi_operand_object *package_object;
u32 length = 0; union acpi_operand_object **package_elements;
u32 this_index; acpi_native_uint i;
u32 object_space = 0;
union acpi_operand_object *this_internal_obj;
union acpi_object *this_external_obj;
ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage); ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
/* /* Create the package object */
* First package at head of the buffer
*/
external_object = (union acpi_object *)buffer;
/* package_object =
* Free space begins right after the first package acpi_ut_create_package_object(external_object->package.count);
*/ if (!package_object) {
free_space = buffer + sizeof(union acpi_object); return_ACPI_STATUS(AE_NO_MEMORY);
}
external_object->type = ACPI_GET_OBJECT_TYPE(internal_object); package_elements = package_object->package.elements;
external_object->package.count = internal_object->package.count;
external_object->package.elements = (union acpi_object *)free_space;
/* /*
* Build an array of ACPI_OBJECTS in the buffer * Recursive implementation. Probably ok, since nested external packages
* and move the free space past it * as parameters should be very rare.
*/ */
free_space += for (i = 0; i < external_object->package.count; i++) {
external_object->package.count * sizeof(union acpi_object); status =
acpi_ut_copy_eobject_to_iobject(&external_object->package.
elements[i],
&package_elements[i]);
if (ACPI_FAILURE(status)) {
/* Call walk_package */ /* Truncate package and delete it */
} package_object->package.count = i;
package_elements[i] = NULL;
acpi_ut_remove_reference(package_object);
return_ACPI_STATUS(status);
}
}
#endif /* Future implementation */ *internal_object = package_object;
return_ACPI_STATUS(status);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_copy_eobject_to_iobject * FUNCTION: acpi_ut_copy_eobject_to_iobject
* *
* PARAMETERS: *internal_object - The external object to be converted * PARAMETERS: external_object - The external object to be converted
* *buffer_ptr - Where the internal object is returned * internal_object - Where the internal object is returned
* *
* RETURN: Status - the status of the call * RETURN: Status - the status of the call
* *
...@@ -603,16 +603,10 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object, ...@@ -603,16 +603,10 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject); ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject);
if (external_object->type == ACPI_TYPE_PACKAGE) { if (external_object->type == ACPI_TYPE_PACKAGE) {
/* status =
* Packages as external input to control methods are not supported, acpi_ut_copy_epackage_to_ipackage(external_object,
*/ internal_object);
ACPI_ERROR((AE_INFO, } else {
"Packages as parameters not implemented!"));
return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
}
else {
/* /*
* Build a simple object (no nested objects) * Build a simple object (no nested objects)
*/ */
...@@ -803,33 +797,19 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type, ...@@ -803,33 +797,19 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
* Create and build the package object * Create and build the package object
*/ */
target_object = target_object =
acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE); acpi_ut_create_package_object(source_object->package.count);
if (!target_object) { if (!target_object) {
return (AE_NO_MEMORY); return (AE_NO_MEMORY);
} }
target_object->package.count = source_object->package.count;
target_object->common.flags = source_object->common.flags; target_object->common.flags = source_object->common.flags;
/* /* Pass the new package object back to the package walk routine */
* Create the object array
*/
target_object->package.elements =
ACPI_ALLOCATE_ZEROED(((acpi_size) source_object->package.
count + 1) * sizeof(void *));
if (!target_object->package.elements) {
status = AE_NO_MEMORY;
goto error_exit;
}
/*
* Pass the new package object back to the package walk routine
*/
state->pkg.this_target_obj = target_object; state->pkg.this_target_obj = target_object;
/* /* Store the object pointer in the parent package object */
* Store the object pointer in the parent package object
*/
*this_target_ptr = target_object; *this_target_ptr = target_object;
break; break;
......
...@@ -144,6 +144,48 @@ union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name, ...@@ -144,6 +144,48 @@ union acpi_operand_object *acpi_ut_create_internal_object_dbg(char *module_name,
return_PTR(object); return_PTR(object);
} }
/*******************************************************************************
*
* FUNCTION: acpi_ut_create_package_object
*
* PARAMETERS: Count - Number of package elements
*
* RETURN: Pointer to a new Package object, null on failure
*
* DESCRIPTION: Create a fully initialized package object
*
******************************************************************************/
union acpi_operand_object *acpi_ut_create_package_object(u32 count)
{
union acpi_operand_object *package_desc;
union acpi_operand_object **package_elements;
ACPI_FUNCTION_TRACE_U32(ut_create_package_object, count);
/* Create a new Package object */
package_desc = acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
if (!package_desc) {
return_PTR(NULL);
}
/*
* Create the element array. Count+1 allows the array to be null
* terminated.
*/
package_elements = ACPI_ALLOCATE_ZEROED((acpi_size)
(count + 1) * sizeof(void *));
if (!package_elements) {
ACPI_FREE(package_desc);
return_PTR(NULL);
}
package_desc->package.count = count;
package_desc->package.elements = package_elements;
return_PTR(package_desc);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ut_create_buffer_object * FUNCTION: acpi_ut_create_buffer_object
......
...@@ -390,6 +390,8 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object); ...@@ -390,6 +390,8 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object);
u8 acpi_ut_valid_internal_object(void *object); u8 acpi_ut_valid_internal_object(void *object);
union acpi_operand_object *acpi_ut_create_package_object(u32 count);
union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size); union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size);
union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size); union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment