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