xref: /freebsd/sys/contrib/dev/acpica/components/resources/rsxface.c (revision f5f7c05209ca2c3748fd8b27c5e80ffad49120eb)
1 /*******************************************************************************
2  *
3  * Module Name: rsxface - Public interfaces to the resource manager
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2013, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 
45 #define __RSXFACE_C__
46 
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acresrc.h>
50 #include <contrib/dev/acpica/include/acnamesp.h>
51 
52 #define _COMPONENT          ACPI_RESOURCES
53         ACPI_MODULE_NAME    ("rsxface")
54 
55 /* Local macros for 16,32-bit to 64-bit conversion */
56 
57 #define ACPI_COPY_FIELD(Out, In, Field)  ((Out)->Field = (In)->Field)
58 #define ACPI_COPY_ADDRESS(Out, In)                      \
59     ACPI_COPY_FIELD(Out, In, ResourceType);              \
60     ACPI_COPY_FIELD(Out, In, ProducerConsumer);          \
61     ACPI_COPY_FIELD(Out, In, Decode);                    \
62     ACPI_COPY_FIELD(Out, In, MinAddressFixed);           \
63     ACPI_COPY_FIELD(Out, In, MaxAddressFixed);           \
64     ACPI_COPY_FIELD(Out, In, Info);                      \
65     ACPI_COPY_FIELD(Out, In, Granularity);               \
66     ACPI_COPY_FIELD(Out, In, Minimum);                   \
67     ACPI_COPY_FIELD(Out, In, Maximum);                   \
68     ACPI_COPY_FIELD(Out, In, TranslationOffset);         \
69     ACPI_COPY_FIELD(Out, In, AddressLength);             \
70     ACPI_COPY_FIELD(Out, In, ResourceSource);
71 
72 
73 /* Local prototypes */
74 
75 static ACPI_STATUS
76 AcpiRsMatchVendorResource (
77     ACPI_RESOURCE           *Resource,
78     void                    *Context);
79 
80 static ACPI_STATUS
81 AcpiRsValidateParameters (
82     ACPI_HANDLE             DeviceHandle,
83     ACPI_BUFFER             *Buffer,
84     ACPI_NAMESPACE_NODE     **ReturnNode);
85 
86 
87 /*******************************************************************************
88  *
89  * FUNCTION:    AcpiRsValidateParameters
90  *
91  * PARAMETERS:  DeviceHandle    - Handle to a device
92  *              Buffer          - Pointer to a data buffer
93  *              ReturnNode      - Pointer to where the device node is returned
94  *
95  * RETURN:      Status
96  *
97  * DESCRIPTION: Common parameter validation for resource interfaces
98  *
99  ******************************************************************************/
100 
101 static ACPI_STATUS
102 AcpiRsValidateParameters (
103     ACPI_HANDLE             DeviceHandle,
104     ACPI_BUFFER             *Buffer,
105     ACPI_NAMESPACE_NODE     **ReturnNode)
106 {
107     ACPI_STATUS             Status;
108     ACPI_NAMESPACE_NODE     *Node;
109 
110 
111     ACPI_FUNCTION_TRACE (RsValidateParameters);
112 
113 
114     /*
115      * Must have a valid handle to an ACPI device
116      */
117     if (!DeviceHandle)
118     {
119         return_ACPI_STATUS (AE_BAD_PARAMETER);
120     }
121 
122     Node = AcpiNsValidateHandle (DeviceHandle);
123     if (!Node)
124     {
125         return_ACPI_STATUS (AE_BAD_PARAMETER);
126     }
127 
128     if (Node->Type != ACPI_TYPE_DEVICE)
129     {
130         return_ACPI_STATUS (AE_TYPE);
131     }
132 
133     /*
134      * Validate the user buffer object
135      *
136      * if there is a non-zero buffer length we also need a valid pointer in
137      * the buffer. If it's a zero buffer length, we'll be returning the
138      * needed buffer size (later), so keep going.
139      */
140     Status = AcpiUtValidateBuffer (Buffer);
141     if (ACPI_FAILURE (Status))
142     {
143         return_ACPI_STATUS (Status);
144     }
145 
146     *ReturnNode = Node;
147     return_ACPI_STATUS (AE_OK);
148 }
149 
150 
151 /*******************************************************************************
152  *
153  * FUNCTION:    AcpiGetIrqRoutingTable
154  *
155  * PARAMETERS:  DeviceHandle    - Handle to the Bus device we are querying
156  *              RetBuffer       - Pointer to a buffer to receive the
157  *                                current resources for the device
158  *
159  * RETURN:      Status
160  *
161  * DESCRIPTION: This function is called to get the IRQ routing table for a
162  *              specific bus. The caller must first acquire a handle for the
163  *              desired bus. The routine table is placed in the buffer pointed
164  *              to by the RetBuffer variable parameter.
165  *
166  *              If the function fails an appropriate status will be returned
167  *              and the value of RetBuffer is undefined.
168  *
169  *              This function attempts to execute the _PRT method contained in
170  *              the object indicated by the passed DeviceHandle.
171  *
172  ******************************************************************************/
173 
174 ACPI_STATUS
175 AcpiGetIrqRoutingTable  (
176     ACPI_HANDLE             DeviceHandle,
177     ACPI_BUFFER             *RetBuffer)
178 {
179     ACPI_STATUS             Status;
180     ACPI_NAMESPACE_NODE     *Node;
181 
182 
183     ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
184 
185 
186     /* Validate parameters then dispatch to internal routine */
187 
188     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
189     if (ACPI_FAILURE (Status))
190     {
191         return_ACPI_STATUS (Status);
192     }
193 
194     Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
195     return_ACPI_STATUS (Status);
196 }
197 
198 ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
199 
200 
201 /*******************************************************************************
202  *
203  * FUNCTION:    AcpiGetCurrentResources
204  *
205  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
206  *                                device we are querying
207  *              RetBuffer       - Pointer to a buffer to receive the
208  *                                current resources for the device
209  *
210  * RETURN:      Status
211  *
212  * DESCRIPTION: This function is called to get the current resources for a
213  *              specific device. The caller must first acquire a handle for
214  *              the desired device. The resource data is placed in the buffer
215  *              pointed to by the RetBuffer variable parameter.
216  *
217  *              If the function fails an appropriate status will be returned
218  *              and the value of RetBuffer is undefined.
219  *
220  *              This function attempts to execute the _CRS method contained in
221  *              the object indicated by the passed DeviceHandle.
222  *
223  ******************************************************************************/
224 
225 ACPI_STATUS
226 AcpiGetCurrentResources (
227     ACPI_HANDLE             DeviceHandle,
228     ACPI_BUFFER             *RetBuffer)
229 {
230     ACPI_STATUS             Status;
231     ACPI_NAMESPACE_NODE     *Node;
232 
233 
234     ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
235 
236 
237     /* Validate parameters then dispatch to internal routine */
238 
239     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
240     if (ACPI_FAILURE (Status))
241     {
242         return_ACPI_STATUS (Status);
243     }
244 
245     Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
246     return_ACPI_STATUS (Status);
247 }
248 
249 ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
250 
251 
252 /*******************************************************************************
253  *
254  * FUNCTION:    AcpiGetPossibleResources
255  *
256  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
257  *                                device we are querying
258  *              RetBuffer       - Pointer to a buffer to receive the
259  *                                resources for the device
260  *
261  * RETURN:      Status
262  *
263  * DESCRIPTION: This function is called to get a list of the possible resources
264  *              for a specific device. The caller must first acquire a handle
265  *              for the desired device. The resource data is placed in the
266  *              buffer pointed to by the RetBuffer variable.
267  *
268  *              If the function fails an appropriate status will be returned
269  *              and the value of RetBuffer is undefined.
270  *
271  ******************************************************************************/
272 
273 ACPI_STATUS
274 AcpiGetPossibleResources (
275     ACPI_HANDLE             DeviceHandle,
276     ACPI_BUFFER             *RetBuffer)
277 {
278     ACPI_STATUS             Status;
279     ACPI_NAMESPACE_NODE     *Node;
280 
281 
282     ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
283 
284 
285     /* Validate parameters then dispatch to internal routine */
286 
287     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
288     if (ACPI_FAILURE (Status))
289     {
290         return_ACPI_STATUS (Status);
291     }
292 
293     Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
294     return_ACPI_STATUS (Status);
295 }
296 
297 ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
298 
299 
300 /*******************************************************************************
301  *
302  * FUNCTION:    AcpiSetCurrentResources
303  *
304  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
305  *                                device we are setting resources
306  *              InBuffer        - Pointer to a buffer containing the
307  *                                resources to be set for the device
308  *
309  * RETURN:      Status
310  *
311  * DESCRIPTION: This function is called to set the current resources for a
312  *              specific device. The caller must first acquire a handle for
313  *              the desired device. The resource data is passed to the routine
314  *              the buffer pointed to by the InBuffer variable.
315  *
316  ******************************************************************************/
317 
318 ACPI_STATUS
319 AcpiSetCurrentResources (
320     ACPI_HANDLE             DeviceHandle,
321     ACPI_BUFFER             *InBuffer)
322 {
323     ACPI_STATUS             Status;
324     ACPI_NAMESPACE_NODE     *Node;
325 
326 
327     ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
328 
329 
330     /* Validate the buffer, don't allow zero length */
331 
332     if ((!InBuffer) ||
333         (!InBuffer->Pointer) ||
334         (!InBuffer->Length))
335     {
336         return_ACPI_STATUS (AE_BAD_PARAMETER);
337     }
338 
339     /* Validate parameters then dispatch to internal routine */
340 
341     Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
342     if (ACPI_FAILURE (Status))
343     {
344         return_ACPI_STATUS (Status);
345     }
346 
347     Status = AcpiRsSetSrsMethodData (Node, InBuffer);
348     return_ACPI_STATUS (Status);
349 }
350 
351 ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
352 
353 
354 /*******************************************************************************
355  *
356  * FUNCTION:    AcpiGetEventResources
357  *
358  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
359  *                                device we are getting resources
360  *              InBuffer        - Pointer to a buffer containing the
361  *                                resources to be set for the device
362  *
363  * RETURN:      Status
364  *
365  * DESCRIPTION: This function is called to get the event resources for a
366  *              specific device. The caller must first acquire a handle for
367  *              the desired device. The resource data is passed to the routine
368  *              the buffer pointed to by the InBuffer variable. Uses the
369  *              _AEI method.
370  *
371  ******************************************************************************/
372 
373 ACPI_STATUS
374 AcpiGetEventResources (
375     ACPI_HANDLE             DeviceHandle,
376     ACPI_BUFFER             *RetBuffer)
377 {
378     ACPI_STATUS             Status;
379     ACPI_NAMESPACE_NODE     *Node;
380 
381 
382     ACPI_FUNCTION_TRACE (AcpiGetEventResources);
383 
384 
385     /* Validate parameters then dispatch to internal routine */
386 
387     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
388     if (ACPI_FAILURE (Status))
389     {
390         return_ACPI_STATUS (Status);
391     }
392 
393     Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
394     return_ACPI_STATUS (Status);
395 }
396 
397 ACPI_EXPORT_SYMBOL (AcpiGetEventResources)
398 
399 
400 /******************************************************************************
401  *
402  * FUNCTION:    AcpiResourceToAddress64
403  *
404  * PARAMETERS:  Resource        - Pointer to a resource
405  *              Out             - Pointer to the users's return buffer
406  *                                (a struct acpi_resource_address64)
407  *
408  * RETURN:      Status
409  *
410  * DESCRIPTION: If the resource is an address16, address32, or address64,
411  *              copy it to the address64 return buffer. This saves the
412  *              caller from having to duplicate code for different-sized
413  *              addresses.
414  *
415  ******************************************************************************/
416 
417 ACPI_STATUS
418 AcpiResourceToAddress64 (
419     ACPI_RESOURCE               *Resource,
420     ACPI_RESOURCE_ADDRESS64     *Out)
421 {
422     ACPI_RESOURCE_ADDRESS16     *Address16;
423     ACPI_RESOURCE_ADDRESS32     *Address32;
424 
425 
426     if (!Resource || !Out)
427     {
428         return (AE_BAD_PARAMETER);
429     }
430 
431     /* Convert 16 or 32 address descriptor to 64 */
432 
433     switch (Resource->Type)
434     {
435     case ACPI_RESOURCE_TYPE_ADDRESS16:
436 
437         Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data);
438         ACPI_COPY_ADDRESS (Out, Address16);
439         break;
440 
441     case ACPI_RESOURCE_TYPE_ADDRESS32:
442 
443         Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data);
444         ACPI_COPY_ADDRESS (Out, Address32);
445         break;
446 
447     case ACPI_RESOURCE_TYPE_ADDRESS64:
448 
449         /* Simple copy for 64 bit source */
450 
451         ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
452         break;
453 
454     default:
455         return (AE_BAD_PARAMETER);
456     }
457 
458     return (AE_OK);
459 }
460 
461 ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
462 
463 
464 /*******************************************************************************
465  *
466  * FUNCTION:    AcpiGetVendorResource
467  *
468  * PARAMETERS:  DeviceHandle    - Handle for the parent device object
469  *              Name            - Method name for the parent resource
470  *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
471  *              Uuid            - Pointer to the UUID to be matched.
472  *                                includes both subtype and 16-byte UUID
473  *              RetBuffer       - Where the vendor resource is returned
474  *
475  * RETURN:      Status
476  *
477  * DESCRIPTION: Walk a resource template for the specified device to find a
478  *              vendor-defined resource that matches the supplied UUID and
479  *              UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
480  *
481  ******************************************************************************/
482 
483 ACPI_STATUS
484 AcpiGetVendorResource (
485     ACPI_HANDLE             DeviceHandle,
486     char                    *Name,
487     ACPI_VENDOR_UUID        *Uuid,
488     ACPI_BUFFER             *RetBuffer)
489 {
490     ACPI_VENDOR_WALK_INFO   Info;
491     ACPI_STATUS             Status;
492 
493 
494     /* Other parameters are validated by AcpiWalkResources */
495 
496     if (!Uuid || !RetBuffer)
497     {
498         return (AE_BAD_PARAMETER);
499     }
500 
501     Info.Uuid = Uuid;
502     Info.Buffer = RetBuffer;
503     Info.Status = AE_NOT_EXIST;
504 
505     /* Walk the _CRS or _PRS resource list for this device */
506 
507     Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource,
508                 &Info);
509     if (ACPI_FAILURE (Status))
510     {
511         return (Status);
512     }
513 
514     return (Info.Status);
515 }
516 
517 ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
518 
519 
520 /*******************************************************************************
521  *
522  * FUNCTION:    AcpiRsMatchVendorResource
523  *
524  * PARAMETERS:  ACPI_WALK_RESOURCE_CALLBACK
525  *
526  * RETURN:      Status
527  *
528  * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
529  *
530  ******************************************************************************/
531 
532 static ACPI_STATUS
533 AcpiRsMatchVendorResource (
534     ACPI_RESOURCE           *Resource,
535     void                    *Context)
536 {
537     ACPI_VENDOR_WALK_INFO       *Info = Context;
538     ACPI_RESOURCE_VENDOR_TYPED  *Vendor;
539     ACPI_BUFFER                 *Buffer;
540     ACPI_STATUS                 Status;
541 
542 
543     /* Ignore all descriptors except Vendor */
544 
545     if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
546     {
547         return (AE_OK);
548     }
549 
550     Vendor = &Resource->Data.VendorTyped;
551 
552     /*
553      * For a valid match, these conditions must hold:
554      *
555      * 1) Length of descriptor data must be at least as long as a UUID struct
556      * 2) The UUID subtypes must match
557      * 3) The UUID data must match
558      */
559     if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
560         (Vendor->UuidSubtype != Info->Uuid->Subtype)  ||
561         (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
562     {
563         return (AE_OK);
564     }
565 
566     /* Validate/Allocate/Clear caller buffer */
567 
568     Buffer = Info->Buffer;
569     Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
570     if (ACPI_FAILURE (Status))
571     {
572         return (Status);
573     }
574 
575     /* Found the correct resource, copy and return it */
576 
577     ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length);
578     Buffer->Length = Resource->Length;
579 
580     /* Found the desired descriptor, terminate resource walk */
581 
582     Info->Status = AE_OK;
583     return (AE_CTRL_TERMINATE);
584 }
585 
586 
587 /*******************************************************************************
588  *
589  * FUNCTION:    AcpiWalkResourceBuffer
590  *
591  * PARAMETERS:  Buffer          - Formatted buffer returned by one of the
592  *                                various Get*Resource functions
593  *              UserFunction    - Called for each resource
594  *              Context         - Passed to UserFunction
595  *
596  * RETURN:      Status
597  *
598  * DESCRIPTION: Walks the input resource template. The UserFunction is called
599  *              once for each resource in the list.
600  *
601  ******************************************************************************/
602 
603 ACPI_STATUS
604 AcpiWalkResourceBuffer (
605     ACPI_BUFFER                 *Buffer,
606     ACPI_WALK_RESOURCE_CALLBACK UserFunction,
607     void                        *Context)
608 {
609     ACPI_STATUS                 Status = AE_OK;
610     ACPI_RESOURCE               *Resource;
611     ACPI_RESOURCE               *ResourceEnd;
612 
613 
614     ACPI_FUNCTION_TRACE (AcpiWalkResourceBuffer);
615 
616 
617     /* Parameter validation */
618 
619     if (!Buffer || !Buffer->Pointer || !UserFunction)
620     {
621         return_ACPI_STATUS (AE_BAD_PARAMETER);
622     }
623 
624     /* Buffer contains the resource list and length */
625 
626     Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer->Pointer);
627     ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer->Pointer, Buffer->Length);
628 
629     /* Walk the resource list until the EndTag is found (or buffer end) */
630 
631     while (Resource < ResourceEnd)
632     {
633         /* Sanity check the resource */
634 
635         if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
636         {
637             Status = AE_AML_INVALID_RESOURCE_TYPE;
638             break;
639         }
640 
641         /* Invoke the user function, abort on any error returned */
642 
643         Status = UserFunction (Resource, Context);
644         if (ACPI_FAILURE (Status))
645         {
646             if (Status == AE_CTRL_TERMINATE)
647             {
648                 /* This is an OK termination by the user function */
649 
650                 Status = AE_OK;
651             }
652             break;
653         }
654 
655         /* EndTag indicates end-of-list */
656 
657         if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
658         {
659             break;
660         }
661 
662         /* Get the next resource descriptor */
663 
664         Resource = ACPI_NEXT_RESOURCE (Resource);
665     }
666 
667     return_ACPI_STATUS (Status);
668 }
669 
670 ACPI_EXPORT_SYMBOL (AcpiWalkResourceBuffer)
671 
672 
673 /*******************************************************************************
674  *
675  * FUNCTION:    AcpiWalkResources
676  *
677  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
678  *                                device we are querying
679  *              Name            - Method name of the resources we want.
680  *                                (METHOD_NAME__CRS, METHOD_NAME__PRS, or
681  *                                METHOD_NAME__AEI)
682  *              UserFunction    - Called for each resource
683  *              Context         - Passed to UserFunction
684  *
685  * RETURN:      Status
686  *
687  * DESCRIPTION: Retrieves the current or possible resource list for the
688  *              specified device. The UserFunction is called once for
689  *              each resource in the list.
690  *
691  ******************************************************************************/
692 
693 ACPI_STATUS
694 AcpiWalkResources (
695     ACPI_HANDLE                 DeviceHandle,
696     char                        *Name,
697     ACPI_WALK_RESOURCE_CALLBACK UserFunction,
698     void                        *Context)
699 {
700     ACPI_STATUS                 Status;
701     ACPI_BUFFER                 Buffer;
702 
703 
704     ACPI_FUNCTION_TRACE (AcpiWalkResources);
705 
706 
707     /* Parameter validation */
708 
709     if (!DeviceHandle || !UserFunction || !Name ||
710         (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
711          !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS) &&
712          !ACPI_COMPARE_NAME (Name, METHOD_NAME__AEI)))
713     {
714         return_ACPI_STATUS (AE_BAD_PARAMETER);
715     }
716 
717     /* Get the _CRS/_PRS/_AEI resource list */
718 
719     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
720     Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
721     if (ACPI_FAILURE (Status))
722     {
723         return_ACPI_STATUS (Status);
724     }
725 
726     /* Walk the resource list and cleanup */
727 
728     Status = AcpiWalkResourceBuffer (&Buffer, UserFunction, Context);
729     ACPI_FREE (Buffer.Pointer);
730     return_ACPI_STATUS (Status);
731 }
732 
733 ACPI_EXPORT_SYMBOL (AcpiWalkResources)
734