Ejemplo n.º 1
0
ACPI_STATUS
acpi_tb_validate_table_header (
	ACPI_TABLE_HEADER       *table_header)
{
	ACPI_NAME               signature;


	/* Verify that this is a valid address */

	if (!acpi_os_readable (table_header, sizeof (ACPI_TABLE_HEADER))) {
		return (AE_BAD_ADDRESS);
	}


	/* Ensure that the signature is 4 ASCII characters */

	MOVE_UNALIGNED32_TO_32 (&signature, &table_header->signature);
	if (!acpi_cm_valid_acpi_name (signature)) {
		REPORT_WARNING (("Invalid table signature found\n"));
		return (AE_BAD_SIGNATURE);
	}


	/* Validate the table length */

	if (table_header->length < sizeof (ACPI_TABLE_HEADER)) {
		REPORT_WARNING (("Invalid table header length found\n"));
		return (AE_BAD_HEADER);
	}

	return (AE_OK);
}
Ejemplo n.º 2
0
ACPI_STATUS
AcpiDsMethodDataInit (
    ACPI_WALK_STATE         *WalkState)
{
    UINT32                  i;


    FUNCTION_TRACE ("DsMethodDataInit");

    /*
     * WalkState fields are initialized to zero by the
     * ACPI_MEM_CALLOCATE().
     *
     * An Node is assigned to each argument and local so
     * that RefOf() can return a pointer to the Node.
     */

    /* Init the method arguments */

    for (i = 0; i < MTH_NUM_ARGS; i++)
    {
        MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name,
                                NAMEOF_ARG_NTE);
        WalkState->Arguments[i].Name       |= (i << 24);
        WalkState->Arguments[i].DataType    = ACPI_DESC_TYPE_NAMED;
        WalkState->Arguments[i].Type        = ACPI_TYPE_ANY;
        WalkState->Arguments[i].Flags       = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
    }

    /* Init the method locals */

    for (i = 0; i < MTH_NUM_LOCALS; i++)
    {
        MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name,
                                NAMEOF_LOCAL_NTE);

        WalkState->LocalVariables[i].Name    |= (i << 24);
        WalkState->LocalVariables[i].DataType = ACPI_DESC_TYPE_NAMED;
        WalkState->LocalVariables[i].Type     = ACPI_TYPE_ANY;
        WalkState->LocalVariables[i].Flags    = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
    }

    return_ACPI_STATUS (AE_OK);
}
Ejemplo n.º 3
0
acpi_status
acpi_ds_method_data_init (
    acpi_walk_state         *walk_state)
{
    u32                     i;


    FUNCTION_TRACE ("Ds_method_data_init");

    /*
     * Walk_state fields are initialized to zero by the
     * ACPI_MEM_CALLOCATE().
     *
     * An Node is assigned to each argument and local so
     * that Ref_of() can return a pointer to the Node.
     */

    /* Init the method arguments */

    for (i = 0; i < MTH_NUM_ARGS; i++) {
        MOVE_UNALIGNED32_TO_32 (&walk_state->arguments[i].name,
                                NAMEOF_ARG_NTE);
        walk_state->arguments[i].name      |= (i << 24);
        walk_state->arguments[i].data_type  = ACPI_DESC_TYPE_NAMED;
        walk_state->arguments[i].type       = ACPI_TYPE_ANY;
        walk_state->arguments[i].flags      = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
    }

    /* Init the method locals */

    for (i = 0; i < MTH_NUM_LOCALS; i++) {
        MOVE_UNALIGNED32_TO_32 (&walk_state->local_variables[i].name,
                                NAMEOF_LOCAL_NTE);

        walk_state->local_variables[i].name  |= (i << 24);
        walk_state->local_variables[i].data_type = ACPI_DESC_TYPE_NAMED;
        walk_state->local_variables[i].type   = ACPI_TYPE_ANY;
        walk_state->local_variables[i].flags  = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
    }

    return_ACPI_STATUS (AE_OK);
}
Ejemplo n.º 4
0
acpi_status
acpi_ns_handle_to_pathname (
	acpi_handle             target_handle,
	u32                     *buf_size,
	NATIVE_CHAR             *user_buffer)
{
	acpi_status             status = AE_OK;
	acpi_namespace_node     *node;
	u32                     path_length;
	u32                     user_buf_size;
	acpi_name               name;
	u32                     size;


	FUNCTION_TRACE_PTR ("Ns_handle_to_pathname", target_handle);


	if (!acpi_gbl_root_node) {
		/*
		 * If the name space has not been initialized,
		 * this function should not have been called.
		 */
		return_ACPI_STATUS (AE_NO_NAMESPACE);
	}

	node = acpi_ns_map_handle_to_node (target_handle);
	if (!node) {
		return_ACPI_STATUS (AE_BAD_PARAMETER);
	}


	/* Set return length to the required path length */

	path_length = acpi_ns_get_pathname_length (node);
	size = path_length - 1;

	user_buf_size = *buf_size;
	*buf_size = path_length;

	/* Check if the user buffer is sufficiently large */

	if (path_length > user_buf_size) {
		status = AE_BUFFER_OVERFLOW;
		goto exit;
	}

	/* Store null terminator */

	user_buffer[size] = 0;
	size -= ACPI_NAME_SIZE;

	/* Put the original ACPI name at the end of the path */

	MOVE_UNALIGNED32_TO_32 ((user_buffer + size),
			 &node->name);

	user_buffer[--size] = PATH_SEPARATOR;

	/* Build name backwards, putting "." between segments */

	while ((size > ACPI_NAME_SIZE) && node) {
		size -= ACPI_NAME_SIZE;
		name = acpi_ns_find_parent_name (node);
		MOVE_UNALIGNED32_TO_32 ((user_buffer + size), &name);

		user_buffer[--size] = PATH_SEPARATOR;
		node = acpi_ns_get_parent_object (node);
	}

	/*
	 * Overlay the "." preceding the first segment with
	 * the root name "\"
	 */
	user_buffer[size] = '\\';

	ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Len=%X, %s \n", path_length, user_buffer));

exit:
	return_ACPI_STATUS (status);
}
Ejemplo n.º 5
0
ACPI_STATUS
AcpiExGetBufferFieldValue (
    ACPI_OPERAND_OBJECT     *ObjDesc,
    ACPI_OPERAND_OBJECT     *ResultDesc)
{
    ACPI_STATUS             Status;
    UINT32                  Mask;
    UINT8                   *Location;


    FUNCTION_TRACE ("ExGetBufferFieldValue");


    /*
     * Parameter validation
     */
    if (!ObjDesc)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null field pointer\n"));
        return_ACPI_STATUS (AE_AML_NO_OPERAND);
    }

    if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
    {
        Status = AcpiDsGetBufferFieldArguments (ObjDesc);
        if (ACPI_FAILURE (Status))
        {
            return_ACPI_STATUS (Status);
        }
    }

    if (!ObjDesc->BufferField.BufferObj)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null container pointer\n"));
        return_ACPI_STATUS (AE_AML_INTERNAL);
    }

    if (ACPI_TYPE_BUFFER != ObjDesc->BufferField.BufferObj->Common.Type)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - container is not a Buffer\n"));
        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
    }

    if (!ResultDesc)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null result pointer\n"));
        return_ACPI_STATUS (AE_AML_INTERNAL);
    }


    /* Field location is (base of buffer) + (byte offset) */

    Location = ObjDesc->BufferField.BufferObj->Buffer.Pointer
                + ObjDesc->BufferField.BaseByteOffset;

    /*
     * Construct Mask with as many 1 bits as the field width
     *
     * NOTE: Only the bottom 5 bits are valid for a shift operation, so
     *  special care must be taken for any shift greater than 31 bits.
     *
     * TBD: [Unhandled] Fields greater than 32 bits will not work.
     */
    if (ObjDesc->BufferField.BitLength < 32)
    {
        Mask = ((UINT32) 1 << ObjDesc->BufferField.BitLength) - (UINT32) 1;
    }
    else
    {
        Mask = ACPI_UINT32_MAX;
    }

    ResultDesc->Integer.Type = (UINT8) ACPI_TYPE_INTEGER;

    /* Get the 32 bit value at the location */

    MOVE_UNALIGNED32_TO_32 (&ResultDesc->Integer.Value, Location);

    /*
     * Shift the 32-bit word containing the field, and mask off the
     * resulting value
     */
    ResultDesc->Integer.Value =
        (ResultDesc->Integer.Value >> ObjDesc->BufferField.StartFieldBitOffset) & Mask;

    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
        "** Read from buffer %p byte %ld bit %d width %d addr %p mask %08lx val %08lx\n",
        ObjDesc->BufferField.BufferObj->Buffer.Pointer,
        ObjDesc->BufferField.BaseByteOffset,
        ObjDesc->BufferField.StartFieldBitOffset,
        ObjDesc->BufferField.BitLength,
        Location, Mask, ResultDesc->Integer.Value));

    return_ACPI_STATUS (AE_OK);
}
Ejemplo n.º 6
0
ACPI_STATUS
acpi_ns_lookup (
	ACPI_GENERIC_STATE      *scope_info,
	NATIVE_CHAR             *pathname,
	OBJECT_TYPE_INTERNAL    type,
	OPERATING_MODE          interpreter_mode,
	u32                     flags,
	ACPI_WALK_STATE         *walk_state,
	ACPI_NAMESPACE_NODE     **return_node)
{
	ACPI_STATUS             status;
	ACPI_NAMESPACE_NODE      *prefix_node;
	ACPI_NAMESPACE_NODE     *current_node = NULL;
	ACPI_NAMESPACE_NODE     *scope_to_push = NULL;
	ACPI_NAMESPACE_NODE     *this_node = NULL;
	u32                     num_segments;
	ACPI_NAME               simple_name;
	u8                      null_name_path = FALSE;
	OBJECT_TYPE_INTERNAL    type_to_check_for;
	OBJECT_TYPE_INTERNAL    this_search_type;

	DEBUG_ONLY_MEMBERS      (u32 i)


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


	acpi_gbl_ns_lookup_count++;

	*return_node = ENTRY_NOT_FOUND;


	if (!acpi_gbl_root_node) {
		return (AE_NO_NAMESPACE);
	}

	/*
	 * Get the prefix scope.
	 * A null scope means use the root scope
	 */

	if ((!scope_info) ||
		(!scope_info->scope.node))
	{
		prefix_node = acpi_gbl_root_node;
	}
	else {
		prefix_node = scope_info->scope.node;
	}


	/*
	 * This check is explicitly split provide relax the Type_to_check_for
	 * conditions for Bank_field_defn. Originally, both Bank_field_defn and
	 * Def_field_defn caused Type_to_check_for to be set to ACPI_TYPE_REGION,
	 * but the Bank_field_defn may also check for a Field definition as well
	 * as an Operation_region.
	 */

	if (INTERNAL_TYPE_DEF_FIELD_DEFN == type) {
		/* Def_field_defn defines fields in a Region */

		type_to_check_for = ACPI_TYPE_REGION;
	}

	else if (INTERNAL_TYPE_BANK_FIELD_DEFN == type) {
		/* Bank_field_defn defines data fields in a Field Object */

		type_to_check_for = ACPI_TYPE_ANY;
	}

	else {
		type_to_check_for = type;
	}


	/* TBD: [Restructure] - Move the pathname stuff into a new procedure */

	/* Examine the name pointer */

	if (!pathname) {
		/*  8-12-98 ASL Grammar Update supports null Name_path  */

		null_name_path = TRUE;
		num_segments = 0;
		this_node = acpi_gbl_root_node;

	}

	else {
		/*
		 * Valid name pointer (Internal name format)
		 *
		 * Check for prefixes.  As represented in the AML stream, a
		 * Pathname consists of an optional scope prefix followed by
		 * a segment part.
		 *
		 * If present, the scope prefix is either a Root_prefix (in
		 * which case the name is fully qualified), or zero or more
		 * Parent_prefixes (in which case the name's scope is relative
		 * to the current scope).
		 *
		 * The segment part consists of either:
		 *  - A single 4-byte name segment, or
		 *  - A Dual_name_prefix followed by two 4-byte name segments, or
		 *  - A Multi_name_prefix_op, followed by a byte indicating the
		 *    number of segments and the segments themselves.
		 */

		if (*pathname == AML_ROOT_PREFIX) {
			/* Pathname is fully qualified, look in root name table */

			current_node = acpi_gbl_root_node;

			/* point to segment part */

			pathname++;

			/* Direct reference to root, "\" */

			if (!(*pathname)) {
				this_node = acpi_gbl_root_node;
				goto check_for_new_scope_and_exit;
			}
		}

		else {
			/* Pathname is relative to current scope, start there */

			current_node = prefix_node;

			/*
			 * Handle up-prefix (carat).  More than one prefix
			 * is supported
			 */

			while (*pathname == AML_PARENT_PREFIX) {
				/* Point to segment part or next Parent_prefix */

				pathname++;

				/*  Backup to the parent's scope  */

				this_node = acpi_ns_get_parent_object (current_node);
				if (!this_node) {
					/* Current scope has no parent scope */

					REPORT_ERROR (("Too many parent prefixes (^) - reached root\n"));
					return (AE_NOT_FOUND);
				}

				current_node = this_node;
			}
		}


		/*
		 * Examine the name prefix opcode, if any,
		 * to determine the number of segments
		 */

		if (*pathname == AML_DUAL_NAME_PREFIX) {
			num_segments = 2;

			/* point to first segment */

			pathname++;

		}

		else if (*pathname == AML_MULTI_NAME_PREFIX_OP) {
			num_segments = (u32)* (u8 *) ++pathname;

			/* point to first segment */

			pathname++;

		}

		else {
			/*
			 * No Dual or Multi prefix, hence there is only one
			 * segment and Pathname is already pointing to it.
			 */
			num_segments = 1;

		}

	}


	/*
	 * Search namespace for each segment of the name.
	 * Loop through and verify/add each name segment.
	 */


	while (num_segments-- && current_node) {
		/*
		 * Search for the current name segment under the current
		 * named object.  The Type is significant only at the last (topmost)
		 * level.  (We don't care about the types along the path, only
		 * the type of the final target object.)
		 */
		this_search_type = ACPI_TYPE_ANY;
		if (!num_segments) {
			this_search_type = type;
		}

		/* Pluck one ACPI name from the front of the pathname */

		MOVE_UNALIGNED32_TO_32 (&simple_name, pathname);

		/* Try to find the ACPI name */

		status = acpi_ns_search_and_enter (simple_name, walk_state,
				   current_node, interpreter_mode,
				   this_search_type, flags,
				   &this_node);

		if (ACPI_FAILURE (status)) {
			if (status == AE_NOT_FOUND) {
				/* Name not found in ACPI namespace  */

			}

			return (status);
		}


		/*
		 * If 1) This is the last segment (Num_segments == 0)
		 *    2) and looking for a specific type
		 *       (Not checking for TYPE_ANY)
		 *    3) Which is not an alias
		 *    4) which is not a local type (TYPE_DEF_ANY)
		 *    5) which is not a local type (TYPE_SCOPE)
		 *    6) which is not a local type (TYPE_INDEX_FIELD_DEFN)
		 *    7) and type of object is known (not TYPE_ANY)
		 *    8) and object does not match request
		 *
		 * Then we have a type mismatch.  Just warn and ignore it.
		 */
		if ((num_segments       == 0)                               &&
			(type_to_check_for  != ACPI_TYPE_ANY)                   &&
			(type_to_check_for  != INTERNAL_TYPE_ALIAS)             &&
			(type_to_check_for  != INTERNAL_TYPE_DEF_ANY)           &&
			(type_to_check_for  != INTERNAL_TYPE_SCOPE)             &&
			(type_to_check_for  != INTERNAL_TYPE_INDEX_FIELD_DEFN)  &&
			(this_node->type    != ACPI_TYPE_ANY)                   &&
			(this_node->type    != type_to_check_for))
		{
			/* Complain about a type mismatch */

			REPORT_WARNING (
				("Ns_lookup: %4.4s, type %X, checking for type %X\n",
				&simple_name, this_node->type, type_to_check_for));
		}

		/*
		 * If this is the last name segment and we are not looking for a
		 * specific type, but the type of found object is known, use that type
		 * to see if it opens a scope.
		 */

		if ((0 == num_segments) && (ACPI_TYPE_ANY == type)) {
			type = this_node->type;
		}

		if ((num_segments || acpi_ns_opens_scope (type)) &&
			(this_node->child == NULL))
		{
			/*
			 * More segments or the type implies enclosed scope,
			 * and the next scope has not been allocated.
			 */

		}

		current_node = this_node;

		/* point to next name segment */

		pathname += ACPI_NAME_SIZE;
	}


	/*
	 * Always check if we need to open a new scope
	 */

check_for_new_scope_and_exit:

	if (!(flags & NS_DONT_OPEN_SCOPE) && (walk_state)) {
		/*
		 * If entry is a type which opens a scope,
		 * push the new scope on the scope stack.
		 */

		if (acpi_ns_opens_scope (type_to_check_for)) {
			/*  8-12-98 ASL Grammar Update supports null Name_path  */

			if (null_name_path) {
				/* TBD: [Investigate] - is this the correct thing to do? */

				scope_to_push = NULL;
			}
			else {
				scope_to_push = this_node;
			}

			status = acpi_ds_scope_stack_push (scope_to_push, type,
					   walk_state);
			if (ACPI_FAILURE (status)) {
				return (status);
			}

		}
	}

	*return_node = this_node;
	return (AE_OK);
}
Ejemplo n.º 7
0
void
AcpiUtDumpBuffer (
    UINT8                   *Buffer,
    UINT32                  Count,
    UINT32                  Display,
    UINT32                  ComponentId)
{
    UINT32                  i = 0;
    UINT32                  j;
    UINT32                  Temp32;
    UINT8                   BufChar;


    /* Only dump the buffer if tracing is enabled */

    if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
        (ComponentId & AcpiDbgLayer)))
    {
        return;
    }


    /*
     * Nasty little dump buffer routine!
     */
    while (i < Count)
    {
        /* Print current offset */

        AcpiOsPrintf ("%05X    ", i);


        /* Print 16 hex chars */

        for (j = 0; j < 16;)
        {
            if (i + j >= Count)
            {
                AcpiOsPrintf ("\n");
                return;
            }

            /* Make sure that the INT8 doesn't get sign-extended! */

            switch (Display)
            {
            /* Default is BYTE display */

            default:

                AcpiOsPrintf ("%02X ",
                        *((UINT8 *) &Buffer[i + j]));
                j += 1;
                break;


            case DB_WORD_DISPLAY:

                MOVE_UNALIGNED16_TO_32 (&Temp32,
                                        &Buffer[i + j]);
                AcpiOsPrintf ("%04X ", Temp32);
                j += 2;
                break;


            case DB_DWORD_DISPLAY:

                MOVE_UNALIGNED32_TO_32 (&Temp32,
                                        &Buffer[i + j]);
                AcpiOsPrintf ("%08X ", Temp32);
                j += 4;
                break;


            case DB_QWORD_DISPLAY:

                MOVE_UNALIGNED32_TO_32 (&Temp32,
                                        &Buffer[i + j]);
                AcpiOsPrintf ("%08X", Temp32);

                MOVE_UNALIGNED32_TO_32 (&Temp32,
                                        &Buffer[i + j + 4]);
                AcpiOsPrintf ("%08X ", Temp32);
                j += 8;
                break;
            }
        }


        /*
         * Print the ASCII equivalent characters
         * But watch out for the bad unprintable ones...
         */

        for (j = 0; j < 16; j++)
        {
            if (i + j >= Count)
            {
                AcpiOsPrintf ("\n");
                return;
            }

            BufChar = Buffer[i + j];
            if ((BufChar > 0x1F && BufChar < 0x2E) ||
                (BufChar > 0x2F && BufChar < 0x61) ||
                (BufChar > 0x60 && BufChar < 0x7F))
            {
                AcpiOsPrintf ("%c", BufChar);
            }
            else
            {
                AcpiOsPrintf (".");
            }
        }

        /* Done with that line. */

        AcpiOsPrintf ("\n");
        i += 16;
    }

    return;
}
Ejemplo n.º 8
0
acpi_status
acpi_ex_system_memory_space_handler (
	u32                     function,
	ACPI_PHYSICAL_ADDRESS   address,
	u32                     bit_width,
	u32                     *value,
	void                    *handler_context,
	void                    *region_context)
{
	acpi_status             status = AE_OK;
	void                    *logical_addr_ptr = NULL;
	acpi_mem_space_context  *mem_info = region_context;
	u32                     length;


	FUNCTION_TRACE ("Ex_system_memory_space_handler");


	/* Validate and translate the bit width */

	switch (bit_width) {
	case 8:
		length = 1;
		break;

	case 16:
		length = 2;
		break;

	case 32:
		length = 4;
		break;

	default:
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid System_memory width %d\n",
			bit_width));
		return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
		break;
	}


	/*
	 * Does the request fit into the cached memory mapping?
	 * Is 1) Address below the current mapping? OR
	 *    2) Address beyond the current mapping?
	 */
	if ((address < mem_info->mapped_physical_address) ||
		(((acpi_integer) address + length) >
			((acpi_integer) mem_info->mapped_physical_address + mem_info->mapped_length))) {
		/*
		 * The request cannot be resolved by the current memory mapping;
		 * Delete the existing mapping and create a new one.
		 */
		if (mem_info->mapped_length) {
			/* Valid mapping, delete it */

			acpi_os_unmap_memory (mem_info->mapped_logical_address,
					   mem_info->mapped_length);
		}

		mem_info->mapped_length = 0; /* In case of failure below */

		/* Create a new mapping starting at the address given */

		status = acpi_os_map_memory (address, SYSMEM_REGION_WINDOW_SIZE,
				  (void **) &mem_info->mapped_logical_address);
		if (ACPI_FAILURE (status)) {
			return_ACPI_STATUS (status);
		}

		/* Save the physical address and mapping size */

		mem_info->mapped_physical_address = address;
		mem_info->mapped_length = SYSMEM_REGION_WINDOW_SIZE;
	}


	/*
	 * Generate a logical pointer corresponding to the address we want to
	 * access
	 */

	/* TBD: should these pointers go to 64-bit in all cases ? */

	logical_addr_ptr = mem_info->mapped_logical_address +
			  ((acpi_integer) address - (acpi_integer) mem_info->mapped_physical_address);

	ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
		"System_memory %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
		HIDWORD (address), LODWORD (address)));

   /* Perform the memory read or write */

	switch (function) {

	case ACPI_READ_ADR_SPACE:

		switch (bit_width) {
		case 8:
			*value = (u32)* (u8 *) logical_addr_ptr;
			break;

		case 16:
			MOVE_UNALIGNED16_TO_32 (value, logical_addr_ptr);
			break;

		case 32:
			MOVE_UNALIGNED32_TO_32 (value, logical_addr_ptr);
			break;
		}

		break;


	case ACPI_WRITE_ADR_SPACE:

		switch (bit_width) {
		case 8:
			*(u8 *) logical_addr_ptr = (u8) *value;
			break;

		case 16:
			MOVE_UNALIGNED16_TO_16 (logical_addr_ptr, value);
			break;

		case 32:
			MOVE_UNALIGNED32_TO_32 (logical_addr_ptr, value);
			break;
		}

		break;


	default:
		status = AE_BAD_PARAMETER;
		break;
	}

	return_ACPI_STATUS (status);
}
Ejemplo n.º 9
0
ACPI_STATUS
AcpiNsHandleToPathname (
    ACPI_HANDLE             TargetHandle,
    UINT32                  *BufSize,
    NATIVE_CHAR             *UserBuffer)
{
    ACPI_STATUS             Status = AE_OK;
    ACPI_NAMESPACE_NODE     *Node;
    UINT32                  PathLength;
    UINT32                  UserBufSize;
    ACPI_NAME               Name;
    UINT32                  Size;


    FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle);


    if (!AcpiGbl_RootNode)
    {
        /*
         * If the name space has not been initialized,
         * this function should not have been called.
         */
        return_ACPI_STATUS (AE_NO_NAMESPACE);
    }

    Node = AcpiNsConvertHandleToEntry (TargetHandle);
    if (!Node)
    {
        return_ACPI_STATUS (AE_BAD_PARAMETER);
    }


    /* Set return length to the required path length */

    PathLength = AcpiNsGetPathnameLength (Node);
    Size = PathLength - 1;

    UserBufSize = *BufSize;
    *BufSize = PathLength;

    /* Check if the user buffer is sufficiently large */

    if (PathLength > UserBufSize)
    {
        Status = AE_BUFFER_OVERFLOW;
        goto Exit;
    }

    /* Store null terminator */

    UserBuffer[Size] = 0;
    Size -= ACPI_NAME_SIZE;

    /* Put the original ACPI name at the end of the path */

    MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size),
                            &Node->Name);

    UserBuffer[--Size] = PATH_SEPARATOR;

    /* Build name backwards, putting "." between segments */

    while ((Size > ACPI_NAME_SIZE) && Node)
    {
        Size -= ACPI_NAME_SIZE;
        Name = AcpiNsFindParentName (Node);
        MOVE_UNALIGNED32_TO_32 ((UserBuffer + Size), &Name);

        UserBuffer[--Size] = PATH_SEPARATOR;
        Node = AcpiNsGetParentObject (Node);
    }

    /*
     * Overlay the "." preceding the first segment with
     * the root name "\"
     */
    UserBuffer[Size] = '\\';

    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Len=%X, %s \n", PathLength, UserBuffer));

