summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/rsutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/rsutils.c')
-rw-r--r--sys/contrib/dev/acpica/rsutils.c160
1 files changed, 52 insertions, 108 deletions
diff --git a/sys/contrib/dev/acpica/rsutils.c b/sys/contrib/dev/acpica/rsutils.c
index cbe498d..1b92806 100644
--- a/sys/contrib/dev/acpica/rsutils.c
+++ b/sys/contrib/dev/acpica/rsutils.c
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: rsutils - Utilities for the resource manager
- * $Revision: 23 $
+ * $Revision: 29 $
*
******************************************************************************/
@@ -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 @@
#define _COMPONENT ACPI_RESOURCES
- MODULE_NAME ("rsutils")
+ ACPI_MODULE_NAME ("rsutils")
/*******************************************************************************
@@ -151,15 +151,12 @@ AcpiRsGetPrtMethodData (
{
ACPI_OPERAND_OBJECT *RetObj;
ACPI_STATUS Status;
- UINT32 BufferSpaceNeeded;
- FUNCTION_TRACE ("RsGetPrtMethodData");
+ ACPI_FUNCTION_TRACE ("RsGetPrtMethodData");
- /* already validated params, so we won't repeat here */
-
- BufferSpaceNeeded = RetBuffer->Length;
+ /* Parameters guaranteed valid by caller */
/*
* Execute the method, no parameters
@@ -178,35 +175,26 @@ AcpiRsGetPrtMethodData (
return_ACPI_STATUS (AE_TYPE);
}
-
/*
- * The return object will be a package, so check the
- * parameters. If the return object is not a package,
- * then the underlying AML code is corrupt or improperly
- * written.
+ * The return object will be a package, so check the parameters. If the
+ * return object is not a package, then the underlying AML code is corrupt
+ * or improperly written.
*/
if (ACPI_TYPE_PACKAGE != RetObj->Common.Type)
{
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_PRT did not return a Package, returned %s\n",
+ AcpiUtGetTypeName (RetObj->Common.Type)));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
/*
- * Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the _CRS method
- * execution.
- */
- Status = AcpiRsCreatePciRoutingTable (RetObj, RetBuffer->Pointer,
- &BufferSpaceNeeded);
-
- /*
- * Tell the user how much of the buffer we have used or is needed
- * and return the final status.
+ * Create a resource linked list from the byte stream buffer that comes
+ * back from the _CRS method execution.
*/
- RetBuffer->Length = BufferSpaceNeeded;
+ Status = AcpiRsCreatePciRoutingTable (RetObj, RetBuffer);
-
- /* On exit, we must delete the object returned by evaluateObject */
+ /* On exit, we must delete the object returned by EvaluateObject */
Cleanup:
@@ -240,16 +228,15 @@ AcpiRsGetCrsMethodData (
{
ACPI_OPERAND_OBJECT *RetObj;
ACPI_STATUS Status;
- UINT32 BufferSpaceNeeded = RetBuffer->Length;
- FUNCTION_TRACE ("RsGetCrsMethodData");
+ ACPI_FUNCTION_TRACE ("RsGetCrsMethodData");
- /* already validated params, so we won't repeat here */
+ /* Parameters guaranteed valid by caller */
/*
- * Execute the method, no parameters
+ * Execute the method, no parameters
*/
Status = AcpiNsEvaluateRelative (Handle, "_CRS", NULL, &RetObj);
if (ACPI_FAILURE (Status))
@@ -267,31 +254,24 @@ AcpiRsGetCrsMethodData (
/*
* The return object will be a buffer, but check the
- * parameters. If the return object is not a buffer,
- * then the underlying AML code is corrupt or improperly
- * written.
+ * parameters. If the return object is not a buffer,
+ * then the underlying AML code is corrupt or improperly
+ * written.
*/
if (ACPI_TYPE_BUFFER != RetObj->Common.Type)
{
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_CRS did not return a Buffer, returned %s\n",
+ AcpiUtGetTypeName (RetObj->Common.Type)));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
/*
* Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the _CRS method
- * execution.
- */
- Status = AcpiRsCreateResourceList (RetObj, RetBuffer->Pointer,
- &BufferSpaceNeeded);
-
-
- /*
- * Tell the user how much of the buffer we have used or is needed
- * and return the final status.
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
*/
- RetBuffer->Length = BufferSpaceNeeded;
-
+ Status = AcpiRsCreateResourceList (RetObj, RetBuffer);
/* On exit, we must delete the object returned by evaluateObject */
@@ -327,16 +307,15 @@ AcpiRsGetPrsMethodData (
{
ACPI_OPERAND_OBJECT *RetObj;
ACPI_STATUS Status;
- UINT32 BufferSpaceNeeded = RetBuffer->Length;
- FUNCTION_TRACE ("RsGetPrsMethodData");
+ ACPI_FUNCTION_TRACE ("RsGetPrsMethodData");
- /* already validated params, so we won't repeat here */
+ /* Parameters guaranteed valid by caller */
/*
- * Execute the method, no parameters
+ * Execute the method, no parameters
*/
Status = AcpiNsEvaluateRelative (Handle, "_PRS", NULL, &RetObj);
if (ACPI_FAILURE (Status))
@@ -354,30 +333,24 @@ AcpiRsGetPrsMethodData (
/*
* The return object will be a buffer, but check the
- * parameters. If the return object is not a buffer,
- * then the underlying AML code is corrupt or improperly
- * written..
+ * parameters. If the return object is not a buffer,
+ * then the underlying AML code is corrupt or improperly
+ * written..
*/
if (ACPI_TYPE_BUFFER != RetObj->Common.Type)
{
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_PRS did not return a Buffer, returned %s\n",
+ AcpiUtGetTypeName (RetObj->Common.Type)));
Status = AE_AML_OPERAND_TYPE;
goto Cleanup;
}
/*
* Make the call to create a resource linked list from the
- * byte stream buffer that comes back from the _CRS method
- * execution.
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
*/
- Status = AcpiRsCreateResourceList (RetObj, RetBuffer->Pointer,
- &BufferSpaceNeeded);
-
- /*
- * Tell the user how much of the buffer we have used or is needed
- * and return the final status.
- */
- RetBuffer->Length = BufferSpaceNeeded;
-
+ Status = AcpiRsCreateResourceList (RetObj, RetBuffer);
/* On exit, we must delete the object returned by evaluateObject */
@@ -413,53 +386,26 @@ AcpiRsSetSrsMethodData (
{
ACPI_OPERAND_OBJECT *Params[2];
ACPI_STATUS Status;
- UINT8 *ByteStream = NULL;
- UINT32 BufferSizeNeeded = 0;
+ ACPI_BUFFER Buffer;
- FUNCTION_TRACE ("RsSetSrsMethodData");
+ ACPI_FUNCTION_TRACE ("RsSetSrsMethodData");
- /* already validated params, so we won't repeat here */
+ /* Parameters guaranteed valid by caller */
/*
* The InBuffer parameter will point to a linked list of
* resource parameters. It needs to be formatted into a
- * byte stream to be sent in as an input parameter.
- */
- BufferSizeNeeded = 0;
-
- /*
- * First call is to get the buffer size needed
+ * byte stream to be sent in as an input parameter to _SRS
+ *
+ * Convert the linked list into a byte stream
*/
- Status = AcpiRsCreateByteStream (InBuffer->Pointer, ByteStream,
- &BufferSizeNeeded);
- /*
- * We expect a return of AE_BUFFER_OVERFLOW
- * if not, exit with the error
- */
- if (AE_BUFFER_OVERFLOW != Status)
- {
- return_ACPI_STATUS (Status);
- }
-
- /*
- * Allocate the buffer needed
- */
- ByteStream = ACPI_MEM_CALLOCATE (BufferSizeNeeded);
- if (NULL == ByteStream)
- {
- return_ACPI_STATUS (AE_NO_MEMORY);
- }
-
- /*
- * Now call to convert the linked list into a byte stream
- */
- Status = AcpiRsCreateByteStream (InBuffer->Pointer, ByteStream,
- &BufferSizeNeeded);
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiRsCreateByteStream (InBuffer->Pointer, &Buffer);
if (ACPI_FAILURE (Status))
{
- goto Cleanup;
+ return_ACPI_STATUS (Status);
}
/*
@@ -468,28 +414,26 @@ AcpiRsSetSrsMethodData (
Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
if (!Params[0])
{
- Status = AE_NO_MEMORY;
- goto Cleanup;
+ AcpiOsFree (Buffer.Pointer);
+ return_ACPI_STATUS (AE_NO_MEMORY);
}
- Params [1] = NULL;
/*
- * Set up the parameter object
+ * Set up the parameter object
*/
- Params[0]->Buffer.Length = BufferSizeNeeded;
- Params[0]->Buffer.Pointer = ByteStream;
+ Params[0]->Buffer.Length = Buffer.Length;
+ Params[0]->Buffer.Pointer = Buffer.Pointer;
+ Params[1] = NULL;
/*
* Execute the method, no return value
*/
Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL);
- AcpiUtRemoveReference (Params[0]);
/*
* Clean up and return the status from AcpiNsEvaluateRelative
*/
-Cleanup:
-
+ AcpiUtRemoveReference (Params[0]);
return_ACPI_STATUS (Status);
}
OpenPOWER on IntegriCloud