Subversion Repositories Kolibri OS

Rev

Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1498 serge 1
 
2
 *
3
 * Module Name: aslresource - Resource template/descriptor utilities
4
 *
5
 *****************************************************************************/
6
7
 
8
 *
9
 * 1. Copyright Notice
10
 *
11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
2216 Serge 12
 * All rights reserved.
1498 serge 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
 
117
 
118
#include "aslcompiler.y.h"
119
#include "amlcode.h"
120
121
 
122
 
123
        ACPI_MODULE_NAME    ("aslresource")
124
125
 
126
 
127
 *
128
 * FUNCTION:    RsSmallAddressCheck
129
 *
130
 * PARAMETERS:  Minimum             - Address Min value
131
 *              Maximum             - Address Max value
132
 *              Length              - Address range value
133
 *              Alignment           - Address alignment value
134
 *              MinOp               - Original Op for Address Min
135
 *              MaxOp               - Original Op for Address Max
136
 *              LengthOp            - Original Op for address range
137
 *              AlignOp             - Original Op for address alignment. If
138
 *                                    NULL, means "zero value for alignment is
139
 *                                    OK, and means 64K alignment" (for
140
 *                                    Memory24 descriptor)
141
 *              Op                  - Parent Op for entire construct
2216 Serge 142
 *
1498 serge 143
 * RETURN:      None. Adds error messages to error log if necessary
144
 *
145
 * DESCRIPTION: Perform common value checks for "small" address descriptors.
146
 *              Currently:
147
 *                  Io, Memory24, Memory32
148
 *
149
 ******************************************************************************/
150
151
 
152
RsSmallAddressCheck (
153
    UINT8                   Type,
154
    UINT32                  Minimum,
155
    UINT32                  Maximum,
156
    UINT32                  Length,
157
    UINT32                  Alignment,
158
    ACPI_PARSE_OBJECT       *MinOp,
159
    ACPI_PARSE_OBJECT       *MaxOp,
160
    ACPI_PARSE_OBJECT       *LengthOp,
161
    ACPI_PARSE_OBJECT       *AlignOp,
2216 Serge 162
    ACPI_PARSE_OBJECT       *Op)
163
{
1498 serge 164
165
 
166
    {
167
        return;
168
    }
169
170
 
2216 Serge 171
     * Check for a so-called "null descriptor". These are descriptors that are
172
     * created with most fields set to zero. The intent is that the descriptor
173
     * will be updated/completed at runtime via a BufferField.
174
     *
175
     * If the descriptor does NOT have a resource tag, it cannot be referenced
176
     * by a BufferField and we will flag this as an error. Conversely, if
177
     * the descriptor has a resource tag, we will assume that a BufferField
178
     * will be used to dynamically update it, so no error.
179
     *
180
     * A possible enhancement to this check would be to verify that in fact
181
     * a BufferField is created using the resource tag, and perhaps even
182
     * verify that a Store is performed to the BufferField.
183
     *
184
     * Note: for these descriptors, Alignment is allowed to be zero
185
     */
186
    if (!Minimum && !Maximum && !Length)
187
    {
188
        if (!Op->Asl.ExternalName)
189
        {
190
            /* No resource tag. Descriptor is fixed and is also illegal */
191
192
 
193
        }
194
195
 
196
    }
197
198
 
1498 serge 199
200
 
201
    {
202
        if (!Alignment) /* Alignment==0 means 64K - no invalid alignment */
203
        {
204
            Alignment = ACPI_UINT16_MAX + 1;
205
        }
206
207
 
208
        Maximum <<= 8;
209
        Length *= 256;
210
    }
211
212
 
213
214
 
215
    {
216
        /* Basic checks on Min/Max/Length */
217
218
 
219
        {
220
            AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL);
221
        }
222
        else if (Length > (Maximum - Minimum + 1))
223
        {
224
            AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL);
225
        }
226
    }
227
228
 
229
230
 
231
    {
232
        Alignment = 1;
233
    }
234
235
 
236
237
 
238
    {
239
        AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL);
240
    }
