xref: /freebsd/sys/contrib/dev/acpica/components/resources/rsmisc.c (revision 298cf604ccf133b101c6fad42d1a078a1fac58ca)
1 /*******************************************************************************
2  *
3  * Module Name: rsmisc - Miscellaneous resource descriptors
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2012, 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 __RSMISC_C__
45 
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acresrc.h>
49 
50 #define _COMPONENT          ACPI_RESOURCES
51         ACPI_MODULE_NAME    ("rsmisc")
52 
53 
54 #define INIT_RESOURCE_TYPE(i)       i->ResourceOffset
55 #define INIT_RESOURCE_LENGTH(i)     i->AmlOffset
56 #define INIT_TABLE_LENGTH(i)        i->Value
57 
58 #define COMPARE_OPCODE(i)           i->ResourceOffset
59 #define COMPARE_TARGET(i)           i->AmlOffset
60 #define COMPARE_VALUE(i)            i->Value
61 
62 
63 /*******************************************************************************
64  *
65  * FUNCTION:    AcpiRsConvertAmlToResource
66  *
67  * PARAMETERS:  Resource            - Pointer to the resource descriptor
68  *              Aml                 - Where the AML descriptor is returned
69  *              Info                - Pointer to appropriate conversion table
70  *
71  * RETURN:      Status
72  *
73  * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
74  *              internal resource descriptor
75  *
76  ******************************************************************************/
77 
78 ACPI_STATUS
79 AcpiRsConvertAmlToResource (
80     ACPI_RESOURCE           *Resource,
81     AML_RESOURCE            *Aml,
82     ACPI_RSCONVERT_INFO     *Info)
83 {
84     ACPI_RS_LENGTH          AmlResourceLength;
85     void                    *Source;
86     void                    *Destination;
87     char                    *Target;
88     UINT8                   Count;
89     UINT8                   FlagsMode = FALSE;
90     UINT16                  ItemCount = 0;
91     UINT16                  Temp16 = 0;
92 
93 
94     ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
95 
96 
97     if (!Info)
98     {
99         return_ACPI_STATUS (AE_BAD_PARAMETER);
100     }
101 
102     if (((ACPI_SIZE) Resource) & 0x3)
103     {
104         /* Each internal resource struct is expected to be 32-bit aligned */
105 
106         ACPI_WARNING ((AE_INFO,
107             "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
108             Resource, Resource->Type, Resource->Length));
109     }
110 
111     /* Extract the resource Length field (does not include header length) */
112 
113     AmlResourceLength = AcpiUtGetResourceLength (Aml);
114 
115     /*
116      * First table entry must be ACPI_RSC_INITxxx and must contain the
117      * table length (# of table entries)
118      */
119     Count = INIT_TABLE_LENGTH (Info);
120     while (Count)
121     {
122         /*
123          * Source is the external AML byte stream buffer,
124          * destination is the internal resource descriptor
125          */
126         Source      = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
127         Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
128 
129         switch (Info->Opcode)
130         {
131         case ACPI_RSC_INITGET:
132             /*
133              * Get the resource type and the initial (minimum) length
134              */
135             ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
136             Resource->Type = INIT_RESOURCE_TYPE (Info);
137             Resource->Length = INIT_RESOURCE_LENGTH (Info);
138             break;
139 
140 
141         case ACPI_RSC_INITSET:
142             break;
143 
144 
145         case ACPI_RSC_FLAGINIT:
146 
147             FlagsMode = TRUE;
148             break;
149 
150 
151         case ACPI_RSC_1BITFLAG:
152             /*
153              * Mask and shift the flag bit
154              */
155             ACPI_SET8 (Destination,
156                 ((ACPI_GET8 (Source) >> Info->Value) & 0x01));
157             break;
158 
159 
160         case ACPI_RSC_2BITFLAG:
161             /*
162              * Mask and shift the flag bits
163              */
164             ACPI_SET8 (Destination,
165                 ((ACPI_GET8 (Source) >> Info->Value) & 0x03));
166             break;
167 
168 
169         case ACPI_RSC_3BITFLAG:
170             /*
171              * Mask and shift the flag bits
172              */
173             ACPI_SET8 (Destination,
174                 ((ACPI_GET8 (Source) >> Info->Value) & 0x07));
175             break;
176 
177 
178         case ACPI_RSC_COUNT:
179 
180             ItemCount = ACPI_GET8 (Source);
181             ACPI_SET8 (Destination, ItemCount);
182 
183             Resource->Length = Resource->Length +
184                 (Info->Value * (ItemCount - 1));
185             break;
186 
187 
188         case ACPI_RSC_COUNT16:
189 
190             ItemCount = AmlResourceLength;
191             ACPI_SET16 (Destination, ItemCount);
192 
193             Resource->Length = Resource->Length +
194                 (Info->Value * (ItemCount - 1));
195             break;
196 
197 
198         case ACPI_RSC_COUNT_GPIO_PIN:
199 
200             Target = ACPI_ADD_PTR (void, Aml, Info->Value);
201             ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
202 
203             Resource->Length = Resource->Length + ItemCount;
204             ItemCount = ItemCount / 2;
205             ACPI_SET16 (Destination, ItemCount);
206             break;
207 
208 
209         case ACPI_RSC_COUNT_GPIO_VEN:
210 
211             ItemCount = ACPI_GET8 (Source);
212             ACPI_SET8 (Destination, ItemCount);
213 
214             Resource->Length = Resource->Length +
215                 (Info->Value * ItemCount);
216             break;
217 
218 
219         case ACPI_RSC_COUNT_GPIO_RES:
220 
221             /*
222              * Vendor data is optional (length/offset may both be zero)
223              * Examine vendor data length field first
224              */
225             Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));
226             if (ACPI_GET16 (Target))
227             {
228                 /* Use vendor offset to get resource source length */
229 
230                 Target = ACPI_ADD_PTR (void, Aml, Info->Value);
231                 ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
232             }
233             else
234             {
235                 /* No vendor data to worry about */
236 
237                 ItemCount = Aml->LargeHeader.ResourceLength +
238                     sizeof (AML_RESOURCE_LARGE_HEADER) -
239                     ACPI_GET16 (Source);
240             }
241 
242             Resource->Length = Resource->Length + ItemCount;
243             ACPI_SET16 (Destination, ItemCount);
244             break;
245 
246 
247         case ACPI_RSC_COUNT_SERIAL_VEN:
248 
249             ItemCount = ACPI_GET16 (Source) - Info->Value;
250 
251             Resource->Length = Resource->Length + ItemCount;
252             ACPI_SET16 (Destination, ItemCount);
253             break;
254 
255 
256         case ACPI_RSC_COUNT_SERIAL_RES:
257 
258             ItemCount = (AmlResourceLength +
259                 sizeof (AML_RESOURCE_LARGE_HEADER)) -
260                 ACPI_GET16 (Source) - Info->Value;
261 
262             Resource->Length = Resource->Length + ItemCount;
263             ACPI_SET16 (Destination, ItemCount);
264             break;
265 
266 
267         case ACPI_RSC_LENGTH:
268 
269             Resource->Length = Resource->Length + Info->Value;
270             break;
271 
272 
273         case ACPI_RSC_MOVE8:
274         case ACPI_RSC_MOVE16:
275         case ACPI_RSC_MOVE32:
276         case ACPI_RSC_MOVE64:
277             /*
278              * Raw data move. Use the Info value field unless ItemCount has
279              * been previously initialized via a COUNT opcode
280              */
281             if (Info->Value)
282             {
283                 ItemCount = Info->Value;
284             }
285             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
286             break;
287 
288 
289         case ACPI_RSC_MOVE_GPIO_PIN:
290 
291             /* Generate and set the PIN data pointer */
292 
293             Target = (char *) ACPI_ADD_PTR (void, Resource,
294                   (Resource->Length - ItemCount * 2));
295             *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target);
296 
297             /* Copy the PIN data */
298 
299             Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
300             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
301             break;
302 
303 
304         case ACPI_RSC_MOVE_GPIO_RES:
305 
306             /* Generate and set the ResourceSource string pointer */
307 
308             Target = (char *) ACPI_ADD_PTR (void, Resource,
309                   (Resource->Length - ItemCount));
310             *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
311 
312             /* Copy the ResourceSource string */
313 
314             Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
315             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
316             break;
317 
318 
319         case ACPI_RSC_MOVE_SERIAL_VEN:
320 
321             /* Generate and set the Vendor Data pointer */
322 
323             Target = (char *) ACPI_ADD_PTR (void, Resource,
324                   (Resource->Length - ItemCount));
325             *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
326 
327             /* Copy the Vendor Data */
328 
329             Source = ACPI_ADD_PTR (void, Aml, Info->Value);
330             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
331             break;
332 
333 
334         case ACPI_RSC_MOVE_SERIAL_RES:
335 
336             /* Generate and set the ResourceSource string pointer */
337 
338             Target = (char *) ACPI_ADD_PTR (void, Resource,
339                   (Resource->Length - ItemCount));
340             *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
341 
342             /* Copy the ResourceSource string */
343 
344             Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value));
345             AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
346             break;
347 
348 
349         case ACPI_RSC_SET8:
350 
351             ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
352             break;
353 
354 
355         case ACPI_RSC_DATA8:
356 
357             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
358             ACPI_MEMCPY (Destination, Source,  ACPI_GET16 (Target));
359             break;
360 
361 
362         case ACPI_RSC_ADDRESS:
363             /*
364              * Common handler for address descriptor flags
365              */
366             if (!AcpiRsGetAddressCommon (Resource, Aml))
367             {
368                 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
369             }
370             break;
371 
372 
373         case ACPI_RSC_SOURCE:
374             /*
375              * Optional ResourceSource (Index and String)
376              */
377             Resource->Length +=
378                 AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
379                     Destination, Aml, NULL);
380             break;
381 
382 
383         case ACPI_RSC_SOURCEX:
384             /*
385              * Optional ResourceSource (Index and String). This is the more
386              * complicated case used by the Interrupt() macro
387              */
388             Target = ACPI_ADD_PTR (char, Resource,
389                 Info->AmlOffset + (ItemCount * 4));
390 
391             Resource->Length +=
392                 AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)
393                     (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
394                     Destination, Aml, Target);
395             break;
396 
397 
398         case ACPI_RSC_BITMASK:
399             /*
400              * 8-bit encoded bitmask (DMA macro)
401              */
402             ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
403             if (ItemCount)
404             {
405                 Resource->Length += (ItemCount - 1);
406             }
407 
408             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
409             ACPI_SET8 (Target, ItemCount);
410             break;
411 
412 
413         case ACPI_RSC_BITMASK16:
414             /*
415              * 16-bit encoded bitmask (IRQ macro)
416              */
417             ACPI_MOVE_16_TO_16 (&Temp16, Source);
418 
419             ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
420             if (ItemCount)
421             {
422                 Resource->Length += (ItemCount - 1);
423             }
424 
425             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
426             ACPI_SET8 (Target, ItemCount);
427             break;
428 
429 
430         case ACPI_RSC_EXIT_NE:
431             /*
432              * Control - Exit conversion if not equal
433              */
434             switch (Info->ResourceOffset)
435             {
436             case ACPI_RSC_COMPARE_AML_LENGTH:
437                 if (AmlResourceLength != Info->Value)
438                 {
439                     goto Exit;
440                 }
441                 break;
442 
443             case ACPI_RSC_COMPARE_VALUE:
444                 if (ACPI_GET8 (Source) != Info->Value)
445                 {
446                     goto Exit;
447                 }
448                 break;
449 
450             default:
451 
452                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
453                 return_ACPI_STATUS (AE_BAD_PARAMETER);
454             }
455             break;
456 
457 
458         default:
459 
460             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
461             return_ACPI_STATUS (AE_BAD_PARAMETER);
462         }
463 
464         Count--;
465         Info++;
466     }
467 
468 Exit:
469     if (!FlagsMode)
470     {
471         /* Round the resource struct length up to the next boundary (32 or 64) */
472 
473         Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
474     }
475     return_ACPI_STATUS (AE_OK);
476 }
477 
478 
479 /*******************************************************************************
480  *
481  * FUNCTION:    AcpiRsConvertResourceToAml
482  *
483  * PARAMETERS:  Resource            - Pointer to the resource descriptor
484  *              Aml                 - Where the AML descriptor is returned
485  *              Info                - Pointer to appropriate conversion table
486  *
487  * RETURN:      Status
488  *
489  * DESCRIPTION: Convert an internal resource descriptor to the corresponding
490  *              external AML resource descriptor.
491  *
492  ******************************************************************************/
493 
494 ACPI_STATUS
495 AcpiRsConvertResourceToAml (
496     ACPI_RESOURCE           *Resource,
497     AML_RESOURCE            *Aml,
498     ACPI_RSCONVERT_INFO     *Info)
499 {
500     void                    *Source = NULL;
501     void                    *Destination;
502     char                    *Target;
503     ACPI_RSDESC_SIZE        AmlLength = 0;
504     UINT8                   Count;
505     UINT16                  Temp16 = 0;
506     UINT16                  ItemCount = 0;
507 
508 
509     ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
510 
511 
512     if (!Info)
513     {
514         return_ACPI_STATUS (AE_BAD_PARAMETER);
515     }
516 
517     /*
518      * First table entry must be ACPI_RSC_INITxxx and must contain the
519      * table length (# of table entries)
520      */
521     Count = INIT_TABLE_LENGTH (Info);
522 
523     while (Count)
524     {
525         /*
526          * Source is the internal resource descriptor,
527          * destination is the external AML byte stream buffer
528          */
529         Source      = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
530         Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
531 
532         switch (Info->Opcode)
533         {
534         case ACPI_RSC_INITSET:
535 
536             ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
537             AmlLength = INIT_RESOURCE_LENGTH (Info);
538             AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
539             break;
540 
541 
542         case ACPI_RSC_INITGET:
543             break;
544 
545 
546         case ACPI_RSC_FLAGINIT:
547             /*
548              * Clear the flag byte
549              */
550             ACPI_SET8 (Destination, 0);
551             break;
552 
553 
554         case ACPI_RSC_1BITFLAG:
555             /*
556              * Mask and shift the flag bit
557              */
558             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
559                 ((ACPI_GET8 (Source) & 0x01) << Info->Value));
560             break;
561 
562 
563         case ACPI_RSC_2BITFLAG:
564             /*
565              * Mask and shift the flag bits
566              */
567             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
568                 ((ACPI_GET8 (Source) & 0x03) << Info->Value));
569             break;
570 
571 
572         case ACPI_RSC_3BITFLAG:
573             /*
574              * Mask and shift the flag bits
575              */
576             ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
577                 ((ACPI_GET8 (Source) & 0x07) << Info->Value));
578             break;
579 
580 
581         case ACPI_RSC_COUNT:
582 
583             ItemCount = ACPI_GET8 (Source);
584             ACPI_SET8 (Destination, ItemCount);
585 
586             AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
587             break;
588 
589 
590         case ACPI_RSC_COUNT16:
591 
592             ItemCount = ACPI_GET16 (Source);
593             AmlLength = (UINT16) (AmlLength + ItemCount);
594             AcpiRsSetResourceLength (AmlLength, Aml);
595             break;
596 
597 
598         case ACPI_RSC_COUNT_GPIO_PIN:
599 
600             ItemCount = ACPI_GET16 (Source);
601             ACPI_SET16 (Destination, AmlLength);
602 
603             AmlLength = (UINT16) (AmlLength + ItemCount * 2);
604             Target = ACPI_ADD_PTR (void, Aml, Info->Value);
605             ACPI_SET16 (Target, AmlLength);
606             AcpiRsSetResourceLength (AmlLength, Aml);
607             break;
608 
609 
610         case ACPI_RSC_COUNT_GPIO_VEN:
611 
612             ItemCount = ACPI_GET16 (Source);
613             ACPI_SET16 (Destination, ItemCount);
614 
615             AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount));
616             AcpiRsSetResourceLength (AmlLength, Aml);
617             break;
618 
619 
620         case ACPI_RSC_COUNT_GPIO_RES:
621 
622             /* Set resource source string length */
623 
624             ItemCount = ACPI_GET16 (Source);
625             ACPI_SET16 (Destination, AmlLength);
626 
627             /* Compute offset for the Vendor Data */
628 
629             AmlLength = (UINT16) (AmlLength + ItemCount);
630             Target = ACPI_ADD_PTR (void, Aml, Info->Value);
631 
632             /* Set vendor offset only if there is vendor data */
633 
634             if (Resource->Data.Gpio.VendorLength)
635             {
636                 ACPI_SET16 (Target, AmlLength);
637             }
638 
639             AcpiRsSetResourceLength (AmlLength, Aml);
640             break;
641 
642 
643         case ACPI_RSC_COUNT_SERIAL_VEN:
644 
645             ItemCount = ACPI_GET16 (Source);
646             ACPI_SET16 (Destination, ItemCount + Info->Value);
647             AmlLength = (UINT16) (AmlLength + ItemCount);
648             AcpiRsSetResourceLength (AmlLength, Aml);
649             break;
650 
651 
652         case ACPI_RSC_COUNT_SERIAL_RES:
653 
654             ItemCount = ACPI_GET16 (Source);
655             AmlLength = (UINT16) (AmlLength + ItemCount);
656             AcpiRsSetResourceLength (AmlLength, Aml);
657             break;
658 
659 
660         case ACPI_RSC_LENGTH:
661 
662             AcpiRsSetResourceLength (Info->Value, Aml);
663             break;
664 
665 
666         case ACPI_RSC_MOVE8:
667         case ACPI_RSC_MOVE16:
668         case ACPI_RSC_MOVE32:
669         case ACPI_RSC_MOVE64:
670 
671             if (Info->Value)
672             {
673                 ItemCount = Info->Value;
674             }
675             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
676             break;
677 
678 
679         case ACPI_RSC_MOVE_GPIO_PIN:
680 
681             Destination = (char *) ACPI_ADD_PTR (void, Aml,
682                   ACPI_GET16 (Destination));
683             Source = * (UINT16 **) Source;
684             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
685             break;
686 
687 
688         case ACPI_RSC_MOVE_GPIO_RES:
689 
690             /* Used for both ResourceSource string and VendorData */
691 
692             Destination = (char *) ACPI_ADD_PTR (void, Aml,
693                   ACPI_GET16 (Destination));
694             Source = * (UINT8 **) Source;
695             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
696             break;
697 
698 
699         case ACPI_RSC_MOVE_SERIAL_VEN:
700 
701             Destination = (char *) ACPI_ADD_PTR (void, Aml,
702                   (AmlLength - ItemCount));
703             Source = * (UINT8 **) Source;
704             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
705             break;
706 
707 
708         case ACPI_RSC_MOVE_SERIAL_RES:
709 
710             Destination = (char *) ACPI_ADD_PTR (void, Aml,
711                   (AmlLength - ItemCount));
712             Source = * (UINT8 **) Source;
713             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
714             break;
715 
716 
717         case ACPI_RSC_ADDRESS:
718 
719             /* Set the Resource Type, General Flags, and Type-Specific Flags */
720 
721             AcpiRsSetAddressCommon (Aml, Resource);
722             break;
723 
724 
725         case ACPI_RSC_SOURCEX:
726             /*
727              * Optional ResourceSource (Index and String)
728              */
729             AmlLength = AcpiRsSetResourceSource (
730                             Aml, (ACPI_RS_LENGTH) AmlLength, Source);
731             AcpiRsSetResourceLength (AmlLength, Aml);
732             break;
733 
734 
735         case ACPI_RSC_SOURCE:
736             /*
737              * Optional ResourceSource (Index and String). This is the more
738              * complicated case used by the Interrupt() macro
739              */
740             AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
741             AcpiRsSetResourceLength (AmlLength, Aml);
742             break;
743 
744 
745         case ACPI_RSC_BITMASK:
746             /*
747              * 8-bit encoded bitmask (DMA macro)
748              */
749             ACPI_SET8 (Destination,
750                 AcpiRsEncodeBitmask (Source,
751                     *ACPI_ADD_PTR (UINT8, Resource, Info->Value)));
752             break;
753 
754 
755         case ACPI_RSC_BITMASK16:
756             /*
757              * 16-bit encoded bitmask (IRQ macro)
758              */
759             Temp16 = AcpiRsEncodeBitmask (Source,
760                         *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
761             ACPI_MOVE_16_TO_16 (Destination, &Temp16);
762             break;
763 
764 
765         case ACPI_RSC_EXIT_LE:
766             /*
767              * Control - Exit conversion if less than or equal
768              */
769             if (ItemCount <= Info->Value)
770             {
771                 goto Exit;
772             }
773             break;
774 
775 
776         case ACPI_RSC_EXIT_NE:
777             /*
778              * Control - Exit conversion if not equal
779              */
780             switch (COMPARE_OPCODE (Info))
781             {
782             case ACPI_RSC_COMPARE_VALUE:
783 
784                 if (*ACPI_ADD_PTR (UINT8, Resource,
785                         COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
786                 {
787                     goto Exit;
788                 }
789                 break;
790 
791             default:
792 
793                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
794                 return_ACPI_STATUS (AE_BAD_PARAMETER);
795             }
796             break;
797 
798 
799         case ACPI_RSC_EXIT_EQ:
800             /*
801              * Control - Exit conversion if equal
802              */
803             if (*ACPI_ADD_PTR (UINT8, Resource,
804                     COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
805             {
806                 goto Exit;
807             }
808             break;
809 
810 
811         default:
812 
813             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
814             return_ACPI_STATUS (AE_BAD_PARAMETER);
815         }
816 
817         Count--;
818         Info++;
819     }
820 
821 Exit:
822     return_ACPI_STATUS (AE_OK);
823 }
824 
825 
826 #if 0
827 /* Previous resource validations */
828 
829     if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
830     {
831         return_ACPI_STATUS (AE_SUPPORT);
832     }
833 
834     if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
835     {
836         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
837     }
838 
839     if (((Aml->Irq.Flags & 0x09) == 0x00) ||
840         ((Aml->Irq.Flags & 0x09) == 0x09))
841     {
842         /*
843          * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
844          * polarity/trigger interrupts are allowed (ACPI spec, section
845          * "IRQ Format"), so 0x00 and 0x09 are illegal.
846          */
847         ACPI_ERROR ((AE_INFO,
848             "Invalid interrupt polarity/trigger in resource list, 0x%X",
849             Aml->Irq.Flags));
850         return_ACPI_STATUS (AE_BAD_DATA);
851     }
852 
853     Resource->Data.ExtendedIrq.InterruptCount = Temp8;
854     if (Temp8 < 1)
855     {
856         /* Must have at least one IRQ */
857 
858         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
859     }
860 
861     if (Resource->Data.Dma.Transfer == 0x03)
862     {
863         ACPI_ERROR ((AE_INFO,
864             "Invalid DMA.Transfer preference (3)"));
865         return_ACPI_STATUS (AE_BAD_DATA);
866     }
867 #endif
868