aboutsummaryrefslogtreecommitdiff
path: root/drivers/acpi/utilities
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities')
-rw-r--r--drivers/acpi/utilities/Makefile9
-rw-r--r--drivers/acpi/utilities/utalloc.c383
-rw-r--r--drivers/acpi/utilities/utcopy.c970
-rw-r--r--drivers/acpi/utilities/utdebug.c651
-rw-r--r--drivers/acpi/utilities/utdelete.c677
-rw-r--r--drivers/acpi/utilities/uteval.c752
-rw-r--r--drivers/acpi/utilities/utglobal.c823
-rw-r--r--drivers/acpi/utilities/utinit.c152
-rw-r--r--drivers/acpi/utilities/utmath.c312
-rw-r--r--drivers/acpi/utilities/utmisc.c1093
-rw-r--r--drivers/acpi/utilities/utmutex.c342
-rw-r--r--drivers/acpi/utilities/utobject.c677
-rw-r--r--drivers/acpi/utilities/utresrc.c616
-rw-r--r--drivers/acpi/utilities/utstate.c347
-rw-r--r--drivers/acpi/utilities/utxface.c512
15 files changed, 0 insertions, 8316 deletions
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
deleted file mode 100644
index 66a71a54cb0..00000000000
--- a/drivers/acpi/utilities/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for all Linux ACPI interpreter subdirectories
-#
-
-obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
- utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
- utstate.o utmutex.o utobject.o utresrc.o
-
-EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
deleted file mode 100644
index 2a017b29aa4..00000000000
--- a/drivers/acpi/utilities/utalloc.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utalloc - local memory allocation routines
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acdebug.h>
-
-#define _COMPONENT ACPI_UTILITIES
-ACPI_MODULE_NAME("utalloc")
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_create_caches
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Create all local caches
- *
- ******************************************************************************/
-acpi_status acpi_ut_create_caches(void)
-{
- acpi_status status;
-
- /* Object Caches, for frequently used objects */
-
- status =
- acpi_os_create_cache("Acpi-Namespace",
- sizeof(struct acpi_namespace_node),
- ACPI_MAX_NAMESPACE_CACHE_DEPTH,
- &acpi_gbl_namespace_cache);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- status =
- acpi_os_create_cache("Acpi-State", sizeof(union acpi_generic_state),
- ACPI_MAX_STATE_CACHE_DEPTH,
- &acpi_gbl_state_cache);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- status =
- acpi_os_create_cache("Acpi-Parse",
- sizeof(struct acpi_parse_obj_common),
- ACPI_MAX_PARSE_CACHE_DEPTH,
- &acpi_gbl_ps_node_cache);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- status =
- acpi_os_create_cache("Acpi-ParseExt",
- sizeof(struct acpi_parse_obj_named),
- ACPI_MAX_EXTPARSE_CACHE_DEPTH,
- &acpi_gbl_ps_node_ext_cache);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- status =
- acpi_os_create_cache("Acpi-Operand",
- sizeof(union acpi_operand_object),
- ACPI_MAX_OBJECT_CACHE_DEPTH,
- &acpi_gbl_operand_cache);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
- /* Memory allocation lists */
-
- status = acpi_ut_create_list("Acpi-Global", 0, &acpi_gbl_global_list);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-
- status =
- acpi_ut_create_list("Acpi-Namespace",
- sizeof(struct acpi_namespace_node),
- &acpi_gbl_ns_node_list);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
-#endif
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_delete_caches
- *
- * PARAMETERS: None
- *
- * RETURN: Status
- *
- * DESCRIPTION: Purge and delete all local caches
- *
- ******************************************************************************/
-
-acpi_status acpi_ut_delete_caches(void)
-{
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
- char buffer[7];
-
- if (acpi_gbl_display_final_mem_stats) {
- ACPI_STRCPY(buffer, "MEMORY");
- (void)acpi_db_display_statistics(buffer);
- }
-#endif
-
- (void)acpi_os_delete_cache(acpi_gbl_namespace_cache);
- acpi_gbl_namespace_cache = NULL;
-
- (void)acpi_os_delete_cache(acpi_gbl_state_cache);
- acpi_gbl_state_cache = NULL;
-
- (void)acpi_os_delete_cache(acpi_gbl_operand_cache);
- acpi_gbl_operand_cache = NULL;
-
- (void)acpi_os_delete_cache(acpi_gbl_ps_node_cache);
- acpi_gbl_ps_node_cache = NULL;
-
- (void)acpi_os_delete_cache(acpi_gbl_ps_node_ext_cache);
- acpi_gbl_ps_node_ext_cache = NULL;
-
-#ifdef ACPI_DBG_TRACK_ALLOCATIONS
-
- /* Debug only - display leftover memory allocation, if any */
-
- acpi_ut_dump_allocations(ACPI_UINT32_MAX, NULL);
-
- /* Free memory lists */
-
- ACPI_FREE(acpi_gbl_global_list);
- acpi_gbl_global_list = NULL;
-
- ACPI_FREE(acpi_gbl_ns_node_list);
- acpi_gbl_ns_node_list = NULL;
-#endif
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_validate_buffer
- *
- * PARAMETERS: Buffer - Buffer descriptor to be validated
- *
- * RETURN: Status
- *
- * DESCRIPTION: Perform parameter validation checks on an struct acpi_buffer
- *
- ******************************************************************************/
-
-acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
-{
-
- /* Obviously, the structure pointer must be valid */
-
- if (!buffer) {
- return (AE_BAD_PARAMETER);
- }
-
- /* Special semantics for the length */
-
- if ((buffer->length == ACPI_NO_BUFFER) ||
- (buffer->length == ACPI_ALLOCATE_BUFFER) ||
- (buffer->length == ACPI_ALLOCATE_LOCAL_BUFFER)) {
- return (AE_OK);
- }
-
- /* Length is valid, the buffer pointer must be also */
-
- if (!buffer->pointer) {
- return (AE_BAD_PARAMETER);
- }
-
- return (AE_OK);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_initialize_buffer
- *
- * PARAMETERS: Buffer - Buffer to be validated
- * required_length - Length needed
- *
- * RETURN: Status
- *
- * DESCRIPTION: Validate that the buffer is of the required length or
- * allocate a new buffer. Returned buffer is always zeroed.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
- acpi_size required_length)
-{
- acpi_size input_buffer_length;
-
- /* Parameter validation */
-
- if (!buffer || !required_length) {
- return (AE_BAD_PARAMETER);
- }
-
- /*
- * Buffer->Length is used as both an input and output parameter. Get the
- * input actual length and set the output required buffer length.
- */
- input_buffer_length = buffer->length;
- buffer->length = required_length;
-
- /*
- * The input buffer length contains the actual buffer length, or the type
- * of buffer to be allocated by this routine.
- */
- switch (input_buffer_length) {
- case ACPI_NO_BUFFER:
-
- /* Return the exception (and the required buffer length) */
-
- return (AE_BUFFER_OVERFLOW);
-
- case ACPI_ALLOCATE_BUFFER:
-
- /* Allocate a new buffer */
-
- buffer->pointer = acpi_os_allocate(required_length);
- break;
-
- case ACPI_ALLOCATE_LOCAL_BUFFER:
-
- /* Allocate a new buffer with local interface to allow tracking */
-
- buffer->pointer = ACPI_ALLOCATE(required_length);
- break;
-
- default:
-
- /* Existing buffer: Validate the size of the buffer */
-
- if (input_buffer_length < required_length) {
- return (AE_BUFFER_OVERFLOW);
- }
- break;
- }
-
- /* Validate allocation from above or input buffer pointer */
-
- if (!buffer->pointer) {
- return (AE_NO_MEMORY);
- }
-
- /* Have a valid buffer, clear it */
-
- ACPI_MEMSET(buffer->pointer, 0, required_length);
- return (AE_OK);
-}
-
-#ifdef NOT_USED_BY_LINUX
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_allocate
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of malloc.
- *
- ******************************************************************************/
-
-void *acpi_ut_allocate(acpi_size size,
- u32 component, const char *module, u32 line)
-{
- void *allocation;
-
- ACPI_FUNCTION_TRACE_U32(ut_allocate, size);
-
- /* Check for an inadvertent size of zero bytes */
-
- if (!size) {
- ACPI_WARNING((module, line,
- "Attempt to allocate zero bytes, allocating 1 byte"));
- size = 1;
- }
-
- allocation = acpi_os_allocate(size);
- if (!allocation) {
-
- /* Report allocation error */
-
- ACPI_WARNING((module, line,
- "Could not allocate size %X", (u32) size));
-
- return_PTR(NULL);
- }
-
- return_PTR(allocation);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_allocate_zeroed
- *
- * PARAMETERS: Size - Size of the allocation
- * Component - Component type of caller
- * Module - Source file name of caller
- * Line - Line number of caller
- *
- * RETURN: Address of the allocated memory on success, NULL on failure.
- *
- * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory.
- *
- ******************************************************************************/
-
-void *acpi_ut_allocate_zeroed(acpi_size size,
- u32 component, const char *module, u32 line)
-{
- void *allocation;
-
- ACPI_FUNCTION_ENTRY();
-
- allocation = acpi_ut_allocate(size, component, module, line);
- if (allocation) {
-
- /* Clear the memory block */
-
- ACPI_MEMSET(allocation, 0, size);
- }
-
- return (allocation);
-}
-#endif
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
deleted file mode 100644
index e6f3002312e..00000000000
--- a/drivers/acpi/utilities/utcopy.c
+++ /dev/null
@@ -1,970 +0,0 @@
-/******************************************************************************
- *
- * Module Name: utcopy - Internal to external object translation utilities
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2008, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions, and the following disclaimer,
- * without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- * substantially similar to the "NO WARRANTY" disclaimer below
- * ("Disclaimer") and any redistribution must be conditioned upon
- * including a substantially similar Disclaimer requirement for further
- * binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- * of any contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include <acpi/acpi.h>
-#include <acpi/accommon.h>
-#include <acpi/acnamesp.h>
-
-
-#define _COMPONENT ACPI_UTILITIES
-ACPI_MODULE_NAME("utcopy")
-
-/* Local prototypes */
-static acpi_status
-acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
- union acpi_object *external_object,
- u8 * data_space, acpi_size * buffer_space_used);
-
-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);
-
-static acpi_status
-acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
- u8 * buffer, acpi_size * space_used);
-
-static acpi_status
-acpi_ut_copy_esimple_to_isimple(union acpi_object *user_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
-acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
- union acpi_operand_object *dest_desc);
-
-static acpi_status
-acpi_ut_copy_ielement_to_eelement(u8 object_type,
- union acpi_operand_object *source_object,
- union acpi_generic_state *state,
- void *context);
-
-static 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);
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_isimple_to_esimple
- *
- * PARAMETERS: internal_object - Source object to be copied
- * external_object - Where to return the copied object
- * data_space - Where object data is returned (such as
- * buffer and string data)
- * buffer_space_used - Length of data_space that was used
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to copy a simple internal object to
- * an external object.
- *
- * The data_space buffer is assumed to have sufficient space for
- * the object.
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
- union acpi_object *external_object,
- u8 * data_space, acpi_size * buffer_space_used)
-{
- acpi_status status = AE_OK;
-
- ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple);
-
- *buffer_space_used = 0;
-
- /*
- * Check for NULL object case (could be an uninitialized
- * package element)
- */
- if (!internal_object) {
- return_ACPI_STATUS(AE_OK);
- }
-
- /* Always clear the external object */
-
- ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
-
- /*
- * In general, the external object will be the same type as
- * the internal object
- */
- external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
-
- /* However, only a limited number of external types are supported */
-
- switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
- case ACPI_TYPE_STRING:
-
- external_object->string.pointer = (char *)data_space;
- external_object->string.length = internal_object->string.length;
- *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
- internal_object->
- string.
- length + 1);
-
- ACPI_MEMCPY((void *)data_space,
- (void *)internal_object->string.pointer,
- (acpi_size) internal_object->string.length + 1);
- break;
-
- case ACPI_TYPE_BUFFER:
-
- external_object->buffer.pointer = data_space;
- external_object->buffer.length = internal_object->buffer.length;
- *buffer_space_used =
- ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
- length);
-
- ACPI_MEMCPY((void *)data_space,
- (void *)internal_object->buffer.pointer,
- internal_object->buffer.length);
- break;
-
- case ACPI_TYPE_INTEGER:
-
- external_object->integer.value = internal_object->integer.value;
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- /* This is an object reference. */
-
- switch (internal_object->reference.class) {
- case ACPI_REFCLASS_NAME:
-
- /*
- * For namepath, return the object handle ("reference")
- * We are referring to the namespace node
- */
- external_object->reference.handle =
- internal_object->reference.node;
- external_object->reference.actual_type =
- acpi_ns_get_type(internal_object->reference.node);
- break;
-
- default:
-
- /* All other reference types are unsupported */
-
- return_ACPI_STATUS(AE_TYPE);
- }
- break;
-
- case ACPI_TYPE_PROCESSOR:
-
- external_object->processor.proc_id =
- internal_object->processor.proc_id;
- external_object->processor.pblk_address =
- internal_object->processor.address;
- external_object->processor.pblk_length =
- internal_object->processor.length;
- break;
-
- case ACPI_TYPE_POWER:
-
- external_object->power_resource.system_level =
- internal_object->power_resource.system_level;
-
- external_object->power_resource.resource_order =
- internal_object->power_resource.resource_order;
- break;
-
- default:
- /*
- * There is no corresponding external object type
- */
- ACPI_ERROR((AE_INFO,
- "Unsupported object type, cannot convert to external object: %s",
- acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
- (internal_object))));
-
- return_ACPI_STATUS(AE_SUPPORT);
- }
-
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_ielement_to_eelement
- *
- * PARAMETERS: acpi_pkg_callback
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy one package element to another package element
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ut_copy_ielement_to_eelement(u8 object_type,
- union acpi_operand_object *source_object,
- union acpi_generic_state *state,
- void *context)
-{
- acpi_status status = AE_OK;
- struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
- acpi_size object_space;
- u32 this_index;
- union acpi_object *target_object;
-
- ACPI_FUNCTION_ENTRY();
-
- this_index = state->pkg.index;
- target_object = (union acpi_object *)
- &((union acpi_object *)(state->pkg.dest_object))->package.
- elements[this_index];
-
- switch (object_type) {
- case ACPI_COPY_TYPE_SIMPLE:
-
- /*
- * This is a simple or null object
- */
- status = acpi_ut_copy_isimple_to_esimple(source_object,
- target_object,
- info->free_space,
- &object_space);
- if (ACPI_FAILURE(status)) {
- return (status);
- }
- break;
-
- case ACPI_COPY_TYPE_PACKAGE:
-
- /*
- * Build the package object
- */
- target_object->type = ACPI_TYPE_PACKAGE;
- target_object->package.count = source_object->package.count;
- target_object->package.elements =
- ACPI_CAST_PTR(union acpi_object, info->free_space);
-
- /*
- * Pass the new package object back to the package walk routine
- */
- state->pkg.this_target_obj = target_object;
-
- /*
- * Save space for the array of objects (Package elements)
- * update the buffer length counter
- */
- object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
- target_object->
- package.count *
- sizeof(union
- acpi_object));
- break;
-
- default:
- return (AE_BAD_PARAMETER);
- }
-
- info->free_space += object_space;
- info->length += object_space;
- return (status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_ipackage_to_epackage
- *
- * PARAMETERS: internal_object - Pointer to the object we are returning
- * Buffer - Where the object is returned
- * space_used - Where the object length is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to place a package object in a user
- * buffer. A package object by definition contains other objects.
- *
- * 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
-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);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_iobject_to_eobject
- *
- * PARAMETERS: internal_object - The internal object to be converted
- * buffer_ptr - Where the object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function is called to build an API object to be returned to
- * the caller.
- *
- ******************************************************************************/
-
-acpi_status
-acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
- struct acpi_buffer *ret_buffer)
-{
- acpi_status status;
-
- ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
-
- if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
- /*
- * Package object: Copy all subobjects (including
- * nested packages)
- */
- status = acpi_ut_copy_ipackage_to_epackage(internal_object,
- ret_buffer->pointer,
- &ret_buffer->length);
- } else {
- /*
- * Build a simple object (no nested objects)
- */
- status = acpi_ut_copy_isimple_to_esimple(internal_object,
- ACPI_CAST_PTR(union
- acpi_object,
- ret_buffer->
- pointer),
- ACPI_ADD_PTR(u8,
- ret_buffer->
- pointer,
- ACPI_ROUND_UP_TO_NATIVE_WORD
- (sizeof
- (union
- acpi_object))),
- &ret_buffer->length);
- /*
- * build simple does not include the object size in the length
- * so we add it in here
- */
- ret_buffer->length += sizeof(union acpi_object);
- }
-
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_esimple_to_isimple
- *
- * PARAMETERS: external_object - The external object to be converted
- * ret_internal_object - Where the internal object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: This function copies an external object to an internal one.
- * NOTE: Pointers can be copied, we don't need to copy data.
- * (The pointers have to be valid in our address space no matter
- * what we do with them!)
- *
- ******************************************************************************/
-
-static acpi_status
-acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
- union acpi_operand_object **ret_internal_object)
-{
- union acpi_operand_object *internal_object;
-
- ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple);
-
- /*
- * Simple types supported are: String, Buffer, Integer
- */
- switch (external_object->type) {
- case ACPI_TYPE_STRING:
- case ACPI_TYPE_BUFFER:
- case ACPI_TYPE_INTEGER:
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- internal_object = acpi_ut_create_internal_object((u8)
- external_object->
- type);
- if (!internal_object) {
- return_ACPI_STATUS(AE_NO_MEMORY);
- }
- break;
-
- case ACPI_TYPE_ANY: /* This is the case for a NULL object */
-
- *ret_internal_object = NULL;
- return_ACPI_STATUS(AE_OK);
-
- default:
- /* All other types are not supported */
-
- ACPI_ERROR((AE_INFO,
- "Unsupported object type, cannot convert to internal object: %s",
- acpi_ut_get_type_name(external_object->type)));
-
- return_ACPI_STATUS(AE_SUPPORT);
- }
-
- /* Must COPY string and buffer contents */
-
- switch (external_object->type) {
- case ACPI_TYPE_STRING:
-
- internal_object->string.pointer =
- ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string.
- length + 1);
- if (!internal_object->string.pointer) {
- goto error_exit;
- }
-
- ACPI_MEMCPY(internal_object->string.pointer,
- external_object->string.pointer,
- external_object->string.length);
-
- internal_object->string.length = external_object->string.length;
- break;
-
- case ACPI_TYPE_BUFFER:
-
- internal_object->buffer.pointer =
- ACPI_ALLOCATE_ZEROED(external_object->buffer.length);
- if (!internal_object->buffer.pointer) {
- goto error_exit;
- }
-
- ACPI_MEMCPY(internal_object->buffer.pointer,
- external_object->buffer.pointer,
- external_object->buffer.length);
-
- internal_object->buffer.length = external_object->buffer.length;
-
- /* Mark buffer data valid */
-
- internal_object->buffer.flags |= AOPOBJ_DATA_VALID;
- break;
-
- case ACPI_TYPE_INTEGER:
-
- internal_object->integer.value = external_object->integer.value;
- break;
-
- case ACPI_TYPE_LOCAL_REFERENCE:
-
- /* TBD: should validate incoming handle */
-
- internal_object->reference.class = ACPI_REFCLASS_NAME;
- internal_object->reference.node =
- external_object->reference.handle;
- break;
-
- default:
- /* Other types can't get here */
- break;
- }
-
- *ret_internal_object = internal_object;
- return_ACPI_STATUS(AE_OK);
-
- error_exit:
- acpi_ut_remove_reference(internal_object);
- return_ACPI_STATUS(AE_NO_MEMORY);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_epackage_to_ipackage
- *
- * PARAMETERS: external_object - The external object to be converted
- * internal_object - Where the internal object is returned
- *
- * RETURN: Status
- *
- * DESCRIPTION: Copy an external package object to an internal package.
- * Handles nested packages.
- *
- ******************************************************************************/
-
-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;
- u32 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);
- }
- }
-
- /* Mark package data valid */
-
- package_object->package.flags |= AOPOBJ_DATA_VALID;
-
- *internal_object = package_object;
- return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
- * FUNCTION: acpi_ut_copy_eobject_to_iobject
- *
- * PARAMETERS: external_object - The external object to b