241
    if (Maximum % Alignment)
242
    {
243
        AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, NULL);
244
    }
245
}
246
247
 
248
 
249
 *
250
 * FUNCTION:    RsLargeAddressCheck
251
 *
252
 * PARAMETERS:  Minimum             - Address Min value
253
 *              Maximum             - Address Max value
254
 *              Length              - Address range value
255
 *              Granularity         - Address granularity value
256
 *              Flags               - General flags for address descriptors:
257
 *                                    _MIF, _MAF, _DEC
258
 *              MinOp               - Original Op for Address Min
259
 *              MaxOp               - Original Op for Address Max
260
 *              LengthOp            - Original Op for address range
261
 *              GranOp              - Original Op for address granularity
262
 *              Op                  - Parent Op for entire construct
2216 Serge 263
 *
1498 serge 264
 * RETURN:      None. Adds error messages to error log if necessary
265
 *
266
 * DESCRIPTION: Perform common value checks for "large" address descriptors.
267
 *              Currently:
268
 *                  WordIo,     WordBusNumber,  WordSpace
269
 *                  DWordIo,    DWordMemory,    DWordSpace
270
 *                  QWordIo,    QWordMemory,    QWordSpace
271
 *                  ExtendedIo, ExtendedMemory, ExtendedSpace
272
 *
273
 * _MIF flag set means that the minimum address is fixed and is not relocatable
274
 * _MAF flag set means that the maximum address is fixed and is not relocatable
275
 * Length of zero means that the record size is variable
276
 *
277
 * This function implements the LEN/MIF/MAF/MIN/MAX/GRA rules within Table 6-40
278
 * of the ACPI 4.0a specification. Added 04/2010.
279
 *
280
 ******************************************************************************/
281
282
 
283
RsLargeAddressCheck (
284
    UINT64                  Minimum,
285
    UINT64                  Maximum,
286
    UINT64                  Length,
287
    UINT64                  Granularity,
288
    UINT8                   Flags,
289
    ACPI_PARSE_OBJECT       *MinOp,
290
    ACPI_PARSE_OBJECT       *MaxOp,
291
    ACPI_PARSE_OBJECT       *LengthOp,
292
    ACPI_PARSE_OBJECT       *GranOp,
2216 Serge 293
    ACPI_PARSE_OBJECT       *Op)
294
{
1498 serge 295
296
 
297
    {
298
        return;
299
    }
300
301
 
2216 Serge 302
     * Check for a so-called "null descriptor". These are descriptors that are
303
     * created with most fields set to zero. The intent is that the descriptor
304
     * will be updated/completed at runtime via a BufferField.
305
     *
306
     * If the descriptor does NOT have a resource tag, it cannot be referenced
307
     * by a BufferField and we will flag this as an error. Conversely, if
308
     * the descriptor has a resource tag, we will assume that a BufferField
309
     * will be used to dynamically update it, so no error.
310
     *
311
     * A possible enhancement to this check would be to verify that in fact
312
     * a BufferField is created using the resource tag, and perhaps even
313
     * verify that a Store is performed to the BufferField.
314
     */
315
    if (!Minimum && !Maximum && !Length && !Granularity)
316
    {
317
        if (!Op->Asl.ExternalName)
318
        {
319
            /* No resource tag. Descriptor is fixed and is also illegal */
320
321
 
322
        }
323
324
 
325
    }
326
327
 
1498 serge 328
329
 
330
    {
331
        AslError (ASL_ERROR, ASL_MSG_INVALID_MIN_MAX, MinOp, NULL);
332
        return;
333
    }
334
    else if (Length > (Maximum - Minimum + 1))
335
    {
336
        AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH, LengthOp, NULL);
337
        return;
338
    }
339
340
 
341
342
 
343
    {
344
        if ((Granularity + 1) &
345
             Granularity)
346
        {
347
            AslError (ASL_ERROR, ASL_MSG_INVALID_GRANULARITY, GranOp, NULL);
348
            return;
349
        }
350
    }
351
352
 
353
     * Check the various combinations of Length, MinFixed, and MaxFixed
