Beispiel #1
0
OBJECT_TYPE_INTERNAL
acpi_ds_method_data_get_type (
	u32                     type,
	u32                     index,
	ACPI_WALK_STATE         *walk_state)
{
	ACPI_STATUS             status;
	ACPI_OPERAND_OBJECT     **entry;
	ACPI_OPERAND_OBJECT     *object;


	/* Get a pointer to the requested stack entry */

	status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry);
	if (ACPI_FAILURE (status)) {
		return ((ACPI_TYPE_NOT_FOUND));
	}

	/* Get the object from the method stack */

	object = *entry;

	/* Get the object type */

	if (!object) {
		/* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */
		return (ACPI_TYPE_ANY);
	}

	return (object->common.type);
}
Beispiel #2
0
ACPI_STATUS
acpi_ds_method_data_set_entry (
	u32                     type,
	u32                     index,
	ACPI_OPERAND_OBJECT     *object,
	ACPI_WALK_STATE         *walk_state)
{
	ACPI_STATUS             status;
	ACPI_OPERAND_OBJECT     **entry;


	/* Get a pointer to the stack entry to set */

	status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry);
	if (ACPI_FAILURE (status)) {
		return (status);
	}

	/* Increment ref count so object can't be deleted while installed */

	acpi_cm_add_reference (object);

	/* Install the object into the stack entry */

	*entry = object;

	return (AE_OK);
}
Beispiel #3
0
acpi_object_type8
acpi_ds_method_data_get_type (
    u16                     opcode,
    u32                     index,
    acpi_walk_state         *walk_state)
{
    acpi_status             status;
    acpi_operand_object     **entry;
    acpi_operand_object     *object;


    FUNCTION_TRACE ("Ds_method_data_get_type");


    /* Get a pointer to the requested stack entry */

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

    /* Get the object from the method stack */

    object = *entry;

    /* Get the object type */

    if (!object) {
        /* Any == 0 => "uninitialized" -- see spec 15.2.3.5.2.28 */
        return_VALUE (ACPI_TYPE_ANY);
    }

    return_VALUE (object->common.type);
}
Beispiel #4
0
acpi_status
acpi_ds_method_data_set_entry (
    u16                     opcode,
    u32                     index,
    acpi_operand_object     *object,
    acpi_walk_state         *walk_state)
{
    acpi_status             status;
    acpi_operand_object     **entry;


    FUNCTION_TRACE ("Ds_method_data_set_entry");


    /* Get a pointer to the stack entry to set */

    status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
    if (ACPI_FAILURE (status)) {
        return_ACPI_STATUS (status);
    }

    /* Increment ref count so object can't be deleted while installed */

    acpi_ut_add_reference (object);

    /* Install the object into the stack entry */

    *entry = object;

    return_ACPI_STATUS (AE_OK);
}
Beispiel #5
0
ACPI_STATUS
acpi_ds_method_data_delete_value (
	u32                     type,
	u32                     index,
	ACPI_WALK_STATE         *walk_state)
{
	ACPI_STATUS             status;
	ACPI_OPERAND_OBJECT     **entry;
	ACPI_OPERAND_OBJECT     *object;


	/* Get a pointer to the requested entry */

	status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry);
	if (ACPI_FAILURE (status)) {
		return (status);
	}

	/* Get the current entry in this slot k */

	object = *entry;

	/*
	 * Undefine the Arg or Local by setting its descriptor
	 * pointer to NULL. Locals/Args can contain both
	 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
	 */
	*entry = NULL;


	if ((object) &&
		(VALID_DESCRIPTOR_TYPE (object, ACPI_DESC_TYPE_INTERNAL)))
	{
		/*
		 * There is a valid object in this slot
		 * Decrement the reference count by one to balance the
		 * increment when the object was stored in the slot.
		 */

		acpi_cm_remove_reference (object);
	}


	return (AE_OK);
}
Beispiel #6
0
ACPI_STATUS
acpi_ds_method_data_set_value (
	u32                     type,
	u32                     index,
	ACPI_OPERAND_OBJECT     *src_desc,
	ACPI_WALK_STATE         *walk_state)
{
	ACPI_STATUS             status;
	ACPI_OPERAND_OBJECT     **entry;


	/* Parameter validation */

	if (!src_desc) {
		return (AE_BAD_PARAMETER);
	}


	/* Get a pointer to the requested method stack entry */

	status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry);
	if (ACPI_FAILURE (status)) {
		goto cleanup;
	}

	if (*entry == src_desc) {
		goto cleanup;
	}


	/*
	 * If there is an object already in this slot, we either
	 * have to delete it, or if this is an argument and there
	 * is an object reference stored there, we have to do
	 * an indirect store!
	 */

	if (*entry) {
		/*
		 * Check for an indirect store if an argument
		 * contains an object reference (stored as an Node).
		 * We don't allow this automatic dereferencing for
		 * locals, since a store to a local should overwrite
		 * anything there, including an object reference.
		 *
		 * If both Arg0 and Local0 contain Ref_of (Local4):
		 *
		 * Store (1, Arg0)             - Causes indirect store to local4
		 * Store (1, Local0)           - Stores 1 in local0, overwriting
		 *                                  the reference to local4
		 * Store (1, De_refof (Local0)) - Causes indirect store to local4
		 *
		 * Weird, but true.
		 */

		if ((type == MTH_TYPE_ARG) &&
			(VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED)))
		{
			/* Detach an existing object from the Node */

			acpi_ns_detach_object ((ACPI_NAMESPACE_NODE *) *entry);

			/*
			 * Store this object into the Node
			 * (do the indirect store)
			 */

			status = acpi_ns_attach_object ((ACPI_NAMESPACE_NODE *) *entry, src_desc,
					   src_desc->common.type);
			return (status);
		}


		/*
		 * Otherwise, just delete the existing object
		 * before storing the new one
		 */

		acpi_ds_method_data_delete_value (type, index, walk_state);
	}


	/*
	 * Install the Obj_stack descriptor (*Src_desc) into
	 * the descriptor for the Arg or Local.
	 * Install the new object in the stack entry
	 * (increments the object reference count by one)
	 */

	status = acpi_ds_method_data_set_entry (type, index, src_desc, walk_state);
	if (ACPI_FAILURE (status)) {
		goto cleanup;
	}

	/* Normal exit */

	return (AE_OK);


	/* Error exit */

