xref: /onnv-gate/usr/src/uts/intel/io/acpica/resources/rsmisc.c (revision 3446:5903aece022d)
1*3446Smrj /*******************************************************************************
2*3446Smrj  *
3*3446Smrj  * Module Name: rsmisc - Miscellaneous resource descriptors
4*3446Smrj  *              $Revision: 1.45 $
5*3446Smrj  *
6*3446Smrj  ******************************************************************************/
7*3446Smrj 
8*3446Smrj /******************************************************************************
9*3446Smrj  *
10*3446Smrj  * 1. Copyright Notice
11*3446Smrj  *
12*3446Smrj  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13*3446Smrj  * All rights reserved.
14*3446Smrj  *
15*3446Smrj  * 2. License
16*3446Smrj  *
17*3446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
18*3446Smrj  * rights.  You may have additional license terms from the party that provided
19*3446Smrj  * you this software, covering your right to use that party's intellectual
20*3446Smrj  * property rights.
21*3446Smrj  *
22*3446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23*3446Smrj  * copy of the source code appearing in this file ("Covered Code") an
24*3446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25*3446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
26*3446Smrj  * make derivatives, distribute, use and display any portion of the Covered
27*3446Smrj  * Code in any form, with the right to sublicense such rights; and
28*3446Smrj  *
29*3446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30*3446Smrj  * license (with the right to sublicense), under only those claims of Intel
31*3446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
32*3446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
33*3446Smrj  * solely to the minimum extent necessary to exercise the above copyright
34*3446Smrj  * license, and in no event shall the patent license extend to any additions
35*3446Smrj  * to or modifications of the Original Intel Code.  No other license or right
36*3446Smrj  * is granted directly or by implication, estoppel or otherwise;
37*3446Smrj  *
38*3446Smrj  * The above copyright and patent license is granted only if the following
39*3446Smrj  * conditions are met:
40*3446Smrj  *
41*3446Smrj  * 3. Conditions
42*3446Smrj  *
43*3446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
45*3446Smrj  * Code or modification with rights to further distribute source must include
46*3446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
47*3446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
48*3446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
49*3446Smrj  * contain a file documenting the changes Licensee made to create that Covered
50*3446Smrj  * Code and the date of any change.  Licensee must include in that file the
51*3446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
52*3446Smrj  * must include a prominent statement that the modification is derived,
53*3446Smrj  * directly or indirectly, from Original Intel Code.
54*3446Smrj  *
55*3446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
57*3446Smrj  * Code or modification without rights to further distribute source must
58*3446Smrj  * include the following Disclaimer and Export Compliance provision in the
59*3446Smrj  * documentation and/or other materials provided with distribution.  In
60*3446Smrj  * addition, Licensee may not authorize further sublicense of source of any
61*3446Smrj  * portion of the Covered Code, and must include terms to the effect that the
62*3446Smrj  * license from Licensee to its licensee is limited to the intellectual
63*3446Smrj  * property embodied in the software Licensee provides to its licensee, and
64*3446Smrj  * not to intellectual property embodied in modifications its licensee may
65*3446Smrj  * make.
66*3446Smrj  *
67*3446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68*3446Smrj  * substantial portion of the Covered Code or modification must reproduce the
69*3446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
70*3446Smrj  * provision in the documentation and/or other materials provided with the
71*3446Smrj  * distribution.
72*3446Smrj  *
73*3446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
74*3446Smrj  * Intel Code.
75*3446Smrj  *
76*3446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77*3446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
78*3446Smrj  * other dealings in products derived from or relating to the Covered Code
79*3446Smrj  * without prior written authorization from Intel.
80*3446Smrj  *
81*3446Smrj  * 4. Disclaimer and Export Compliance
82*3446Smrj  *
83*3446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84*3446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85*3446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86*3446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87*3446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88*3446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89*3446Smrj  * PARTICULAR PURPOSE.
90*3446Smrj  *
91*3446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92*3446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93*3446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94*3446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95*3446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96*3446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97*3446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98*3446Smrj  * LIMITED REMEDY.
99*3446Smrj  *
100*3446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101*3446Smrj  * software or system incorporating such software without first obtaining any
102*3446Smrj  * required license or other approval from the U. S. Department of Commerce or
103*3446Smrj  * any other agency or department of the United States Government.  In the
104*3446Smrj  * event Licensee exports any such software from the United States or
105*3446Smrj  * re-exports any such software from a foreign destination, Licensee shall
106*3446Smrj  * ensure that the distribution and export/re-export of the software is in
107*3446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
108*3446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109*3446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
110*3446Smrj  * software, or service, directly or indirectly, to any country for which the
111*3446Smrj  * United States government or any agency thereof requires an export license,
112*3446Smrj  * other governmental approval, or letter of assurance, without first obtaining
113*3446Smrj  * such license, approval or letter.
114*3446Smrj  *
115*3446Smrj  *****************************************************************************/
116*3446Smrj 
117*3446Smrj #define __RSMISC_C__
118*3446Smrj 
119*3446Smrj #include "acpi.h"
120*3446Smrj #include "acresrc.h"
121*3446Smrj 
122*3446Smrj #define _COMPONENT          ACPI_RESOURCES
123*3446Smrj         ACPI_MODULE_NAME    ("rsmisc")
124*3446Smrj 
125*3446Smrj 
126*3446Smrj #define INIT_RESOURCE_TYPE(i)       i->ResourceOffset
127*3446Smrj #define INIT_RESOURCE_LENGTH(i)     i->AmlOffset
128*3446Smrj #define INIT_TABLE_LENGTH(i)        i->Value
129*3446Smrj 
130*3446Smrj #define COMPARE_OPCODE(i)           i->ResourceOffset
131*3446Smrj #define COMPARE_TARGET(i)           i->AmlOffset
132*3446Smrj #define COMPARE_VALUE(i)            i->Value
133*3446Smrj 
134*3446Smrj 
135*3446Smrj /*******************************************************************************
136*3446Smrj  *
137*3446Smrj  * FUNCTION:    AcpiRsConvertAmlToResource
138*3446Smrj  *
139*3446Smrj  * PARAMETERS:  Resource            - Pointer to the resource descriptor
140*3446Smrj  *              Aml                 - Where the AML descriptor is returned
141*3446Smrj  *              Info                - Pointer to appropriate conversion table
142*3446Smrj  *
143*3446Smrj  * RETURN:      Status
144*3446Smrj  *
145*3446Smrj  * DESCRIPTION: Convert an external AML resource descriptor to the corresponding
146*3446Smrj  *              internal resource descriptor
147*3446Smrj  *
148*3446Smrj  ******************************************************************************/
149*3446Smrj 
150*3446Smrj ACPI_STATUS
151*3446Smrj AcpiRsConvertAmlToResource (
152*3446Smrj     ACPI_RESOURCE           *Resource,
153*3446Smrj     AML_RESOURCE            *Aml,
154*3446Smrj     ACPI_RSCONVERT_INFO     *Info)
155*3446Smrj {
156*3446Smrj     ACPI_RS_LENGTH          AmlResourceLength;
157*3446Smrj     void                    *Source;
158*3446Smrj     void                    *Destination;
159*3446Smrj     char                    *Target;
160*3446Smrj     UINT8                   Count;
161*3446Smrj     UINT8                   FlagsMode = FALSE;
162*3446Smrj     UINT16                  ItemCount = 0;
163*3446Smrj     UINT16                  Temp16 = 0;
164*3446Smrj 
165*3446Smrj 
166*3446Smrj     ACPI_FUNCTION_TRACE (RsConvertAmlToResource);
167*3446Smrj 
168*3446Smrj 
169*3446Smrj     if (((ACPI_NATIVE_UINT) Resource) & 0x3)
170*3446Smrj     {
171*3446Smrj         /* Each internal resource struct is expected to be 32-bit aligned */
172*3446Smrj 
173*3446Smrj         ACPI_WARNING ((AE_INFO,
174*3446Smrj             "Misaligned resource pointer (get): %p Type %2.2X Len %X",
175*3446Smrj             Resource, Resource->Type, Resource->Length));
176*3446Smrj     }
177*3446Smrj 
178*3446Smrj     /* Extract the resource Length field (does not include header length) */
179*3446Smrj 
180*3446Smrj     AmlResourceLength = AcpiUtGetResourceLength (Aml);
181*3446Smrj 
182*3446Smrj     /*
183*3446Smrj      * First table entry must be ACPI_RSC_INITxxx and must contain the
184*3446Smrj      * table length (# of table entries)
185*3446Smrj      */
186*3446Smrj     Count = INIT_TABLE_LENGTH (Info);
187*3446Smrj 
188*3446Smrj     while (Count)
189*3446Smrj     {
190*3446Smrj         /*
191*3446Smrj          * Source is the external AML byte stream buffer,
192*3446Smrj          * destination is the internal resource descriptor
193*3446Smrj          */
194*3446Smrj         Source      = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
195*3446Smrj         Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
196*3446Smrj 
197*3446Smrj         switch (Info->Opcode)
198*3446Smrj         {
199*3446Smrj         case ACPI_RSC_INITGET:
200*3446Smrj             /*
201*3446Smrj              * Get the resource type and the initial (minimum) length
202*3446Smrj              */
203*3446Smrj             ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info));
204*3446Smrj             Resource->Type = INIT_RESOURCE_TYPE (Info);
205*3446Smrj             Resource->Length = INIT_RESOURCE_LENGTH (Info);
206*3446Smrj             break;
207*3446Smrj 
208*3446Smrj 
209*3446Smrj         case ACPI_RSC_INITSET:
210*3446Smrj             break;
211*3446Smrj 
212*3446Smrj 
213*3446Smrj         case ACPI_RSC_FLAGINIT:
214*3446Smrj 
215*3446Smrj             FlagsMode = TRUE;
216*3446Smrj             break;
217*3446Smrj 
218*3446Smrj 
219*3446Smrj         case ACPI_RSC_1BITFLAG:
220*3446Smrj             /*
221*3446Smrj              * Mask and shift the flag bit
222*3446Smrj              */
223*3446Smrj             ACPI_SET8 (Destination) = (UINT8)
224*3446Smrj                 ((ACPI_GET8 (Source) >> Info->Value) & 0x01);
225*3446Smrj             break;
226*3446Smrj 
227*3446Smrj 
228*3446Smrj         case ACPI_RSC_2BITFLAG:
229*3446Smrj             /*
230*3446Smrj              * Mask and shift the flag bits
231*3446Smrj              */
232*3446Smrj             ACPI_SET8 (Destination) = (UINT8)
233*3446Smrj                 ((ACPI_GET8 (Source) >> Info->Value) & 0x03);
234*3446Smrj             break;
235*3446Smrj 
236*3446Smrj 
237*3446Smrj         case ACPI_RSC_COUNT:
238*3446Smrj 
239*3446Smrj             ItemCount = ACPI_GET8 (Source);
240*3446Smrj             ACPI_SET8 (Destination) = (UINT8) ItemCount;
241*3446Smrj 
242*3446Smrj             Resource->Length = Resource->Length +
243*3446Smrj                 (Info->Value * (ItemCount - 1));
244*3446Smrj             break;
245*3446Smrj 
246*3446Smrj 
247*3446Smrj         case ACPI_RSC_COUNT16:
248*3446Smrj 
249*3446Smrj             ItemCount = AmlResourceLength;
250*3446Smrj             ACPI_SET16 (Destination) = ItemCount;
251*3446Smrj 
252*3446Smrj             Resource->Length = Resource->Length +
253*3446Smrj                 (Info->Value * (ItemCount - 1));
254*3446Smrj             break;
255*3446Smrj 
256*3446Smrj 
257*3446Smrj         case ACPI_RSC_LENGTH:
258*3446Smrj 
259*3446Smrj             Resource->Length = Resource->Length + Info->Value;
260*3446Smrj             break;
261*3446Smrj 
262*3446Smrj 
263*3446Smrj         case ACPI_RSC_MOVE8:
264*3446Smrj         case ACPI_RSC_MOVE16:
265*3446Smrj         case ACPI_RSC_MOVE32:
266*3446Smrj         case ACPI_RSC_MOVE64:
267*3446Smrj             /*
268*3446Smrj              * Raw data move. Use the Info value field unless ItemCount has
269*3446Smrj              * been previously initialized via a COUNT opcode
270*3446Smrj              */
271*3446Smrj             if (Info->Value)
272*3446Smrj             {
273*3446Smrj                 ItemCount = Info->Value;
274*3446Smrj             }
275*3446Smrj             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
276*3446Smrj             break;
277*3446Smrj 
278*3446Smrj 
279*3446Smrj         case ACPI_RSC_SET8:
280*3446Smrj 
281*3446Smrj             ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value);
282*3446Smrj             break;
283*3446Smrj 
284*3446Smrj 
285*3446Smrj         case ACPI_RSC_DATA8:
286*3446Smrj 
287*3446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
288*3446Smrj             ACPI_MEMCPY (Destination, Source,  ACPI_GET16 (Target));
289*3446Smrj             break;
290*3446Smrj 
291*3446Smrj 
292*3446Smrj         case ACPI_RSC_ADDRESS:
293*3446Smrj             /*
294*3446Smrj              * Common handler for address descriptor flags
295*3446Smrj              */
296*3446Smrj             if (!AcpiRsGetAddressCommon (Resource, Aml))
297*3446Smrj             {
298*3446Smrj                 return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
299*3446Smrj             }
300*3446Smrj             break;
301*3446Smrj 
302*3446Smrj 
303*3446Smrj         case ACPI_RSC_SOURCE:
304*3446Smrj             /*
305*3446Smrj              * Optional ResourceSource (Index and String)
306*3446Smrj              */
307*3446Smrj             Resource->Length +=
308*3446Smrj                 AcpiRsGetResourceSource (AmlResourceLength, Info->Value,
309*3446Smrj                     Destination, Aml, NULL);
310*3446Smrj             break;
311*3446Smrj 
312*3446Smrj 
313*3446Smrj         case ACPI_RSC_SOURCEX:
314*3446Smrj             /*
315*3446Smrj              * Optional ResourceSource (Index and String). This is the more
316*3446Smrj              * complicated case used by the Interrupt() macro
317*3446Smrj              */
318*3446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4));
319*3446Smrj 
320*3446Smrj             Resource->Length +=
321*3446Smrj                 AcpiRsGetResourceSource (AmlResourceLength,
322*3446Smrj                     (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value),
323*3446Smrj                     Destination, Aml, Target);
324*3446Smrj             break;
325*3446Smrj 
326*3446Smrj 
327*3446Smrj         case ACPI_RSC_BITMASK:
328*3446Smrj             /*
329*3446Smrj              * 8-bit encoded bitmask (DMA macro)
330*3446Smrj              */
331*3446Smrj             ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination);
332*3446Smrj             if (ItemCount)
333*3446Smrj             {
334*3446Smrj                 Resource->Length += (ItemCount - 1);
335*3446Smrj             }
336*3446Smrj 
337*3446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
338*3446Smrj             ACPI_SET8 (Target) = (UINT8) ItemCount;
339*3446Smrj             break;
340*3446Smrj 
341*3446Smrj 
342*3446Smrj         case ACPI_RSC_BITMASK16:
343*3446Smrj             /*
344*3446Smrj              * 16-bit encoded bitmask (IRQ macro)
345*3446Smrj              */
346*3446Smrj             ACPI_MOVE_16_TO_16 (&Temp16, Source);
347*3446Smrj 
348*3446Smrj             ItemCount = AcpiRsDecodeBitmask (Temp16, Destination);
349*3446Smrj             if (ItemCount)
350*3446Smrj             {
351*3446Smrj                 Resource->Length += (ItemCount - 1);
352*3446Smrj             }
353*3446Smrj 
354*3446Smrj             Target = ACPI_ADD_PTR (char, Resource, Info->Value);
355*3446Smrj             ACPI_SET8 (Target) = (UINT8) ItemCount;
356*3446Smrj             break;
357*3446Smrj 
358*3446Smrj 
359*3446Smrj         case ACPI_RSC_EXIT_NE:
360*3446Smrj             /*
361*3446Smrj              * Control - Exit conversion if not equal
362*3446Smrj              */
363*3446Smrj             switch (Info->ResourceOffset)
364*3446Smrj             {
365*3446Smrj             case ACPI_RSC_COMPARE_AML_LENGTH:
366*3446Smrj                 if (AmlResourceLength != Info->Value)
367*3446Smrj                 {
368*3446Smrj                     goto Exit;
369*3446Smrj                 }
370*3446Smrj                 break;
371*3446Smrj 
372*3446Smrj             case ACPI_RSC_COMPARE_VALUE:
373*3446Smrj                 if (ACPI_GET8 (Source) != Info->Value)
374*3446Smrj                 {
375*3446Smrj                     goto Exit;
376*3446Smrj                 }
377*3446Smrj                 break;
378*3446Smrj 
379*3446Smrj             default:
380*3446Smrj 
381*3446Smrj                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
382*3446Smrj                 return_ACPI_STATUS (AE_BAD_PARAMETER);
383*3446Smrj             }
384*3446Smrj             break;
385*3446Smrj 
386*3446Smrj 
387*3446Smrj         default:
388*3446Smrj 
389*3446Smrj             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
390*3446Smrj             return_ACPI_STATUS (AE_BAD_PARAMETER);
391*3446Smrj         }
392*3446Smrj 
393*3446Smrj         Count--;
394*3446Smrj         Info++;
395*3446Smrj     }
396*3446Smrj 
397*3446Smrj Exit:
398*3446Smrj     if (!FlagsMode)
399*3446Smrj     {
400*3446Smrj         /* Round the resource struct length up to the next boundary (32 or 64) */
401*3446Smrj 
402*3446Smrj         Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length);
403*3446Smrj     }
404*3446Smrj     return_ACPI_STATUS (AE_OK);
405*3446Smrj }
406*3446Smrj 
407*3446Smrj 
408*3446Smrj /*******************************************************************************
409*3446Smrj  *
410*3446Smrj  * FUNCTION:    AcpiRsConvertResourceToAml
411*3446Smrj  *
412*3446Smrj  * PARAMETERS:  Resource            - Pointer to the resource descriptor
413*3446Smrj  *              Aml                 - Where the AML descriptor is returned
414*3446Smrj  *              Info                - Pointer to appropriate conversion table
415*3446Smrj  *
416*3446Smrj  * RETURN:      Status
417*3446Smrj  *
418*3446Smrj  * DESCRIPTION: Convert an internal resource descriptor to the corresponding
419*3446Smrj  *              external AML resource descriptor.
420*3446Smrj  *
421*3446Smrj  ******************************************************************************/
422*3446Smrj 
423*3446Smrj ACPI_STATUS
424*3446Smrj AcpiRsConvertResourceToAml (
425*3446Smrj     ACPI_RESOURCE           *Resource,
426*3446Smrj     AML_RESOURCE            *Aml,
427*3446Smrj     ACPI_RSCONVERT_INFO     *Info)
428*3446Smrj {
429*3446Smrj     void                    *Source = NULL;
430*3446Smrj     void                    *Destination;
431*3446Smrj     ACPI_RSDESC_SIZE        AmlLength = 0;
432*3446Smrj     UINT8                   Count;
433*3446Smrj     UINT16                  Temp16 = 0;
434*3446Smrj     UINT16                  ItemCount = 0;
435*3446Smrj 
436*3446Smrj 
437*3446Smrj     ACPI_FUNCTION_TRACE (RsConvertResourceToAml);
438*3446Smrj 
439*3446Smrj 
440*3446Smrj     /*
441*3446Smrj      * First table entry must be ACPI_RSC_INITxxx and must contain the
442*3446Smrj      * table length (# of table entries)
443*3446Smrj      */
444*3446Smrj     Count = INIT_TABLE_LENGTH (Info);
445*3446Smrj 
446*3446Smrj     while (Count)
447*3446Smrj     {
448*3446Smrj         /*
449*3446Smrj          * Source is the internal resource descriptor,
450*3446Smrj          * destination is the external AML byte stream buffer
451*3446Smrj          */
452*3446Smrj         Source      = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset);
453*3446Smrj         Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset);
454*3446Smrj 
455*3446Smrj         switch (Info->Opcode)
456*3446Smrj         {
457*3446Smrj         case ACPI_RSC_INITSET:
458*3446Smrj 
459*3446Smrj             ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info));
460*3446Smrj             AmlLength = INIT_RESOURCE_LENGTH (Info);
461*3446Smrj             AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml);
462*3446Smrj             break;
463*3446Smrj 
464*3446Smrj 
465*3446Smrj         case ACPI_RSC_INITGET:
466*3446Smrj             break;
467*3446Smrj 
468*3446Smrj 
469*3446Smrj         case ACPI_RSC_FLAGINIT:
470*3446Smrj             /*
471*3446Smrj              * Clear the flag byte
472*3446Smrj              */
473*3446Smrj             ACPI_SET8 (Destination) = 0;
474*3446Smrj             break;
475*3446Smrj 
476*3446Smrj 
477*3446Smrj         case ACPI_RSC_1BITFLAG:
478*3446Smrj             /*
479*3446Smrj              * Mask and shift the flag bit
480*3446Smrj              */
481*3446Smrj             ACPI_SET8 (Destination) |= (UINT8)
482*3446Smrj                 ((ACPI_GET8 (Source) & 0x01) << Info->Value);
483*3446Smrj             break;
484*3446Smrj 
485*3446Smrj 
486*3446Smrj         case ACPI_RSC_2BITFLAG:
487*3446Smrj             /*
488*3446Smrj              * Mask and shift the flag bits
489*3446Smrj              */
490*3446Smrj             ACPI_SET8 (Destination) |= (UINT8)
491*3446Smrj                 ((ACPI_GET8 (Source) & 0x03) << Info->Value);
492*3446Smrj             break;
493*3446Smrj 
494*3446Smrj 
495*3446Smrj         case ACPI_RSC_COUNT:
496*3446Smrj 
497*3446Smrj             ItemCount = ACPI_GET8 (Source);
498*3446Smrj             ACPI_SET8 (Destination) = (UINT8) ItemCount;
499*3446Smrj 
500*3446Smrj             AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1)));
501*3446Smrj             break;
502*3446Smrj 
503*3446Smrj 
504*3446Smrj         case ACPI_RSC_COUNT16:
505*3446Smrj 
506*3446Smrj             ItemCount = ACPI_GET16 (Source);
507*3446Smrj             AmlLength = (UINT16) (AmlLength + ItemCount);
508*3446Smrj             AcpiRsSetResourceLength (AmlLength, Aml);
509*3446Smrj             break;
510*3446Smrj 
511*3446Smrj 
512*3446Smrj         case ACPI_RSC_LENGTH:
513*3446Smrj 
514*3446Smrj             AcpiRsSetResourceLength (Info->Value, Aml);
515*3446Smrj             break;
516*3446Smrj 
517*3446Smrj 
518*3446Smrj         case ACPI_RSC_MOVE8:
519*3446Smrj         case ACPI_RSC_MOVE16:
520*3446Smrj         case ACPI_RSC_MOVE32:
521*3446Smrj         case ACPI_RSC_MOVE64:
522*3446Smrj 
523*3446Smrj             if (Info->Value)
524*3446Smrj             {
525*3446Smrj                 ItemCount = Info->Value;
526*3446Smrj             }
527*3446Smrj             AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode);
528*3446Smrj             break;
529*3446Smrj 
530*3446Smrj 
531*3446Smrj         case ACPI_RSC_ADDRESS:
532*3446Smrj 
533*3446Smrj             /* Set the Resource Type, General Flags, and Type-Specific Flags */
534*3446Smrj 
535*3446Smrj             AcpiRsSetAddressCommon (Aml, Resource);
536*3446Smrj             break;
537*3446Smrj 
538*3446Smrj 
539*3446Smrj         case ACPI_RSC_SOURCEX:
540*3446Smrj             /*
541*3446Smrj              * Optional ResourceSource (Index and String)
542*3446Smrj              */
543*3446Smrj             AmlLength = AcpiRsSetResourceSource (
544*3446Smrj                             Aml, (ACPI_RS_LENGTH) AmlLength, Source);
545*3446Smrj             AcpiRsSetResourceLength (AmlLength, Aml);
546*3446Smrj             break;
547*3446Smrj 
548*3446Smrj 
549*3446Smrj         case ACPI_RSC_SOURCE:
550*3446Smrj             /*
551*3446Smrj              * Optional ResourceSource (Index and String). This is the more
552*3446Smrj              * complicated case used by the Interrupt() macro
553*3446Smrj              */
554*3446Smrj             AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source);
555*3446Smrj             AcpiRsSetResourceLength (AmlLength, Aml);
556*3446Smrj             break;
557*3446Smrj 
558*3446Smrj 
559*3446Smrj         case ACPI_RSC_BITMASK:
560*3446Smrj             /*
561*3446Smrj              * 8-bit encoded bitmask (DMA macro)
562*3446Smrj              */
563*3446Smrj             ACPI_SET8 (Destination) = (UINT8)
564*3446Smrj                 AcpiRsEncodeBitmask (Source,
565*3446Smrj                     *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
566*3446Smrj             break;
567*3446Smrj 
568*3446Smrj 
569*3446Smrj         case ACPI_RSC_BITMASK16:
570*3446Smrj             /*
571*3446Smrj              * 16-bit encoded bitmask (IRQ macro)
572*3446Smrj              */
573*3446Smrj             Temp16 = AcpiRsEncodeBitmask (Source,
574*3446Smrj                         *ACPI_ADD_PTR (UINT8, Resource, Info->Value));
575*3446Smrj             ACPI_MOVE_16_TO_16 (Destination, &Temp16);
576*3446Smrj             break;
577*3446Smrj 
578*3446Smrj 
579*3446Smrj         case ACPI_RSC_EXIT_LE:
580*3446Smrj             /*
581*3446Smrj              * Control - Exit conversion if less than or equal
582*3446Smrj              */
583*3446Smrj             if (ItemCount <= Info->Value)
584*3446Smrj             {
585*3446Smrj                 goto Exit;
586*3446Smrj             }
587*3446Smrj             break;
588*3446Smrj 
589*3446Smrj 
590*3446Smrj         case ACPI_RSC_EXIT_NE:
591*3446Smrj             /*
592*3446Smrj              * Control - Exit conversion if not equal
593*3446Smrj              */
594*3446Smrj             switch (COMPARE_OPCODE (Info))
595*3446Smrj             {
596*3446Smrj             case ACPI_RSC_COMPARE_VALUE:
597*3446Smrj 
598*3446Smrj                 if (*ACPI_ADD_PTR (UINT8, Resource,
599*3446Smrj                         COMPARE_TARGET (Info)) != COMPARE_VALUE (Info))
600*3446Smrj                 {
601*3446Smrj                     goto Exit;
602*3446Smrj                 }
603*3446Smrj                 break;
604*3446Smrj 
605*3446Smrj             default:
606*3446Smrj 
607*3446Smrj                 ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode"));
608*3446Smrj                 return_ACPI_STATUS (AE_BAD_PARAMETER);
609*3446Smrj             }
610*3446Smrj             break;
611*3446Smrj 
612*3446Smrj 
613*3446Smrj         default:
614*3446Smrj 
615*3446Smrj             ACPI_ERROR ((AE_INFO, "Invalid conversion opcode"));
616*3446Smrj             return_ACPI_STATUS (AE_BAD_PARAMETER);
617*3446Smrj         }
618*3446Smrj 
619*3446Smrj         Count--;
620*3446Smrj         Info++;
621*3446Smrj     }
622*3446Smrj 
623*3446Smrj Exit:
624*3446Smrj     return_ACPI_STATUS (AE_OK);
625*3446Smrj }
626*3446Smrj 
627*3446Smrj 
628*3446Smrj #if 0
629*3446Smrj /* Previous resource validations */
630*3446Smrj 
631*3446Smrj     if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION)
632*3446Smrj     {
633*3446Smrj         return_ACPI_STATUS (AE_SUPPORT);
634*3446Smrj     }
635*3446Smrj 
636*3446Smrj     if (Resource->Data.StartDpf.PerformanceRobustness >= 3)
637*3446Smrj     {
638*3446Smrj         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
639*3446Smrj     }
640*3446Smrj 
641*3446Smrj     if (((Aml->Irq.Flags & 0x09) == 0x00) ||
642*3446Smrj         ((Aml->Irq.Flags & 0x09) == 0x09))
643*3446Smrj     {
644*3446Smrj         /*
645*3446Smrj          * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive]
646*3446Smrj          * polarity/trigger interrupts are allowed (ACPI spec, section
647*3446Smrj          * "IRQ Format"), so 0x00 and 0x09 are illegal.
648*3446Smrj          */
649*3446Smrj         ACPI_ERROR ((AE_INFO,
650*3446Smrj             "Invalid interrupt polarity/trigger in resource list, %X",
651*3446Smrj             Aml->Irq.Flags));
652*3446Smrj         return_ACPI_STATUS (AE_BAD_DATA);
653*3446Smrj     }
654*3446Smrj 
655*3446Smrj     Resource->Data.ExtendedIrq.InterruptCount = Temp8;
656*3446Smrj     if (Temp8 < 1)
657*3446Smrj     {
658*3446Smrj         /* Must have at least one IRQ */
659*3446Smrj 
660*3446Smrj         return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
661*3446Smrj     }
662*3446Smrj 
663*3446Smrj     if (Resource->Data.Dma.Transfer == 0x03)
664*3446Smrj     {
665*3446Smrj         ACPI_ERROR ((AE_INFO,
666*3446Smrj             "Invalid DMA.Transfer preference (3)"));
667*3446Smrj         return_ACPI_STATUS (AE_BAD_DATA);
668*3446Smrj     }
669*3446Smrj #endif
670*3446Smrj 
671*3446Smrj 
672