exconcat.c revision 7b1019a6d29ccb7999dc76cba3dde1c627e8e609
/******************************************************************************
*
* Module Name: exconcat - Concatenate-type AML operators
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, 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.
*/
#include "acpi.h"
#include "accommon.h"
#include "acinterp.h"
#include "amlresrc.h"
#define _COMPONENT ACPI_EXECUTER
ACPI_MODULE_NAME ("exconcat")
/* Local Prototypes */
static ACPI_STATUS
/*******************************************************************************
*
* FUNCTION: AcpiExDoConcatenate
*
* PARAMETERS: Operand0 - First source object
* Operand1 - Second source object
* ActualReturnDesc - Where to place the return object
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Concatenate two objects with the ACPI-defined conversion
* rules as necessary.
* NOTE:
* Per the ACPI spec (up to 6.1), Concatenate only supports Integer,
* String, and Buffer objects. However, we support all objects here
* as an extension. This improves the usefulness of both Concatenate
* describing the object type for the other objects.
* 02/2016.
*
******************************************************************************/
{
char *Buffer;
/* Operand 0 preprocessing */
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
break;
default:
/* For all other types, get the "object type" string */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
break;
}
/* Operand 1 preprocessing */
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
break;
default:
/* For all other types, get the "object type" string */
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
break;
}
/*
* Convert the second operand if necessary. The first operand (0)
* determines the type of the second operand (1) (See the Data Types
* section of the ACPI specification). Both object types are
* resolution mechanism.
*/
switch (Operand0Type)
{
case ACPI_TYPE_INTEGER:
break;
case ACPI_TYPE_BUFFER:
break;
case ACPI_TYPE_STRING:
switch (Operand1Type)
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/* Other types have already been converted to string */
break;
default:
break;
}
break;
default:
}
if (ACPI_FAILURE (Status))
{
goto Cleanup;
}
/* Take care with any newly created operand objects */
if ((LocalOperand1 != Operand1) &&
(LocalOperand1 != TempOperand1))
{
}
/*
* Both operands are now known to be the same object type
* (Both are Integer, String, or Buffer), and we can now perform
* the concatenation.
*
* There are three cases to handle, as per the ACPI spec:
*
* 1) Two Integers concatenated to produce a new Buffer
* 2) Two Strings concatenated to produce a new String
* 3) Two Buffers concatenated to produce a new Buffer
*/
switch (Operand0Type)
{
case ACPI_TYPE_INTEGER:
/* Result of two Integers is a Buffer */
/* Need enough buffer space for two integers */
if (!ReturnDesc)
{
goto Cleanup;
}
/* Copy the first integer, LSB first */
/* Copy the second integer (LSB first) after the first */
break;
case ACPI_TYPE_STRING:
/* Result of two Strings is a String */
if (!ReturnDesc)
{
goto Cleanup;
}
/* Concatenate the strings */
break;
case ACPI_TYPE_BUFFER:
/* Result of two Buffers is a Buffer */
if (!ReturnDesc)
{
goto Cleanup;
}
/* Concatenate the buffers */
break;
default:
/* Invalid object type, should not happen here */
goto Cleanup;
}
if (LocalOperand0 != Operand0)
{
}
if (LocalOperand1 != Operand1)
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiExConvertToObjectTypeString
*
* PARAMETERS: ObjDesc - Object to be converted
* ReturnDesc - Where to place the return object
*
* RETURN: Status
*
* DESCRIPTION: Convert an object of arbitrary type to a string object that
* contains the namestring for the object. Used for the
* concatenate operator.
*
******************************************************************************/
static ACPI_STATUS
{
const char *TypeString;
if (!ReturnDesc)
{
return (AE_NO_MEMORY);
}
*ResultDesc = ReturnDesc;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiExConcatTemplate
*
* PARAMETERS: Operand0 - First source object
* Operand1 - Second source object
* ActualReturnDesc - Where to place the return object
* WalkState - Current walk state
*
* RETURN: Status
*
* DESCRIPTION: Concatenate two resource templates
*
******************************************************************************/
{
/*
* Find the EndTag descriptor in each resource template.
* Note1: returned pointers point TO the EndTag, not past it.
* Note2: zero-length buffers are allowed; treated like one EndTag
*/
/* Get the length of the first resource template */
if (ACPI_FAILURE (Status))
{
}
/* Get the length of the second resource template */
if (ACPI_FAILURE (Status))
{
}
/* Combine both lengths, minimum size will be 2 for EndTag */
/* Create a new buffer object for the result (with one EndTag) */
if (!ReturnDesc)
{
}
/*
* Copy the templates to the new buffer, 0 first, then 1 follows. One
* EndTag descriptor is copied from Operand1.
*/
/* Insert EndTag and set the checksum to zero, means "ignore checksum" */
/* Return the completed resource template */
}