Esempio n. 1
0
ACPI_STATUS
AcpiUtCopyIobjectToIobject (
    ACPI_OPERAND_OBJECT     *SourceDesc,
    ACPI_OPERAND_OBJECT     **DestDesc,
    ACPI_WALK_STATE         *WalkState)
{
    ACPI_STATUS             Status = AE_OK;


    ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject);


    /* Create the top level object */

    *DestDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceDesc));
    if (!*DestDesc)
    {
        return_ACPI_STATUS (AE_NO_MEMORY);
    }

    /* Copy the object and possible subobjects */

    if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_PACKAGE)
    {
        Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc,
                        WalkState);
    }
    else
    {
        Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc);
    }

    return_ACPI_STATUS (Status);
}
Esempio n. 2
0
acpi_status
acpi_ut_copy_iobject_to_iobject (
	union acpi_operand_object       *source_desc,
	union acpi_operand_object       **dest_desc,
	struct acpi_walk_state          *walk_state)
{
	acpi_status                     status = AE_OK;


	ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");


	/* Create the top level object */

	*dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc));
	if (!*dest_desc) {
		return_ACPI_STATUS (AE_NO_MEMORY);
	}

	/* Copy the object and possible subobjects */

	if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) {
		status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc,
				  walk_state);
	}
	else {
		status = acpi_ut_copy_simple_object (source_desc, *dest_desc);
	}

	return_ACPI_STATUS (status);
}
Esempio n. 3
0
static acpi_status
acpi_ut_translate_one_cid (
	union acpi_operand_object       *obj_desc,
	struct acpi_compatible_id       *one_cid)
{


	switch (ACPI_GET_OBJECT_TYPE (obj_desc)) {
	case ACPI_TYPE_INTEGER:

		/* Convert the Numeric CID to string */

		acpi_ex_eisa_id_to_string ((u32) obj_desc->integer.value, one_cid->value);
		return (AE_OK);

	case ACPI_TYPE_STRING:

		if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) {
			return (AE_AML_STRING_LIMIT);
		}

		/* Copy the String CID from the returned object */

		acpi_ut_copy_id_string (one_cid->value, obj_desc->string.pointer,
				ACPI_MAX_CID_LENGTH);
		return (AE_OK);

	default:

		return (AE_TYPE);
	}
}
Esempio n. 4
0
ACPI_STATUS
AcpiNsDetachData (
    ACPI_NAMESPACE_NODE     *Node,
    ACPI_OBJECT_HANDLER     Handler)
{
    ACPI_OPERAND_OBJECT     *ObjDesc;
    ACPI_OPERAND_OBJECT     *PrevObjDesc;


    PrevObjDesc = NULL;
    ObjDesc = Node->Object;
    while (ObjDesc)
    {
        if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) &&
            (ObjDesc->Data.Handler == Handler))
        {
            if (PrevObjDesc)
            {
                PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject;
            }
            else
            {
                Node->Object = ObjDesc->Common.NextObject;
            }

            AcpiUtRemoveReference (ObjDesc);
            return (AE_OK);
        }

        PrevObjDesc = ObjDesc;
        ObjDesc = ObjDesc->Common.NextObject;
    }

    return (AE_NOT_FOUND);
}
Esempio n. 5
0
union acpi_operand_object *acpi_ns_get_secondary_object(union
							acpi_operand_object
							*obj_desc)
{
	ACPI_FUNCTION_TRACE_PTR(ns_get_secondary_object, obj_desc);

	if ((!obj_desc) ||
	    (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) ||
	    (!obj_desc->common.next_object) ||
	    (ACPI_GET_OBJECT_TYPE(obj_desc->common.next_object) ==
	     ACPI_TYPE_LOCAL_DATA)) {
		return_PTR(NULL);
	}

	return_PTR(obj_desc->common.next_object);
}
Esempio n. 6
0
acpi_status
acpi_ns_detach_data(struct acpi_namespace_node * node,
		    acpi_object_handler handler)
{
	union acpi_operand_object *obj_desc;
	union acpi_operand_object *prev_obj_desc;

	prev_obj_desc = NULL;
	obj_desc = node->object;
	while (obj_desc) {
		if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
		    (obj_desc->data.handler == handler)) {
			if (prev_obj_desc) {
				prev_obj_desc->common.next_object =
				    obj_desc->common.next_object;
			} else {
				node->object = obj_desc->common.next_object;
			}

			acpi_ut_remove_reference(obj_desc);
			return (AE_OK);
		}

		prev_obj_desc = obj_desc;
		obj_desc = obj_desc->common.next_object;
	}

	return (AE_NOT_FOUND);
}
Esempio n. 7
0
acpi_status
acpi_ut_execute_UID (
	struct acpi_namespace_node      *device_node,
	struct acpi_device_id           *uid)
{
	union acpi_operand_object       *obj_desc;
	acpi_status                     status;


	ACPI_FUNCTION_TRACE ("ut_execute_UID");


	status = acpi_ut_evaluate_object (device_node, METHOD_NAME__UID,
			 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &obj_desc);
	if (ACPI_FAILURE (status)) {
		return_ACPI_STATUS (status);
	}

	if (ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_INTEGER) {
		/* Convert the Numeric UID to string */

		acpi_ex_unsigned_integer_to_string (obj_desc->integer.value, uid->value);
	}
	else {
		/* Copy the String UID from the returned object */

		acpi_ut_copy_id_string (uid->value, obj_desc->string.pointer,
				sizeof (uid->value));
	}

	/* On exit, we must delete the return object */

	acpi_ut_remove_reference (obj_desc);
	return_ACPI_STATUS (status);
}
Esempio n. 8
0
acpi_object_type
acpi_ds_method_data_get_type(u16 opcode,
			     u32 index, struct acpi_walk_state *walk_state)
{
	acpi_status status;
	struct acpi_namespace_node *node;
	union acpi_operand_object *object;

	ACPI_FUNCTION_TRACE(ds_method_data_get_type);

	/* Get the namespace node for the arg/local */

	status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
	if (ACPI_FAILURE(status)) {
		return_VALUE((ACPI_TYPE_NOT_FOUND));
	}

	/* Get the object */

	object = acpi_ns_get_attached_object(node);
	if (!object) {

		/* Uninitialized local/arg, return TYPE_ANY */

		return_VALUE(ACPI_TYPE_ANY);
	}

	/* Get the object type */

	return_VALUE(ACPI_GET_OBJECT_TYPE(object));
}
Esempio n. 9
0
ACPI_OPERAND_OBJECT *
AcpiNsGetSecondaryObject (
    ACPI_OPERAND_OBJECT     *ObjDesc)
{
    ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc);


    if ((!ObjDesc)                                                ||
        (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA)  ||
        (!ObjDesc->Common.NextObject)                             ||
        (ACPI_GET_OBJECT_TYPE (ObjDesc->Common.NextObject) == ACPI_TYPE_LOCAL_DATA))
    {
        return_PTR (NULL);
    }

    return_PTR (ObjDesc->Common.NextObject);
}
Esempio n. 10
0
char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
{

    if (!obj_desc) {
        return ("[NULL Object Descriptor]");
    }

    return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
}
Esempio n. 11
0
void
AcpiNsDetachObject (
    ACPI_NAMESPACE_NODE     *Node)
{
    ACPI_OPERAND_OBJECT     *ObjDesc;


    ACPI_FUNCTION_TRACE (NsDetachObject);


    ObjDesc = Node->Object;

    if (!ObjDesc ||
        (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA))
    {
        return_VOID;
    }

    /* Clear the entry in all cases */

    Node->Object = NULL;
    if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND)
    {
        Node->Object = ObjDesc->Common.NextObject;
        if (Node->Object &&
           (ACPI_GET_OBJECT_TYPE (Node->Object) != ACPI_TYPE_LOCAL_DATA))
        {
            Node->Object = Node->Object->Common.NextObject;
        }
    }

    /* Reset the node type to untyped */

    Node->Type = ACPI_TYPE_ANY;

    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
        Node, AcpiUtGetNodeName (Node), ObjDesc));

    /* Remove one reference on the object (and all subobjects) */

    AcpiUtRemoveReference (ObjDesc);
    return_VOID;
}
Esempio n. 12
0
const char *
AcpiUtGetObjectTypeName (
    ACPI_OPERAND_OBJECT     *ObjDesc)
{

    if (!ObjDesc)
    {
        return ("[NULL Object Descriptor]");
    }

    return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)));
}
Esempio n. 13
0
void
acpi_ns_detach_object (
	struct acpi_namespace_node      *node)
{
	union acpi_operand_object       *obj_desc;


