summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/rscreate.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/rscreate.c')
-rw-r--r--sys/contrib/dev/acpica/rscreate.c171
1 files changed, 74 insertions, 97 deletions
diff --git a/sys/contrib/dev/acpica/rscreate.c b/sys/contrib/dev/acpica/rscreate.c
index 14aaf5d..51e9934 100644
--- a/sys/contrib/dev/acpica/rscreate.c
+++ b/sys/contrib/dev/acpica/rscreate.c
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: rscreate - Create resource lists/tables
- * $Revision: 38 $
+ * $Revision: 53 $
*
******************************************************************************/
@@ -9,7 +9,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -123,7 +123,7 @@
#include "acnamesp.h"
#define _COMPONENT ACPI_RESOURCES
- MODULE_NAME ("rscreate")
+ ACPI_MODULE_NAME ("rscreate")
/*******************************************************************************
@@ -148,17 +148,16 @@
ACPI_STATUS
AcpiRsCreateResourceList (
ACPI_OPERAND_OBJECT *ByteStreamBuffer,
- UINT8 *OutputBuffer,
- UINT32 *OutputBufferLength)
+ ACPI_BUFFER *OutputBuffer)
{
ACPI_STATUS Status;
UINT8 *ByteStreamStart;
- UINT32 ListSizeNeeded = 0;
+ ACPI_SIZE ListSizeNeeded = 0;
UINT32 ByteStreamBufferLength;
- FUNCTION_TRACE ("RsCreateResourceList");
+ ACPI_FUNCTION_TRACE ("RsCreateResourceList");
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamBuffer = %p\n", ByteStreamBuffer));
@@ -183,29 +182,25 @@ AcpiRsCreateResourceList (
return_ACPI_STATUS (Status);
}
- /*
- * Is caller buffer large enough?
- */
- if (ListSizeNeeded > *OutputBufferLength)
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
+ if (ACPI_FAILURE (Status))
{
- *OutputBufferLength = ListSizeNeeded;
- return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ return_ACPI_STATUS (Status);
}
- /*
- * Zero out the return buffer before proceeding
- */
- MEMSET (OutputBuffer, 0x00, *OutputBufferLength);
+ /* Do the conversion */
Status = AcpiRsByteStreamToList (ByteStreamStart, ByteStreamBufferLength,
- &OutputBuffer);
+ OutputBuffer->Pointer);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer = %p\n", OutputBuffer));
- *OutputBufferLength = ListSizeNeeded;
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
@@ -221,71 +216,68 @@ AcpiRsCreateResourceList (
*
* 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 OutputBufferLength will point
+ * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
* to the size buffer needed.
*
* 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
+ * output buffer is aligned properly (if necessary).
+ *
******************************************************************************/
ACPI_STATUS
AcpiRsCreatePciRoutingTable (
ACPI_OPERAND_OBJECT *PackageObject,
- UINT8 *OutputBuffer,
- UINT32 *OutputBufferLength)
+ ACPI_BUFFER *OutputBuffer)
{
- UINT8 *Buffer = OutputBuffer;
+ UINT8 *Buffer;
ACPI_OPERAND_OBJECT **TopObjectList = NULL;
ACPI_OPERAND_OBJECT **SubObjectList = NULL;
ACPI_OPERAND_OBJECT *PackageElement = NULL;
- UINT32 BufferSizeNeeded = 0;
+ ACPI_SIZE BufferSizeNeeded = 0;
UINT32 NumberOfElements = 0;
UINT32 Index = 0;
- PCI_ROUTING_TABLE *UserPrt = NULL;
+ ACPI_PCI_ROUTING_TABLE *UserPrt = NULL;
ACPI_NAMESPACE_NODE *Node;
ACPI_STATUS Status;
+ ACPI_BUFFER PathBuffer;
+
+ ACPI_FUNCTION_TRACE ("RsCreatePciRoutingTable");
- FUNCTION_TRACE ("RsCreatePciRoutingTable");
+ /* Params already validated, so we don't re-validate here */
/*
- * Params already validated, so we don't re-validate here
+ * Get the required buffer length
*/
Status = AcpiRsCalculatePciRoutingTableLength (PackageObject,
&BufferSizeNeeded);
- if (!ACPI_SUCCESS(Status))
+ if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", BufferSizeNeeded));
- /* Is caller buffer large enough? */
+ /* Validate/Allocate/Clear caller buffer */
- if (BufferSizeNeeded > *OutputBufferLength)
+ Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
+ if (ACPI_FAILURE (Status))
{
- return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ return_ACPI_STATUS (Status);
}
- *OutputBufferLength = BufferSizeNeeded;
/*
- * Zero out the return buffer before proceeding
- */
- MEMSET (OutputBuffer, 0x00, *OutputBufferLength);
-
- /*
- * Loop through the ACPI_INTERNAL_OBJECTS - Each object should
- * contain a UINT32 Address, a UINT8 Pin, a Name and a UINT8
- * SourceIndex.
+ * Loop through the ACPI_INTERNAL_OBJECTS - Each object should contain an
+ * ACPI_INTEGER Address, a UINT8 Pin, a Name and a UINT8 SourceIndex.
*/
TopObjectList = PackageObject->Package.Elements;
NumberOfElements = PackageObject->Package.Count;
- UserPrt = (PCI_ROUTING_TABLE *) Buffer;
-
-
- Buffer = ROUND_PTR_UP_TO_8 (Buffer, UINT8);
+ Buffer = OutputBuffer->Pointer;
+ UserPrt = (ACPI_PCI_ROUTING_TABLE *) Buffer;
for (Index = 0; Index < NumberOfElements; Index++)
{
@@ -296,15 +288,14 @@ AcpiRsCreatePciRoutingTable (
* be zero because we cleared the return buffer earlier
*/
Buffer += UserPrt->Length;
- UserPrt = (PCI_ROUTING_TABLE *) Buffer;
+ UserPrt = (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 (PCI_ROUTING_TABLE) -4);
+ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) -4);
/*
* Dereference the sub-package
@@ -312,9 +303,8 @@ AcpiRsCreatePciRoutingTable (
PackageElement = *TopObjectList;
/*
- * The SubObjectList will now point to an array of
- * the four IRQ elements: Address, Pin, Source and
- * SourceIndex
+ * The SubObjectList will now point to an array of the four IRQ
+ * elements: Address, Pin, Source and SourceIndex
*/
SubObjectList = PackageElement->Package.Elements;
@@ -368,37 +358,33 @@ AcpiRsCreatePciRoutingTable (
/* Use *remaining* length of the buffer as max for pathname */
- BufferSizeNeeded = *OutputBufferLength -
- (UINT32) ((UINT8 *) UserPrt->Source - OutputBuffer);
+ PathBuffer.Length = OutputBuffer->Length -
+ (UINT32) ((UINT8 *) UserPrt->Source - (UINT8 *) OutputBuffer->Pointer);
+ PathBuffer.Pointer = UserPrt->Source;
- Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) Node,
- &BufferSizeNeeded, UserPrt->Source);
+ Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) Node, &PathBuffer);
- UserPrt->Length += STRLEN (UserPrt->Source) + 1; /* include null terminator */
+ UserPrt->Length += ACPI_STRLEN (UserPrt->Source) + 1; /* include null terminator */
break;
case ACPI_TYPE_STRING:
- STRCPY (UserPrt->Source,
+ ACPI_STRCPY (UserPrt->Source,
(*SubObjectList)->String.Pointer);
- /*
- * Add to the Length field the length of the string
- */
+ /* Add to the Length field the length of the string */
+
UserPrt->Length += (*SubObjectList)->String.Length;
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.
- */
- /*
- * Add to the Length field the length of
- * the UINT32 NULL
+ * 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;
@@ -409,12 +395,11 @@ AcpiRsCreatePciRoutingTable (
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Need Integer, found %s\n",
AcpiUtGetTypeName ((*SubObjectList)->Common.Type)));
return_ACPI_STATUS (AE_BAD_DATA);
- break;
}
/* Now align the current length */
- UserPrt->Length = ROUND_UP_TO_64BITS (UserPrt->Length);
+ UserPrt->Length = ACPI_ROUND_UP_TO_64BITS (UserPrt->Length);
/*
* 4) Fourth subobject: Dereference the Source Index
@@ -432,16 +417,13 @@ AcpiRsCreatePciRoutingTable (
return_ACPI_STATUS (AE_BAD_DATA);
}
- /*
- * Point to the next ACPI_OPERAND_OBJECT
- */
+ /* Point to the next ACPI_OPERAND_OBJECT */
+
TopObjectList++;
}
- /*
- * Report the amount of buffer used
- */
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer = %p\n", OutputBuffer));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
@@ -452,11 +434,10 @@ AcpiRsCreatePciRoutingTable (
*
* PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
* OutputBuffer - Pointer to the user's buffer
- * OutputBufferLength - Size of OutputBuffer
*
* 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 OutputBufferLength will point
+ * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
* to the size buffer needed.
*
* DESCRIPTION: Takes the linked list of device resources and
@@ -468,14 +449,13 @@ AcpiRsCreatePciRoutingTable (
ACPI_STATUS
AcpiRsCreateByteStream (
ACPI_RESOURCE *LinkedListBuffer,
- UINT8 *OutputBuffer,
- UINT32 *OutputBufferLength)
+ ACPI_BUFFER *OutputBuffer)
{
ACPI_STATUS Status;
- UINT32 ByteStreamSizeNeeded = 0;
+ ACPI_SIZE ByteStreamSizeNeeded = 0;
- FUNCTION_TRACE ("RsCreateByteStream");
+ ACPI_FUNCTION_TRACE ("RsCreateByteStream");
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", LinkedListBuffer));
@@ -496,28 +476,25 @@ AcpiRsCreateByteStream (
return_ACPI_STATUS (Status);
}
- /*
- * Is caller buffer large enough?
- */
- if (ByteStreamSizeNeeded > *OutputBufferLength)
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, ByteStreamSizeNeeded);
+ if (ACPI_FAILURE (Status))
{
- *OutputBufferLength = ByteStreamSizeNeeded;
- return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ return_ACPI_STATUS (Status);
}
- /*
- * Zero out the return buffer before proceeding
- */
- MEMSET (OutputBuffer, 0x00, *OutputBufferLength);
+ /* Do the conversion */
Status = AcpiRsListToByteStream (LinkedListBuffer, ByteStreamSizeNeeded,
- &OutputBuffer);
+ OutputBuffer->Pointer);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
- ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer = %p\n", OutputBuffer));
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, OutputBuffer->Length));
return_ACPI_STATUS (AE_OK);
}
OpenPOWER on IntegriCloud