Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrsxface.c
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * 00003 * Module Name: rsxface - Public interfaces to the resource manager 00004 * 00005 ******************************************************************************/ 00006 00007 /****************************************************************************** 00008 * 00009 * 1. Copyright Notice 00010 * 00011 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00012 * All rights reserved. 00013 * 00014 * 2. License 00015 * 00016 * 2.1. This is your license from Intel Corp. under its intellectual property 00017 * rights. You may have additional license terms from the party that provided 00018 * you this software, covering your right to use that party's intellectual 00019 * property rights. 00020 * 00021 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00022 * copy of the source code appearing in this file ("Covered Code") an 00023 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00024 * base code distributed originally by Intel ("Original Intel Code") to copy, 00025 * make derivatives, distribute, use and display any portion of the Covered 00026 * Code in any form, with the right to sublicense such rights; and 00027 * 00028 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00029 * license (with the right to sublicense), under only those claims of Intel 00030 * patents that are infringed by the Original Intel Code, to make, use, sell, 00031 * offer to sell, and import the Covered Code and derivative works thereof 00032 * solely to the minimum extent necessary to exercise the above copyright 00033 * license, and in no event shall the patent license extend to any additions 00034 * to or modifications of the Original Intel Code. No other license or right 00035 * is granted directly or by implication, estoppel or otherwise; 00036 * 00037 * The above copyright and patent license is granted only if the following 00038 * conditions are met: 00039 * 00040 * 3. Conditions 00041 * 00042 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00043 * Redistribution of source code of any substantial portion of the Covered 00044 * Code or modification with rights to further distribute source must include 00045 * the above Copyright Notice, the above License, this list of Conditions, 00046 * and the following Disclaimer and Export Compliance provision. In addition, 00047 * Licensee must cause all Covered Code to which Licensee contributes to 00048 * contain a file documenting the changes Licensee made to create that Covered 00049 * Code and the date of any change. Licensee must include in that file the 00050 * documentation of any changes made by any predecessor Licensee. Licensee 00051 * must include a prominent statement that the modification is derived, 00052 * directly or indirectly, from Original Intel Code. 00053 * 00054 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00055 * Redistribution of source code of any substantial portion of the Covered 00056 * Code or modification without rights to further distribute source must 00057 * include the following Disclaimer and Export Compliance provision in the 00058 * documentation and/or other materials provided with distribution. In 00059 * addition, Licensee may not authorize further sublicense of source of any 00060 * portion of the Covered Code, and must include terms to the effect that the 00061 * license from Licensee to its licensee is limited to the intellectual 00062 * property embodied in the software Licensee provides to its licensee, and 00063 * not to intellectual property embodied in modifications its licensee may 00064 * make. 00065 * 00066 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00067 * substantial portion of the Covered Code or modification must reproduce the 00068 * above Copyright Notice, and the following Disclaimer and Export Compliance 00069 * provision in the documentation and/or other materials provided with the 00070 * distribution. 00071 * 00072 * 3.4. Intel retains all right, title, and interest in and to the Original 00073 * Intel Code. 00074 * 00075 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00076 * Intel shall be used in advertising or otherwise to promote the sale, use or 00077 * other dealings in products derived from or relating to the Covered Code 00078 * without prior written authorization from Intel. 00079 * 00080 * 4. Disclaimer and Export Compliance 00081 * 00082 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00083 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00084 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00085 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00086 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00087 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00088 * PARTICULAR PURPOSE. 00089 * 00090 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00091 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00092 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00093 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00094 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00095 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00096 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00097 * LIMITED REMEDY. 00098 * 00099 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00100 * software or system incorporating such software without first obtaining any 00101 * required license or other approval from the U. S. Department of Commerce or 00102 * any other agency or department of the United States Government. In the 00103 * event Licensee exports any such software from the United States or 00104 * re-exports any such software from a foreign destination, Licensee shall 00105 * ensure that the distribution and export/re-export of the software is in 00106 * compliance with all laws, regulations, orders, or other restrictions of the 00107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00108 * any of its subsidiaries will export/re-export any technical data, process, 00109 * software, or service, directly or indirectly, to any country for which the 00110 * United States government or any agency thereof requires an export license, 00111 * other governmental approval, or letter of assurance, without first obtaining 00112 * such license, approval or letter. 00113 * 00114 *****************************************************************************/ 00115 00116 00117 #define __RSXFACE_C__ 00118 00119 #include "acpi.h" 00120 #include "accommon.h" 00121 #include "acresrc.h" 00122 #include "acnamesp.h" 00123 00124 #define _COMPONENT ACPI_RESOURCES 00125 ACPI_MODULE_NAME ("rsxface") 00126 00127 /* Local macros for 16,32-bit to 64-bit conversion */ 00128 00129 #define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) 00130 #define ACPI_COPY_ADDRESS(Out, In) \ 00131 ACPI_COPY_FIELD(Out, In, ResourceType); \ 00132 ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ 00133 ACPI_COPY_FIELD(Out, In, Decode); \ 00134 ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ 00135 ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ 00136 ACPI_COPY_FIELD(Out, In, Info); \ 00137 ACPI_COPY_FIELD(Out, In, Granularity); \ 00138 ACPI_COPY_FIELD(Out, In, Minimum); \ 00139 ACPI_COPY_FIELD(Out, In, Maximum); \ 00140 ACPI_COPY_FIELD(Out, In, TranslationOffset); \ 00141 ACPI_COPY_FIELD(Out, In, AddressLength); \ 00142 ACPI_COPY_FIELD(Out, In, ResourceSource); 00143 00144 00145 /* Local prototypes */ 00146 00147 static ACPI_STATUS 00148 AcpiRsMatchVendorResource ( 00149 ACPI_RESOURCE *Resource, 00150 void *Context); 00151 00152 static ACPI_STATUS 00153 AcpiRsValidateParameters ( 00154 ACPI_HANDLE DeviceHandle, 00155 ACPI_BUFFER *Buffer, 00156 ACPI_NAMESPACE_NODE **ReturnNode); 00157 00158 00159 /******************************************************************************* 00160 * 00161 * FUNCTION: AcpiRsValidateParameters 00162 * 00163 * PARAMETERS: DeviceHandle - Handle to a device 00164 * Buffer - Pointer to a data buffer 00165 * ReturnNode - Pointer to where the device node is returned 00166 * 00167 * RETURN: Status 00168 * 00169 * DESCRIPTION: Common parameter validation for resource interfaces 00170 * 00171 ******************************************************************************/ 00172 00173 static ACPI_STATUS 00174 AcpiRsValidateParameters ( 00175 ACPI_HANDLE DeviceHandle, 00176 ACPI_BUFFER *Buffer, 00177 ACPI_NAMESPACE_NODE **ReturnNode) 00178 { 00179 ACPI_STATUS Status; 00180 ACPI_NAMESPACE_NODE *Node; 00181 00182 00183 ACPI_FUNCTION_TRACE (RsValidateParameters); 00184 00185 00186 /* 00187 * Must have a valid handle to an ACPI device 00188 */ 00189 if (!DeviceHandle) 00190 { 00191 return_ACPI_STATUS (AE_BAD_PARAMETER); 00192 } 00193 00194 Node = AcpiNsValidateHandle (DeviceHandle); 00195 if (!Node) 00196 { 00197 return_ACPI_STATUS (AE_BAD_PARAMETER); 00198 } 00199 00200 if (Node->Type != ACPI_TYPE_DEVICE) 00201 { 00202 return_ACPI_STATUS (AE_TYPE); 00203 } 00204 00205 /* 00206 * Validate the user buffer object 00207 * 00208 * if there is a non-zero buffer length we also need a valid pointer in 00209 * the buffer. If it's a zero buffer length, we'll be returning the 00210 * needed buffer size (later), so keep going. 00211 */ 00212 Status = AcpiUtValidateBuffer (Buffer); 00213 if (ACPI_FAILURE (Status)) 00214 { 00215 return_ACPI_STATUS (Status); 00216 } 00217 00218 *ReturnNode = Node; 00219 return_ACPI_STATUS (AE_OK); 00220 } 00221 00222 00223 /******************************************************************************* 00224 * 00225 * FUNCTION: AcpiGetIrqRoutingTable 00226 * 00227 * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying 00228 * RetBuffer - Pointer to a buffer to receive the 00229 * current resources for the device 00230 * 00231 * RETURN: Status 00232 * 00233 * DESCRIPTION: This function is called to get the IRQ routing table for a 00234 * specific bus. The caller must first acquire a handle for the 00235 * desired bus. The routine table is placed in the buffer pointed 00236 * to by the RetBuffer variable parameter. 00237 * 00238 * If the function fails an appropriate status will be returned 00239 * and the value of RetBuffer is undefined. 00240 * 00241 * This function attempts to execute the _PRT method contained in 00242 * the object indicated by the passed DeviceHandle. 00243 * 00244 ******************************************************************************/ 00245 00246 ACPI_STATUS 00247 AcpiGetIrqRoutingTable ( 00248 ACPI_HANDLE DeviceHandle, 00249 ACPI_BUFFER *RetBuffer) 00250 { 00251 ACPI_STATUS Status; 00252 ACPI_NAMESPACE_NODE *Node; 00253 00254 00255 ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable); 00256 00257 00258 /* Validate parameters then dispatch to internal routine */ 00259 00260 Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); 00261 if (ACPI_FAILURE (Status)) 00262 { 00263 return_ACPI_STATUS (Status); 00264 } 00265 00266 Status = AcpiRsGetPrtMethodData (Node, RetBuffer); 00267 return_ACPI_STATUS (Status); 00268 } 00269 00270 ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable) 00271 00272 00273 /******************************************************************************* 00274 * 00275 * FUNCTION: AcpiGetCurrentResources 00276 * 00277 * PARAMETERS: DeviceHandle - Handle to the device object for the 00278 * device we are querying 00279 * RetBuffer - Pointer to a buffer to receive the 00280 * current resources for the device 00281 * 00282 * RETURN: Status 00283 * 00284 * DESCRIPTION: This function is called to get the current resources for a 00285 * specific device. The caller must first acquire a handle for 00286 * the desired device. The resource data is placed in the buffer 00287 * pointed to by the RetBuffer variable parameter. 00288 * 00289 * If the function fails an appropriate status will be returned 00290 * and the value of RetBuffer is undefined. 00291 * 00292 * This function attempts to execute the _CRS method contained in 00293 * the object indicated by the passed DeviceHandle. 00294 * 00295 ******************************************************************************/ 00296 00297 ACPI_STATUS 00298 AcpiGetCurrentResources ( 00299 ACPI_HANDLE DeviceHandle, 00300 ACPI_BUFFER *RetBuffer) 00301 { 00302 ACPI_STATUS Status; 00303 ACPI_NAMESPACE_NODE *Node; 00304 00305 00306 ACPI_FUNCTION_TRACE (AcpiGetCurrentResources); 00307 00308 00309 /* Validate parameters then dispatch to internal routine */ 00310 00311 Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); 00312 if (ACPI_FAILURE (Status)) 00313 { 00314 return_ACPI_STATUS (Status); 00315 } 00316 00317 Status = AcpiRsGetCrsMethodData (Node, RetBuffer); 00318 return_ACPI_STATUS (Status); 00319 } 00320 00321 ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources) 00322 00323 00324 /******************************************************************************* 00325 * 00326 * FUNCTION: AcpiGetPossibleResources 00327 * 00328 * PARAMETERS: DeviceHandle - Handle to the device object for the 00329 * device we are querying 00330 * RetBuffer - Pointer to a buffer to receive the 00331 * resources for the device 00332 * 00333 * RETURN: Status 00334 * 00335 * DESCRIPTION: This function is called to get a list of the possible resources 00336 * for a specific device. The caller must first acquire a handle 00337 * for the desired device. The resource data is placed in the 00338 * buffer pointed to by the RetBuffer variable. 00339 * 00340 * If the function fails an appropriate status will be returned 00341 * and the value of RetBuffer is undefined. 00342 * 00343 ******************************************************************************/ 00344 00345 ACPI_STATUS 00346 AcpiGetPossibleResources ( 00347 ACPI_HANDLE DeviceHandle, 00348 ACPI_BUFFER *RetBuffer) 00349 { 00350 ACPI_STATUS Status; 00351 ACPI_NAMESPACE_NODE *Node; 00352 00353 00354 ACPI_FUNCTION_TRACE (AcpiGetPossibleResources); 00355 00356 00357 /* Validate parameters then dispatch to internal routine */ 00358 00359 Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); 00360 if (ACPI_FAILURE (Status)) 00361 { 00362 return_ACPI_STATUS (Status); 00363 } 00364 00365 Status = AcpiRsGetPrsMethodData (Node, RetBuffer); 00366 return_ACPI_STATUS (Status); 00367 } 00368 00369 ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources) 00370 00371 00372 /******************************************************************************* 00373 * 00374 * FUNCTION: AcpiSetCurrentResources 00375 * 00376 * PARAMETERS: DeviceHandle - Handle to the device object for the 00377 * device we are setting resources 00378 * InBuffer - Pointer to a buffer containing the 00379 * resources to be set for the device 00380 * 00381 * RETURN: Status 00382 * 00383 * DESCRIPTION: This function is called to set the current resources for a 00384 * specific device. The caller must first acquire a handle for 00385 * the desired device. The resource data is passed to the routine 00386 * the buffer pointed to by the InBuffer variable. 00387 * 00388 ******************************************************************************/ 00389 00390 ACPI_STATUS 00391 AcpiSetCurrentResources ( 00392 ACPI_HANDLE DeviceHandle, 00393 ACPI_BUFFER *InBuffer) 00394 { 00395 ACPI_STATUS Status; 00396 ACPI_NAMESPACE_NODE *Node; 00397 00398 00399 ACPI_FUNCTION_TRACE (AcpiSetCurrentResources); 00400 00401 00402 /* Validate the buffer, don't allow zero length */ 00403 00404 if ((!InBuffer) || 00405 (!InBuffer->Pointer) || 00406 (!InBuffer->Length)) 00407 { 00408 return_ACPI_STATUS (AE_BAD_PARAMETER); 00409 } 00410 00411 /* Validate parameters then dispatch to internal routine */ 00412 00413 Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node); 00414 if (ACPI_FAILURE (Status)) 00415 { 00416 return_ACPI_STATUS (Status); 00417 } 00418 00419 Status = AcpiRsSetSrsMethodData (Node, InBuffer); 00420 return_ACPI_STATUS (Status); 00421 } 00422 00423 ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources) 00424 00425 00426 /****************************************************************************** 00427 * 00428 * FUNCTION: AcpiResourceToAddress64 00429 * 00430 * PARAMETERS: Resource - Pointer to a resource 00431 * Out - Pointer to the users's return buffer 00432 * (a struct acpi_resource_address64) 00433 * 00434 * RETURN: Status 00435 * 00436 * DESCRIPTION: If the resource is an address16, address32, or address64, 00437 * copy it to the address64 return buffer. This saves the 00438 * caller from having to duplicate code for different-sized 00439 * addresses. 00440 * 00441 ******************************************************************************/ 00442 00443 ACPI_STATUS 00444 AcpiResourceToAddress64 ( 00445 ACPI_RESOURCE *Resource, 00446 ACPI_RESOURCE_ADDRESS64 *Out) 00447 { 00448 ACPI_RESOURCE_ADDRESS16 *Address16; 00449 ACPI_RESOURCE_ADDRESS32 *Address32; 00450 00451 00452 if (!Resource || !Out) 00453 { 00454 return (AE_BAD_PARAMETER); 00455 } 00456 00457 /* Convert 16 or 32 address descriptor to 64 */ 00458 00459 switch (Resource->Type) 00460 { 00461 case ACPI_RESOURCE_TYPE_ADDRESS16: 00462 00463 Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); 00464 ACPI_COPY_ADDRESS (Out, Address16); 00465 break; 00466 00467 case ACPI_RESOURCE_TYPE_ADDRESS32: 00468 00469 Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); 00470 ACPI_COPY_ADDRESS (Out, Address32); 00471 break; 00472 00473 case ACPI_RESOURCE_TYPE_ADDRESS64: 00474 00475 /* Simple copy for 64 bit source */ 00476 00477 ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); 00478 break; 00479 00480 default: 00481 return (AE_BAD_PARAMETER); 00482 } 00483 00484 return (AE_OK); 00485 } 00486 00487 ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64) 00488 00489 00490 /******************************************************************************* 00491 * 00492 * FUNCTION: AcpiGetVendorResource 00493 * 00494 * PARAMETERS: DeviceHandle - Handle for the parent device object 00495 * Name - Method name for the parent resource 00496 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 00497 * Uuid - Pointer to the UUID to be matched. 00498 * includes both subtype and 16-byte UUID 00499 * RetBuffer - Where the vendor resource is returned 00500 * 00501 * RETURN: Status 00502 * 00503 * DESCRIPTION: Walk a resource template for the specified evice to find a 00504 * vendor-defined resource that matches the supplied UUID and 00505 * UUID subtype. Returns a ACPI_RESOURCE of type Vendor. 00506 * 00507 ******************************************************************************/ 00508 00509 ACPI_STATUS 00510 AcpiGetVendorResource ( 00511 ACPI_HANDLE DeviceHandle, 00512 char *Name, 00513 ACPI_VENDOR_UUID *Uuid, 00514 ACPI_BUFFER *RetBuffer) 00515 { 00516 ACPI_VENDOR_WALK_INFO Info; 00517 ACPI_STATUS Status; 00518 00519 00520 /* Other parameters are validated by AcpiWalkResources */ 00521 00522 if (!Uuid || !RetBuffer) 00523 { 00524 return (AE_BAD_PARAMETER); 00525 } 00526 00527 Info.Uuid = Uuid; 00528 Info.Buffer = RetBuffer; 00529 Info.Status = AE_NOT_EXIST; 00530 00531 /* Walk the _CRS or _PRS resource list for this device */ 00532 00533 Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource, 00534 &Info); 00535 if (ACPI_FAILURE (Status)) 00536 { 00537 return (Status); 00538 } 00539 00540 return (Info.Status); 00541 } 00542 00543 ACPI_EXPORT_SYMBOL (AcpiGetVendorResource) 00544 00545 00546 /******************************************************************************* 00547 * 00548 * FUNCTION: AcpiRsMatchVendorResource 00549 * 00550 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK 00551 * 00552 * RETURN: Status 00553 * 00554 * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID 00555 * 00556 ******************************************************************************/ 00557 00558 static ACPI_STATUS 00559 AcpiRsMatchVendorResource ( 00560 ACPI_RESOURCE *Resource, 00561 void *Context) 00562 { 00563 ACPI_VENDOR_WALK_INFO *Info = Context; 00564 ACPI_RESOURCE_VENDOR_TYPED *Vendor; 00565 ACPI_BUFFER *Buffer; 00566 ACPI_STATUS Status; 00567 00568 00569 /* Ignore all descriptors except Vendor */ 00570 00571 if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR) 00572 { 00573 return (AE_OK); 00574 } 00575 00576 Vendor = &Resource->Data.VendorTyped; 00577 00578 /* 00579 * For a valid match, these conditions must hold: 00580 * 00581 * 1) Length of descriptor data must be at least as long as a UUID struct 00582 * 2) The UUID subtypes must match 00583 * 3) The UUID data must match 00584 */ 00585 if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) || 00586 (Vendor->UuidSubtype != Info->Uuid->Subtype) || 00587 (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) 00588 { 00589 return (AE_OK); 00590 } 00591 00592 /* Validate/Allocate/Clear caller buffer */ 00593 00594 Buffer = Info->Buffer; 00595 Status = AcpiUtInitializeBuffer (Buffer, Resource->Length); 00596 if (ACPI_FAILURE (Status)) 00597 { 00598 return (Status); 00599 } 00600 00601 /* Found the correct resource, copy and return it */ 00602 00603 ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length); 00604 Buffer->Length = Resource->Length; 00605 00606 /* Found the desired descriptor, terminate resource walk */ 00607 00608 Info->Status = AE_OK; 00609 return (AE_CTRL_TERMINATE); 00610 } 00611 00612 00613 /******************************************************************************* 00614 * 00615 * FUNCTION: AcpiWalkResources 00616 * 00617 * PARAMETERS: DeviceHandle - Handle to the device object for the 00618 * device we are querying 00619 * Name - Method name of the resources we want 00620 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 00621 * UserFunction - Called for each resource 00622 * Context - Passed to UserFunction 00623 * 00624 * RETURN: Status 00625 * 00626 * DESCRIPTION: Retrieves the current or possible resource list for the 00627 * specified device. The UserFunction is called once for 00628 * each resource in the list. 00629 * 00630 ******************************************************************************/ 00631 00632 ACPI_STATUS 00633 AcpiWalkResources ( 00634 ACPI_HANDLE DeviceHandle, 00635 char *Name, 00636 ACPI_WALK_RESOURCE_CALLBACK UserFunction, 00637 void *Context) 00638 { 00639 ACPI_STATUS Status; 00640 ACPI_BUFFER Buffer; 00641 ACPI_RESOURCE *Resource; 00642 ACPI_RESOURCE *ResourceEnd; 00643 00644 00645 ACPI_FUNCTION_TRACE (AcpiWalkResources); 00646 00647 00648 /* Parameter validation */ 00649 00650 if (!DeviceHandle || !UserFunction || !Name || 00651 (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) && 00652 !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS))) 00653 { 00654 return_ACPI_STATUS (AE_BAD_PARAMETER); 00655 } 00656 00657 /* Get the _CRS or _PRS resource list */ 00658 00659 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 00660 Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); 00661 if (ACPI_FAILURE (Status)) 00662 { 00663 return_ACPI_STATUS (Status); 00664 } 00665 00666 /* Buffer now contains the resource list */ 00667 00668 Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); 00669 ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); 00670 00671 /* Walk the resource list until the EndTag is found (or buffer end) */ 00672 00673 while (Resource < ResourceEnd) 00674 { 00675 /* Sanity check the resource */ 00676 00677 if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) 00678 { 00679 Status = AE_AML_INVALID_RESOURCE_TYPE; 00680 break; 00681 } 00682 00683 /* Invoke the user function, abort on any error returned */ 00684 00685 Status = UserFunction (Resource, Context); 00686 if (ACPI_FAILURE (Status)) 00687 { 00688 if (Status == AE_CTRL_TERMINATE) 00689 { 00690 /* This is an OK termination by the user function */ 00691 00692 Status = AE_OK; 00693 } 00694 break; 00695 } 00696 00697 /* EndTag indicates end-of-list */ 00698 00699 if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) 00700 { 00701 break; 00702 } 00703 00704 /* Get the next resource descriptor */ 00705 00706 Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); 00707 } 00708 00709 ACPI_FREE (Buffer.Pointer); 00710 return_ACPI_STATUS (Status); 00711 } 00712 00713 ACPI_EXPORT_SYMBOL (AcpiWalkResources) Generated on Sun May 27 2012 04:27:22 for ReactOS by
1.7.6.1
|