*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
- * rights. You may have additional license terms from the party that provided
+ * rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
- * to or modifications of the Original Intel Code. No other license or right
+ * to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
- * and the following Disclaimer and Export Compliance provision. In addition,
+ * and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
- * Code and the date of any change. Licensee must include in that file the
- * documentation of any changes made by any predecessor Licensee. Licensee
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
- * documentation and/or other materials provided with distribution. In
+ * documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
- * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
- * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
- * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
- * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
- * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
- * any other agency or department of the United States Government. In the
+ * any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
*
*****************************************************************************/
-#define __RSCREATE_C__
-
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
ACPI_MODULE_NAME ("rscreate")
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiBufferToResource
+ *
+ * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
+ * AmlBufferLength - Length of the AmlBuffer
+ * ResourcePtr - Where the converted resource is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Convert a raw AML buffer to a resource list
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiBufferToResource (
+ UINT8 *AmlBuffer,
+ UINT16 AmlBufferLength,
+ ACPI_RESOURCE **ResourcePtr)
+{
+ ACPI_STATUS Status;
+ ACPI_SIZE ListSizeNeeded;
+ void *Resource;
+ void *CurrentResourcePtr;
+
+
+ ACPI_FUNCTION_TRACE (AcpiBufferToResource);
+
+
+ /*
+ * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
+ * is not required here.
+ */
+
+ /* Get the required length for the converted resource */
+
+ Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength,
+ &ListSizeNeeded);
+ if (Status == AE_AML_NO_RESOURCE_END_TAG)
+ {
+ Status = AE_OK;
+ }
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Allocate a buffer for the converted resource */
+
+ Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded);
+ CurrentResourcePtr = Resource;
+ if (!Resource)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Perform the AML-to-Resource conversion */
+
+ Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength,
+ AcpiRsConvertAmlToResources, &CurrentResourcePtr);
+ if (Status == AE_AML_NO_RESOURCE_END_TAG)
+ {
+ Status = AE_OK;
+ }
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_FREE (Resource);
+ }
+ else
+ {
+ *ResourcePtr = Resource;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiBufferToResource)
+
+
/*******************************************************************************
*
* FUNCTION: AcpiRsCreateResourceList
/* Do the conversion */
Resource = OutputBuffer->Pointer;
- Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
+ Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength,
AcpiRsConvertAmlToResources, &Resource);
if (ACPI_FAILURE (Status))
{
*
* FUNCTION: AcpiRsCreatePciRoutingTable
*
- * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
- * package
+ * PARAMETERS: PackageObject - Pointer to a package containing one
+ * of more ACPI_OPERAND_OBJECTs
* OutputBuffer - Pointer to the user's buffer
*
* RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
* AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
* to the size buffer needed.
*
- * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
+ * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
* linked list of PCI interrupt descriptions
*
* NOTE: It is the caller's responsibility to ensure that the start of the
*/
UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
- /* Each element of the top-level package must also be a package */
-
- if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
- {
- ACPI_ERROR ((AE_INFO,
- "(PRT[%u]) Need sub-package, found %s",
- Index, AcpiUtGetObjectTypeName (*TopObjectList)));
- return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
- }
-
- /* Each sub-package must be of length 4 */
+ /* Each subpackage must be of length 4 */
if ((*TopObjectList)->Package.Count != 4)
{
}
/*
- * Dereference the sub-package.
+ * Dereference the subpackage.
* The SubObjectList will now point to an array of the four IRQ
* elements: [Address, Pin, Source, SourceIndex]
*/
/* 1) First subobject: Dereference the PRT.Address */
ObjDesc = SubObjectList[0];
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
/* 2) Second subobject: Dereference the PRT.Pin */
ObjDesc = SubObjectList[1];
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
- /*
- * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
- * and the SourceIndex (index 3), fix it. _PRT is important enough to
- * workaround this BIOS error. This also provides compatibility with
- * other ACPI implementations.
- */
- ObjDesc = SubObjectList[3];
- if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
- {
- SubObjectList[3] = SubObjectList[2];
- SubObjectList[2] = ObjDesc;
-
- ACPI_WARNING ((AE_INFO,
- "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
- Index));
- }
-
/*
* 3) Third subobject: Dereference the PRT.SourceName
* The name may be unresolved (slack mode), so allow a null object
(UINT8 *) OutputBuffer->Pointer);
PathBuffer.Pointer = UserPrt->Source;
- Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
+ Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node,
+ &PathBuffer, FALSE);
/* +1 to include null terminator */
- UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
+ UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1;
break;
-
case ACPI_TYPE_STRING:
- ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
+ strcpy (UserPrt->Source, ObjDesc->String.Pointer);
/*
* Add to the Length field the length of the string
UserPrt->Length += ObjDesc->String.Length + 1;
break;
-
case ACPI_TYPE_INTEGER:
/*
* If this is a number, then the Source Name is NULL, since the
UserPrt->Length += sizeof (UINT32);
break;
-
default:
ACPI_ERROR ((AE_INFO,
/* 4) Fourth subobject: Dereference the PRT.SourceIndex */
ObjDesc = SubObjectList[3];
- if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+ if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
{
ACPI_ERROR ((AE_INFO,
"(PRT[%u].SourceIndex) Need Integer, found %s",
*
* FUNCTION: AcpiRsCreateAmlResources
*
- * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
- * OutputBuffer - Pointer to the user's buffer
+ * PARAMETERS: ResourceList - Pointer to the resource list buffer
+ * OutputBuffer - Where the AML buffer is returned
*
* RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
* If the OutputBuffer is too small, the error will be
* AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
* to the size buffer needed.
*
- * DESCRIPTION: Takes the linked list of device resources and
- * creates a bytestream to be used as input for the
- * _SRS control method.
+ * DESCRIPTION: Converts a list of device resources to an AML bytestream
+ * to be used as input for the _SRS control method.
*
******************************************************************************/
ACPI_STATUS
AcpiRsCreateAmlResources (
- ACPI_RESOURCE *LinkedListBuffer,
+ ACPI_BUFFER *ResourceList,
ACPI_BUFFER *OutputBuffer)
{
ACPI_STATUS Status;
ACPI_FUNCTION_TRACE (RsCreateAmlResources);
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
- LinkedListBuffer));
+ /* Params already validated, no need to re-validate here */
- /*
- * Params already validated, so we don't re-validate here
- *
- * Pass the LinkedListBuffer into a module that calculates
- * the buffer size needed for the byte stream.
- */
- Status = AcpiRsGetAmlLength (LinkedListBuffer,
- &AmlSizeNeeded);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n",
+ ResourceList->Pointer));
+
+ /* Get the buffer size needed for the AML byte stream */
+
+ Status = AcpiRsGetAmlLength (ResourceList->Pointer,
+ ResourceList->Length, &AmlSizeNeeded);
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
(UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
/* Do the conversion */
- Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
- OutputBuffer->Pointer);
+ Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer,
+ AmlSizeNeeded, OutputBuffer->Pointer);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
- OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
-