Exit:
    return_ACPI_STATUS (Status);
}
Ejemplo n.º 10
0
ACPI_PARSE_OBJECT *
AcpiPsGetNextField (
    ACPI_PARSE_STATE        *ParserState)
{
    UINT32                  AmlOffset = ParserState->Aml -
                                        ParserState->AmlStart;
    ACPI_PARSE_OBJECT       *Field;
    UINT16                  Opcode;
    UINT32                  Name;


    FUNCTION_TRACE ("PsGetNextField");


    /* determine field type */

    switch (GET8 (ParserState->Aml))
    {

    default:

        Opcode = AML_INT_NAMEDFIELD_OP;
        break;


    case 0x00:

        Opcode = AML_INT_RESERVEDFIELD_OP;
        ParserState->Aml++;
        break;


    case 0x01:

        Opcode = AML_INT_ACCESSFIELD_OP;
        ParserState->Aml++;
        break;
    }


    /* Allocate a new field op */

    Field = AcpiPsAllocOp (Opcode);
    if (Field)
    {
        Field->AmlOffset = AmlOffset;

        /* Decode the field type */

        switch (Opcode)
        {
        case AML_INT_NAMEDFIELD_OP:

            /* Get the 4-character name */

            MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml);
            AcpiPsSetName (Field, Name);
            ParserState->Aml += 4;

            /* Get the length which is encoded as a package length */

            Field->Value.Size = AcpiPsGetNextPackageLength (ParserState);
            break;


        case AML_INT_RESERVEDFIELD_OP:

            /* Get the length which is encoded as a package length */

            Field->Value.Size = AcpiPsGetNextPackageLength (ParserState);
            break;


        case AML_INT_ACCESSFIELD_OP:

            /* Get AccessType and AccessAtrib and merge into the field Op */

            Field->Value.Integer = ((GET8 (ParserState->Aml) << 8) |
                                     GET8 (ParserState->Aml));
            ParserState->Aml += 2;
            break;
        }
    }

    return_PTR (Field);
}
Ejemplo n.º 11
0
void
AcpiPsGetNextSimpleArg (
    ACPI_PARSE_STATE        *ParserState,
    UINT32                  ArgType,
    ACPI_PARSE_OBJECT       *Arg)
{

    FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType);


    switch (ArgType)
    {

    case ARGP_BYTEDATA:

        AcpiPsInitOp (Arg, AML_BYTE_OP);
        Arg->Value.Integer = (UINT32) GET8 (ParserState->Aml);
        ParserState->Aml++;
        break;


    case ARGP_WORDDATA:

        AcpiPsInitOp (Arg, AML_WORD_OP);

        /* Get 2 bytes from the AML stream */

        MOVE_UNALIGNED16_TO_32 (&Arg->Value.Integer, ParserState->Aml);
        ParserState->Aml += 2;
        break;


    case ARGP_DWORDDATA:

        AcpiPsInitOp (Arg, AML_DWORD_OP);

        /* Get 4 bytes from the AML stream */

        MOVE_UNALIGNED32_TO_32 (&Arg->Value.Integer, ParserState->Aml);
        ParserState->Aml += 4;
        break;


    case ARGP_QWORDDATA:

        AcpiPsInitOp (Arg, AML_QWORD_OP);

        /* Get 8 bytes from the AML stream */

        MOVE_UNALIGNED64_TO_64 (&Arg->Value.Integer, ParserState->Aml);
        ParserState->Aml += 8;
        break;


    case ARGP_CHARLIST:

        AcpiPsInitOp (Arg, AML_STRING_OP);
        Arg->Value.String = (char*) ParserState->Aml;

        while (GET8 (ParserState->Aml) != '\0')
        {
            ParserState->Aml++;
        }
        ParserState->Aml++;
        break;


    case ARGP_NAME:
    case ARGP_NAMESTRING:

        AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP);
        Arg->Value.Name = AcpiPsGetNextNamestring (ParserState);
        break;
    }

    return_VOID;
}
Ejemplo n.º 12
0
Archivo: utdebug.c Proyecto: nhanh0/hah
void
acpi_ut_dump_buffer (
    u8                      *buffer,
    u32                     count,
    u32                     display,
    u32                     component_id)
{
    u32                     i = 0;
    u32                     j;
    u32                     temp32;
    u8                      buf_char;


    /* Only dump the buffer if tracing is enabled */

    if (!((ACPI_LV_TABLES & acpi_dbg_level) &&
            (component_id & acpi_dbg_layer))) {
        return;
    }


    /*
     * Nasty little dump buffer routine!
     */
    while (i < count) {
        /* Print current offset */

        acpi_os_printf ("%05X  ", i);


        /* Print 16 hex chars */

        for (j = 0; j < 16;) {
            if (i + j >= count) {
                acpi_os_printf ("\n");
                return;
            }

            /* Make sure that the s8 doesn't get sign-extended! */

            switch (display) {
            /* Default is BYTE display */

            default:

                acpi_os_printf ("%02X ",
                                *((u8 *) &buffer[i + j]));
                j += 1;
                break;


            case DB_WORD_DISPLAY:

                MOVE_UNALIGNED16_TO_32 (&temp32,
                                        &buffer[i + j]);
                acpi_os_printf ("%04X ", temp32);
                j += 2;
                break;


            case DB_DWORD_DISPLAY:

                MOVE_UNALIGNED32_TO_32 (&temp32,
                                        &buffer[i + j]);
                acpi_os_printf ("%08X ", temp32);
                j += 4;
                break;


            case DB_QWORD_DISPLAY:

                MOVE_UNALIGNED32_TO_32 (&temp32,
                                        &buffer[i + j]);
                acpi_os_printf ("%08X", temp32);

                MOVE_UNALIGNED32_TO_32 (&temp32,
                                        &buffer[i + j + 4]);
                acpi_os_printf ("%08X ", temp32);
                j += 8;
                break;
            }
        }


        /*
         * Print the ASCII equivalent characters
         * But watch out for the bad unprintable ones...
         */

        for (j = 0; j < 16; j++) {
            if (i + j >= count) {
                acpi_os_printf ("\n");
                return;
            }

            buf_char = buffer[i + j];
            if ((buf_char > 0x1F && buf_char < 0x2E) ||
                    (buf_char > 0x2F && buf_char < 0x61) ||
                    (buf_char > 0x60 && buf_char < 0x7F)) {
                acpi_os_printf ("%c", buf_char);
            }
            else {
                acpi_os_printf (".");
            }
        }

        /* Done with that line. */

        acpi_os_printf ("\n");
        i += 16;
    }

    return;
}
Ejemplo n.º 13
0
ACPI_PARSE_OBJECT *
acpi_ps_get_next_field (
	ACPI_PARSE_STATE        *parser_state)
{
	ACPI_PTRDIFF            aml_offset = parser_state->aml -
			 parser_state->aml_start;
	ACPI_PARSE_OBJECT       *field;
	u16                     opcode;
	u32                     name;


	/* determine field type */

	switch (GET8 (parser_state->aml))
	{

	default:

		opcode = AML_NAMEDFIELD_OP;
		break;


	case 0x00:

		opcode = AML_RESERVEDFIELD_OP;
		parser_state->aml++;
		break;


	case 0x01:

		opcode = AML_ACCESSFIELD_OP;
		parser_state->aml++;
		break;
	}


	/* Allocate a new field op */

	field = acpi_ps_alloc_op (opcode);
	if (field) {
		field->aml_offset = aml_offset;

		/* Decode the field type */

		switch (opcode)
		{
		case AML_NAMEDFIELD_OP:

			/* Get the 4-character name */

			MOVE_UNALIGNED32_TO_32 (&name, parser_state->aml);
			acpi_ps_set_name (field, name);
			parser_state->aml += 4;

			/* Get the length which is encoded as a package length */

			field->value.size = acpi_ps_get_next_package_length (parser_state);
			break;


		case AML_RESERVEDFIELD_OP:

			/* Get the length which is encoded as a package length */

			field->value.size = acpi_ps_get_next_package_length (parser_state);
			break;


		case AML_ACCESSFIELD_OP:

			/* Get Access_type and Access_atrib and merge into the field Op */

			field->value.integer = ((GET8 (parser_state->aml) << 8) |
					  GET8 (parser_state->aml));
			parser_state->aml += 2;
			break;
		}
	}

	return (field);
}
Ejemplo n.º 14
0
void
acpi_ps_get_next_simple_arg (
	ACPI_PARSE_STATE        *parser_state,
	u32                     arg_type,
	ACPI_PARSE_OBJECT       *arg)
{


	switch (arg_type)
	{

	case ARGP_BYTEDATA:

		acpi_ps_init_op (arg, AML_BYTE_OP);
		arg->value.integer = (u32) GET8 (parser_state->aml);
		parser_state->aml++;
		break;


	case ARGP_WORDDATA:

		acpi_ps_init_op (arg, AML_WORD_OP);

		/* Get 2 bytes from the AML stream */

		MOVE_UNALIGNED16_TO_32 (&arg->value.integer, parser_state->aml);
		parser_state->aml += 2;
		break;


	case ARGP_DWORDDATA:

		acpi_ps_init_op (arg, AML_DWORD_OP);

		/* Get 4 bytes from the AML stream */

		MOVE_UNALIGNED32_TO_32 (&arg->value.integer, parser_state->aml);
		parser_state->aml += 4;
		break;


	case ARGP_CHARLIST:

		acpi_ps_init_op (arg, AML_STRING_OP);
		arg->value.string = (char*) parser_state->aml;

		while (GET8 (parser_state->aml) != '\0') {
			parser_state->aml++;
		}
		parser_state->aml++;
		break;


	case ARGP_NAME:
	case ARGP_NAMESTRING:

		acpi_ps_init_op (arg, AML_NAMEPATH_OP);
		arg->value.name = acpi_ps_get_next_namestring (parser_state);
		break;
	}

	return;
}
Ejemplo n.º 15
0
NATIVE_CHAR *
acpi_ns_get_table_pathname (
	acpi_namespace_node     *node)
{
	NATIVE_CHAR             *name_buffer;
	u32                     size;
	acpi_name               name;
	acpi_namespace_node     *child_node;
	acpi_namespace_node     *parent_node;


	FUNCTION_TRACE_PTR ("Ns_get_table_pathname", node);


	if (!acpi_gbl_root_node || !node) {
		/*
		 * If the name space has not been initialized,
		 * this function should not have been called.
		 */
		return_PTR (NULL);
	}

	child_node = node->child;


	/* Calculate required buffer size based on depth below root */

	size = 1;
	parent_node = child_node;
	while (parent_node) {
		parent_node = acpi_ns_get_parent_object (parent_node);
		if (parent_node) {
			size += ACPI_NAME_SIZE;
		}
	}


	/* Allocate a buffer to be returned to caller */

	name_buffer = ACPI_MEM_CALLOCATE (size + 1);
	if (!name_buffer) {
		REPORT_ERROR (("Ns_get_table_pathname: allocation failure\n"));
		return_PTR (NULL);
	}


	/* Store terminator byte, then build name backwards */

	name_buffer[size] = '\0';
	while ((size > ACPI_NAME_SIZE) &&
		acpi_ns_get_parent_object (child_node)) {
		size -= ACPI_NAME_SIZE;
		name = acpi_ns_find_parent_name (child_node);

		/* Put the name into the buffer */

		MOVE_UNALIGNED32_TO_32 ((name_buffer + size), &name);
		child_node = acpi_ns_get_parent_object (child_node);
	}

	name_buffer[--size] = AML_ROOT_PREFIX;

	if (size != 0) {
		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad pointer returned; size=%X\n", size));
	}

	return_PTR (name_buffer);
}
Ejemplo n.º 16
0
NATIVE_CHAR *
AcpiNsGetTablePathname (
    ACPI_NAMESPACE_NODE     *Node)
{
    NATIVE_CHAR             *NameBuffer;
    UINT32                  Size;
    ACPI_NAME               Name;
    ACPI_NAMESPACE_NODE     *ChildNode;
    ACPI_NAMESPACE_NODE     *ParentNode;


    FUNCTION_TRACE_PTR ("NsGetTablePathname", Node);


    if (!AcpiGbl_RootNode || !Node)
    {
        /*
         * If the name space has not been initialized,
         * this function should not have been called.
         */
        return_PTR (NULL);
    }

    ChildNode = Node->Child;


    /* Calculate required buffer size based on depth below root */

    Size = 1;
    ParentNode = ChildNode;
    while (ParentNode)
    {
        ParentNode = AcpiNsGetParentObject (ParentNode);
        if (ParentNode)
        {
            Size += ACPI_NAME_SIZE;
        }
    }


    /* Allocate a buffer to be returned to caller */

    NameBuffer = ACPI_MEM_CALLOCATE (Size + 1);
    if (!NameBuffer)
    {
        REPORT_ERROR (("NsGetTablePathname: allocation failure\n"));
        return_PTR (NULL);
    }


    /* Store terminator byte, then build name backwards */

    NameBuffer[Size] = '\0';
    while ((Size > ACPI_NAME_SIZE) &&
        AcpiNsGetParentObject (ChildNode))
    {
        Size -= ACPI_NAME_SIZE;
        Name = AcpiNsFindParentName (ChildNode);

        /* Put the name into the buffer */

        MOVE_UNALIGNED32_TO_32 ((NameBuffer + Size), &Name);
        ChildNode = AcpiNsGetParentObject (ChildNode);
    }

    NameBuffer[--Size] = AML_ROOT_PREFIX;

    if (Size != 0)
    {
        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad pointer returned; size=%X\n", Size));
    }

    return_PTR (NameBuffer);
}
Ejemplo n.º 17
0
static acpi_status
acpi_ev_save_method_info (
	acpi_handle             obj_handle,
	u32                     level,
	void                    *obj_desc,
	void                    **return_value)
{
	u32                     gpe_number;
	NATIVE_CHAR             name[ACPI_NAME_SIZE + 1];
	u8                      type;


	PROC_NAME ("Ev_save_method_info");


	/* Extract the name from the object and convert to a string */

	MOVE_UNALIGNED32_TO_32 (name, &((acpi_namespace_node *) obj_handle)->name);
	name[ACPI_NAME_SIZE] = 0;

	/*
	 * Edge/Level determination is based on the 2nd s8 of the method name
	 */
	if (name[1] == 'L') {
		type = ACPI_EVENT_LEVEL_TRIGGERED;
	}
	else if (name[1] == 'E') {
		type = ACPI_EVENT_EDGE_TRIGGERED;
	}
	else {
		/* Unknown method type, just ignore it! */

		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n",
			name));
		return (AE_OK);
	}

	/* Convert the last two characters of the name to the Gpe Number */

	gpe_number = STRTOUL (&name[2], NULL, 16);
	if (gpe_number == ACPI_UINT32_MAX) {
		/* Conversion failed; invalid method, just ignore it */

		ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
			"Could not extract GPE number from name: %s (name not of form _Lnn or _Enn)\n",
			name));
		return (AE_OK);
	}

	/* Ensure that we have a valid GPE number */

	if (acpi_gbl_gpe_valid[gpe_number] == ACPI_GPE_INVALID) {
		/* Not valid, all we can do here is ignore it */

		return (AE_OK);
	}

	/*
	 * Now we can add this information to the Gpe_info block
	 * for use during dispatch of this GPE.
	 */
	acpi_gbl_gpe_info [gpe_number].type         = type;
	acpi_gbl_gpe_info [gpe_number].method_handle = obj_handle;


	/*
	 * Enable the GPE (SCIs should be disabled at this point)
	 */
	acpi_hw_enable_gpe (gpe_number);

	ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registered GPE method %s as GPE number %X\n",
		name, gpe_number));
	return (AE_OK);
}