cleanup:

	return (status);
}
Beispiel #7
0
ACPI_STATUS
acpi_ds_method_data_get_value (
	u32                     type,
	u32                     index,
	ACPI_WALK_STATE         *walk_state,
	ACPI_OPERAND_OBJECT     **dest_desc)
{
	ACPI_STATUS             status;
	ACPI_OPERAND_OBJECT     **entry;
	ACPI_OPERAND_OBJECT     *object;


	/* Validate the object descriptor */

	if (!dest_desc) {
		return (AE_BAD_PARAMETER);
	}


	/* Get a pointer to the requested method stack entry */

	status = acpi_ds_method_data_get_entry (type, index, walk_state, &entry);
	if (ACPI_FAILURE (status)) {
		return (status);
	}

	/* Get the object from the method stack */

	object = *entry;


	/* Examine the returned object, it must be valid. */

	if (!object) {
		/*
		 * Index points to uninitialized object stack value.
		 * This means that either 1) The expected argument was
		 * not passed to the method, or 2) A local variable
		 * was referenced by the method (via the ASL)
		 * before it was initialized.  Either case is an error.
		 */

		switch (type)
		{
		case MTH_TYPE_ARG:
			return (AE_AML_UNINITIALIZED_ARG);
			break;

		case MTH_TYPE_LOCAL:
			return (AE_AML_UNINITIALIZED_LOCAL);
			break;
		}
	}


	/*
	 * Index points to initialized and valid object stack value.
	 * Return an additional reference to the object
	 */

	*dest_desc = object;
	acpi_cm_add_reference (object);

	return (AE_OK);
}
Beispiel #8
0
acpi_status
acpi_ds_store_object_to_local (
    u16                     opcode,
    u32                     index,
    acpi_operand_object     *src_desc,
    acpi_walk_state         *walk_state)
{
    acpi_status             status;
    acpi_operand_object     **entry;


    FUNCTION_TRACE ("Ds_method_data_set_value");
    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n",
                       opcode, index, src_desc));


    /* Parameter validation */

    if (!src_desc) {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }


    /* Get a pointer to the requested method stack entry */

    status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
    if (ACPI_FAILURE (status)) {
        goto cleanup;
    }

    if (*entry == src_desc) {
        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", src_desc));
        goto cleanup;
    }


    /*
     * If there is an object already in this slot, we either
     * have to delete it, or if this is an argument and there
     * is an object reference stored there, we have to do
     * an indirect store!
     */
    if (*entry) {
        /*
         * Check for an indirect store if an argument
         * contains an object reference (stored as an Node).
         * We don't allow this automatic dereferencing for
         * locals, since a store to a local should overwrite
         * anything there, including an object reference.
         *
         * If both Arg0 and Local0 contain Ref_of (Local4):
         *
         * Store (1, Arg0)             - Causes indirect store to local4
         * Store (1, Local0)           - Stores 1 in local0, overwriting
         *                                  the reference to local4
         * Store (1, De_refof (Local0)) - Causes indirect store to local4
         *
         * Weird, but true.
         */
        if ((opcode == AML_ARG_OP) &&
                (VALID_DESCRIPTOR_TYPE (*entry, ACPI_DESC_TYPE_NAMED))) {
            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
                               "Arg (%p) is an Obj_ref(Node), storing in %p\n",
                               src_desc, *entry));

            /* Detach an existing object from the Node */

            acpi_ns_detach_object ((acpi_namespace_node *) *entry);

            /*
             * Store this object into the Node
             * (do the indirect store)
             */
            status = acpi_ns_attach_object ((acpi_namespace_node *) *entry, src_desc,
                                            src_desc->common.type);
            return_ACPI_STATUS (status);
        }