354
     */
355
    if (Length)
356
    {
357
        /* Fixed non-zero length */
358
359
 
360
        {
361
        case 0:
362
            /*
363
             * Fixed length, variable locations (both _MIN and _MAX).
364
             * Length must be a multiple of granularity
365
             */
366
            if (Granularity & Length)
367
            {
368
                AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, LengthOp, NULL);
369
            }
370
            break;
371
372
 
373
374
 
375
376
 
377
            {
378
                AslError (ASL_ERROR, ASL_MSG_INVALID_GRAN_FIXED, GranOp, NULL);
379
            }
380
381
 
382
383
 
384
            {
385
                AslError (ASL_ERROR, ASL_MSG_INVALID_LENGTH_FIXED, LengthOp, NULL);
386
            }
387
            break;
388
389
 
390
391
 
392
        case ACPI_RESOURCE_FLAG_MAF:
393
        default:
394
            AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL);
395
        }
396
    }
397
    else
398
    {
399
        /* Variable length (length==0) */
400
401
 
402
        {
403
        case 0:
404
            /*
405
             * Both _MIN and _MAX are variable.
406
             * No additional requirements, just exit
407
             */
408
            break;
409
410
 
411
412
 
413
414
 
415
             * The granularity is defined by the ACPI specification to be a
416
             * power-of-two minus one, therefore the granularity is a
417
             * bitmask which can be used to easily validate the addresses.
418
             */
419
            if (Granularity & Minimum)
420
            {
421
                AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MinOp, NULL);
422
            }
423
            break;
424
425
 
426
427
 
428
429
 
430
            {
431
                AslError (ASL_ERROR, ASL_MSG_ALIGNMENT, MaxOp, "-1");
432
            }
433
            break;
434
435
 
436
437
 
438
        default:
439
            AslError (ASL_ERROR, ASL_MSG_INVALID_ADDR_FLAGS, LengthOp, NULL);
440
        }
441
    }
442
}
443
444
 
445
 
446
 *
447
 * FUNCTION:    RsGetStringDataLength
448
 *
449
 * PARAMETERS:  InitializerOp     - Start of a subtree of init nodes
450
 *
451
 * RETURN:      Valid string length if a string node is found (otherwise 0)
452
 *
453
 * DESCRIPTION: In a list of peer nodes, find the first one that contains a
454
 *              string and return the length of the string.
455
 *
456
 ******************************************************************************/
457
458
 
459
RsGetStringDataLength (
460
    ACPI_PARSE_OBJECT       *InitializerOp)
461
{
462
463
 
464
    {
465
        if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL)
466
        {
467
            return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1));
468
        }
469
        InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
470
    }
471
472
 
473
}
474
475
 
476
 
477
 *
478
 * FUNCTION:    RsAllocateResourceNode
479
 *
480
 * PARAMETERS:  Size        - Size of node in bytes
481
 *
482
 * RETURN:      The allocated node - aborts on allocation failure
483
 *
484
 * DESCRIPTION: Allocate a resource description node and the resource
485
 *              descriptor itself (the nodes are used to link descriptors).
486
 *
487
 ******************************************************************************/
488
489
 
490
RsAllocateResourceNode (
491
    UINT32                  Size)
492
{
493
    ASL_RESOURCE_NODE       *Rnode;
494
495
 
496
 
497
498
 
499
500
 
501
502
 
503
    Rnode->BufferLength = Size;
504
505
 
506
}
507
508
 
509
 
510
 *
511
 * FUNCTION:    RsCreateBitField
512
 *
513
 * PARAMETERS:  Op              - Resource field node
514
 *              Name            - Name of the field (Used only to reference
515
 *                                the field in the ASL, not in the AML)
516
 *              ByteOffset      - Offset from the field start
517
 *              BitOffset       - Additional bit offset
518
 *
519
 * RETURN:      None, sets fields within the input node
520
 *
521
 * DESCRIPTION: Utility function to generate a named bit field within a
522
 *              resource descriptor.  Mark a node as 1) a field in a resource
