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: aslrestype1i - Small I/O-related resource descriptors
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
120
 
121
        ACPI_MODULE_NAME    ("aslrestype1i")
122
123
 
124
 * This module contains the I/O-related small resource descriptors:
125
 *
126
 * DMA
127
 * FixedIO
128
 * IO
129
 * IRQ
130
 * IRQNoFlags
131
 */
132
133
 
134
 *
135
 * FUNCTION:    RsDoDmaDescriptor
136
 *
137
 * PARAMETERS:  Op                  - Parent resource descriptor parse node
138
 *              CurrentByteOffset   - Offset into the resource template AML
139
 *                                    buffer (to track references to the desc)
140
 *
141
 * RETURN:      Completed resource node
142
 *
143
 * DESCRIPTION: Construct a short "DMA" descriptor
144
 *
145
 ******************************************************************************/
146
147
 
148
RsDoDmaDescriptor (
149
    ACPI_PARSE_OBJECT       *Op,
150
    UINT32                  CurrentByteOffset)
151
{
152
    AML_RESOURCE            *Descriptor;
153
    ACPI_PARSE_OBJECT       *InitializerOp;
154
    ASL_RESOURCE_NODE       *Rnode;
155
    UINT32                  i;
156
    UINT8                   DmaChannelMask = 0;
157
    UINT8                   DmaChannels = 0;
158
159
 
160
 
161
    Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA));
162
163
 
164
    Descriptor->Dma.DescriptorType  = ACPI_RESOURCE_NAME_DMA |
165
                                        ASL_RDESC_DMA_SIZE;
166
167
 
168
169
 
170
    {
171
        switch (i)
172
        {
173
        case 0: /* DMA type */
174
175
 
176
            RsCreateBitField (InitializerOp, ACPI_RESTAG_DMATYPE,
177
                CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5);
178
            break;
179
180
 
181
182
 
183
            RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER,
184
                CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
185
            break;
186
187
 
188
189
 
190
            RsCreateBitField (InitializerOp, ACPI_RESTAG_XFERTYPE,
191
                CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0);
192
            break;
193
194
 
195
196
 
197
            break;
198
199
 
200
201
 
202
203
 
204
            {
205
                /* Up to 8 channels can be specified in the list */
206
207
 
208
                if (DmaChannels > 8)
209
                {
210
                    AslError (ASL_ERROR, ASL_MSG_DMA_LIST,
211
                        InitializerOp, NULL);
212
                    return (Rnode);
213
                }
214
215
 
216
217
 
218
                {
219
                    AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL,
220
                        InitializerOp, NULL);
221
                }
222
223
 
224
225
 
226
                    (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
227
            }
228
229
 
230
            {
231
                /* Check now for duplicates in list */
232
233
 
234
235
 
236
237
 
238
                    CurrentByteOffset +
239
                    ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
240
            }
241
            break;
242
        }
243
244
 
245
    }
246
247
 
248
249
 
250
    return (Rnode);
251
}
252
253
 
254
 
255
 *
256
 * FUNCTION:    RsDoFixedIoDescriptor
257
 *
258
 * PARAMETERS:  Op                  - Parent resource descriptor parse node
259
 *              CurrentByteOffset   - Offset into the resource template AML
260
 *                                    buffer (to track references to the desc)
261
 *
262
 * RETURN:      Completed resource node
263
 *
264
 * DESCRIPTION: Construct a short "FixedIO" descriptor
265
 *
266
 ******************************************************************************/
267
268
 
269
RsDoFixedIoDescriptor (
270
    ACPI_PARSE_OBJECT       *Op,
271
    UINT32                  CurrentByteOffset)
272
{
273
    AML_RESOURCE            *Descriptor;
274
    ACPI_PARSE_OBJECT       *InitializerOp;
275
    ACPI_PARSE_OBJECT       *AddressOp = NULL;
276
    ASL_RESOURCE_NODE       *Rnode;
277
    UINT32                  i;
278
279
 
280
 
281
    Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO));
282
283
 
284
    Descriptor->Io.DescriptorType  = ACPI_RESOURCE_NAME_FIXED_IO |