#ifdef ACPI_ENABLE_IMPLICIT_CONVERSION
        /*
         * Perform "Implicit conversion" of the new object to the type of the
         * existing object
         */
        status = acpi_ex_convert_to_target_type ((*entry)->common.type, &src_desc, walk_state);
        if (ACPI_FAILURE (status)) {
            goto cleanup;
        }
#endif

        /*
         * Delete the existing object
         * before storing the new one
         */
        acpi_ds_method_data_delete_value (opcode, index, walk_state);
    }


    /*
     * Install the Obj_stack descriptor (*Src_desc) into
     * the descriptor for the Arg or Local.
     * Install the new object in the stack entry
     * (increments the object reference count by one)
     */
    status = acpi_ds_method_data_set_entry (opcode, index, src_desc, walk_state);
    if (ACPI_FAILURE (status)) {
        goto cleanup;
    }

    /* Normal exit */

    return_ACPI_STATUS (AE_OK);


    /* Error exit */

cleanup:

    return_ACPI_STATUS (status);
}
Beispiel #9
0
acpi_status
acpi_ds_method_data_get_value (
    u16                     opcode,
    u32                     index,
    acpi_walk_state         *walk_state,
    acpi_operand_object     **dest_desc)
{
    acpi_status             status;
    acpi_operand_object     **entry;
    acpi_operand_object     *object;


    FUNCTION_TRACE ("Ds_method_data_get_value");


    /* Validate the object descriptor */

    if (!dest_desc) {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n"));
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }


    /* Get a pointer to the requested method stack entry */

    status = acpi_ds_method_data_get_entry (opcode, index, walk_state, &entry);
    if (ACPI_FAILURE (status)) {
        return_ACPI_STATUS (status);
    }

    /* Get the object from the method stack */

    object = *entry;


    /* Examine the returned object, it must be valid. */

    if (!object) {
        /*
         * Index points to uninitialized object stack value.
         * This means that either 1) The expected argument was
         * not passed to the method, or 2) A local variable
         * was referenced by the method (via the ASL)
         * before it was initialized.  Either case is an error.
         */
        switch (opcode) {
        case AML_ARG_OP:

            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at entry %p\n",
                               index, entry));

            return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
            break;

        case AML_LOCAL_OP:

            ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at entry %p\n",
                               index, entry));

            return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
            break;
        }
    }


    /*
     * Index points to initialized and valid object stack value.
     * Return an additional reference to the object
     */
    *dest_desc = object;
    acpi_ut_add_reference (object);

    return_ACPI_STATUS (AE_OK);
}