523
 *              descriptor, and 2) set the value to be a BIT offset
524
 *
525
 ******************************************************************************/
526
527
 
528
RsCreateBitField (
529
    ACPI_PARSE_OBJECT       *Op,
530
    char                    *Name,
531
    UINT32                  ByteOffset,
532
    UINT32                  BitOffset)
533
{
534
535
 
536
    Op->Asl.Value.Integer     = ((UINT64) ByteOffset * 8) + BitOffset;
537
    Op->Asl.CompileFlags     |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET);
538
}
539
540
 
541
 
542
 *
543
 * FUNCTION:    RsCreateByteField
544
 *
545
 * PARAMETERS:  Op              - Resource field node
546
 *              Name            - Name of the field (Used only to reference
547
 *                                the field in the ASL, not in the AML)
548
 *              ByteOffset      - Offset from the field start
549
 *
550
 * RETURN:      None, sets fields within the input node
551
 *
552
 * DESCRIPTION: Utility function to generate a named byte field within a
553
 *              resource descriptor.  Mark a node as 1) a field in a resource
554
 *              descriptor, and 2) set the value to be a BYTE offset
555
 *
556
 ******************************************************************************/
557
558
 
559
RsCreateByteField (
560
    ACPI_PARSE_OBJECT       *Op,
561
    char                    *Name,
562
    UINT32                  ByteOffset)
563
{
564
565
 
566
    Op->Asl.Value.Integer     = ByteOffset;
567
    Op->Asl.CompileFlags     |= NODE_IS_RESOURCE_FIELD;
568
}
569
570
 
571
 
572
 *
573
 * FUNCTION:    RsSetFlagBits
574
 *
575
 * PARAMETERS:  *Flags          - Pointer to the flag byte
576
 *              Op              - Flag initialization node
577
 *              Position        - Bit position within the flag byte
578
 *              Default         - Used if the node is DEFAULT.
579
 *
580
 * RETURN:      Sets bits within the *Flags output byte.
581
 *
582
 * DESCRIPTION: Set a bit in a cumulative flags word from an initialization
583
 *              node.  Will use a default value if the node is DEFAULT, meaning
584
 *              that no value was specified in the ASL.  Used to merge multiple
585
 *              keywords into a single flags byte.
586
 *
587
 ******************************************************************************/
588
589
 
590
RsSetFlagBits (
591
    UINT8                   *Flags,
592
    ACPI_PARSE_OBJECT       *Op,
593
    UINT8                   Position,
594
    UINT8                   DefaultBit)
595
{
596
597
 
598
    {
599
        /* Use the default bit */
600
601
 
602
    }
603
    else
604
    {
605
        /* Use the bit specified in the initialization node */
606
607
 
608
    }
609
}
610
611
 
612
 
613
 *
614
 * FUNCTION:    RsCompleteNodeAndGetNext
615
 *
616
 * PARAMETERS:  Op            - Resource node to be completed
617
 *
618
 * RETURN:      The next peer to the input node.
619
 *
620
 * DESCRIPTION: Mark the current node completed and return the next peer.
621
 *              The node ParseOpcode is set to DEFAULT_ARG, meaning that
622
 *              this node is to be ignored from now on.
623
 *
624
 ******************************************************************************/
625
626
 
627
RsCompleteNodeAndGetNext (
628
    ACPI_PARSE_OBJECT       *Op)
629
{
630
631
 
632
633
 
634
635
 
636
637
 
638
}
639
640
 
641
 
642
 *
643
 * FUNCTION:    RsCheckListForDuplicates
644
 *
645
 * PARAMETERS:  Op                  - First op in the initializer list
646
 *
647
 * RETURN:      None
648
 *
649
 * DESCRIPTION: Check an initializer list for duplicate values. Emits an error
650
 *              if any duplicates are found.
651
 *
652
 ******************************************************************************/
653
654
 
655
RsCheckListForDuplicates (
656
    ACPI_PARSE_OBJECT       *Op)