285
                                      ASL_RDESC_FIXED_IO_SIZE;
286
287
 
288
289
 
290
    {
291
        switch (i)
292
        {
293
        case 0: /* Base Address */
294
295
 
296
                (UINT16) InitializerOp->Asl.Value.Integer;
297
            RsCreateByteField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
298
                CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
299
            AddressOp = InitializerOp;
300
            break;
301
302
 
303
304
 
305
                (UINT8) InitializerOp->Asl.Value.Integer;
306
            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
307
                CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength));
308
            break;
309
310
 
311
312
 
313
            break;
314
315
 
316
317
 
318
            break;
319
        }
320
321
 
322
    }
323
324
 
325
326
 
327
    {
328
        AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
329
    }
330
331
 
332
}
333
334
 
335
 
336
 *
337
 * FUNCTION:    RsDoIoDescriptor
338
 *
339
 * PARAMETERS:  Op                  - Parent resource descriptor parse node
340
 *              CurrentByteOffset   - Offset into the resource template AML
341
 *                                    buffer (to track references to the desc)
342
 *
343
 * RETURN:      Completed resource node
344
 *
345
 * DESCRIPTION: Construct a short "IO" descriptor
346
 *
347
 ******************************************************************************/
348
349
 
350
RsDoIoDescriptor (
351
    ACPI_PARSE_OBJECT       *Op,
352
    UINT32                  CurrentByteOffset)
353
{
354
    AML_RESOURCE            *Descriptor;
355
    ACPI_PARSE_OBJECT       *InitializerOp;
356
    ACPI_PARSE_OBJECT       *MinOp = NULL;
357
    ACPI_PARSE_OBJECT       *MaxOp = NULL;
358
    ACPI_PARSE_OBJECT       *LengthOp = NULL;
359
    ACPI_PARSE_OBJECT       *AlignOp = NULL;
360
    ASL_RESOURCE_NODE       *Rnode;
361
    UINT32                  i;
362
363
 
364
 
365
    Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO));
366
367
 
368
    Descriptor->Io.DescriptorType  = ACPI_RESOURCE_NAME_IO |
369
                                      ASL_RDESC_IO_SIZE;
370
371
 
372
373
 
374
    {
375
        switch (i)
376
        {
377
        case 0: /* Decode size */
378
379
 
380
            RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
381
                CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0);
382
            break;
383
384
 
385
386
 
387
                (UINT16) InitializerOp->Asl.Value.Integer;
388
            RsCreateByteField (InitializerOp, ACPI_RESTAG_MINADDR,
389
                CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
390
            MinOp = InitializerOp;
391
            break;
392
393
 
394
395
 
396
                (UINT16) InitializerOp->Asl.Value.Integer;
397
            RsCreateByteField (InitializerOp, ACPI_RESTAG_MAXADDR,
398
                CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
399
            MaxOp = InitializerOp;
400
            break;
401
402
 
403
404
 
405
                (UINT8) InitializerOp->Asl.Value.Integer;
406
            RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
407
                CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment));
408
            AlignOp = InitializerOp;
409
            break;
410
411
 
412
413
 
414
                (UINT8) InitializerOp->Asl.Value.Integer;
415
            RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
416
                CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength));
417
            LengthOp = InitializerOp;
418
            break;
419
420
 
421
422
 
423
            break;
424
425
 
426
427
 
428
            break;
429
        }
430
431
 
432
    }
433
434
 
435
436
 
437
        Descriptor->Io.Minimum,
438
        Descriptor->Io.Maximum,
439
        Descriptor->Io.AddressLength,
440
        Descriptor->Io.Alignment,
441
        MinOp, MaxOp, LengthOp, AlignOp, Op);
2216 Serge 442
1498 serge 443
 
444
}
445
446
 
447
 
448
 *
449
 * FUNCTION:    RsDoIrqDescriptor
450
 *
451
 * PARAMETERS:  Op                  - Parent resource descriptor parse node
452
 *              CurrentByteOffset   - Offset into the resource template AML
453
 *                                    buffer (to track references to the desc)
454
 *
455
 * RETURN:      Completed resource node
456
 *
