summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/io/acpica/resources/rscreate.c
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2016-07-26 15:05:29 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2016-07-26 15:05:29 +0000
commitd103e8b98085dbb5f7707242723b9d3ce74f2723 (patch)
tree263af7aa964a6c36a7cd561cd80268d6cbba5d5d /usr/src/uts/intel/io/acpica/resources/rscreate.c
parent9b221abb819d37d8c917941b8348a6c0e49c74b1 (diff)
downloadillumos-joyent-d103e8b98085dbb5f7707242723b9d3ce74f2723.tar.gz
OS-5536 update to ACPI version 6.x
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Reviewed by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/uts/intel/io/acpica/resources/rscreate.c')
-rw-r--r--usr/src/uts/intel/io/acpica/resources/rscreate.c148
1 files changed, 60 insertions, 88 deletions
diff --git a/usr/src/uts/intel/io/acpica/resources/rscreate.c b/usr/src/uts/intel/io/acpica/resources/rscreate.c
index f06ea0cb4d..64bbdbe995 100644
--- a/usr/src/uts/intel/io/acpica/resources/rscreate.c
+++ b/usr/src/uts/intel/io/acpica/resources/rscreate.c
@@ -5,7 +5,7 @@
******************************************************************************/
/*
- * Copyright (C) 2000 - 2012, Intel Corp.
+ * Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,6 @@
* POSSIBILITY OF SUCH DAMAGES.
*/
-#define __RSCREATE_C__
-
#include "acpi.h"
#include "accommon.h"
#include "acresrc.h"
@@ -77,6 +75,10 @@ AcpiBufferToResource (
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.
@@ -84,15 +86,15 @@ AcpiBufferToResource (
/* Get the required length for the converted resource */
- Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength,
- &ListSizeNeeded);
+ Status = AcpiRsGetListLength (
+ AmlBuffer, AmlBufferLength, &ListSizeNeeded);
if (Status == AE_AML_NO_RESOURCE_END_TAG)
{
Status = AE_OK;
}
if (ACPI_FAILURE (Status))
{
- return (Status);
+ return_ACPI_STATUS (Status);
}
/* Allocate a buffer for the converted resource */
@@ -101,13 +103,13 @@ AcpiBufferToResource (
CurrentResourcePtr = Resource;
if (!Resource)
{
- return (AE_NO_MEMORY);
+ return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Perform the AML-to-Resource conversion */
- Status = AcpiUtWalkAmlResources (AmlBuffer, AmlBufferLength,
- AcpiRsConvertAmlToResources, &CurrentResourcePtr);
+ Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength,
+ AcpiRsConvertAmlToResources, &CurrentResourcePtr);
if (Status == AE_AML_NO_RESOURCE_END_TAG)
{
Status = AE_OK;
@@ -121,9 +123,11 @@ AcpiBufferToResource (
*ResourcePtr = Resource;
}
- return (Status);
+ return_ACPI_STATUS (Status);
}
+ACPI_EXPORT_SYMBOL (AcpiBufferToResource)
+
/*******************************************************************************
*
@@ -192,15 +196,15 @@ AcpiRsCreateResourceList (
/* Do the conversion */
Resource = OutputBuffer->Pointer;
- Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
- AcpiRsConvertAmlToResources, &Resource);
+ Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength,
+ AcpiRsConvertAmlToResources, &Resource);
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);
}
@@ -209,8 +213,8 @@ AcpiRsCreateResourceList (
*
* 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.
@@ -218,7 +222,7 @@ AcpiRsCreateResourceList (
* 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
@@ -251,8 +255,8 @@ AcpiRsCreatePciRoutingTable (
/* Get the required buffer length */
- Status = AcpiRsGetPciRoutingTableLength (PackageObject,
- &BufferSizeNeeded);
+ Status = AcpiRsGetPciRoutingTableLength (
+ PackageObject,&BufferSizeNeeded);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@@ -274,10 +278,10 @@ AcpiRsCreatePciRoutingTable (
* package that in turn contains an UINT64 Address, a UINT8 Pin,
* a Name, and a UINT8 SourceIndex.
*/
- TopObjectList = PackageObject->Package.Elements;
+ TopObjectList = PackageObject->Package.Elements;
NumberOfElements = PackageObject->Package.Count;
- Buffer = OutputBuffer->Pointer;
- UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+ Buffer = OutputBuffer->Pointer;
+ UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
for (Index = 0; Index < NumberOfElements; Index++)
{
@@ -291,23 +295,13 @@ AcpiRsCreatePciRoutingTable (
UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
/*
- * Fill in the Length field with the information we have at this point.
- * The minus four is to subtract the size of the UINT8 Source[4] member
- * because it is added below.
+ * Fill in the Length field with the information we have at this
+ * point. The minus four is to subtract the size of the UINT8
+ * Source[4] member because it is added below.
*/
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)
{
@@ -318,7 +312,7 @@ AcpiRsCreatePciRoutingTable (
}
/*
- * Dereference the sub-package.
+ * Dereference the subpackage.
* The SubObjectList will now point to an array of the four IRQ
* elements: [Address, Pin, Source, SourceIndex]
*/
@@ -327,9 +321,10 @@ AcpiRsCreatePciRoutingTable (
/* 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",
+ ACPI_ERROR ((AE_INFO,
+ "(PRT[%u].Address) Need Integer, found %s",
Index, AcpiUtGetObjectTypeName (ObjDesc)));
return_ACPI_STATUS (AE_BAD_DATA);
}
@@ -339,7 +334,7 @@ AcpiRsCreatePciRoutingTable (
/* 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)));
@@ -349,23 +344,6 @@ AcpiRsCreatePciRoutingTable (
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
*/
@@ -389,21 +367,21 @@ AcpiRsCreatePciRoutingTable (
/* Use *remaining* length of the buffer as max for pathname */
PathBuffer.Length = OutputBuffer->Length -
- (UINT32) ((UINT8 *) UserPrt->Source -
- (UINT8 *) OutputBuffer->Pointer);
+ (UINT32) ((UINT8 *) UserPrt->Source -
+ (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
@@ -412,18 +390,16 @@ AcpiRsCreatePciRoutingTable (
UserPrt->Length += ObjDesc->String.Length + 1;
break;
-
case ACPI_TYPE_INTEGER:
/*
- * If this is a number, then the Source Name is NULL, since the
- * entire buffer was zeroed out, we can leave this alone.
+ * If this is a number, then the Source Name is NULL, since
+ * the entire buffer was zeroed out, we can leave this alone.
*
* Add to the Length field the length of the UINT32 NULL
*/
UserPrt->Length += sizeof (UINT32);
break;
-
default:
ACPI_ERROR ((AE_INFO,
@@ -440,7 +416,7 @@ AcpiRsCreatePciRoutingTable (
/* 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",
@@ -456,7 +432,7 @@ AcpiRsCreatePciRoutingTable (
}
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);
}
@@ -465,23 +441,22 @@ AcpiRsCreatePciRoutingTable (
*
* 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;
@@ -491,17 +466,15 @@ AcpiRsCreateAmlResources (
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)));
@@ -520,15 +493,14 @@ AcpiRsCreateAmlResources (
/* 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);
}
-