	ACPI_FUNCTION_TRACE ("ns_detach_object");


	obj_desc = node->object;

	if (!obj_desc ||
		(ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA)) {
		return_VOID;
	}

	/* Clear the entry in all cases */

	node->object = NULL;
	if (ACPI_GET_DESCRIPTOR_TYPE (obj_desc) == ACPI_DESC_TYPE_OPERAND) {
		node->object = obj_desc->common.next_object;
		if (node->object &&
		   (ACPI_GET_OBJECT_TYPE (node->object) != ACPI_TYPE_LOCAL_DATA)) {
			node->object = node->object->common.next_object;
		}
	}

	/* Reset the node type to untyped */

	node->type = ACPI_TYPE_ANY;

	ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n",
		node, acpi_ut_get_node_name (node), obj_desc));

	/* Remove one reference on the object (and all subobjects) */

	acpi_ut_remove_reference (obj_desc);
	return_VOID;
}
Esempio n. 14
0
ACPI_STATUS
AcpiDsCreateNode (
    ACPI_WALK_STATE         *WalkState,
    ACPI_NAMESPACE_NODE     *Node,
    ACPI_PARSE_OBJECT       *Op)
{
    ACPI_STATUS             Status;
    ACPI_OPERAND_OBJECT     *ObjDesc;


    ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);


    /*
     * Because of the execution pass through the non-control-method
     * parts of the table, we can arrive here twice.  Only init
     * the named object node the first time through
     */
    if (AcpiNsGetAttachedObject (Node))
    {
        return_ACPI_STATUS (AE_OK);
    }

    if (!Op->Common.Value.Arg)
    {
        /* No arguments, there is nothing to do */

        return_ACPI_STATUS (AE_OK);
    }

    /* Build an internal object for the argument(s) */

    Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg,
                &ObjDesc);
    if (ACPI_FAILURE (Status))
    {
        return_ACPI_STATUS (Status);
    }

    /* Re-type the object according to its argument */

    Node->Type = ACPI_GET_OBJECT_TYPE (ObjDesc);

    /* Attach obj to node */

    Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);

    /* Remove local reference to the object */

    AcpiUtRemoveReference (ObjDesc);
    return_ACPI_STATUS (Status);
}
Esempio n. 15
0
ACPI_STATUS
AcpiNsAttachData (
    ACPI_NAMESPACE_NODE     *Node,
    ACPI_OBJECT_HANDLER     Handler,
    void                    *Data)
{
    ACPI_OPERAND_OBJECT     *PrevObjDesc;
    ACPI_OPERAND_OBJECT     *ObjDesc;
    ACPI_OPERAND_OBJECT     *DataDesc;


    /* We only allow one attachment per handler */

    PrevObjDesc = NULL;
    ObjDesc = Node->Object;
    while (ObjDesc)
    {
        if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) &&
            (ObjDesc->Data.Handler == Handler))
        {
            return (AE_ALREADY_EXISTS);
        }

        PrevObjDesc = ObjDesc;
        ObjDesc = ObjDesc->Common.NextObject;
    }

    /* Create an internal object for the data */

    DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA);
    if (!DataDesc)
    {
        return (AE_NO_MEMORY);
    }

    DataDesc->Data.Handler = Handler;
    DataDesc->Data.Pointer = Data;

    /* Install the data object */

    if (PrevObjDesc)
    {
        PrevObjDesc->Common.NextObject = DataDesc;
    }
    else
    {
        Node->Object = DataDesc;
    }

    return (AE_OK);
}
Esempio n. 16
0
acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
{
	acpi_status status = AE_OK;
	union acpi_operand_object *table_desc = ddb_handle;
	u32 table_index;
	struct acpi_table_header *table;

	ACPI_FUNCTION_TRACE(ex_unload_table);

	/*
	 * Validate the handle
	 * Although the handle is partially validated in acpi_ex_reconfiguration(),
	 * when it calls acpi_ex_resolve_operands(), the handle is more completely
	 * validated here.
	 */
	if ((!ddb_handle) ||
	    (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
	    (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
		return_ACPI_STATUS(AE_BAD_PARAMETER);
	}

	/* Get the table index from the ddb_handle (acpi_size for 64-bit case) */

	table_index = (u32) (acpi_size) table_desc->reference.object;

	/* Invoke table handler if present */

	if (acpi_gbl_table_handler) {
		status = acpi_get_table_by_index(table_index, &table);
		if (ACPI_SUCCESS(status)) {
			(void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD,
						     table,
						     acpi_gbl_table_handler_context);
		}
	}

	/*
	 * Delete the entire namespace under this table Node
	 * (Offset contains the table_id)
	 */
	acpi_tb_delete_namespace_by_owner(table_index);
	(void)acpi_tb_release_owner_id(table_index);

	acpi_tb_set_table_loaded_flag(table_index, FALSE);

	/* Table unloaded, remove a reference to the ddb_handle object */

	acpi_ut_remove_reference(ddb_handle);
	return_ACPI_STATUS(AE_OK);
}
Esempio n. 17
0
static ACPI_STATUS
AcpiUtCopyIpackageToEpackage (
    ACPI_OPERAND_OBJECT     *InternalObject,
    UINT8                   *Buffer,
    ACPI_SIZE               *SpaceUsed)
{
    ACPI_OBJECT             *ExternalObject;
    ACPI_STATUS             Status;
    ACPI_PKG_INFO           Info;


    ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage);


    /*
     * First package at head of the buffer
     */
    ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer);

    /*
     * Free space begins right after the first package
     */
    Info.Length      = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
    Info.FreeSpace   = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (
                                    sizeof (ACPI_OBJECT));
    Info.ObjectSpace = 0;
    Info.NumPackages = 1;

    ExternalObject->Type             = ACPI_GET_OBJECT_TYPE (InternalObject);
    ExternalObject->Package.Count    = InternalObject->Package.Count;
    ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT,
                                            Info.FreeSpace);

    /*
     * Leave room for an array of ACPI_OBJECTS in the buffer
     * and move the free space past it
     */
    Info.Length    += (ACPI_SIZE) ExternalObject->Package.Count *
                            ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
    Info.FreeSpace += ExternalObject->Package.Count *
                            ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));

    Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject,
                AcpiUtCopyIelementToEelement, &Info);

    *SpaceUsed = Info.Length;
    return_ACPI_STATUS (Status);
}
Esempio n. 18
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);
}
Esempio n. 19
0
acpi_status
acpi_ns_attach_data (
	struct acpi_namespace_node      *node,
	acpi_object_handler             handler,
	void                            *data)
{
	union acpi_operand_object       *prev_obj_desc;
	union acpi_operand_object       *obj_desc;
	union acpi_operand_object       *data_desc;


	/* We only allow one attachment per handler */

	prev_obj_desc = NULL;
	obj_desc = node->object;
	while (obj_desc) {
		if ((ACPI_GET_OBJECT_TYPE (obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
			(obj_desc->data.handler == handler)) {
			return (AE_ALREADY_EXISTS);
		}

		prev_obj_desc = obj_desc;
		obj_desc = obj_desc->common.next_object;
	}

	/* Create an internal object for the data */

	data_desc = acpi_ut_create_internal_object (ACPI_TYPE_LOCAL_DATA);
	if (!data_desc) {
		return (AE_NO_MEMORY);
	}

	data_desc->data.handler = handler;
	data_desc->data.pointer = data;

	/* Install the data object */

	if (prev_obj_desc) {
		prev_obj_desc->common.next_object = data_desc;
	}
	else {
		node->object = data_desc;
	}

	return (AE_OK);
}
Esempio n. 20
0
static acpi_status
acpi_ut_copy_epackage_to_ipackage (
	union acpi_operand_object       *internal_object,
	u8                              *buffer,
	u32                             *space_used)
{
	u8                              *free_space;
	union acpi_object               *external_object;
	u32                             length = 0;
	u32                             this_index;
	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");


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

	/*
	 * Free space begins right after the first package
	 */
	free_space = buffer + sizeof(union acpi_object);


	external_object->type              = ACPI_GET_OBJECT_TYPE (internal_object);
	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
	 * and move the free space past it
	 */
	free_space += external_object->package.count * sizeof(union acpi_object);


	/* Call walk_package */

}
Esempio n. 21
0
static ACPI_STATUS
AcpiUtCopyEpackageToIpackage (
    ACPI_OPERAND_OBJECT     *InternalObject,
    UINT8                   *Buffer,
    UINT32                  *SpaceUsed)
{
    UINT8                   *FreeSpace;
    ACPI_OBJECT             *ExternalObject;
    UINT32                  Length = 0;
    UINT32                  ThisIndex;
    UINT32                  ObjectSpace = 0;
    ACPI_OPERAND_OBJECT     *ThisInternalObj;
    ACPI_OBJECT             *ThisExternalObj;


    ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage);


    /*
     * First package at head of the buffer
     */
    ExternalObject = (ACPI_OBJECT *)Buffer;

    /*
     * Free space begins right after the first package
     */
    FreeSpace = Buffer + sizeof(ACPI_OBJECT);


    ExternalObject->Type               = ACPI_GET_OBJECT_TYPE (InternalObject);
    ExternalObject->Package.Count      = InternalObject->Package.Count;
    ExternalObject->Package.Elements   = (ACPI_OBJECT *)FreeSpace;

    /*
     * Build an array of ACPI_OBJECTS in the buffer
     * and move the free space past it
     */
    FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT);


    /* Call WalkPackage */

}
Esempio n. 22
0
static ACPI_STATUS
AcpiUtCopyIpackageToIpackage (
    ACPI_OPERAND_OBJECT     *SourceObj,
    ACPI_OPERAND_OBJECT     *DestObj,
    ACPI_WALK_STATE         *WalkState)
{
    ACPI_STATUS             Status = AE_OK;


    ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage);


    DestObj->Common.Type    = ACPI_GET_OBJECT_TYPE (SourceObj);
    DestObj->Common.Flags   = SourceObj->Common.Flags;
    DestObj->Package.Count  = SourceObj->Package.Count;

    /*
     * Create the object array and walk the source package tree
     */
    DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED (
                                    ((ACPI_SIZE) SourceObj->Package.Count + 1) *
                                    sizeof (void *));
    if (!DestObj->Package.Elements)
    {
        ACPI_ERROR ((AE_INFO, "Package allocation failure"));
        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 = AcpiUtWalkPackageTree (SourceObj, DestObj,
                AcpiUtCopyIelementToIelement, WalkState);
    if (ACPI_FAILURE (Status))
    {
        /* On failure, delete the destination package object */

        AcpiUtRemoveReference (DestObj);
    }

    return_ACPI_STATUS (Status);
}
Esempio n. 23
0
acpi_status
acpi_ns_get_attached_data(struct acpi_namespace_node * node,
			  acpi_object_handler handler, void **data)
{
	union acpi_operand_object *obj_desc;

	obj_desc = node->object;
	while (obj_desc) {
		if ((ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_DATA) &&
		    (obj_desc->data.handler == handler)) {
			*data = obj_desc->data.pointer;
			return (AE_OK);
		}

		obj_desc = obj_desc->common.next_object;
	}

	return (AE_NOT_FOUND);
}
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);
}
Esempio n. 25
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);
}
Esempio n. 26
0
union acpi_operand_object *acpi_ns_get_attached_object(struct
						       acpi_namespace_node
						       *node)
{
	ACPI_FUNCTION_TRACE_PTR(ns_get_attached_object, node);

	if (!node) {
		ACPI_WARNING((AE_INFO, "Null Node ptr"));
		return_PTR(NULL);
	}

	if (!node->object ||
	    ((ACPI_GET_DESCRIPTOR_TYPE(node->object) != ACPI_DESC_TYPE_OPERAND)
	     && (ACPI_GET_DESCRIPTOR_TYPE(node->object) !=
		 ACPI_DESC_TYPE_NAMED))
	    || (ACPI_GET_OBJECT_TYPE(node->object) == ACPI_TYPE_LOCAL_DATA)) {
		return_PTR(NULL);
	}

	return_PTR(node->object);
}
Esempio n. 27
0
acpi_status
acpi_ut_get_object_size(union acpi_operand_object *internal_object,
			acpi_size * obj_length)
{
	acpi_status status;

	ACPI_FUNCTION_ENTRY();

	if ((ACPI_GET_DESCRIPTOR_TYPE(internal_object) ==
	     ACPI_DESC_TYPE_OPERAND)
	    && (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE)) {
		status =
		    acpi_ut_get_package_object_size(internal_object,
						    obj_length);
	} else {
		status =
		    acpi_ut_get_simple_object_size(internal_object, obj_length);
	}

	return (status);
}
acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
{
	acpi_status status = AE_OK;
	union acpi_operand_object *table_desc = ddb_handle;
	struct acpi_table_desc *table_info;

	ACPI_FUNCTION_TRACE("ex_unload_table");

	/*
	 * Validate the handle
	 * Although the handle is partially validated in acpi_ex_reconfiguration(),
	 * when it calls acpi_ex_resolve_operands(), the handle is more completely
	 * validated here.
	 */
	if ((!ddb_handle) ||
	    (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
	    (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
		return_ACPI_STATUS(AE_BAD_PARAMETER);
	}

	/* Get the actual table descriptor from the ddb_handle */

	table_info = (struct acpi_table_desc *)table_desc->reference.object;

	/*
	 * Delete the entire namespace under this table Node
	 * (Offset contains the table_id)
	 */
	acpi_ns_delete_namespace_by_owner(table_info->owner_id);
	acpi_ut_release_owner_id(&table_info->owner_id);

	/* Delete the table itself */

	(void)acpi_tb_uninstall_table(table_info->installed_desc);

	/* Delete the table descriptor (ddb_handle) */

	acpi_ut_remove_reference(table_desc);
	return_ACPI_STATUS(status);
}
Esempio n. 29
0
ACPI_STATUS
AcpiUtCopyIobjectToEobject (
    ACPI_OPERAND_OBJECT     *InternalObject,
    ACPI_BUFFER             *RetBuffer)
{
    ACPI_STATUS             Status;


    ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject);


    if (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE)
    {
        /*
         * Package object:  Copy all subobjects (including
         * nested packages)
         */
        Status = AcpiUtCopyIpackageToEpackage (InternalObject,
                        RetBuffer->Pointer, &RetBuffer->Length);
    }
    else
    {
        /*
         * Build a simple object (no nested objects)
         */
        Status = AcpiUtCopyIsimpleToEsimple (InternalObject,
                    ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer),
                    ACPI_ADD_PTR (UINT8, RetBuffer->Pointer,
                        ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))),
                    &RetBuffer->Length);
        /*
         * build simple does not include the object size in the length
         * so we add it in here
         */
        RetBuffer->Length += sizeof (ACPI_OBJECT);
    }

    return_ACPI_STATUS (Status);
}
Esempio n. 30
0
acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
{
	acpi_status status = AE_OK;
	union acpi_operand_object *table_desc = ddb_handle;
	acpi_native_uint table_index;

	ACPI_FUNCTION_TRACE(ex_unload_table);

	/*
	 * Validate the handle
	 * Although the handle is partially validated in acpi_ex_reconfiguration(),
	 * when it calls acpi_ex_resolve_operands(), the handle is more completely
	 * validated here.
	 */
	if ((!ddb_handle) ||
	    (ACPI_GET_DESCRIPTOR_TYPE(ddb_handle) != ACPI_DESC_TYPE_OPERAND) ||
	    (ACPI_GET_OBJECT_TYPE(ddb_handle) != ACPI_TYPE_LOCAL_REFERENCE)) {
		return_ACPI_STATUS(AE_BAD_PARAMETER);
	}

	/* Get the table index from the ddb_handle */

	table_index = (acpi_native_uint) table_desc->reference.object;

	/*
	 * Delete the entire namespace under this table Node
	 * (Offset contains the table_id)
	 */
	acpi_tb_delete_namespace_by_owner(table_index);
	acpi_tb_release_owner_id(table_index);

	acpi_tb_set_table_loaded_flag(table_index, FALSE);

	/* Delete the table descriptor (ddb_handle) */

	acpi_ut_remove_reference(table_desc);
	return_ACPI_STATUS(status);
}