657
{
658
    ACPI_PARSE_OBJECT       *NextValueOp = Op;
659
    ACPI_PARSE_OBJECT       *NextOp;
660
    UINT32                  Value;
661
662
 
663
 
664
    {
665
        return;
666
    }
667
668
 
669
670
 
671
    {
672
        Value = (UINT32) NextValueOp->Asl.Value.Integer;
673
674
 
675
676
 
677
        while (NextOp)
678
        {
679
            if (NextOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
680
            {
681
                /* Compare values */
682
683
 
684
                {
685
                    /* Emit error only once per duplicate node */
686
687
 
688
                    {
689
                        NextOp->Asl.CompileFlags |= NODE_IS_DUPLICATE;
690
                        AslError (ASL_ERROR, ASL_MSG_DUPLICATE_ITEM,
691
                            NextOp, NULL);
692
                    }
693
                }
694
            }
695
696
 
697
        }
698
699
 
700
    }
701
}
702
703
 
704
 
705
 *
706
 * FUNCTION:    RsDoOneResourceDescriptor
707
 *
708
 * PARAMETERS:  DescriptorTypeOp    - Parent parse node of the descriptor
709
 *              CurrentByteOffset   - Offset in the resource descriptor
710
 *                                    buffer.
711
 *
712
 * RETURN:      A valid resource node for the descriptor
713
 *
714
 * DESCRIPTION: Dispatches the processing of one resource descriptor
715
 *
716
 ******************************************************************************/
717
718
 
719
RsDoOneResourceDescriptor (
720
    ACPI_PARSE_OBJECT       *DescriptorTypeOp,
721
    UINT32                  CurrentByteOffset,
722
    UINT8                   *State)
723
{
724
    ASL_RESOURCE_NODE       *Rnode = NULL;
725
726
 
727
 
728
729
 
730
    {
731
    case PARSEOP_DMA:
732
        Rnode = RsDoDmaDescriptor (DescriptorTypeOp,
733
                    CurrentByteOffset);
734
        break;
735
736
 
737
        Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp,
738
                    CurrentByteOffset);
739
        break;
740
741
 
742
        Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp,
743
                    CurrentByteOffset);
744
        break;
745
746
 
747
        Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp,
748
                    CurrentByteOffset);
749
        break;
750
751
 
752
        switch (*State)
753
        {
754
        case ACPI_RSTATE_NORMAL:
755
            AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT,
756
                DescriptorTypeOp, NULL);
757
            break;
758
759
 
760
            AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
761
                DescriptorTypeOp, NULL);
762
            break;
763
764
 
765
        default:
766
            break;
767
        }
768
769
 
770
        Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp,
771
                    CurrentByteOffset);
772
        break;
773
774
 
775
        Rnode = RsDoEndTagDescriptor (DescriptorTypeOp,
776
                    CurrentByteOffset);
777
        break;
778
779
 
780
        Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp,
781
                    CurrentByteOffset);
782
        break;
783
784
 
785
        Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp,
786
                    CurrentByteOffset);
787
        break;
788
789
 
790
        Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp,
791
                    CurrentByteOffset);
792
        break;
793
794
 
795
        Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp,
796
                    CurrentByteOffset);
797
        break;
798
799
 
800
        Rnode = RsDoInterruptDescriptor (DescriptorTypeOp,
801
                    CurrentByteOffset);
802
        break;
803
804
 
805
        Rnode = RsDoIoDescriptor (DescriptorTypeOp,
806
                    CurrentByteOffset);
807
        break;
808
809
 
810
        Rnode = RsDoIrqDescriptor (DescriptorTypeOp,
811
                    CurrentByteOffset);
812
        break;
813
814
 
815
        Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp,
816
                    CurrentByteOffset);
817
        break;
818
819
 
820
        Rnode = RsDoMemory24Descriptor (DescriptorTypeOp,
821
                    CurrentByteOffset);
822
        break;
823
824
 
825
        Rnode = RsDoMemory32Descriptor (DescriptorTypeOp,
826
                    CurrentByteOffset);
827
        break;
828
829
 
830
        Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp,
831
                    CurrentByteOffset);
832
        break;
833
834
 
835
        Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp,
836
                    CurrentByteOffset);
837
        break;
838
839
 
840
        Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp,
841
                    CurrentByteOffset);
842
        break;
843
844
 
845
        Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp,
846
                    CurrentByteOffset);
847
        break;
848
849
 
850
        Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp,
851
                    CurrentByteOffset);
852
        break;
853
854
 
855
        switch (*State)
856
        {
857
        case ACPI_RSTATE_START_DEPENDENT:
858
            AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
859
                DescriptorTypeOp, NULL);
860
            break;
861
862
 
863
        case ACPI_RSTATE_DEPENDENT_LIST:
864
        default:
865
            break;
866
        }
867
868
 
869
        Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp,
870
                    CurrentByteOffset);
871
        *State = ACPI_RSTATE_DEPENDENT_LIST;
872
        break;
873
874
 
875
        switch (*State)
876
        {
877
        case ACPI_RSTATE_START_DEPENDENT:
878
            AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING,
879
                DescriptorTypeOp, NULL);
880
            break;
881
882
 
883
        case ACPI_RSTATE_DEPENDENT_LIST:
884
        default:
885
            break;
886
        }
887
888
 
889
        Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp,
890
                    CurrentByteOffset);
891
        *State = ACPI_RSTATE_DEPENDENT_LIST;
892
        break;
893
894
 
895
        Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp,
896
                    CurrentByteOffset);
897
        break;
898
899
 
900
        Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp,
901
                    CurrentByteOffset);
902
        break;
903
904
 
905
        Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp,
906
                    CurrentByteOffset);
907
        break;
908
909
 
910
        Rnode = RsDoWordIoDescriptor (DescriptorTypeOp,
911
                    CurrentByteOffset);
912
        break;
913
914
 
915
        Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp,
916
                    CurrentByteOffset);
917
        break;
918
919
 
920
        /* Just ignore any of these, they are used as fillers/placeholders */
921
        break;
922
923
 
924
        printf ("Unknown resource descriptor type [%s]\n",
925
                    DescriptorTypeOp->Asl.ParseOpName);
926
        break;
927
    }
928
929
 
930
     * Mark original node as unused, but head of a resource descriptor.
931
     * This allows the resource to be installed in the namespace so that
932
     * references to the descriptor can be resolved.
933
     */
934
    DescriptorTypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
935
    DescriptorTypeOp->Asl.CompileFlags = NODE_IS_RESOURCE_DESC;
936
    DescriptorTypeOp->Asl.Value.Integer = CurrentByteOffset;
937
938
 
939
    {
940
        DescriptorTypeOp->Asl.FinalAmlLength = Rnode->BufferLength;
941
    }
942
943
 
944
}
945
946
 
947
 
948
 *
949
 * FUNCTION:    RsLinkDescriptorChain
950
 *
951
 * PARAMETERS:  PreviousRnode       - Pointer to the node that will be previous
952
 *                                    to the linked node,  At exit, set to the
953
 *                                    last node in the new chain.
954
 *              Rnode               - Resource node to link into the list
955
 *
956
 * RETURN:      Cumulative buffer byte offset of the new segment of chain
957
 *
958
 * DESCRIPTION: Link a descriptor chain at the end of an existing chain.
959
 *
960
 ******************************************************************************/
961
962
 
963
RsLinkDescriptorChain (
964
    ASL_RESOURCE_NODE       **PreviousRnode,
965
    ASL_RESOURCE_NODE       *Rnode)
966
{
967
    ASL_RESOURCE_NODE       *LastRnode;
968
    UINT32                  CurrentByteOffset;
969
970
 
971
 
972
973
 
974
    {
975
        return 0;
976
    }
977
978
 
979
980
 
981
    CurrentByteOffset = Rnode->BufferLength;
982
983
 
984
985
 
986
    while (LastRnode->Next)
987
    {
988
        LastRnode = LastRnode->Next;
989
        CurrentByteOffset += LastRnode->BufferLength;
990
    }
991
992
 
993
994
 
995
    return CurrentByteOffset;
996
}
997
998
 
999
 
1000
 *
1001
 * FUNCTION:    RsDoResourceTemplate
1002
 *
1003
 * PARAMETERS:  Op        - Parent of a resource template list
1004
 *
1005
 * RETURN:      None.  Sets input node to point to a list of AML code
1006
 *
1007
 * DESCRIPTION: Merge a list of resource descriptors into a single AML buffer,
1008
 *              in preparation for output to the AML output file.
1009
 *
1010
 ******************************************************************************/
1011
1012
 
1013
RsDoResourceTemplate (
1014
    ACPI_PARSE_OBJECT       *Op)
1015
{
1016
    ACPI_PARSE_OBJECT       *BufferLengthOp;
1017
    ACPI_PARSE_OBJECT       *BufferOp;
1018
    ACPI_PARSE_OBJECT       *DescriptorTypeOp;
1019
    ACPI_PARSE_OBJECT       *LastOp = NULL;
1020
    UINT32                  CurrentByteOffset = 0;
1021
    ASL_RESOURCE_NODE       HeadRnode;
1022
    ASL_RESOURCE_NODE       *PreviousRnode;
1023
    ASL_RESOURCE_NODE       *Rnode;
1024
    UINT8                   State;
1025
1026
 
1027
 
1028
1029
 
1030
    {
1031
        Op->Asl.Parent->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC;
1032
    }
1033
1034
 
1035
    /* Buffer Length node is first child */
1036
1037
 
1038
1039
 
1040
1041
 
1042
1043
 
1044
1045
 
1046
1047
 
1048
     * Process all resource descriptors in the list
1049
     * Note: It is assumed that the EndTag node has been automatically
1050
     * inserted at the end of the template by the parser.
1051
     */
1052
    State = ACPI_RSTATE_NORMAL;
1053
    PreviousRnode = &HeadRnode;
1054
    while (DescriptorTypeOp)
1055
    {
1056
        DescriptorTypeOp->Asl.CompileFlags |= NODE_IS_RESOURCE_DESC;
1057
        Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset,
1058
                    &State);
1059
1060
 
1061
         * Update current byte offset to indicate the number of bytes from the
1062
         * start of the buffer.  Buffer can include multiple descriptors, we
1063
         * must keep track of the offset of not only each descriptor, but each
1064
         * element (field) within each descriptor as well.
1065
         */
1066
        CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode);
1067
1068
 
1069
1070
 
1071
        DescriptorTypeOp = ASL_GET_PEER_NODE (DescriptorTypeOp);
1072
    }
1073
1074
 
1075
    {
1076
        if (LastOp)
1077
        {
1078
            LastOp = LastOp->Asl.Parent;
1079
        }
1080
        AslError (ASL_ERROR, ASL_MSG_MISSING_ENDDEPENDENT, LastOp, NULL);
1081
    }
1082
1083
 
1084
     * Transform the nodes into the following
1085
     *
1086
     * Op           -> AML_BUFFER_OP
1087
     * First Child  -> BufferLength
1088
     * Second Child -> Descriptor Buffer (raw byte data)
1089
     */
1090
    Op->Asl.ParseOpcode               = PARSEOP_BUFFER;
1091
    Op->Asl.AmlOpcode                 = AML_BUFFER_OP;
1092
    Op->Asl.CompileFlags              = NODE_AML_PACKAGE | NODE_IS_RESOURCE_DESC;
1093
1094
 
1095
    BufferLengthOp->Asl.Value.Integer = CurrentByteOffset;
1096
    (void) OpcSetOptimalIntegerSize (BufferLengthOp);
1097
1098
 
1099
    BufferOp->Asl.AmlOpcode           = AML_RAW_DATA_CHAIN;
1100
    BufferOp->Asl.AmlOpcodeLength     = 0;
1101
    BufferOp->Asl.AmlLength           = CurrentByteOffset;
1102
    BufferOp->Asl.Value.Buffer        = (UINT8 *) HeadRnode.Next;
1103
    BufferOp->Asl.CompileFlags       |= NODE_IS_RESOURCE_DATA;
1104
1105
 
1106
}
1107