1 /******************************************************************************
3 * Module Name: aslrestype1 - Miscellaneous small resource descriptors
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include <contrib/dev/acpica/compiler/aslcompiler.h>
46 #include "aslcompiler.y.h"
48 #define _COMPONENT ACPI_COMPILER
49 ACPI_MODULE_NAME ("aslrestype1")
52 * This module contains miscellaneous small resource descriptors:
60 * StartDependentFnNoPri
64 /*******************************************************************************
66 * FUNCTION: RsDoEndTagDescriptor
68 * PARAMETERS: Op - Parent resource descriptor parse node
69 * CurrentByteOffset - Offset into the resource template AML
70 * buffer (to track references to the desc)
72 * RETURN: Completed resource node
74 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
76 ******************************************************************************/
79 RsDoEndTagDescriptor (
80 ACPI_PARSE_OBJECT *Op,
81 UINT32 CurrentByteOffset)
83 AML_RESOURCE *Descriptor;
84 ASL_RESOURCE_NODE *Rnode;
87 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG));
89 Descriptor = Rnode->Buffer;
90 Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG |
91 ASL_RDESC_END_TAG_SIZE;
92 Descriptor->EndTag.Checksum = 0;
98 /*******************************************************************************
100 * FUNCTION: RsDoEndDependentDescriptor
102 * PARAMETERS: Op - Parent resource descriptor parse node
103 * CurrentByteOffset - Offset into the resource template AML
104 * buffer (to track references to the desc)
106 * RETURN: Completed resource node
108 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
110 ******************************************************************************/
113 RsDoEndDependentDescriptor (
114 ACPI_PARSE_OBJECT *Op,
115 UINT32 CurrentByteOffset)
117 AML_RESOURCE *Descriptor;
118 ASL_RESOURCE_NODE *Rnode;
121 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
123 Descriptor = Rnode->Buffer;
124 Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT |
125 ASL_RDESC_END_DEPEND_SIZE;
130 /*******************************************************************************
132 * FUNCTION: RsDoMemory24Descriptor
134 * PARAMETERS: Op - Parent resource descriptor parse node
135 * CurrentByteOffset - Offset into the resource template AML
136 * buffer (to track references to the desc)
138 * RETURN: Completed resource node
140 * DESCRIPTION: Construct a short "Memory24" descriptor
142 ******************************************************************************/
145 RsDoMemory24Descriptor (
146 ACPI_PARSE_OBJECT *Op,
147 UINT32 CurrentByteOffset)
149 AML_RESOURCE *Descriptor;
150 ACPI_PARSE_OBJECT *InitializerOp;
151 ACPI_PARSE_OBJECT *MinOp = NULL;
152 ACPI_PARSE_OBJECT *MaxOp = NULL;
153 ACPI_PARSE_OBJECT *LengthOp = NULL;
154 ASL_RESOURCE_NODE *Rnode;
158 InitializerOp = Op->Asl.Child;
159 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
161 Descriptor = Rnode->Buffer;
162 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
163 Descriptor->Memory24.ResourceLength = 9;
165 /* Process all child initialization nodes */
167 for (i = 0; InitializerOp; i++)
171 case 0: /* Read/Write type */
173 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
174 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
175 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
178 case 1: /* Min Address */
180 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
181 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
182 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
183 MinOp = InitializerOp;
186 case 2: /* Max Address */
188 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
189 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
190 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
191 MaxOp = InitializerOp;
194 case 3: /* Alignment */
196 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
197 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
198 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
203 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
204 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
205 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
206 LengthOp = InitializerOp;
211 UtAttachNamepathToOwner (Op, InitializerOp);
216 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
220 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
223 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
225 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
226 Descriptor->Memory24.Minimum,
227 Descriptor->Memory24.Maximum,
228 Descriptor->Memory24.AddressLength,
229 Descriptor->Memory24.Alignment,
230 MinOp, MaxOp, LengthOp, NULL, Op);
236 /*******************************************************************************
238 * FUNCTION: RsDoMemory32Descriptor
240 * PARAMETERS: Op - Parent resource descriptor parse node
241 * CurrentByteOffset - Offset into the resource template AML
242 * buffer (to track references to the desc)
244 * RETURN: Completed resource node
246 * DESCRIPTION: Construct a short "Memory32" descriptor
248 ******************************************************************************/
251 RsDoMemory32Descriptor (
252 ACPI_PARSE_OBJECT *Op,
253 UINT32 CurrentByteOffset)
255 AML_RESOURCE *Descriptor;
256 ACPI_PARSE_OBJECT *InitializerOp;
257 ACPI_PARSE_OBJECT *MinOp = NULL;
258 ACPI_PARSE_OBJECT *MaxOp = NULL;
259 ACPI_PARSE_OBJECT *LengthOp = NULL;
260 ACPI_PARSE_OBJECT *AlignOp = NULL;
261 ASL_RESOURCE_NODE *Rnode;
265 InitializerOp = Op->Asl.Child;
266 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
268 Descriptor = Rnode->Buffer;
269 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
270 Descriptor->Memory32.ResourceLength = 17;
272 /* Process all child initialization nodes */
274 for (i = 0; InitializerOp; i++)
278 case 0: /* Read/Write type */
280 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
281 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
282 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
285 case 1: /* Min Address */
287 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
288 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
289 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
290 MinOp = InitializerOp;
293 case 2: /* Max Address */
295 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
296 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
297 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
298 MaxOp = InitializerOp;
301 case 3: /* Alignment */
303 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
304 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
305 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
306 AlignOp = InitializerOp;
311 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
312 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
313 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
314 LengthOp = InitializerOp;
319 UtAttachNamepathToOwner (Op, InitializerOp);
324 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
328 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
331 /* Validate the Min/Max/Len/Align values */
333 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
334 Descriptor->Memory32.Minimum,
335 Descriptor->Memory32.Maximum,
336 Descriptor->Memory32.AddressLength,
337 Descriptor->Memory32.Alignment,
338 MinOp, MaxOp, LengthOp, AlignOp, Op);
344 /*******************************************************************************
346 * FUNCTION: RsDoMemory32FixedDescriptor
348 * PARAMETERS: Op - Parent resource descriptor parse node
349 * CurrentByteOffset - Offset into the resource template AML
350 * buffer (to track references to the desc)
352 * RETURN: Completed resource node
354 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
356 ******************************************************************************/
359 RsDoMemory32FixedDescriptor (
360 ACPI_PARSE_OBJECT *Op,
361 UINT32 CurrentByteOffset)
363 AML_RESOURCE *Descriptor;
364 ACPI_PARSE_OBJECT *InitializerOp;
365 ASL_RESOURCE_NODE *Rnode;
369 InitializerOp = Op->Asl.Child;
370 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
372 Descriptor = Rnode->Buffer;
373 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
374 Descriptor->FixedMemory32.ResourceLength = 9;
376 /* Process all child initialization nodes */
378 for (i = 0; InitializerOp; i++)
382 case 0: /* Read/Write type */
384 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
385 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
386 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
389 case 1: /* Address */
391 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
392 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
393 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
398 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
399 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
400 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
405 UtAttachNamepathToOwner (Op, InitializerOp);
410 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
414 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
421 /*******************************************************************************
423 * FUNCTION: RsDoStartDependentDescriptor
425 * PARAMETERS: Op - Parent resource descriptor parse node
426 * CurrentByteOffset - Offset into the resource template AML
427 * buffer (to track references to the desc)
429 * RETURN: Completed resource node
431 * DESCRIPTION: Construct a short "StartDependentFn" descriptor
433 ******************************************************************************/
436 RsDoStartDependentDescriptor (
437 ACPI_PARSE_OBJECT *Op,
438 UINT32 CurrentByteOffset)
440 AML_RESOURCE *Descriptor;
441 ACPI_PARSE_OBJECT *InitializerOp;
442 ASL_RESOURCE_NODE *Rnode;
443 ASL_RESOURCE_NODE *PreviousRnode;
444 ASL_RESOURCE_NODE *NextRnode;
449 InitializerOp = Op->Asl.Child;
450 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
452 PreviousRnode = Rnode;
453 Descriptor = Rnode->Buffer;
455 /* Increment offset past StartDependent descriptor */
457 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT);
459 /* Descriptor has priority byte */
461 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
462 (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
464 /* Process all child initialization nodes */
466 State = ACPI_RSTATE_START_DEPENDENT;
467 for (i = 0; InitializerOp; i++)
471 case 0: /* Compatibility Priority */
473 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
475 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
476 InitializerOp, NULL);
479 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
482 case 1: /* Performance/Robustness Priority */
484 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
486 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
487 InitializerOp, NULL);
490 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
495 NextRnode = RsDoOneResourceDescriptor (InitializerOp,
496 CurrentByteOffset, &State);
499 * Update current byte offset to indicate the number of bytes from the
500 * start of the buffer. Buffer can include multiple descriptors, we
501 * must keep track of the offset of not only each descriptor, but each
502 * element (field) within each descriptor as well.
504 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode,
509 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
516 /*******************************************************************************
518 * FUNCTION: RsDoStartDependentNoPriDescriptor
520 * PARAMETERS: Op - Parent resource descriptor parse node
521 * CurrentByteOffset - Offset into the resource template AML
522 * buffer (to track references to the desc)
524 * RETURN: Completed resource node
526 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
528 ******************************************************************************/
531 RsDoStartDependentNoPriDescriptor (
532 ACPI_PARSE_OBJECT *Op,
533 UINT32 CurrentByteOffset)
535 AML_RESOURCE *Descriptor;
536 ACPI_PARSE_OBJECT *InitializerOp;
537 ASL_RESOURCE_NODE *Rnode;
538 ASL_RESOURCE_NODE *PreviousRnode;
539 ASL_RESOURCE_NODE *NextRnode;
543 InitializerOp = Op->Asl.Child;
544 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
546 Descriptor = Rnode->Buffer;
547 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
548 ASL_RDESC_ST_DEPEND_SIZE;
549 PreviousRnode = Rnode;
551 /* Increment offset past StartDependentNoPri descriptor */
553 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO);
555 /* Process all child initialization nodes */
557 State = ACPI_RSTATE_START_DEPENDENT;
558 while (InitializerOp)
560 NextRnode = RsDoOneResourceDescriptor (InitializerOp,
561 CurrentByteOffset, &State);
564 * Update current byte offset to indicate the number of bytes from the
565 * start of the buffer. Buffer can include multiple descriptors, we
566 * must keep track of the offset of not only each descriptor, but each
567 * element (field) within each descriptor as well.
569 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
571 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
578 /*******************************************************************************
580 * FUNCTION: RsDoVendorSmallDescriptor
582 * PARAMETERS: Op - Parent resource descriptor parse node
583 * CurrentByteOffset - Offset into the resource template AML
584 * buffer (to track references to the desc)
586 * RETURN: Completed resource node
588 * DESCRIPTION: Construct a short "VendorShort" descriptor
590 ******************************************************************************/
593 RsDoVendorSmallDescriptor (
594 ACPI_PARSE_OBJECT *Op,
595 UINT32 CurrentByteOffset)
597 AML_RESOURCE *Descriptor;
598 ACPI_PARSE_OBJECT *InitializerOp;
599 ASL_RESOURCE_NODE *Rnode;
604 InitializerOp = Op->Asl.Child;
606 /* Allocate worst case - 7 vendor bytes */
608 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
610 Descriptor = Rnode->Buffer;
611 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL;
612 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
614 /* Process all child initialization nodes */
616 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
617 for (i = 0; InitializerOp; i++)
619 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
624 /* Maximum 7 vendor data bytes allowed (0-6) */
628 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
630 /* Eat the excess initializers */
632 while (InitializerOp)
634 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
639 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
640 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
643 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
645 Rnode->BufferLength -= (7 - i);
647 /* Set the length in the Type Tag */
649 Descriptor->VendorSmall.DescriptorType |= (UINT8) i;