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