rsmisc.c revision 152069
1116742Ssam/*******************************************************************************
2116904Ssam *
3170360Ssam * Module Name: rsmisc - Miscellaneous resource descriptors
4116742Ssam *              $Revision: 1.35 $
5116742Ssam *
6116742Ssam ******************************************************************************/
7116742Ssam
8116742Ssam/******************************************************************************
9116742Ssam *
10116904Ssam * 1. Copyright Notice
11116904Ssam *
12116904Ssam * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13116904Ssam * All rights reserved.
14116742Ssam *
15116904Ssam * 2. License
16116904Ssam *
17116904Ssam * 2.1. This is your license from Intel Corp. under its intellectual property
18116904Ssam * rights.  You may have additional license terms from the party that provided
19116904Ssam * you this software, covering your right to use that party's intellectual
20116904Ssam * property rights.
21116904Ssam *
22116904Ssam * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23116904Ssam * copy of the source code appearing in this file ("Covered Code") an
24116904Ssam * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25116742Ssam * base code distributed originally by Intel ("Original Intel Code") to copy,
26116742Ssam * make derivatives, distribute, use and display any portion of the Covered
27116742Ssam * Code in any form, with the right to sublicense such rights; and
28116742Ssam *
29116742Ssam * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30116742Ssam * license (with the right to sublicense), under only those claims of Intel
31116742Ssam * patents that are infringed by the Original Intel Code, to make, use, sell,
32116742Ssam * offer to sell, and import the Covered Code and derivative works thereof
33116742Ssam * solely to the minimum extent necessary to exercise the above copyright
34116742Ssam * license, and in no event shall the patent license extend to any additions
35116742Ssam * to or modifications of the Original Intel Code.  No other license or right
36116742Ssam * is granted directly or by implication, estoppel or otherwise;
37138568Ssam *
38170530Ssam * The above copyright and patent license is granted only if the following
39170530Ssam * conditions are met:
40116742Ssam *
41116742Ssam * 3. Conditions
42116742Ssam *
43116742Ssam * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44138568Ssam * Redistribution of source code of any substantial portion of the Covered
45116742Ssam * Code or modification with rights to further distribute source must include
46116742Ssam * the above Copyright Notice, the above License, this list of Conditions,
47116742Ssam * and the following Disclaimer and Export Compliance provision.  In addition,
48138568Ssam * Licensee must cause all Covered Code to which Licensee contributes to
49138568Ssam * contain a file documenting the changes Licensee made to create that Covered
50138568Ssam * Code and the date of any change.  Licensee must include in that file the
51116742Ssam * documentation of any changes made by any predecessor Licensee.  Licensee
52116742Ssam * must include a prominent statement that the modification is derived,
53116742Ssam * directly or indirectly, from Original Intel Code.
54116742Ssam *
55116742Ssam * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56116742Ssam * Redistribution of source code of any substantial portion of the Covered
57116742Ssam * Code or modification without rights to further distribute source must
58116742Ssam * include the following Disclaimer and Export Compliance provision in the
59116742Ssam * documentation and/or other materials provided with distribution.  In
60138568Ssam * addition, Licensee may not authorize further sublicense of source of any
61138568Ssam * portion of the Covered Code, and must include terms to the effect that the
62138568Ssam * license from Licensee to its licensee is limited to the intellectual
63138568Ssam * property embodied in the software Licensee provides to its licensee, and
64138568Ssam * not to intellectual property embodied in modifications its licensee may
65138568Ssam * make.
66167283Ssam *
67167283Ssam * 3.3. Redistribution of Executable. Redistribution in executable form of any
68167283Ssam * substantial portion of the Covered Code or modification must reproduce the
69167283Ssam * above Copyright Notice, and the following Disclaimer and Export Compliance
70167283Ssam * provision in the documentation and/or other materials provided with the
71167283Ssam * distribution.
72167283Ssam *
73167283Ssam * 3.4. Intel retains all right, title, and interest in and to the Original
74167283Ssam * Intel Code.
75167283Ssam *
76117811Ssam * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77117811Ssam * Intel shall be used in advertising or otherwise to promote the sale, use or
78117811Ssam * other dealings in products derived from or relating to the Covered Code
79117811Ssam * without prior written authorization from Intel.
80117811Ssam *
81117811Ssam * 4. Disclaimer and Export Compliance
82117811Ssam *
83138568Ssam * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84138568Ssam * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85138568Ssam * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86138568Ssam * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87138568Ssam * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88138568Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89138568Ssam * PARTICULAR PURPOSE.
90116742Ssam *
91117811Ssam * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92117811Ssam * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93116742Ssam * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94138568Ssam * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95116742Ssam * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96138568Ssam * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97116742Ssam * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98138568Ssam * LIMITED REMEDY.
99138568Ssam *
100116742Ssam * 4.3. Licensee shall not export, either directly or indirectly, any of this
101116742Ssam * software or system incorporating such software without first obtaining any
102148291Ssam * required license or other approval from the U. S. Department of Commerce or
103148290Ssam * any other agency or department of the United States Government.  In the
104153349Ssam * event Licensee exports any such software from the United States or
105154736Ssam * re-exports any such software from a foreign destination, Licensee shall
106170530Ssam * ensure that the distribution and export/re-export of the software is in
107153346Ssam * compliance with all laws, regulations, orders, or other restrictions of the
108127648Ssam * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109138568Ssam * any of its subsidiaries will export/re-export any technical data, process,
110116742Ssam * software, or service, directly or indirectly, to any country for which the
111138568Ssam * United States government or any agency thereof requires an export license,
112138568Ssam * other governmental approval, or letter of assurance, without first obtaining
113138568Ssam * such license, approval or letter.
114121816Sbrooks *
115116742Ssam *****************************************************************************/
116117811Ssam
117117811Ssam#define __RSMISC_C__
118117811Ssam
119116742Ssam#include <contrib/dev/acpica/acpi.h>
120116742Ssam#include <contrib/dev/acpica/acresrc.h>
121116742Ssam
122160690Ssam#define _COMPONENT          ACPI_RESOURCES
123116742Ssam        ACPI_MODULE_NAME    ("rsmisc")
124116742Ssam
125116742Ssam
126138568Ssam#define INIT_RESOURCE_TYPE(i)       i->ResourceOffset
127116742Ssam#define INIT_RESOURCE_LENGTH(i)     i->AmlOffset
128116742Ssam#define INIT_TABLE_LENGTH(i)        i->Value
129138568Ssam
130138568Ssam#define COMPARE_OPCODE(i)           i->ResourceOffset
131138568Ssam#define COMPARE_TARGET(i)           i->AmlOffset
132138568Ssam#define COMPARE_VALUE(i)            i->Value
133138568Ssam
134138568Ssam
135138568Ssam/*******************************************************************************
136138568Ssam *
137165894Ssam * FUNCTION:    AcpiRsConvertAmlToResource
138116742Ssam *
139138568Ssam * PARAMETERS:  Resource            - Pointer to the resource descriptor
140138568Ssam *              Aml                 - Where the AML descriptor is returned
141138568Ssam *              Info                - Pointer to appropriate conversion table
142138568Ssam *
143138568Ssam * RETURN:      Status
144138568Ssam *
145116742Ssam * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
146116742Ssam *              internal resource descriptor
147138568Ssam *
148138568Ssam ******************************************************************************/
149138568Ssam
150138568SsamACPI_STATUS
151138568SsamAcpiRsConvertAmlToResource (
152138568Ssam    ACPI_RESOURCE           *Resource,
153138568Ssam    AML_RESOURCE            *Aml,
154138568Ssam    ACPI_RSCONVERT_INFO     *Info)
155138568Ssam{
156138568Ssam    ACPI_RS_LENGTH          AmlResourceLength;
157138568Ssam    void                    *Source;
158138568Ssam    void                    *Destination;
159138568Ssam    char                    *Target;
160138568Ssam    UINT8                   Count;
161138568Ssam    UINT8                   FlagsMode = FALSE;
162138568Ssam    UINT16                  ItemCount = 0;
163138568Ssam    UINT16                  Temp16 = 0;
164138568Ssam
165138568Ssam
166138568Ssam    ACPI_FUNCTION_TRACE ("RsGetResource");
167138568Ssam
168138568Ssam
169138568Ssam    if (((ACPI_NATIVE_UINT) Resource) & 0x3)
170138568Ssam    {
171138568Ssam        AcpiOsPrintf ("**** GET: Misaligned resource pointer: %p Type %2.2X Len %X\n",
172138568Ssam            Resource, Resource->Type, Resource->Length);
173138568Ssam    }
174138568Ssam
175138568Ssam    /* Extract the resource Length field (does not include header length) */
176138568Ssam
177138568Ssam    AmlResourceLength = AcpiUtGetResourceLength (Aml);
178138568Ssam
179138568Ssam    /*
180138568Ssam     * First table entry must be ACPI_RSC_INITxxx and must contain the
181138568Ssam     * table length (# of table entries)
182138568Ssam     */
183138568Ssam    Count = INIT_TABLE_LENGTH (Info);
184138568Ssam
185138568Ssam    while (Count)
186138568Ssam    {
187138568Ssam        /*
188138568Ssam         * Source is the external AML byte stream buffer,
189138568Ssam         * destination is the internal resource descriptor
190138568Ssam         */
191138568Ssam        Source      = ((UINT8 *) Aml) + Info->AmlOffset;
192138568Ssam        Destination = ((UINT8 *) Resource) + Info->ResourceOffset;
193116742Ssam
194138568Ssam        switch (Info->Opcode)
195138568Ssam        {
196116742Ssam        case ACPI_RSC_INITGET:
197138568Ssam            /*
198138568Ssam             * Get the resource type and the initial (minimum) length
199138568Ssam             */
200138568Ssam            ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
201138568Ssam            Resource->Type = INIT_RESOURCE_TYPE (Info);
202138568Ssam            Resource->Length = INIT_RESOURCE_LENGTH (Info);
203138568Ssam            break;
204138568Ssam
205138568Ssam
206138568Ssam        case ACPI_RSC_INITSET:
207138568Ssam            break;
208138568Ssam
209138568Ssam
210138568Ssam        case ACPI_RSC_FLAGINIT:
211138568Ssam
212138568Ssam            FlagsMode = TRUE;
213138568Ssam            break;
214138568Ssam
215138568Ssam
216138568Ssam        case ACPI_RSC_1BITFLAG:
217138568Ssam            /*
218138568Ssam             * Mask and shift the flag bit
219138568Ssam             */
220138568Ssam            *((UINT8 *) Destination) = (UINT8)
221138568Ssam                ((*((UINT8 *) Source) >> Info->Value) & 0x01);
222138568Ssam            break;
223138568Ssam
224138568Ssam
225138568Ssam        case ACPI_RSC_2BITFLAG:
226138568Ssam            /*
227138568Ssam             * Mask and shift the flag bits
228138568Ssam             */
229138568Ssam            *((UINT8 *) Destination) = (UINT8)
230138568Ssam                ((*((UINT8 *) Source) >> Info->Value) & 0x03);
231138568Ssam            break;
232138568Ssam
233138568Ssam
234138568Ssam        case ACPI_RSC_COUNT:
235138568Ssam
236138568Ssam            ItemCount = *((UINT8 *) Source);
237138568Ssam            *((UINT8 *) Destination) = (UINT8) ItemCount;
238138568Ssam
239138568Ssam            Resource->Length = Resource->Length +
240138568Ssam                (Info->Value * (ItemCount - 1));
241170530Ssam            break;
242138568Ssam
243170530Ssam
244116742Ssam        case ACPI_RSC_COUNT16:
245116742Ssam
246116742Ssam            ItemCount = AmlResourceLength;
247116742Ssam            *((UINT16 *) Destination) = ItemCount;
248116742Ssam
249116742Ssam            Resource->Length = Resource->Length +
250116742Ssam                (Info->Value * (ItemCount - 1));
251116742Ssam            break;
252116742Ssam
253116742Ssam
254116742Ssam        case ACPI_RSC_LENGTH:
255116742Ssam
256116742Ssam            Resource->Length = Resource->Length + Info->Value;
257116742Ssam            break;
258116742Ssam
259116742Ssam
260116742Ssam        case ACPI_RSC_MOVE8:
261116742Ssam        case ACPI_RSC_MOVE16:
262116742Ssam        case ACPI_RSC_MOVE32:
263116742Ssam        case ACPI_RSC_MOVE64:
264116742Ssam            /*
265116742Ssam             * Raw data move. Use the Info value field unless ItemCount has
266170530Ssam             * been previously initialized via a COUNT opcode
267170530Ssam             */
268116742Ssam            if (Info->Value)
269138568Ssam            {
270116742Ssam                ItemCount = Info->Value;
271116742Ssam            }
272138568Ssam            AcpiRsMoveData (Destination, Source, ItemCount,
273116742Ssam                Info->Opcode);
274116742Ssam            break;
275116742Ssam
276116742Ssam
277116742Ssam        case ACPI_RSC_SET8:
278116742Ssam
279116742Ssam            ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
280116742Ssam            break;
281116742Ssam
282116742Ssam
283116742Ssam        case ACPI_RSC_DATA8:
284116742Ssam
285116742Ssam            Target = ((char *) Resource) + Info->Value;
286116742Ssam            ACPI_MEMCPY (Destination, Source,  *(ACPI_CAST_PTR (UINT16, Target)));
287116742Ssam            break;
288116742Ssam
289116742Ssam
290170530Ssam        case ACPI_RSC_ADDRESS:
291116742Ssam            /*
292116742Ssam             * Common handler for address descriptor flags
293116742Ssam             */
294116742Ssam            if (!AcpiRsGetAddressCommon (Resource, Aml))
295116742Ssam            {
296116742Ssam                return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
297116742Ssam            }
298116742Ssam            break;
299116742Ssam
300116742Ssam
301116742Ssam        case ACPI_RSC_SOURCE:
302116742Ssam            /*
303116742Ssam             * Optional ResourceSource (Index and String)
304116742Ssam             */
305116742Ssam            Resource->Length +=
306116742Ssam                AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
307116742Ssam                    Destination, Aml, NULL);
308116742Ssam            break;
309170530Ssam
310170530Ssam
311170530Ssam        case ACPI_RSC_SOURCEX:
312170530Ssam            /*
313170530Ssam             * Optional ResourceSource (Index and String). This is the more
314170530Ssam             * complicated case used by the Interrupt() macro
315138568Ssam             */
316170530Ssam            Target = ((char *) Resource) + Info->AmlOffset + (ItemCount * 4);
317170530Ssam
318170530Ssam            Resource->Length +=
319170530Ssam                AcpiRsGetResourceSource (AmlResourceLength,
320170530Ssam                    (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
321170530Ssam                    Destination, Aml, Target);
322170530Ssam            break;
323170530Ssam
324170530Ssam
325138568Ssam        case ACPI_RSC_BITMASK:
326116742Ssam            /*
327116742Ssam             * 8-bit encoded bitmask (DMA macro)
328116742Ssam             */
329116742Ssam            ItemCount = AcpiRsDecodeBitmask (*((UINT8 *) Source), Destination);
330116742Ssam            if (ItemCount)
331116742Ssam            {
332116742Ssam                Resource->Length += (ItemCount - 1);
333116742Ssam            }
334116742Ssam
335116742Ssam            Target = ((char *) Resource) + Info->Value;
336116742Ssam            *((UINT8 *) Target) = (UINT8) ItemCount;
337116742Ssam            break;
338116742Ssam
339116742Ssam
340116742Ssam        case ACPI_RSC_BITMASK16:
341165887Ssam            /*
342165887Ssam             * 16-bit encoded bitmask (IRQ macro)
343165887Ssam             */
344165887Ssam            ACPI_MOVE_16_TO_16 (&Temp16, Source);
345165887Ssam
346165887Ssam            ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
347165887Ssam            if (ItemCount)
348165887Ssam            {
349165887Ssam                Resource->Length += (ItemCount - 1);
350165887Ssam            }
351165887Ssam
352116742Ssam            Target = ((char *) Resource) + Info->Value;
353167442Ssam            *((UINT8 *) Target) = (UINT8) ItemCount;
354167442Ssam            break;
355116742Ssam
356116742Ssam
357148299Ssam        case ACPI_RSC_EXIT_NE:
358165887Ssam            /*
359138568Ssam             * Control - Exit conversion if not equal
360165569Ssam             */
361170530Ssam            switch (Info->ResourceOffset)
362116742Ssam            {
363116742Ssam            case ACPI_RSC_COMPARE_AML_LENGTH:
364170530Ssam                if (AmlResourceLength != Info->Value)
365170530Ssam                {
366165569Ssam                    goto Exit;
367120482Ssam                }
368116742Ssam                break;
369116742Ssam
370116742Ssam            case ACPI_RSC_COMPARE_VALUE:
371116742Ssam                if (*((UINT8 *) Source) != Info->Value)
372116742Ssam                {
373116742Ssam                    goto Exit;
374116742Ssam                }
375116742Ssam                break;
376116742Ssam
377116742Ssam            default:
378116742Ssam                AcpiOsPrintf ("*** Invalid conversion sub-opcode\n");
379116742Ssam                return_ACPI_STATUS (AE_BAD_PARAMETER);
380116742Ssam            }
381116742Ssam            break;
382165887Ssam
383170530Ssam
384170530Ssam        default:
385170530Ssam
386170530Ssam            AcpiOsPrintf ("*** Invalid conversion opcode\n");
387170530Ssam            return_ACPI_STATUS (AE_BAD_PARAMETER);
388165887Ssam        }
389165887Ssam
390165887Ssam        Count--;
391116742Ssam        Info++;
392165887Ssam    }
393120482Ssam
394120482SsamExit:
395120482Ssam    if (!FlagsMode)
396165887Ssam    {
397120482Ssam        /* Round the resource struct length up to the next 32-bit boundary */
398120482Ssam
399165887Ssam        Resource->Length = ACPI_ROUND_UP_TO_32BITS (Resource->Length);
400120482Ssam    }
401116742Ssam    return_ACPI_STATUS (AE_OK);
402165887Ssam}
403165887Ssam
404165887Ssam
405165887Ssam/*******************************************************************************
406165887Ssam *
407165887Ssam * FUNCTION:    AcpiRsConvertResourceToAml
408116742Ssam *
409116742Ssam * PARAMETERS:  Resource            - Pointer to the resource descriptor
410165887Ssam *              Aml                 - Where the AML descriptor is returned
411116742Ssam *              Info                - Pointer to appropriate conversion table
412116742Ssam *
413116742Ssam * RETURN:      Status
414165887Ssam *
415165887Ssam * DESCRIPTION: Convert an internal resource descriptor to the corresponding
416165887Ssam *              external AML resource descriptor.
417165887Ssam *
418165887Ssam ******************************************************************************/
419116742Ssam
420165887SsamACPI_STATUS
421116742SsamAcpiRsConvertResourceToAml (
422116742Ssam    ACPI_RESOURCE           *Resource,
423116742Ssam    AML_RESOURCE            *Aml,
424138568Ssam    ACPI_RSCONVERT_INFO     *Info)
425170530Ssam{
426116742Ssam    void                    *Source = NULL;
427116742Ssam    void                    *Destination;
428116742Ssam    ACPI_RSDESC_SIZE        AmlLength = 0;
429116742Ssam    UINT8                   Count;
430116742Ssam    UINT16                  Temp16 = 0;
431116742Ssam    UINT16                  ItemCount = 0;
432138568Ssam
433138568Ssam
434138568Ssam    ACPI_FUNCTION_TRACE ("RsConvertResourceToAml");
435138568Ssam
436138568Ssam
437138568Ssam    /* Validate the Resource pointer, must be 32-bit aligned */
438138568Ssam
439138568Ssam    if (((ACPI_NATIVE_UINT) Resource) & 0x3)
440138568Ssam    {
441138568Ssam        AcpiOsPrintf ("**** SET: Misaligned resource pointer: %p Type %2.2X Len %X\n",
442138568Ssam            Resource, Resource->Type, Resource->Length);
443138568Ssam    }
444138568Ssam
445138568Ssam    /*
446138568Ssam     * First table entry must be ACPI_RSC_INITxxx and must contain the
447170530Ssam     * table length (# of table entries)
448170530Ssam     */
449170530Ssam    Count = INIT_TABLE_LENGTH (Info);
450138568Ssam
451138568Ssam    while (Count)
452138568Ssam    {
453138568Ssam        /*
454138568Ssam         * Source is the internal resource descriptor,
455170530Ssam         * destination is the external AML byte stream buffer
456138568Ssam         */
457138568Ssam        Source      = ((UINT8 *) Resource) + Info->ResourceOffset;
458138568Ssam        Destination = ((UINT8 *) Aml) + Info->AmlOffset;
459138568Ssam
460138568Ssam        switch (Info->Opcode)
461138568Ssam        {
462138568Ssam        case ACPI_RSC_INITSET:
463138568Ssam
464138568Ssam            ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
465138568Ssam            AmlLength = INIT_RESOURCE_LENGTH (Info);
466138568Ssam            AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
467138568Ssam            break;
468138568Ssam
469138568Ssam
470138568Ssam        case ACPI_RSC_INITGET:
471138568Ssam            break;
472138568Ssam
473138568Ssam
474138568Ssam        case ACPI_RSC_FLAGINIT:
475138568Ssam            /*
476138568Ssam             * Clear the flag byte
477138568Ssam             */
478138568Ssam            *((UINT8 *) Destination) = 0;
479138568Ssam            break;
480138568Ssam
481138568Ssam
482138568Ssam        case ACPI_RSC_1BITFLAG:
483138568Ssam            /*
484138568Ssam             * Mask and shift the flag bit
485138568Ssam             */
486138568Ssam            *((UINT8 *) Destination) |= (UINT8)
487138568Ssam                ((*((UINT8 *) Source) & 0x01) << Info->Value);
488138568Ssam            break;
489138568Ssam
490138568Ssam
491138568Ssam        case ACPI_RSC_2BITFLAG:
492138568Ssam            /*
493138568Ssam             * Mask and shift the flag bits
494138568Ssam             */
495138568Ssam            *((UINT8 *) Destination) |= (UINT8)
496138568Ssam                ((*((UINT8 *) Source) & 0x03) << Info->Value);
497138568Ssam            break;
498138568Ssam
499138568Ssam
500138568Ssam        case ACPI_RSC_COUNT:
501138568Ssam
502138568Ssam            ItemCount = *((UINT8 *) Source);
503138568Ssam            *((UINT8 *) Destination) = (UINT8) ItemCount;
504138568Ssam
505138568Ssam            AmlLength = (UINT16) (AmlLength +
506138568Ssam                (Info->Value * (ItemCount - 1)));
507138568Ssam            break;
508138568Ssam
509138568Ssam
510138568Ssam        case ACPI_RSC_COUNT16:
511138568Ssam
512138568Ssam            ItemCount = *((UINT16 *) Source);
513138568Ssam            AmlLength = (UINT16) (AmlLength + ItemCount);
514138568Ssam            AcpiRsSetResourceLength (AmlLength, Aml);
515138568Ssam            break;
516138568Ssam
517138568Ssam
518138568Ssam        case ACPI_RSC_LENGTH:
519170530Ssam
520170530Ssam            AcpiRsSetResourceLength (Info->Value, Aml);
521138568Ssam            break;
522138568Ssam
523138568Ssam
524170530Ssam        case ACPI_RSC_MOVE8:
525138568Ssam        case ACPI_RSC_MOVE16:
526138568Ssam        case ACPI_RSC_MOVE32:
527170530Ssam        case ACPI_RSC_MOVE64:
528170530Ssam
529170530Ssam            if (Info->Value)
530138568Ssam            {
531138568Ssam                ItemCount = Info->Value;
532138568Ssam            }
533138568Ssam            AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
534138568Ssam            break;
535138568Ssam
536138568Ssam
537138568Ssam        case ACPI_RSC_ADDRESS:
538138568Ssam
539138568Ssam            /* Set the Resource Type, General Flags, and Type-Specific Flags */
540138568Ssam
541138568Ssam            AcpiRsSetAddressCommon (Aml, Resource);
542138568Ssam            break;
543138568Ssam
544138568Ssam
545138568Ssam        case ACPI_RSC_SOURCEX:
546138568Ssam            /*
547170530Ssam             * Optional ResourceSource (Index and String)
548170530Ssam             */
549170530Ssam            AmlLength = AcpiRsSetResourceSource (
550170530Ssam                            Aml, (ACPI_RS_LENGTH) AmlLength, Source);
551170530Ssam            AcpiRsSetResourceLength (AmlLength, Aml);
552138568Ssam            break;
553138568Ssam
554138568Ssam
555170530Ssam        case ACPI_RSC_SOURCE:
556170530Ssam            /*
557170530Ssam             * Optional ResourceSource (Index and String). This is the more
558170530Ssam             * complicated case used by the Interrupt() macro
559170530Ssam             */
560170530Ssam            AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
561170530Ssam            AcpiRsSetResourceLength (AmlLength, Aml);
562170530Ssam            break;
563170530Ssam
564170530Ssam
565138568Ssam        case ACPI_RSC_BITMASK:
566138568Ssam            /*
567170530Ssam             * 8-bit encoded bitmask (DMA macro)
568170530Ssam             */
569170530Ssam            *((UINT8 *) Destination) = (UINT8)
570170530Ssam                AcpiRsEncodeBitmask (Source, *(((UINT8 *) Resource) + Info->Value));
571170530Ssam            break;
572170530Ssam
573170530Ssam
574170530Ssam        case ACPI_RSC_BITMASK16:
575170530Ssam            /*
576170530Ssam             * 16-bit encoded bitmask (IRQ macro)
577138568Ssam             */
578138568Ssam            Temp16 = AcpiRsEncodeBitmask (Source, *(((UINT8 *) Resource) + Info->Value));
579170530Ssam            ACPI_MOVE_16_TO_16 (Destination, &Temp16);
580170530Ssam            break;
581170530Ssam
582170530Ssam
583170530Ssam        case ACPI_RSC_EXIT_LE:
584170530Ssam            /*
585170530Ssam             * Control - Exit conversion if less than or equal
586170530Ssam             */
587170530Ssam            if (ItemCount <= Info->Value)
588170530Ssam            {
589138568Ssam                goto Exit;
590138568Ssam            }
591170530Ssam            break;
592170530Ssam
593170530Ssam
594170530Ssam        case ACPI_RSC_EXIT_NE:
595170530Ssam            /*
596170530Ssam             * Control - Exit conversion if not equal
597170530Ssam             */
598170530Ssam            switch (COMPARE_OPCODE (Info))
599170530Ssam            {
600170530Ssam            case ACPI_RSC_COMPARE_VALUE:
601138568Ssam                if (*((UINT8 *) (((UINT8 *) Resource) + COMPARE_TARGET(Info))) != COMPARE_VALUE (Info))
602138568Ssam                {
603138568Ssam                    goto Exit;
604170530Ssam                }
605170530Ssam                break;
606170530Ssam
607170530Ssam            default:
608170530Ssam                AcpiOsPrintf ("*** Invalid conversion sub-opcode\n");
609170530Ssam                return_ACPI_STATUS (AE_BAD_PARAMETER);
610170530Ssam            }
611170530Ssam            break;
612170530Ssam
613170530Ssam
614138568Ssam        default:
615138568Ssam
616170530Ssam            AcpiOsPrintf ("*** Invalid conversion opcode\n");
617170530Ssam            return_ACPI_STATUS (AE_BAD_PARAMETER);
618170530Ssam        }
619170530Ssam
620170530Ssam        Count--;
621170530Ssam        Info++;
622170530Ssam    }
623170530Ssam
624170530SsamExit:
625170530Ssam    return_ACPI_STATUS (AE_OK);
626138568Ssam}
627138568Ssam
628170530Ssam
629170530Ssam#if 0
630170530Ssam/* Previous resource validations */
631170530Ssam
632170530Ssam    if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
633170530Ssam    {
634170530Ssam        return_ACPI_STATUS (AE_SUPPORT);
635170530Ssam    }
636170530Ssam
637170530Ssam    if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
638138568Ssam    {
639138568Ssam        return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
640138568Ssam    }
641138568Ssam
642138568Ssam    if (((Aml->Irq.Flags & 0x09) == 0x00) ||
643138568Ssam        ((Aml->Irq.Flags & 0x09) == 0x09))
644138568Ssam    {
645138568Ssam        /*
646170530Ssam         * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
647138568Ssam         * polarity/trigger interrupts are allowed (ACPI spec, section
648138568Ssam         * "IRQ Format"), so 0x00 and 0x09 are illegal.
649138568Ssam         */
650138568Ssam        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
651138568Ssam            "Invalid interrupt polarity/trigger in resource list, %X\n",
652170530Ssam            Aml->Irq.Flags));
653170530Ssam        return_ACPI_STATUS (AE_BAD_DATA);
654170530Ssam    }
655170530Ssam
656170530Ssam    Resource->Data.ExtendedIrq.InterruptCount = Temp8;
657170530Ssam    if (Temp8 < 1)
658170530Ssam    {
659170530Ssam        /* Must have at least one IRQ */
660170530Ssam
661170530Ssam        return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
662138568Ssam    }
663138568Ssam
664138568Ssam    if (Resource->Data.Dma.Transfer == 0x03)
665170530Ssam    {
666170530Ssam        ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
667138568Ssam            "Invalid DMA.Transfer preference (3)\n"));
668138568Ssam        return_ACPI_STATUS (AE_BAD_DATA);
669170530Ssam    }
670170530Ssam#endif
671138568Ssam
672138568Ssam
673170530Ssam