Exemple #1
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;
}
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);
}
Exemple #3
0
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;
}
Exemple #4
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;
}
Exemple #5
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;
}