mirror of
https://github.com/acpica/acpica/
synced 2025-02-13 12:04:08 +03:00
Add check for type==DEVICE, restructure external interfaces to use common parameter validation. BZ 358
This commit is contained in:
parent
28058079dc
commit
159e9486dd
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: psparse - Parser top level AML parse routines
|
||||
* $Revision: 1.165 $
|
||||
* $Revision: 1.166 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -562,6 +562,7 @@ AcpiPsParseAml (
|
||||
Thread = AcpiUtCreateThreadState ();
|
||||
if (!Thread)
|
||||
{
|
||||
AcpiDsDeleteWalkState (WalkState);
|
||||
return_ACPI_STATUS (AE_NO_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Module Name: rsutils - Utilities for the resource manager
|
||||
* $Revision: 1.63 $
|
||||
* $Revision: 1.64 $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@ -563,7 +563,7 @@ AcpiRsSetResourceSource (
|
||||
*
|
||||
* FUNCTION: AcpiRsGetPrtMethodData
|
||||
*
|
||||
* PARAMETERS: Handle - Handle to the containing object
|
||||
* PARAMETERS: Node - Device node
|
||||
* RetBuffer - Pointer to a buffer structure for the
|
||||
* results
|
||||
*
|
||||
@ -579,7 +579,7 @@ AcpiRsSetResourceSource (
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsGetPrtMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer)
|
||||
{
|
||||
ACPI_OPERAND_OBJECT *ObjDesc;
|
||||
@ -593,7 +593,7 @@ AcpiRsGetPrtMethodData (
|
||||
|
||||
/* Execute the method, no parameters */
|
||||
|
||||
Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRT,
|
||||
Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT,
|
||||
ACPI_BTYPE_PACKAGE, &ObjDesc);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
@ -617,7 +617,7 @@ AcpiRsGetPrtMethodData (
|
||||
*
|
||||
* FUNCTION: AcpiRsGetCrsMethodData
|
||||
*
|
||||
* PARAMETERS: Handle - Handle to the containing object
|
||||
* PARAMETERS: Node - Device node
|
||||
* RetBuffer - Pointer to a buffer structure for the
|
||||
* results
|
||||
*
|
||||
@ -633,7 +633,7 @@ AcpiRsGetPrtMethodData (
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsGetCrsMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer)
|
||||
{
|
||||
ACPI_OPERAND_OBJECT *ObjDesc;
|
||||
@ -647,7 +647,7 @@ AcpiRsGetCrsMethodData (
|
||||
|
||||
/* Execute the method, no parameters */
|
||||
|
||||
Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__CRS,
|
||||
Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS,
|
||||
ACPI_BTYPE_BUFFER, &ObjDesc);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
@ -672,7 +672,7 @@ AcpiRsGetCrsMethodData (
|
||||
*
|
||||
* FUNCTION: AcpiRsGetPrsMethodData
|
||||
*
|
||||
* PARAMETERS: Handle - Handle to the containing object
|
||||
* PARAMETERS: Node - Device node
|
||||
* RetBuffer - Pointer to a buffer structure for the
|
||||
* results
|
||||
*
|
||||
@ -688,7 +688,7 @@ AcpiRsGetCrsMethodData (
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsGetPrsMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer)
|
||||
{
|
||||
ACPI_OPERAND_OBJECT *ObjDesc;
|
||||
@ -702,7 +702,7 @@ AcpiRsGetPrsMethodData (
|
||||
|
||||
/* Execute the method, no parameters */
|
||||
|
||||
Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRS,
|
||||
Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS,
|
||||
ACPI_BTYPE_BUFFER, &ObjDesc);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
@ -760,7 +760,8 @@ AcpiRsGetMethodData (
|
||||
/* Execute the method, no parameters */
|
||||
|
||||
Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
|
||||
if (ACPI_FAILURE (Status)) {
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
@ -782,7 +783,7 @@ AcpiRsGetMethodData (
|
||||
*
|
||||
* FUNCTION: AcpiRsSetSrsMethodData
|
||||
*
|
||||
* PARAMETERS: Handle - Handle to the containing object
|
||||
* PARAMETERS: Node - Device node
|
||||
* InBuffer - Pointer to a buffer structure of the
|
||||
* parameter
|
||||
*
|
||||
@ -798,7 +799,7 @@ AcpiRsGetMethodData (
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsSetSrsMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *InBuffer)
|
||||
{
|
||||
ACPI_PARAMETER_INFO Info;
|
||||
@ -842,7 +843,7 @@ AcpiRsSetSrsMethodData (
|
||||
Params[0]->Common.Flags = AOPOBJ_DATA_VALID;
|
||||
Params[1] = NULL;
|
||||
|
||||
Info.Node = Handle;
|
||||
Info.Node = Node;
|
||||
Info.Parameters = Params;
|
||||
Info.ParameterType = ACPI_PARAM_ARGS;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Module Name: rsxface - Public interfaces to the resource manager
|
||||
* $Revision: 1.44 $
|
||||
* $Revision: 1.45 $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@ -119,6 +119,7 @@
|
||||
|
||||
#include "acpi.h"
|
||||
#include "acresrc.h"
|
||||
#include "acnamesp.h"
|
||||
|
||||
#define _COMPONENT ACPI_RESOURCES
|
||||
ACPI_MODULE_NAME ("rsxface")
|
||||
@ -148,6 +149,79 @@ AcpiRsMatchVendorResource (
|
||||
ACPI_RESOURCE *Resource,
|
||||
void *Context);
|
||||
|
||||
static ACPI_STATUS
|
||||
AcpiRsValidateParameters (
|
||||
ACPI_HANDLE DeviceHandle,
|
||||
ACPI_BUFFER *RetBuffer,
|
||||
ACPI_NAMESPACE_NODE **RetNode);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiRsValidateParameters
|
||||
*
|
||||
* PARAMETERS: DeviceHandle - Handle to a device
|
||||
* RetBuffer - Pointer to a data buffer
|
||||
* RetNode - Pointer to where the device node is returned
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Common parameter validation for resource interfaces
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static ACPI_STATUS
|
||||
AcpiRsValidateParameters (
|
||||
ACPI_HANDLE DeviceHandle,
|
||||
ACPI_BUFFER *RetBuffer,
|
||||
ACPI_NAMESPACE_NODE **RetNode)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_NAMESPACE_NODE *Node;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (RsValidateParameters);
|
||||
|
||||
|
||||
/*
|
||||
* Must have a valid handle to an ACPI device
|
||||
*/
|
||||
if (!DeviceHandle)
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
Node = AcpiNsMapHandleToNode (DeviceHandle);
|
||||
if (!Node)
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
if (Node->Type != ACPI_TYPE_DEVICE)
|
||||
{
|
||||
return_ACPI_STATUS (AE_TYPE);
|
||||
}
|
||||
|
||||
/* Check return buffer if requested */
|
||||
|
||||
if (RetBuffer)
|
||||
{
|
||||
/*
|
||||
* if there is a non-zero buffer length we also need a valid pointer in
|
||||
* the buffer. If it's a zero buffer length, we'll be returning the
|
||||
* needed buffer size (later), so keep going.
|
||||
*/
|
||||
Status = AcpiUtValidateBuffer (RetBuffer);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
}
|
||||
|
||||
*RetNode = Node;
|
||||
return_ACPI_STATUS (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
@ -160,8 +234,8 @@ AcpiRsMatchVendorResource (
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: This function is called to get the IRQ routing table for a
|
||||
* specific bus. The caller must first acquire a handle for the
|
||||
* desired bus. The routine table is placed in the buffer pointed
|
||||
* specific bus. The caller must first acquire a handle for the
|
||||
* desired bus. The routine table is placed in the buffer pointed
|
||||
* to by the RetBuffer variable parameter.
|
||||
*
|
||||
* If the function fails an appropriate status will be returned
|
||||
@ -178,29 +252,21 @@ AcpiGetIrqRoutingTable (
|
||||
ACPI_BUFFER *RetBuffer)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_NAMESPACE_NODE *Node;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
|
||||
|
||||
|
||||
/*
|
||||
* Must have a valid handle and buffer, So we have to have a handle
|
||||
* and a return buffer structure, and if there is a non-zero buffer length
|
||||
* we also need a valid pointer in the buffer. If it's a zero buffer length,
|
||||
* we'll be returning the needed buffer size, so keep going.
|
||||
*/
|
||||
if (!DeviceHandle)
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
/* Validate parameters then dispatch to internal routine */
|
||||
|
||||
Status = AcpiUtValidateBuffer (RetBuffer);
|
||||
Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer);
|
||||
Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
@ -219,8 +285,8 @@ ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: This function is called to get the current resources for a
|
||||
* specific device. The caller must first acquire a handle for
|
||||
* the desired device. The resource data is placed in the buffer
|
||||
* specific device. The caller must first acquire a handle for
|
||||
* the desired device. The resource data is placed in the buffer
|
||||
* pointed to by the RetBuffer variable parameter.
|
||||
*
|
||||
* If the function fails an appropriate status will be returned
|
||||
@ -237,29 +303,21 @@ AcpiGetCurrentResources (
|
||||
ACPI_BUFFER *RetBuffer)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_NAMESPACE_NODE *Node;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
|
||||
|
||||
|
||||
/*
|
||||
* Must have a valid handle and buffer, So we have to have a handle
|
||||
* and a return buffer structure, and if there is a non-zero buffer length
|
||||
* we also need a valid pointer in the buffer. If it's a zero buffer length,
|
||||
* we'll be returning the needed buffer size, so keep going.
|
||||
*/
|
||||
if (!DeviceHandle)
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
/* Validate parameters then dispatch to internal routine */
|
||||
|
||||
Status = AcpiUtValidateBuffer (RetBuffer);
|
||||
Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer);
|
||||
Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
@ -278,8 +336,8 @@ ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: This function is called to get a list of the possible resources
|
||||
* for a specific device. The caller must first acquire a handle
|
||||
* for the desired device. The resource data is placed in the
|
||||
* for a specific device. The caller must first acquire a handle
|
||||
* for the desired device. The resource data is placed in the
|
||||
* buffer pointed to by the RetBuffer variable.
|
||||
*
|
||||
* If the function fails an appropriate status will be returned
|
||||
@ -293,152 +351,41 @@ AcpiGetPossibleResources (
|
||||
ACPI_BUFFER *RetBuffer)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_NAMESPACE_NODE *Node;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
|
||||
|
||||
|
||||
/*
|
||||
* Must have a valid handle and buffer, So we have to have a handle
|
||||
* and a return buffer structure, and if there is a non-zero buffer length
|
||||
* we also need a valid pointer in the buffer. If it's a zero buffer length,
|
||||
* we'll be returning the needed buffer size, so keep going.
|
||||
*/
|
||||
if (!DeviceHandle)
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
/* Validate parameters then dispatch to internal routine */
|
||||
|
||||
Status = AcpiUtValidateBuffer (RetBuffer);
|
||||
Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer);
|
||||
Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiWalkResources
|
||||
*
|
||||
* PARAMETERS: DeviceHandle - Handle to the device object for the
|
||||
* device we are querying
|
||||
* Name - Method name of the resources we want
|
||||
* (METHOD_NAME__CRS or METHOD_NAME__PRS)
|
||||
* UserFunction - Called for each resource
|
||||
* Context - Passed to UserFunction
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Retrieves the current or possible resource list for the
|
||||
* specified device. The UserFunction is called once for
|
||||
* each resource in the list.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiWalkResources (
|
||||
ACPI_HANDLE DeviceHandle,
|
||||
char *Name,
|
||||
ACPI_WALK_RESOURCE_CALLBACK UserFunction,
|
||||
void *Context)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_BUFFER Buffer;
|
||||
ACPI_RESOURCE *Resource;
|
||||
ACPI_RESOURCE *ResourceEnd;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (AcpiWalkResources);
|
||||
|
||||
|
||||
/* Parameter validation */
|
||||
|
||||
if (!DeviceHandle || !UserFunction || !Name ||
|
||||
(!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
|
||||
!ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS)))
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
/* Get the _CRS or _PRS resource list */
|
||||
|
||||
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
|
||||
Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/* Buffer now contains the resource list */
|
||||
|
||||
Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
|
||||
ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
|
||||
|
||||
/* Walk the resource list until the EndTag is found (or buffer end) */
|
||||
|
||||
while (Resource < ResourceEnd)
|
||||
{
|
||||
/* Sanity check the resource */
|
||||
|
||||
if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
|
||||
{
|
||||
Status = AE_AML_INVALID_RESOURCE_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Invoke the user function, abort on any error returned */
|
||||
|
||||
Status = UserFunction (Resource, Context);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
if (Status == AE_CTRL_TERMINATE)
|
||||
{
|
||||
/* This is an OK termination by the user function */
|
||||
|
||||
Status = AE_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* EndTag indicates end-of-list */
|
||||
|
||||
if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the next resource descriptor */
|
||||
|
||||
Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
|
||||
}
|
||||
|
||||
ACPI_FREE (Buffer.Pointer);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
ACPI_EXPORT_SYMBOL (AcpiWalkResources)
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiSetCurrentResources
|
||||
*
|
||||
* PARAMETERS: DeviceHandle - a handle to the device object for the
|
||||
* device we are changing the resources of
|
||||
* device we are setting resources
|
||||
* InBuffer - a pointer to a buffer containing the
|
||||
* resources to be set for the device
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: This function is called to set the current resources for a
|
||||
* specific device. The caller must first acquire a handle for
|
||||
* the desired device. The resource data is passed to the routine
|
||||
* specific device. The caller must first acquire a handle for
|
||||
* the desired device. The resource data is passed to the routine
|
||||
* the buffer pointed to by the InBuffer variable.
|
||||
*
|
||||
******************************************************************************/
|
||||
@ -449,22 +396,30 @@ AcpiSetCurrentResources (
|
||||
ACPI_BUFFER *InBuffer)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_NAMESPACE_NODE *Node;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
|
||||
|
||||
|
||||
/* Must have a valid handle and buffer */
|
||||
/* Validate the buffer */
|
||||
|
||||
if ((!DeviceHandle) ||
|
||||
(!InBuffer) ||
|
||||
if ((!InBuffer) ||
|
||||
(!InBuffer->Pointer) ||
|
||||
(!InBuffer->Length))
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer);
|
||||
/* Validate parameters then dispatch to internal routine */
|
||||
|
||||
Status = AcpiRsValidateParameters (DeviceHandle, NULL, &Node);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
Status = AcpiRsSetSrsMethodData (Node, InBuffer);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
@ -483,7 +438,7 @@ ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: If the resource is an address16, address32, or address64,
|
||||
* copy it to the address64 return buffer. This saves the
|
||||
* copy it to the address64 return buffer. This saves the
|
||||
* caller from having to duplicate code for different-sized
|
||||
* addresses.
|
||||
*
|
||||
@ -658,3 +613,105 @@ AcpiRsMatchVendorResource (
|
||||
return (AE_CTRL_TERMINATE);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiWalkResources
|
||||
*
|
||||
* PARAMETERS: DeviceHandle - Handle to the device object for the
|
||||
* device we are querying
|
||||
* Name - Method name of the resources we want
|
||||
* (METHOD_NAME__CRS or METHOD_NAME__PRS)
|
||||
* UserFunction - Called for each resource
|
||||
* Context - Passed to UserFunction
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Retrieves the current or possible resource list for the
|
||||
* specified device. The UserFunction is called once for
|
||||
* each resource in the list.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiWalkResources (
|
||||
ACPI_HANDLE DeviceHandle,
|
||||
char *Name,
|
||||
ACPI_WALK_RESOURCE_CALLBACK UserFunction,
|
||||
void *Context)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_BUFFER Buffer;
|
||||
ACPI_RESOURCE *Resource;
|
||||
ACPI_RESOURCE *ResourceEnd;
|
||||
|
||||
|
||||
ACPI_FUNCTION_TRACE (AcpiWalkResources);
|
||||
|
||||
|
||||
/* Parameter validation */
|
||||
|
||||
if (!DeviceHandle || !UserFunction || !Name ||
|
||||
(!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
|
||||
!ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS)))
|
||||
{
|
||||
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
||||
}
|
||||
|
||||
/* Get the _CRS or _PRS resource list */
|
||||
|
||||
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
|
||||
Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
/* Buffer now contains the resource list */
|
||||
|
||||
Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
|
||||
ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
|
||||
|
||||
/* Walk the resource list until the EndTag is found (or buffer end) */
|
||||
|
||||
while (Resource < ResourceEnd)
|
||||
{
|
||||
/* Sanity check the resource */
|
||||
|
||||
if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
|
||||
{
|
||||
Status = AE_AML_INVALID_RESOURCE_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Invoke the user function, abort on any error returned */
|
||||
|
||||
Status = UserFunction (Resource, Context);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
if (Status == AE_CTRL_TERMINATE)
|
||||
{
|
||||
/* This is an OK termination by the user function */
|
||||
|
||||
Status = AE_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* EndTag indicates end-of-list */
|
||||
|
||||
if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the next resource descriptor */
|
||||
|
||||
Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
|
||||
}
|
||||
|
||||
ACPI_FREE (Buffer.Pointer);
|
||||
return_ACPI_STATUS (Status);
|
||||
}
|
||||
|
||||
ACPI_EXPORT_SYMBOL (AcpiWalkResources)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: acresrc.h - Resource Manager function prototypes
|
||||
* $Revision: 1.57 $
|
||||
* $Revision: 1.58 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -253,17 +253,17 @@ AcpiRsCreatePciRoutingTable (
|
||||
*/
|
||||
ACPI_STATUS
|
||||
AcpiRsGetPrtMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer);
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsGetCrsMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer);
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsGetPrsMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer);
|
||||
|
||||
ACPI_STATUS
|
||||
@ -274,7 +274,7 @@ AcpiRsGetMethodData (
|
||||
|
||||
ACPI_STATUS
|
||||
AcpiRsSetSrsMethodData (
|
||||
ACPI_HANDLE Handle,
|
||||
ACPI_NAMESPACE_NODE *Node,
|
||||
ACPI_BUFFER *RetBuffer);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user