457
 * DESCRIPTION: Construct a short "IRQ" descriptor
458
 *
459
 ******************************************************************************/
460
461
 
462
RsDoIrqDescriptor (
463
    ACPI_PARSE_OBJECT       *Op,
464
    UINT32                  CurrentByteOffset)
465
{
466
    AML_RESOURCE            *Descriptor;
467
    ACPI_PARSE_OBJECT       *InitializerOp;
468
    ASL_RESOURCE_NODE       *Rnode;
469
    UINT32                  Interrupts = 0;
470
    UINT16                  IrqMask = 0;
471
    UINT32                  i;
472
473
 
474
 
475
    Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ));
476
477
 
478
479
 
480
    Descriptor->Irq.DescriptorType  = ACPI_RESOURCE_NAME_IRQ |
481
                                      (ASL_RDESC_IRQ_SIZE + 0x01);
482
483
 
484
485
 
486
    {
487
        switch (i)
488
        {
489
        case 0: /* Interrupt Type (or Mode - edge/level) */
490
491
 
492
            RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
493
                CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
494
            break;
495
496
 
497
498
 
499
            RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
500
                CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
501
            break;
502
503
 
504
505
 
506
            RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
507
                CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
508
            break;
509
510
 
511
512
 
513
            break;
514
515
 
516
517
 
518
519
 
520
            {
521
                /* Up to 16 interrupts can be specified in the list */
522
523
 
524
                if (Interrupts > 16)
525
                {
526
                    AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
527
                        InitializerOp, NULL);
528
                    return (Rnode);
529
                }
530
531
 
532
533
 
534
                {
535
                    AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
536
                        InitializerOp, NULL);
537
                }
538
                else
539
                {
540
                    IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
541
                }
542
            }
543
544
 
545
546
 
547
            {
548
                /* Check now for duplicates in list */
549
550
 
551
552
 
553
554
 
555
                    CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
556
            }
557
            break;
558
        }
559
560
 
561
    }
562
563
 
564
565
 
566
    return (Rnode);
567
}
568
569
 
570
 
571
 *
572
 * FUNCTION:    RsDoIrqNoFlagsDescriptor
573
 *
574
 * PARAMETERS:  Op                  - Parent resource descriptor parse node
575
 *              CurrentByteOffset   - Offset into the resource template AML
576
 *                                    buffer (to track references to the desc)
577
 *
578
 * RETURN:      Completed resource node
579
 *
580
 * DESCRIPTION: Construct a short "IRQNoFlags" descriptor
581
 *
582
 ******************************************************************************/
583
584
 
585
RsDoIrqNoFlagsDescriptor (
586
    ACPI_PARSE_OBJECT       *Op,
587
    UINT32                  CurrentByteOffset)
588
{
589
    AML_RESOURCE            *Descriptor;
590
    ACPI_PARSE_OBJECT       *InitializerOp;
591
    ASL_RESOURCE_NODE       *Rnode;
592
    UINT16                  IrqMask = 0;
593
    UINT32                  Interrupts = 0;
594
    UINT32                  i;
595
596
 
597
 
598
    Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS));
599
600
 
601
    Descriptor->Irq.DescriptorType  = ACPI_RESOURCE_NAME_IRQ |
602
                                      ASL_RDESC_IRQ_SIZE;
603
604
 
605
606
 
607
    {
608
        switch (i)
609
        {
610
        case 0: /* Name */
611
612
 
613
            break;
614
615
 
616
617
 
618
619
 
620
            {
621
                /* Up to 16 interrupts can be specified in the list */
622
623
 
624
                if (Interrupts > 16)
625
                {
626
                    AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
627
                        InitializerOp, NULL);
628
                    return (Rnode);
629
                }
630
631
 
632
633
 
634
                {
635
                    AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
636
                        InitializerOp, NULL);
637
                }
638
                else
639
                {
640
                    IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
641
                }
642
            }
643
644
 
645
646
 
647
            {
648
                /* Check now for duplicates in list */
649
650
 
651
652
 
653
654
 
655
                    CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
656
            }
657
            break;
658
        }
659
660
 
661
    }
662
663
 
664
665
 
666
    return (Rnode);
667
}
668