rsmisc.c revision 250838
1193323Sed/*******************************************************************************
2193323Sed *
3353358Sdim * Module Name: rsmisc - Miscellaneous resource descriptors
4353358Sdim *
5353358Sdim ******************************************************************************/
6193323Sed
7193323Sed/*
8193323Sed * Copyright (C) 2000 - 2013, Intel Corp.
9193323Sed * All rights reserved.
10193323Sed *
11193323Sed * Redistribution and use in source and binary forms, with or without
12193323Sed * modification, are permitted provided that the following conditions
13280031Sdim * are met:
14280031Sdim * 1. Redistributions of source code must retain the above copyright
15193323Sed *    notice, this list of conditions, and the following disclaimer,
16327952Sdim *    without modification.
17341825Sdim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18193323Sed *    substantially similar to the "NO WARRANTY" disclaimer below
19193323Sed *    ("Disclaimer") and any redistribution must be conditioned upon
20193323Sed *    including a substantially similar Disclaimer requirement for further
21193323Sed *    binary redistribution.
22309124Sdim * 3. Neither the names of the above-listed copyright holders nor the names
23309124Sdim *    of any contributors may be used to endorse or promote products derived
24309124Sdim *    from this software without specific prior written permission.
25193323Sed *
26309124Sdim * Alternatively, this software may be distributed under the terms of the
27309124Sdim * GNU General Public License ("GPL") version 2 as published by the Free
28309124Sdim * Software Foundation.
29309124Sdim *
30309124Sdim * NO WARRANTY
31309124Sdim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32309124Sdim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33193323Sed * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34309124Sdim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35309124Sdim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36309124Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37309124Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38309124Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39309124Sdim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40309124Sdim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41309124Sdim * POSSIBILITY OF SUCH DAMAGES.
42309124Sdim */
43309124Sdim
44309124Sdim#define __RSMISC_C__
45193323Sed
46309124Sdim#include <contrib/dev/acpica/include/acpi.h>
47309124Sdim#include <contrib/dev/acpica/include/accommon.h>
48193323Sed#include <contrib/dev/acpica/include/acresrc.h>
49309124Sdim
50309124Sdim#define _COMPONENT          ACPI_RESOURCES
51309124Sdim        ACPI_MODULE_NAME    ("rsmisc")
52309124Sdim
53309124Sdim
54193323Sed#define INIT_RESOURCE_TYPE(i)       i->ResourceOffset
55309124Sdim#define INIT_RESOURCE_LENGTH(i)     i->AmlOffset
56309124Sdim#define INIT_TABLE_LENGTH(i)        i->Value
57309124Sdim
58193323Sed#define COMPARE_OPCODE(i)           i->ResourceOffset
59309124Sdim#define COMPARE_TARGET(i)           i->AmlOffset
60193323Sed#define COMPARE_VALUE(i)            i->Value
61309124Sdim
62309124Sdim
63309124Sdim/*******************************************************************************
64309124Sdim *
65314564Sdim * FUNCTION:    AcpiRsConvertAmlToResource
66314564Sdim *
67314564Sdim * PARAMETERS:  Resource            - Pointer to the resource descriptor
68314564Sdim *              Aml                 - Where the AML descriptor is returned
69314564Sdim *              Info                - Pointer to appropriate conversion table
70314564Sdim *
71314564Sdim * RETURN:      Status
72314564Sdim *
73309124Sdim * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
74309124Sdim *              internal resource descriptor
75314564Sdim *
76193323Sed ******************************************************************************/
77309124Sdim
78314564SdimACPI_STATUS
79193323SedAcpiRsConvertAmlToResource (
80309124Sdim    ACPI_RESOURCE           *Resource,
81314564Sdim    AML_RESOURCE            *Aml,
82223017Sdim    ACPI_RSCONVERT_INFO     *Info)
83309124Sdim{
84309124Sdim    ACPI_RS_LENGTH          AmlResourceLength;
85309124Sdim    void                    *Source;
86239462Sdim    void                    *Destination;
87309124Sdim    char                    *Target;
88309124Sdim    UINT8                   Count;
89309124Sdim    UINT8                   FlagsMode = FALSE;
90309124Sdim    UINT16                  ItemCount = 0;
91314564Sdim    UINT16                  Temp16 = 0;
92314564Sdim
93314564Sdim
94309124Sdim    ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
95314564Sdim
96314564Sdim
97314564Sdim    if (!Info)
98309124Sdim    {
99314564Sdim        return_ACPI_STATUS (AE_BAD_PARAMETER);
100314564Sdim    }
101314564Sdim
102314564Sdim    if (((ACPI_SIZE) Resource) & 0x3)
103309124Sdim    {
104309124Sdim        /* Each internal resource struct is expected to be 32-bit aligned */
105309124Sdim
106276479Sdim        ACPI_WARNING ((AE_INFO,
107327952Sdim            "Misaligned resource pointer (get): %p Type 0x%2.2X Length %u",
108327952Sdim            Resource, Resource->Type, Resource->Length));
109327952Sdim    }
110309124Sdim
111309124Sdim    /* Extract the resource Length field (does not include header length) */
112309124Sdim
113239462Sdim    AmlResourceLength = AcpiUtGetResourceLength (Aml);
114309124Sdim
115309124Sdim    /*
116288943Sdim     * First table entry must be ACPI_RSC_INITxxx and must contain the
117309124Sdim     * table length (# of table entries)
118309124Sdim     */
119193323Sed    Count = INIT_TABLE_LENGTH (Info);
120309124Sdim    while (Count)
121309124Sdim    {
122309124Sdim        /*
123309124Sdim         * Source is the external AML byte stream buffer,
124309124Sdim         * destination is the internal resource descriptor
125309124Sdim         */
126353358Sdim        Source      = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
127353358Sdim        Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
128353358Sdim
129344779Sdim        switch (Info->Opcode)
130344779Sdim        {
131344779Sdim        case ACPI_RSC_INITGET:
132309124Sdim            /*
133309124Sdim             * Get the resource type and the initial (minimum) length
134309124Sdim             */
135321369Sdim            ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
136321369Sdim            Resource->Type = INIT_RESOURCE_TYPE (Info);
137321369Sdim            Resource->Length = INIT_RESOURCE_LENGTH (Info);
138321369Sdim            break;
139321369Sdim
140321369Sdim        case ACPI_RSC_INITSET:
141321369Sdim            break;
142353358Sdim
143353358Sdim        case ACPI_RSC_FLAGINIT:
144360784Sdim
145353358Sdim            FlagsMode = TRUE;
146353358Sdim            break;
147353358Sdim
148353358Sdim        case ACPI_RSC_1BITFLAG:
149353358Sdim            /*
150353358Sdim             * Mask and shift the flag bit
151353358Sdim             */
152309124Sdim            ACPI_SET8 (Destination,
153309124Sdim                ((ACPI_GET8 (Source) >> Info->Value) & 0x01));
154327952Sdim            break;
155327952Sdim
156327952Sdim        case ACPI_RSC_2BITFLAG:
157327952Sdim            /*
158360784Sdim             * Mask and shift the flag bits
159360784Sdim             */
160360784Sdim            ACPI_SET8 (Destination,
161360784Sdim                ((ACPI_GET8 (Source) >> Info->Value) & 0x03));
162360784Sdim            break;
163360784Sdim
164360784Sdim        case ACPI_RSC_3BITFLAG:
165360784Sdim            /*
166360784Sdim             * Mask and shift the flag bits
167309124Sdim             */
168309124Sdim            ACPI_SET8 (Destination,
169309124Sdim                ((ACPI_GET8 (Source) >> Info->Value) & 0x07));
170309124Sdim            break;
171309124Sdim
172309124Sdim        case ACPI_RSC_COUNT:
173309124Sdim
174309124Sdim            ItemCount = ACPI_GET8 (Source);
175309124Sdim            ACPI_SET8 (Destination, ItemCount);
176309124Sdim
177309124Sdim            Resource->Length = Resource->Length +
178193323Sed                (Info->Value * (ItemCount - 1));
179309124Sdim            break;
180193323Sed
181360784Sdim        case ACPI_RSC_COUNT16:
182309124Sdim
183309124Sdim            ItemCount = AmlResourceLength;
184309124Sdim            ACPI_SET16 (Destination, ItemCount);
185309124Sdim
186309124Sdim            Resource->Length = Resource->Length +
187309124Sdim                (Info->Value * (ItemCount - 1));
188309124Sdim            break;
189309124Sdim
190309124Sdim        case ACPI_RSC_COUNT_GPIO_PIN:
191193323Sed
192193323Sed            Target = ACPI_ADD_PTR (void, Aml, Info->Value);
193193323Sed            ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
194
195            Resource->Length = Resource->Length + ItemCount;
196            ItemCount = ItemCount / 2;
197            ACPI_SET16 (Destination, ItemCount);
198            break;
199
200        case ACPI_RSC_COUNT_GPIO_VEN:
201
202            ItemCount = ACPI_GET8 (Source);
203            ACPI_SET8 (Destination, ItemCount);
204
205            Resource->Length = Resource->Length +
206                (Info->Value * ItemCount);
207            break;
208
209        case ACPI_RSC_COUNT_GPIO_RES:
210            /*
211             * Vendor data is optional (length/offset may both be zero)
212             * Examine vendor data length field first
213             */
214            Target = ACPI_ADD_PTR (void, Aml, (Info->Value + 2));
215            if (ACPI_GET16 (Target))
216            {
217                /* Use vendor offset to get resource source length */
218
219                Target = ACPI_ADD_PTR (void, Aml, Info->Value);
220                ItemCount = ACPI_GET16 (Target) - ACPI_GET16 (Source);
221            }
222            else
223            {
224                /* No vendor data to worry about */
225
226                ItemCount = Aml->LargeHeader.ResourceLength +
227                    sizeof (AML_RESOURCE_LARGE_HEADER) -
228                    ACPI_GET16 (Source);
229            }
230
231            Resource->Length = Resource->Length + ItemCount;
232            ACPI_SET16 (Destination, ItemCount);
233            break;
234
235        case ACPI_RSC_COUNT_SERIAL_VEN:
236
237            ItemCount = ACPI_GET16 (Source) - Info->Value;
238
239            Resource->Length = Resource->Length + ItemCount;
240            ACPI_SET16 (Destination, ItemCount);
241            break;
242
243        case ACPI_RSC_COUNT_SERIAL_RES:
244
245            ItemCount = (AmlResourceLength +
246                sizeof (AML_RESOURCE_LARGE_HEADER)) -
247                ACPI_GET16 (Source) - Info->Value;
248
249            Resource->Length = Resource->Length + ItemCount;
250            ACPI_SET16 (Destination, ItemCount);
251            break;
252
253        case ACPI_RSC_LENGTH:
254
255            Resource->Length = Resource->Length + Info->Value;
256            break;
257
258        case ACPI_RSC_MOVE8:
259        case ACPI_RSC_MOVE16:
260        case ACPI_RSC_MOVE32:
261        case ACPI_RSC_MOVE64:
262            /*
263             * Raw data move. Use the Info value field unless ItemCount has
264             * been previously initialized via a COUNT opcode
265             */
266            if (Info->Value)
267            {
268                ItemCount = Info->Value;
269            }
270            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
271            break;
272
273        case ACPI_RSC_MOVE_GPIO_PIN:
274
275            /* Generate and set the PIN data pointer */
276
277            Target = (char *) ACPI_ADD_PTR (void, Resource,
278                  (Resource->Length - ItemCount * 2));
279            *(UINT16 **) Destination = ACPI_CAST_PTR (UINT16, Target);
280
281            /* Copy the PIN data */
282
283            Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
284            AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
285            break;
286
287        case ACPI_RSC_MOVE_GPIO_RES:
288
289            /* Generate and set the ResourceSource string pointer */
290
291            Target = (char *) ACPI_ADD_PTR (void, Resource,
292                  (Resource->Length - ItemCount));
293            *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
294
295            /* Copy the ResourceSource string */
296
297            Source = ACPI_ADD_PTR (void, Aml, ACPI_GET16 (Source));
298            AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
299            break;
300
301        case ACPI_RSC_MOVE_SERIAL_VEN:
302
303            /* Generate and set the Vendor Data pointer */
304
305            Target = (char *) ACPI_ADD_PTR (void, Resource,
306                  (Resource->Length - ItemCount));
307            *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
308
309            /* Copy the Vendor Data */
310
311            Source = ACPI_ADD_PTR (void, Aml, Info->Value);
312            AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
313            break;
314
315        case ACPI_RSC_MOVE_SERIAL_RES:
316
317            /* Generate and set the ResourceSource string pointer */
318
319            Target = (char *) ACPI_ADD_PTR (void, Resource,
320                  (Resource->Length - ItemCount));
321            *(UINT8 **) Destination = ACPI_CAST_PTR (UINT8, Target);
322
323            /* Copy the ResourceSource string */
324
325            Source = ACPI_ADD_PTR (void, Aml, (ACPI_GET16 (Source) + Info->Value));
326            AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
327            break;
328
329        case ACPI_RSC_SET8:
330
331            ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
332            break;
333
334        case ACPI_RSC_DATA8:
335
336            Target = ACPI_ADD_PTR (char, Resource, Info->Value);
337            ACPI_MEMCPY (Destination, Source,  ACPI_GET16 (Target));
338            break;
339
340        case ACPI_RSC_ADDRESS:
341            /*
342             * Common handler for address descriptor flags
343             */
344            if (!AcpiRsGetAddressCommon (Resource, Aml))
345            {
346                return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
347            }
348            break;
349
350        case ACPI_RSC_SOURCE:
351            /*
352             * Optional ResourceSource (Index and String)
353             */
354            Resource->Length +=
355                AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
356                    Destination, Aml, NULL);
357            break;
358
359        case ACPI_RSC_SOURCEX:
360            /*
361             * Optional ResourceSource (Index and String). This is the more
362             * complicated case used by the Interrupt() macro
363             */
364            Target = ACPI_ADD_PTR (char, Resource,
365                Info->AmlOffset + (ItemCount * 4));
366
367            Resource->Length +=
368                AcpiRsGetResourceSource (AmlResourceLength, (ACPI_RS_LENGTH)
369                    (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
370                    Destination, Aml, Target);
371            break;
372
373        case ACPI_RSC_BITMASK:
374            /*
375             * 8-bit encoded bitmask (DMA macro)
376             */
377            ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
378            if (ItemCount)
379            {
380                Resource->Length += (ItemCount - 1);
381            }
382
383            Target = ACPI_ADD_PTR (char, Resource, Info->Value);
384            ACPI_SET8 (Target, ItemCount);
385            break;
386
387        case ACPI_RSC_BITMASK16:
388            /*
389             * 16-bit encoded bitmask (IRQ macro)
390             */
391            ACPI_MOVE_16_TO_16 (&Temp16, Source);
392
393            ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
394            if (ItemCount)
395            {
396                Resource->Length += (ItemCount - 1);
397            }
398
399            Target = ACPI_ADD_PTR (char, Resource, Info->Value);
400            ACPI_SET8 (Target, ItemCount);
401            break;
402
403        case ACPI_RSC_EXIT_NE:
404            /*
405             * Control - Exit conversion if not equal
406             */
407            switch (Info->ResourceOffset)
408            {
409            case ACPI_RSC_COMPARE_AML_LENGTH:
410
411                if (AmlResourceLength != Info->Value)
412                {
413                    goto Exit;
414                }
415                break;
416
417            case ACPI_RSC_COMPARE_VALUE:
418
419                if (ACPI_GET8 (Source) != Info->Value)
420                {
421                    goto Exit;
422                }
423                break;
424
425            default:
426
427                ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
428                return_ACPI_STATUS (AE_BAD_PARAMETER);
429            }
430            break;
431
432        default:
433
434            ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
435            return_ACPI_STATUS (AE_BAD_PARAMETER);
436        }
437
438        Count--;
439        Info++;
440    }
441
442Exit:
443    if (!FlagsMode)
444    {
445        /* Round the resource struct length up to the next boundary (32 or 64) */
446
447        Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
448    }
449    return_ACPI_STATUS (AE_OK);
450}
451
452
453/*******************************************************************************
454 *
455 * FUNCTION:    AcpiRsConvertResourceToAml
456 *
457 * PARAMETERS:  Resource            - Pointer to the resource descriptor
458 *              Aml                 - Where the AML descriptor is returned
459 *              Info                - Pointer to appropriate conversion table
460 *
461 * RETURN:      Status
462 *
463 * DESCRIPTION: Convert an internal resource descriptor to the corresponding
464 *              external AML resource descriptor.
465 *
466 ******************************************************************************/
467
468ACPI_STATUS
469AcpiRsConvertResourceToAml (
470    ACPI_RESOURCE           *Resource,
471    AML_RESOURCE            *Aml,
472    ACPI_RSCONVERT_INFO     *Info)
473{
474    void                    *Source = NULL;
475    void                    *Destination;
476    char                    *Target;
477    ACPI_RSDESC_SIZE        AmlLength = 0;
478    UINT8                   Count;
479    UINT16                  Temp16 = 0;
480    UINT16                  ItemCount = 0;
481
482
483    ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
484
485
486    if (!Info)
487    {
488        return_ACPI_STATUS (AE_BAD_PARAMETER);
489    }
490
491    /*
492     * First table entry must be ACPI_RSC_INITxxx and must contain the
493     * table length (# of table entries)
494     */
495    Count = INIT_TABLE_LENGTH (Info);
496
497    while (Count)
498    {
499        /*
500         * Source is the internal resource descriptor,
501         * destination is the external AML byte stream buffer
502         */
503        Source      = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
504        Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
505
506        switch (Info->Opcode)
507        {
508        case ACPI_RSC_INITSET:
509
510            ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
511            AmlLength = INIT_RESOURCE_LENGTH (Info);
512            AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
513            break;
514
515        case ACPI_RSC_INITGET:
516            break;
517
518        case ACPI_RSC_FLAGINIT:
519            /*
520             * Clear the flag byte
521             */
522            ACPI_SET8 (Destination, 0);
523            break;
524
525        case ACPI_RSC_1BITFLAG:
526            /*
527             * Mask and shift the flag bit
528             */
529            ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
530                ((ACPI_GET8 (Source) & 0x01) << Info->Value));
531            break;
532
533        case ACPI_RSC_2BITFLAG:
534            /*
535             * Mask and shift the flag bits
536             */
537            ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
538                ((ACPI_GET8 (Source) & 0x03) << Info->Value));
539            break;
540
541        case ACPI_RSC_3BITFLAG:
542            /*
543             * Mask and shift the flag bits
544             */
545            ACPI_SET_BIT (*ACPI_CAST8 (Destination), (UINT8)
546                ((ACPI_GET8 (Source) & 0x07) << Info->Value));
547            break;
548
549        case ACPI_RSC_COUNT:
550
551            ItemCount = ACPI_GET8 (Source);
552            ACPI_SET8 (Destination, ItemCount);
553
554            AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
555            break;
556
557        case ACPI_RSC_COUNT16:
558
559            ItemCount = ACPI_GET16 (Source);
560            AmlLength = (UINT16) (AmlLength + ItemCount);
561            AcpiRsSetResourceLength (AmlLength, Aml);
562            break;
563
564        case ACPI_RSC_COUNT_GPIO_PIN:
565
566            ItemCount = ACPI_GET16 (Source);
567            ACPI_SET16 (Destination, AmlLength);
568
569            AmlLength = (UINT16) (AmlLength + ItemCount * 2);
570            Target = ACPI_ADD_PTR (void, Aml, Info->Value);
571            ACPI_SET16 (Target, AmlLength);
572            AcpiRsSetResourceLength (AmlLength, Aml);
573            break;
574
575        case ACPI_RSC_COUNT_GPIO_VEN:
576
577            ItemCount = ACPI_GET16 (Source);
578            ACPI_SET16 (Destination, ItemCount);
579
580            AmlLength = (UINT16) (AmlLength + (Info->Value * ItemCount));
581            AcpiRsSetResourceLength (AmlLength, Aml);
582            break;
583
584        case ACPI_RSC_COUNT_GPIO_RES:
585
586            /* Set resource source string length */
587
588            ItemCount = ACPI_GET16 (Source);
589            ACPI_SET16 (Destination, AmlLength);
590
591            /* Compute offset for the Vendor Data */
592
593            AmlLength = (UINT16) (AmlLength + ItemCount);
594            Target = ACPI_ADD_PTR (void, Aml, Info->Value);
595
596            /* Set vendor offset only if there is vendor data */
597
598            if (Resource->Data.Gpio.VendorLength)
599            {
600                ACPI_SET16 (Target, AmlLength);
601            }
602
603            AcpiRsSetResourceLength (AmlLength, Aml);
604            break;
605
606        case ACPI_RSC_COUNT_SERIAL_VEN:
607
608            ItemCount = ACPI_GET16 (Source);
609            ACPI_SET16 (Destination, ItemCount + Info->Value);
610            AmlLength = (UINT16) (AmlLength + ItemCount);
611            AcpiRsSetResourceLength (AmlLength, Aml);
612            break;
613
614        case ACPI_RSC_COUNT_SERIAL_RES:
615
616            ItemCount = ACPI_GET16 (Source);
617            AmlLength = (UINT16) (AmlLength + ItemCount);
618            AcpiRsSetResourceLength (AmlLength, Aml);
619            break;
620
621        case ACPI_RSC_LENGTH:
622
623            AcpiRsSetResourceLength (Info->Value, Aml);
624            break;
625
626        case ACPI_RSC_MOVE8:
627        case ACPI_RSC_MOVE16:
628        case ACPI_RSC_MOVE32:
629        case ACPI_RSC_MOVE64:
630
631            if (Info->Value)
632            {
633                ItemCount = Info->Value;
634            }
635            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
636            break;
637
638        case ACPI_RSC_MOVE_GPIO_PIN:
639
640            Destination = (char *) ACPI_ADD_PTR (void, Aml,
641                  ACPI_GET16 (Destination));
642            Source = * (UINT16 **) Source;
643            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
644            break;
645
646        case ACPI_RSC_MOVE_GPIO_RES:
647
648            /* Used for both ResourceSource string and VendorData */
649
650            Destination = (char *) ACPI_ADD_PTR (void, Aml,
651                  ACPI_GET16 (Destination));
652            Source = * (UINT8 **) Source;
653            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
654            break;
655
656        case ACPI_RSC_MOVE_SERIAL_VEN:
657
658            Destination = (char *) ACPI_ADD_PTR (void, Aml,
659                  (AmlLength - ItemCount));
660            Source = * (UINT8 **) Source;
661            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
662            break;
663
664        case ACPI_RSC_MOVE_SERIAL_RES:
665
666            Destination = (char *) ACPI_ADD_PTR (void, Aml,
667                  (AmlLength - ItemCount));
668            Source = * (UINT8 **) Source;
669            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
670            break;
671
672        case ACPI_RSC_ADDRESS:
673
674            /* Set the Resource Type, General Flags, and Type-Specific Flags */
675
676            AcpiRsSetAddressCommon (Aml, Resource);
677            break;
678
679        case ACPI_RSC_SOURCEX:
680            /*
681             * Optional ResourceSource (Index and String)
682             */
683            AmlLength = AcpiRsSetResourceSource (
684                            Aml, (ACPI_RS_LENGTH) AmlLength, Source);
685            AcpiRsSetResourceLength (AmlLength, Aml);
686            break;
687
688        case ACPI_RSC_SOURCE:
689            /*
690             * Optional ResourceSource (Index and String). This is the more
691             * complicated case used by the Interrupt() macro
692             */
693            AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
694            AcpiRsSetResourceLength (AmlLength, Aml);
695            break;
696
697        case ACPI_RSC_BITMASK:
698            /*
699             * 8-bit encoded bitmask (DMA macro)
700             */
701            ACPI_SET8 (Destination,
702                AcpiRsEncodeBitmask (Source,
703                    *ACPI_ADD_PTR (UINT8, Resource, Info->Value)));
704            break;
705
706        case ACPI_RSC_BITMASK16:
707            /*
708             * 16-bit encoded bitmask (IRQ macro)
709             */
710            Temp16 = AcpiRsEncodeBitmask (Source,
711                        *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
712            ACPI_MOVE_16_TO_16 (Destination, &Temp16);
713            break;
714
715        case ACPI_RSC_EXIT_LE:
716            /*
717             * Control - Exit conversion if less than or equal
718             */
719            if (ItemCount <= Info->Value)
720            {
721                goto Exit;
722            }
723            break;
724
725        case ACPI_RSC_EXIT_NE:
726            /*
727             * Control - Exit conversion if not equal
728             */
729            switch (COMPARE_OPCODE (Info))
730            {
731            case ACPI_RSC_COMPARE_VALUE:
732
733                if (*ACPI_ADD_PTR (UINT8, Resource,
734                        COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
735                {
736                    goto Exit;
737                }
738                break;
739
740            default:
741
742                ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
743                return_ACPI_STATUS (AE_BAD_PARAMETER);
744            }
745            break;
746
747        case ACPI_RSC_EXIT_EQ:
748            /*
749             * Control - Exit conversion if equal
750             */
751            if (*ACPI_ADD_PTR (UINT8, Resource,
752                    COMPARE_TARGET (Info)) == COMPARE_VALUE (Info))
753            {
754                goto Exit;
755            }
756            break;
757
758        default:
759
760            ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
761            return_ACPI_STATUS (AE_BAD_PARAMETER);
762        }
763
764        Count--;
765        Info++;
766    }
767
768Exit:
769    return_ACPI_STATUS (AE_OK);
770}
771
772
773#if 0
774/* Previous resource validations */
775
776    if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
777    {
778        return_ACPI_STATUS (AE_SUPPORT);
779    }
780
781    if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
782    {
783        return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
784    }
785
786    if (((Aml->Irq.Flags & 0x09) == 0x00) ||
787        ((Aml->Irq.Flags & 0x09) == 0x09))
788    {
789        /*
790         * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
791         * polarity/trigger interrupts are allowed (ACPI spec, section
792         * "IRQ Format"), so 0x00 and 0x09 are illegal.
793         */
794        ACPI_ERROR ((AE_INFO,
795            "Invalid interrupt polarity/trigger in resource list, 0x%X",
796            Aml->Irq.Flags));
797        return_ACPI_STATUS (AE_BAD_DATA);
798    }
799
800    Resource->Data.ExtendedIrq.InterruptCount = Temp8;
801    if (Temp8 < 1)
802    {
803        /* Must have at least one IRQ */
804
805        return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
806    }
807
808    if (Resource->Data.Dma.Transfer == 0x03)
809    {
810        ACPI_ERROR ((AE_INFO,
811            "Invalid DMA.Transfer preference (3)"));
812        return_ACPI_STATUS (AE_BAD_DATA);
813    }
814#endif
815