dbconvert.c revision 199767f8919635c4928607450d9e0abb932109ce
/*******************************************************************************
*
* Module Name: dbconvert - debugger miscellaneous conversion routines
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2015, 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.
*/
#define _COMPONENT ACPI_CA_DEBUGGER
ACPI_MODULE_NAME ("dbconvert")
#define DB_DEFAULT_PKG_ELEMENTS 33
/*******************************************************************************
*
* FUNCTION: AcpiDbHexCharToValue
*
* PARAMETERS: HexChar - Ascii Hex digit, 0-9|a-f|A-F
* ReturnValue - Where the converted value is returned
*
* RETURN: Status
*
* DESCRIPTION: Convert a single hex character to a 4-bit number (0-16).
*
******************************************************************************/
int HexChar,
{
/* Digit must be ascii [0-9a-fA-F] */
{
return (AE_BAD_HEX_CONSTANT);
}
if (HexChar <= 0x39)
{
}
else
{
}
*ReturnValue = Value;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbHexByteToBinary
*
* PARAMETERS: HexByte - Double hex digit (0x00 - 0xFF) in format:
* HiByte then LoByte.
* ReturnValue - Where the converted value is returned
*
* RETURN: Status
*
* DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255).
*
******************************************************************************/
static ACPI_STATUS
char *HexByte,
{
/* High byte */
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Low byte */
if (ACPI_FAILURE (Status))
{
return (Status);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbConvertToBuffer
*
* PARAMETERS: String - Input string to be converted
* Object - Where the buffer object is returned
*
* RETURN: Status
*
* DESCRIPTION: Convert a string to a buffer object. String is treated a list
* of buffer elements, each separated by a space or comma.
*
******************************************************************************/
static ACPI_STATUS
char *String,
{
UINT32 i;
UINT32 j;
/* Generate the final buffer length */
{
i+=2;
Length++;
while (String[i] &&
{
i++;
}
}
if (!Buffer)
{
return (AE_NO_MEMORY);
}
/* Convert the command line bytes to the buffer */
for (i = 0, j = 0; String[i];)
{
if (ACPI_FAILURE (Status))
{
return (Status);
}
j++;
i+=2;
while (String[i] &&
{
i++;
}
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbConvertToPackage
*
* PARAMETERS: String - Input string to be converted
* Object - Where the package object is returned
*
* RETURN: Status
*
* DESCRIPTION: Convert a string to a package object. Handles nested packages
* via recursion with AcpiDbConvertToObject.
*
******************************************************************************/
char *String,
{
char *This;
char *Next;
UINT32 i;
DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT));
for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++)
{
if (!This)
{
break;
}
/* Recursive call to convert each package element */
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbConvertToObject
*
* PARAMETERS: Type - Object type as determined by parser
* String - Input string to be converted
* Object - Where the new object is returned
*
* RETURN: Status
*
* DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing:
* 1) String objects were surrounded by quotes.
* 2) Buffer objects were surrounded by parentheses.
* 3) Package objects were surrounded by brackets "[]".
* 4) All standalone tokens are treated as integers.
*
******************************************************************************/
char *String,
{
switch (Type)
{
case ACPI_TYPE_STRING:
break;
case ACPI_TYPE_BUFFER:
break;
case ACPI_TYPE_PACKAGE:
break;
default:
break;
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiDbEncodePldBuffer
*
* PARAMETERS: PldInfo - _PLD buffer struct (Using local struct)
*
* RETURN: Encode _PLD buffer suitable for return value from _PLD
*
* DESCRIPTION: Bit-packs a _PLD buffer struct. Used to test the _PLD macros
*
******************************************************************************/
UINT8 *
{
if (!Buffer)
{
return (NULL);
}
/* First 32 bits */
Dword = 0;
/* Second 32 bits */
Dword = 0;
/* Third 32 bits */
Dword = 0;
/* Fourth 32 bits */
Dword = 0;
{
/* Fifth 32 bits */
Dword = 0;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDbDumpPldBuffer
*
* PARAMETERS: ObjDesc - Object returned from _PLD method
*
* RETURN: None.
*
* DESCRIPTION: Dumps formatted contents of a _PLD return buffer.
*
******************************************************************************/
#define ACPI_PLD_OUTPUT "%20s : %-6X\n"
void
{
/* Object must be of type Package with at least one Buffer element */
{
return;
}
{
return;
}
/* Convert _PLD buffer to local _PLD struct */
if (ACPI_FAILURE (Status))
{
return;
}
/* Encode local _PLD struct back to a _PLD buffer */
if (!NewBuffer)
{
return;
}
/* The two bit-packed buffers should match */
{
AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n");
}
/* First 32-bit dword */
/* Second 32-bit dword */
/* Third 32-bit dword */
/* Fourth 32-bit dword */
/* Fifth 32-bit dword */
{
}
}