|
||||
Warning, cross-references for /kernel/drivers/acpica/rsxface.c need to be fixed.
0001 /******************************************************************************* 0002 * 0003 * Module Name: rsxface - Public interfaces to the resource manager 0004 * 0005 ******************************************************************************/ 0006 0007 /****************************************************************************** 0008 * 0009 * 1. Copyright Notice 0010 * 0011 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 0012 * All rights reserved. 0013 * 0014 * 2. License 0015 * 0016 * 2.1. This is your license from Intel Corp. under its intellectual property 0017 * rights. You may have additional license terms from the party that provided 0018 * you this software, covering your right to use that party's intellectual 0019 * property rights. 0020 * 0021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 0022 * copy of the source code appearing in this file ("Covered Code") an 0023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 0024 * base code distributed originally by Intel ("Original Intel Code") to copy, 0025 * make derivatives, distribute, use and display any portion of the Covered 0026 * Code in any form, with the right to sublicense such rights; and 0027 * 0028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 0029 * license (with the right to sublicense), under only those claims of Intel 0030 * patents that are infringed by the Original Intel Code, to make, use, sell, 0031 * offer to sell, and import the Covered Code and derivative works thereof 0032 * solely to the minimum extent necessary to exercise the above copyright 0033 * license, and in no event shall the patent license extend to any additions 0034 * to or modifications of the Original Intel Code. No other license or right 0035 * is granted directly or by implication, estoppel or otherwise; 0036 * 0037 * The above copyright and patent license is granted only if the following 0038 * conditions are met: 0039 * 0040 * 3. Conditions 0041 * 0042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 0043 * Redistribution of source code of any substantial portion of the Covered 0044 * Code or modification with rights to further distribute source must include 0045 * the above Copyright Notice, the above License, this list of Conditions, 0046 * and the following Disclaimer and Export Compliance provision. In addition, 0047 * Licensee must cause all Covered Code to which Licensee contributes to 0048 * contain a file documenting the changes Licensee made to create that Covered 0049 * Code and the date of any change. Licensee must include in that file the 0050 * documentation of any changes made by any predecessor Licensee. Licensee 0051 * must include a prominent statement that the modification is derived, 0052 * directly or indirectly, from Original Intel Code. 0053 * 0054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 0055 * Redistribution of source code of any substantial portion of the Covered 0056 * Code or modification without rights to further distribute source must 0057 * include the following Disclaimer and Export Compliance provision in the 0058 * documentation and/or other materials provided with distribution. In 0059 * addition, Licensee may not authorize further sublicense of source of any 0060 * portion of the Covered Code, and must include terms to the effect that the 0061 * license from Licensee to its licensee is limited to the intellectual 0062 * property embodied in the software Licensee provides to its licensee, and 0063 * not to intellectual property embodied in modifications its licensee may 0064 * make. 0065 * 0066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 0067 * substantial portion of the Covered Code or modification must reproduce the 0068 * above Copyright Notice, and the following Disclaimer and Export Compliance 0069 * provision in the documentation and/or other materials provided with the 0070 * distribution. 0071 * 0072 * 3.4. Intel retains all right, title, and interest in and to the Original 0073 * Intel Code. 0074 * 0075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 0076 * Intel shall be used in advertising or otherwise to promote the sale, use or 0077 * other dealings in products derived from or relating to the Covered Code 0078 * without prior written authorization from Intel. 0079 * 0080 * 4. Disclaimer and Export Compliance 0081 * 0082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 0083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 0084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 0085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 0086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 0087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 0088 * PARTICULAR PURPOSE. 0089 * 0090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 0091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 0092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 0093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 0094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 0095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 0096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 0097 * LIMITED REMEDY. 0098 * 0099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 0100 * software or system incorporating such software without first obtaining any 0101 * required license or other approval from the U. S. Department of Commerce or 0102 * any other agency or department of the United States Government. In the 0103 * event Licensee exports any such software from the United States or 0104 * re-exports any such software from a foreign destination, Licensee shall 0105 * ensure that the distribution and export/re-export of the software is in 0106 * compliance with all laws, regulations, orders, or other restrictions of the 0107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 0108 * any of its subsidiaries will export/re-export any technical data, process, 0109 * software, or service, directly or indirectly, to any country for which the 0110 * United States government or any agency thereof requires an export license, 0111 * other governmental approval, or letter of assurance, without first obtaining 0112 * such license, approval or letter. 0113 * 0114 *****************************************************************************/ 0115 0116 0117 #define __RSXFACE_C__ 0118 0119 #include "acpi.h" 0120 #include "accommon.h" 0121 #include "acresrc.h" 0122 #include "acnamesp.h" 0123 0124 #define _COMPONENT ACPI_RESOURCES 0125 ACPI_MODULE_NAME ("rsxface") 0126 0127 /* Local macros for 16,32-bit to 64-bit conversion */ 0128 0129 #define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) 0130 #define ACPI_COPY_ADDRESS(Out, In) \ 0131 ACPI_COPY_FIELD(Out, In, ResourceType); \ 0132 ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ 0133 ACPI_COPY_FIELD(Out, In, Decode); \ 0134 ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ 0135 ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ 0136 ACPI_COPY_FIELD(Out, In, Info); \ 0137 ACPI_COPY_FIELD(Out, In, Granularity); \ 0138 ACPI_COPY_FIELD(Out, In, Minimum); \ 0139 ACPI_COPY_FIELD(Out, In, Maximum); \ 0140 ACPI_COPY_FIELD(Out, In, TranslationOffset); \ 0141 ACPI_COPY_FIELD(Out, In, AddressLength); \ 0142 ACPI_COPY_FIELD(Out, In, ResourceSource); 0143 0144 0145 /* Local prototypes */ 0146 0147 static ACPI_STATUS 0148 AcpiRsMatchVendorResource ( 0149 ACPI_RESOURCE *Resource, 0150 void *Context); 0151 0152 static ACPI_STATUS 0153 AcpiRsValidateParameters ( 0154 ACPI_HANDLE DeviceHandle, 0155 ACPI_BUFFER *Buffer, 0156 ACPI_NAMESPACE_NODE **ReturnNode); 0157 0158 0159 /******************************************************************************* 0160 * 0161 * FUNCTION: AcpiRsValidateParameters 0162 * 0163 * PARAMETERS: DeviceHandle - Handle to a device 0164 * Buffer - Pointer to a data buffer 0165 * ReturnNode - Pointer to where the device node is returned 0166 * 0167 * RETURN: Status 0168 * 0169 * DESCRIPTION: Common parameter validation for resource interfaces 0170 * 0171 ******************************************************************************/ 0172 0173 static ACPI_STATUS 0174 AcpiRsValidateParameters ( 0175 ACPI_HANDLE DeviceHandle, 0176 ACPI_BUFFER *Buffer, 0177 ACPI_NAMESPACE_NODE **ReturnNode) 0178 { 0179 ACPI_STATUS Status; 0180 ACPI_NAMESPACE_NODE *Node; 0181 0182 0183 ACPI_FUNCTION_TRACE (RsValidateParameters); 0184 0185 0186 /* 0187 * Must have a valid handle to an ACPI device 0188 */ 0189 if (!DeviceHandle) 0190 { 0191 return_ACPI_STATUS (AE_BAD_PARAMETER); 0192 } 0193 0194 Node = AcpiNsMapHandleToNode (DeviceHandle); 0195 if (!Node) 0196 { 0197 return_ACPI_STATUS (AE_BAD_PARAMETER); 0198 } 0199 0200 if (Node->Type != ACPI_TYPE_DEVICE) 0201 { 0202 return_ACPI_STATUS (AE_TYPE); 0203 } 0204 0205 /* 0206 * Validate the user buffer object 0207 * 0208 * if there is a non-zero buffer length we also need a valid pointer in 0209 * the buffer. If it's a zero buffer length, we'll be returning the 0210 * needed buffer size (later), so keep going. 0211 */ 0212 Status = AcpiUtValidateBuffer (Buffer); 0213 if (ACPI_FAILURE (Status)) 0214 { 0215 return_ACPI_STATUS (Status); 0216 } 0217 0218 *ReturnNode = Node; 0219 return_ACPI_STATUS (AE_OK); 0220 } 0221 0222 0223 /******************************************************************************* 0224 * 0225 * FUNCTION: AcpiGetIrqRoutingTable 0226 * 0227 * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying 0228 * RetBuffer - Pointer to a buffer to receive the 0229 * current resources for the device 0230 * 0231 * RETURN: Status 0232 * 0233 * DESCRIPTION: This function is called to get the IRQ routing table for a 0234 * specific bus. The caller must first acquire a handle for the 0235 * desired bus. The routine table is placed in the buffer pointed 0236 * to by the RetBuffer variable parameter. 0237 * 0238 * If the function fails an appropriate status will be returned 0239 * and the value of RetBuffer is undefined. 0240 * 0241 * This function attempts to execute the _PRT method contained in 0242 * the object indicated by the passed DeviceHandle. 0243 * 0244 ******************************************************************************/ 0245 0246 ACPI_STATUS 0247 AcpiGetIrqRoutingTable ( 0248 ACPI_HANDLE DeviceHandle, 0249 ACPI_BUFFER *RetBuffer) 0250 { 0251 ACPI_STATUS Status; 0252 ACPI_NAMESPACE_NODE *Node; 0253 0254 0255 ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable); 0256 0257 0258 /* Validate parameters then dispatch to internal routine */ 0259 0260 Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); 0261 if (ACPI_FAILURE (Status)) 0262 { 0263 return_ACPI_STATUS (Status); 0264 } 0265 0266 Status = AcpiRsGetPrtMethodData (Node, RetBuffer); 0267 return_ACPI_STATUS (Status); 0268 } 0269 0270 ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable) 0271 0272 0273 /******************************************************************************* 0274 * 0275 * FUNCTION: AcpiGetCurrentResources 0276 * 0277 * PARAMETERS: DeviceHandle - Handle to the device object for the 0278 * device we are querying 0279 * RetBuffer - Pointer to a buffer to receive the 0280 * current resources for the device 0281 * 0282 * RETURN: Status 0283 * 0284 * DESCRIPTION: This function is called to get the current resources for a 0285 * specific device. The caller must first acquire a handle for 0286 * the desired device. The resource data is placed in the buffer 0287 * pointed to by the RetBuffer variable parameter. 0288 * 0289 * If the function fails an appropriate status will be returned 0290 * and the value of RetBuffer is undefined. 0291 * 0292 * This function attempts to execute the _CRS method contained in 0293 * the object indicated by the passed DeviceHandle. 0294 * 0295 ******************************************************************************/ 0296 0297 ACPI_STATUS 0298 AcpiGetCurrentResources ( 0299 ACPI_HANDLE DeviceHandle, 0300 ACPI_BUFFER *RetBuffer) 0301 { 0302 ACPI_STATUS Status; 0303 ACPI_NAMESPACE_NODE *Node; 0304 0305 0306 ACPI_FUNCTION_TRACE (AcpiGetCurrentResources); 0307 0308 0309 /* Validate parameters then dispatch to internal routine */ 0310 0311 Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); 0312 if (ACPI_FAILURE (Status)) 0313 { 0314 return_ACPI_STATUS (Status); 0315 } 0316 0317 Status = AcpiRsGetCrsMethodData (Node, RetBuffer); 0318 return_ACPI_STATUS (Status); 0319 } 0320 0321 ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources) 0322 0323 0324 /******************************************************************************* 0325 * 0326 * FUNCTION: AcpiGetPossibleResources 0327 * 0328 * PARAMETERS: DeviceHandle - Handle to the device object for the 0329 * device we are querying 0330 * RetBuffer - Pointer to a buffer to receive the 0331 * resources for the device 0332 * 0333 * RETURN: Status 0334 * 0335 * DESCRIPTION: This function is called to get a list of the possible resources 0336 * for a specific device. The caller must first acquire a handle 0337 * for the desired device. The resource data is placed in the 0338 * buffer pointed to by the RetBuffer variable. 0339 * 0340 * If the function fails an appropriate status will be returned 0341 * and the value of RetBuffer is undefined. 0342 * 0343 ******************************************************************************/ 0344 0345 ACPI_STATUS 0346 AcpiGetPossibleResources ( 0347 ACPI_HANDLE DeviceHandle, 0348 ACPI_BUFFER *RetBuffer) 0349 { 0350 ACPI_STATUS Status; 0351 ACPI_NAMESPACE_NODE *Node; 0352 0353 0354 ACPI_FUNCTION_TRACE (AcpiGetPossibleResources); 0355 0356 0357 /* Validate parameters then dispatch to internal routine */ 0358 0359 Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); 0360 if (ACPI_FAILURE (Status)) 0361 { 0362 return_ACPI_STATUS (Status); 0363 } 0364 0365 Status = AcpiRsGetPrsMethodData (Node, RetBuffer); 0366 return_ACPI_STATUS (Status); 0367 } 0368 0369 ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources) 0370 0371 0372 /******************************************************************************* 0373 * 0374 * FUNCTION: AcpiSetCurrentResources 0375 * 0376 * PARAMETERS: DeviceHandle - Handle to the device object for the 0377 * device we are setting resources 0378 * InBuffer - Pointer to a buffer containing the 0379 * resources to be set for the device 0380 * 0381 * RETURN: Status 0382 * 0383 * DESCRIPTION: This function is called to set the current resources for a 0384 * specific device. The caller must first acquire a handle for 0385 * the desired device. The resource data is passed to the routine 0386 * the buffer pointed to by the InBuffer variable. 0387 * 0388 ******************************************************************************/ 0389 0390 ACPI_STATUS 0391 AcpiSetCurrentResources ( 0392 ACPI_HANDLE DeviceHandle, 0393 ACPI_BUFFER *InBuffer) 0394 { 0395 ACPI_STATUS Status; 0396 ACPI_NAMESPACE_NODE *Node; 0397 0398 0399 ACPI_FUNCTION_TRACE (AcpiSetCurrentResources); 0400 0401 0402 /* Validate the buffer, don't allow zero length */ 0403 0404 if ((!InBuffer) || 0405 (!InBuffer->Pointer) || 0406 (!InBuffer->Length)) 0407 { 0408 return_ACPI_STATUS (AE_BAD_PARAMETER); 0409 } 0410 0411 /* Validate parameters then dispatch to internal routine */ 0412 0413 Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node); 0414 if (ACPI_FAILURE (Status)) 0415 { 0416 return_ACPI_STATUS (Status); 0417 } 0418 0419 Status = AcpiRsSetSrsMethodData (Node, InBuffer); 0420 return_ACPI_STATUS (Status); 0421 } 0422 0423 ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources) 0424 0425 0426 /****************************************************************************** 0427 * 0428 * FUNCTION: AcpiResourceToAddress64 0429 * 0430 * PARAMETERS: Resource - Pointer to a resource 0431 * Out - Pointer to the users's return buffer 0432 * (a struct acpi_resource_address64) 0433 * 0434 * RETURN: Status 0435 * 0436 * DESCRIPTION: If the resource is an address16, address32, or address64, 0437 * copy it to the address64 return buffer. This saves the 0438 * caller from having to duplicate code for different-sized 0439 * addresses. 0440 * 0441 ******************************************************************************/ 0442 0443 ACPI_STATUS 0444 AcpiResourceToAddress64 ( 0445 ACPI_RESOURCE *Resource, 0446 ACPI_RESOURCE_ADDRESS64 *Out) 0447 { 0448 ACPI_RESOURCE_ADDRESS16 *Address16; 0449 ACPI_RESOURCE_ADDRESS32 *Address32; 0450 0451 0452 if (!Resource || !Out) 0453 { 0454 return (AE_BAD_PARAMETER); 0455 } 0456 0457 /* Convert 16 or 32 address descriptor to 64 */ 0458 0459 switch (Resource->Type) 0460 { 0461 case ACPI_RESOURCE_TYPE_ADDRESS16: 0462 0463 Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); 0464 ACPI_COPY_ADDRESS (Out, Address16); 0465 break; 0466 0467 case ACPI_RESOURCE_TYPE_ADDRESS32: 0468 0469 Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); 0470 ACPI_COPY_ADDRESS (Out, Address32); 0471 break; 0472 0473 case ACPI_RESOURCE_TYPE_ADDRESS64: 0474 0475 /* Simple copy for 64 bit source */ 0476 0477 ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); 0478 break; 0479 0480 default: 0481 return (AE_BAD_PARAMETER); 0482 } 0483 0484 return (AE_OK); 0485 } 0486 0487 ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64) 0488 0489 0490 /******************************************************************************* 0491 * 0492 * FUNCTION: AcpiGetVendorResource 0493 * 0494 * PARAMETERS: DeviceHandle - Handle for the parent device object 0495 * Name - Method name for the parent resource 0496 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 0497 * Uuid - Pointer to the UUID to be matched. 0498 * includes both subtype and 16-byte UUID 0499 * RetBuffer - Where the vendor resource is returned 0500 * 0501 * RETURN: Status 0502 * 0503 * DESCRIPTION: Walk a resource template for the specified evice to find a 0504 * vendor-defined resource that matches the supplied UUID and 0505 * UUID subtype. Returns a ACPI_RESOURCE of type Vendor. 0506 * 0507 ******************************************************************************/ 0508 0509 ACPI_STATUS 0510 AcpiGetVendorResource ( 0511 ACPI_HANDLE DeviceHandle, 0512 char *Name, 0513 ACPI_VENDOR_UUID *Uuid, 0514 ACPI_BUFFER *RetBuffer) 0515 { 0516 ACPI_VENDOR_WALK_INFO Info; 0517 ACPI_STATUS Status; 0518 0519 0520 /* Other parameters are validated by AcpiWalkResources */ 0521 0522 if (!Uuid || !RetBuffer) 0523 { 0524 return (AE_BAD_PARAMETER); 0525 } 0526 0527 Info.Uuid = Uuid; 0528 Info.Buffer = RetBuffer; 0529 Info.Status = AE_NOT_EXIST; 0530 0531 /* Walk the _CRS or _PRS resource list for this device */ 0532 0533 Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource, 0534 &Info); 0535 if (ACPI_FAILURE (Status)) 0536 { 0537 return (Status); 0538 } 0539 0540 return (Info.Status); 0541 } 0542 0543 ACPI_EXPORT_SYMBOL (AcpiGetVendorResource) 0544 0545 0546 /******************************************************************************* 0547 * 0548 * FUNCTION: AcpiRsMatchVendorResource 0549 * 0550 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK 0551 * 0552 * RETURN: Status 0553 * 0554 * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID 0555 * 0556 ******************************************************************************/ 0557 0558 static ACPI_STATUS 0559 AcpiRsMatchVendorResource ( 0560 ACPI_RESOURCE *Resource, 0561 void *Context) 0562 { 0563 ACPI_VENDOR_WALK_INFO *Info = Context; 0564 ACPI_RESOURCE_VENDOR_TYPED *Vendor; 0565 ACPI_BUFFER *Buffer; 0566 ACPI_STATUS Status; 0567 0568 0569 /* Ignore all descriptors except Vendor */ 0570 0571 if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR) 0572 { 0573 return (AE_OK); 0574 } 0575 0576 Vendor = &Resource->Data.VendorTyped; 0577 0578 /* 0579 * For a valid match, these conditions must hold: 0580 * 0581 * 1) Length of descriptor data must be at least as long as a UUID struct 0582 * 2) The UUID subtypes must match 0583 * 3) The UUID data must match 0584 */ 0585 if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) || 0586 (Vendor->UuidSubtype != Info->Uuid->Subtype) || 0587 (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) 0588 { 0589 return (AE_OK); 0590 } 0591 0592 /* Validate/Allocate/Clear caller buffer */ 0593 0594 Buffer = Info->Buffer; 0595 Status = AcpiUtInitializeBuffer (Buffer, Resource->Length); 0596 if (ACPI_FAILURE (Status)) 0597 { 0598 return (Status); 0599 } 0600 0601 /* Found the correct resource, copy and return it */ 0602 0603 ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length); 0604 Buffer->Length = Resource->Length; 0605 0606 /* Found the desired descriptor, terminate resource walk */ 0607 0608 Info->Status = AE_OK; 0609 return (AE_CTRL_TERMINATE); 0610 } 0611 0612 0613 /******************************************************************************* 0614 * 0615 * FUNCTION: AcpiWalkResources 0616 * 0617 * PARAMETERS: DeviceHandle - Handle to the device object for the 0618 * device we are querying 0619 * Name - Method name of the resources we want 0620 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 0621 * UserFunction - Called for each resource 0622 * Context - Passed to UserFunction 0623 * 0624 * RETURN: Status 0625 * 0626 * DESCRIPTION: Retrieves the current or possible resource list for the 0627 * specified device. The UserFunction is called once for 0628 * each resource in the list. 0629 * 0630 ******************************************************************************/ 0631 0632 ACPI_STATUS 0633 AcpiWalkResources ( 0634 ACPI_HANDLE DeviceHandle, 0635 char *Name, 0636 ACPI_WALK_RESOURCE_CALLBACK UserFunction, 0637 void *Context) 0638 { 0639 ACPI_STATUS Status; 0640 ACPI_BUFFER Buffer; 0641 ACPI_RESOURCE *Resource; 0642 ACPI_RESOURCE *ResourceEnd; 0643 0644 0645 ACPI_FUNCTION_TRACE (AcpiWalkResources); 0646 0647 0648 /* Parameter validation */ 0649 0650 if (!DeviceHandle || !UserFunction || !Name || 0651 (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) && 0652 !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS))) 0653 { 0654 return_ACPI_STATUS (AE_BAD_PARAMETER); 0655 } 0656 0657 /* Get the _CRS or _PRS resource list */ 0658 0659 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 0660 Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); 0661 if (ACPI_FAILURE (Status)) 0662 { 0663 return_ACPI_STATUS (Status); 0664 } 0665 0666 /* Buffer now contains the resource list */ 0667 0668 Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); 0669 ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); 0670 0671 /* Walk the resource list until the EndTag is found (or buffer end) */ 0672 0673 while (Resource < ResourceEnd) 0674 { 0675 /* Sanity check the resource */ 0676 0677 if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) 0678 { 0679 Status = AE_AML_INVALID_RESOURCE_TYPE; 0680 break; 0681 } 0682 0683 /* Invoke the user function, abort on any error returned */ 0684 0685 Status = UserFunction (Resource, Context); 0686 if (ACPI_FAILURE (Status)) 0687 { 0688 if (Status == AE_CTRL_TERMINATE) 0689 { 0690 /* This is an OK termination by the user function */ 0691 0692 Status = AE_OK; 0693 } 0694 break; 0695 } 0696 0697 /* EndTag indicates end-of-list */ 0698 0699 if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) 0700 { 0701 break; 0702 } 0703 0704 /* Get the next resource descriptor */ 0705 0706 Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); 0707 } 0708 0709 ACPI_FREE (Buffer.Pointer); 0710 return_ACPI_STATUS (Status); 0711 } 0712 0713 ACPI_EXPORT_SYMBOL (AcpiWalkResources)
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |