2 /******************************************************************************
4 * Module Name: aslrestype1 - Miscellaneous small resource descriptors
6 *****************************************************************************/
9 * Copyright (C) 2000 - 2012, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
46 #include <contrib/dev/acpica/compiler/aslcompiler.h>
47 #include "aslcompiler.y.h"
49 #define _COMPONENT ACPI_COMPILER
50 ACPI_MODULE_NAME ("aslrestype1")
53 * This module contains miscellaneous small resource descriptors:
61 * StartDependentFnNoPri
65 /*******************************************************************************
67 * FUNCTION: RsDoEndTagDescriptor
69 * PARAMETERS: Op - Parent resource descriptor parse node
70 * CurrentByteOffset - Offset into the resource template AML
71 * buffer (to track references to the desc)
73 * RETURN: Completed resource node
75 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
77 ******************************************************************************/
80 RsDoEndTagDescriptor (
81 ACPI_PARSE_OBJECT *Op,
82 UINT32 CurrentByteOffset)
84 AML_RESOURCE *Descriptor;
85 ASL_RESOURCE_NODE *Rnode;
88 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG));
90 Descriptor = Rnode->Buffer;
91 Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG |
92 ASL_RDESC_END_TAG_SIZE;
93 Descriptor->EndTag.Checksum = 0;
99 /*******************************************************************************
101 * FUNCTION: RsDoEndDependentDescriptor
103 * PARAMETERS: Op - Parent resource descriptor parse node
104 * CurrentByteOffset - Offset into the resource template AML
105 * buffer (to track references to the desc)
107 * RETURN: Completed resource node
109 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
111 ******************************************************************************/
114 RsDoEndDependentDescriptor (
115 ACPI_PARSE_OBJECT *Op,
116 UINT32 CurrentByteOffset)
118 AML_RESOURCE *Descriptor;
119 ASL_RESOURCE_NODE *Rnode;
122 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
124 Descriptor = Rnode->Buffer;
125 Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT |
126 ASL_RDESC_END_DEPEND_SIZE;
131 /*******************************************************************************
133 * FUNCTION: RsDoMemory24Descriptor
135 * PARAMETERS: Op - Parent resource descriptor parse node
136 * CurrentByteOffset - Offset into the resource template AML
137 * buffer (to track references to the desc)
139 * RETURN: Completed resource node
141 * DESCRIPTION: Construct a short "Memory24" descriptor
143 ******************************************************************************/
146 RsDoMemory24Descriptor (
147 ACPI_PARSE_OBJECT *Op,
148 UINT32 CurrentByteOffset)
150 AML_RESOURCE *Descriptor;
151 ACPI_PARSE_OBJECT *InitializerOp;
152 ACPI_PARSE_OBJECT *MinOp = NULL;
153 ACPI_PARSE_OBJECT *MaxOp = NULL;
154 ACPI_PARSE_OBJECT *LengthOp = NULL;
155 ASL_RESOURCE_NODE *Rnode;
159 InitializerOp = Op->Asl.Child;
160 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
162 Descriptor = Rnode->Buffer;
163 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
164 Descriptor->Memory24.ResourceLength = 9;
166 /* Process all child initialization nodes */
168 for (i = 0; InitializerOp; i++)
172 case 0: /* Read/Write type */
174 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
175 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
176 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
179 case 1: /* Min Address */
181 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
182 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
183 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
184 MinOp = InitializerOp;
187 case 2: /* Max Address */
189 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
190 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
191 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
192 MaxOp = InitializerOp;
195 case 3: /* Alignment */
197 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
198 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
199 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
204 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
205 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
206 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
207 LengthOp = InitializerOp;
212 UtAttachNamepathToOwner (Op, InitializerOp);
217 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
221 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
224 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
226 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
227 Descriptor->Memory24.Minimum,
228 Descriptor->Memory24.Maximum,
229 Descriptor->Memory24.AddressLength,
230 Descriptor->Memory24.Alignment,
231 MinOp, MaxOp, LengthOp, NULL, Op);
237 /*******************************************************************************
239 * FUNCTION: RsDoMemory32Descriptor
241 * PARAMETERS: Op - Parent resource descriptor parse node
242 * CurrentByteOffset - Offset into the resource template AML
243 * buffer (to track references to the desc)
245 * RETURN: Completed resource node
247 * DESCRIPTION: Construct a short "Memory32" descriptor
249 ******************************************************************************/
252 RsDoMemory32Descriptor (
253 ACPI_PARSE_OBJECT *Op,
254 UINT32 CurrentByteOffset)
256 AML_RESOURCE *Descriptor;
257 ACPI_PARSE_OBJECT *InitializerOp;
258 ACPI_PARSE_OBJECT *MinOp = NULL;
259 ACPI_PARSE_OBJECT *MaxOp = NULL;
260 ACPI_PARSE_OBJECT *LengthOp = NULL;
261 ACPI_PARSE_OBJECT *AlignOp = NULL;
262 ASL_RESOURCE_NODE *Rnode;
266 InitializerOp = Op->Asl.Child;
267 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
269 Descriptor = Rnode->Buffer;
270 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
271 Descriptor->Memory32.ResourceLength = 17;
273 /* Process all child initialization nodes */
275 for (i = 0; InitializerOp; i++)
279 case 0: /* Read/Write type */
281 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
282 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
283 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
286 case 1: /* Min Address */
288 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
289 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
290 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
291 MinOp = InitializerOp;
294 case 2: /* Max Address */
296 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
297 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
298 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
299 MaxOp = InitializerOp;
302 case 3: /* Alignment */
304 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
305 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
306 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
307 AlignOp = InitializerOp;
312 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
313 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
314 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
315 LengthOp = InitializerOp;
320 UtAttachNamepathToOwner (Op, InitializerOp);
325 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
329 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
332 /* Validate the Min/Max/Len/Align values */
334 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
335 Descriptor->Memory32.Minimum,
336 Descriptor->Memory32.Maximum,
337 Descriptor->Memory32.AddressLength,
338 Descriptor->Memory32.Alignment,
339 MinOp, MaxOp, LengthOp, AlignOp, Op);
345 /*******************************************************************************
347 * FUNCTION: RsDoMemory32FixedDescriptor
349 * PARAMETERS: Op - Parent resource descriptor parse node
350 * CurrentByteOffset - Offset into the resource template AML
351 * buffer (to track references to the desc)
353 * RETURN: Completed resource node
355 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
357 ******************************************************************************/
360 RsDoMemory32FixedDescriptor (
361 ACPI_PARSE_OBJECT *Op,
362 UINT32 CurrentByteOffset)
364 AML_RESOURCE *Descriptor;
365 ACPI_PARSE_OBJECT *InitializerOp;
366 ASL_RESOURCE_NODE *Rnode;
370 InitializerOp = Op->Asl.Child;
371 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
373 Descriptor = Rnode->Buffer;
374 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
375 Descriptor->FixedMemory32.ResourceLength = 9;
377 /* Process all child initialization nodes */
379 for (i = 0; InitializerOp; i++)
383 case 0: /* Read/Write type */
385 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
386 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
387 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
390 case 1: /* Address */
392 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
393 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
394 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
399 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
400 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
401 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
406 UtAttachNamepathToOwner (Op, InitializerOp);
411 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
415 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
422 /*******************************************************************************
424 * FUNCTION: RsDoStartDependentDescriptor
426 * PARAMETERS: Op - Parent resource descriptor parse node
427 * CurrentByteOffset - Offset into the resource template AML
428 * buffer (to track references to the desc)
430 * RETURN: Completed resource node
432 * DESCRIPTION: Construct a short "StartDependentFn" descriptor
434 ******************************************************************************/
437 RsDoStartDependentDescriptor (
438 ACPI_PARSE_OBJECT *Op,
439 UINT32 CurrentByteOffset)
441 AML_RESOURCE *Descriptor;
442 ACPI_PARSE_OBJECT *InitializerOp;
443 ASL_RESOURCE_NODE *Rnode;
444 ASL_RESOURCE_NODE *PreviousRnode;
445 ASL_RESOURCE_NODE *NextRnode;
450 InitializerOp = Op->Asl.Child;
451 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
453 PreviousRnode = Rnode;
454 Descriptor = Rnode->Buffer;
456 /* Increment offset past StartDependent descriptor */
458 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT);
460 /* Descriptor has priority byte */
462 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
463 (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
465 /* Process all child initialization nodes */
467 State = ACPI_RSTATE_START_DEPENDENT;
468 for (i = 0; InitializerOp; i++)
472 case 0: /* Compatibility Priority */
474 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
476 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
477 InitializerOp, NULL);
480 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
483 case 1: /* Performance/Robustness Priority */
485 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
487 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
488 InitializerOp, NULL);
491 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
496 NextRnode = RsDoOneResourceDescriptor (InitializerOp,
497 CurrentByteOffset, &State);
500 * Update current byte offset to indicate the number of bytes from the
501 * start of the buffer. Buffer can include multiple descriptors, we
502 * must keep track of the offset of not only each descriptor, but each
503 * element (field) within each descriptor as well.
505 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode,
510 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
517 /*******************************************************************************
519 * FUNCTION: RsDoStartDependentNoPriDescriptor
521 * PARAMETERS: Op - Parent resource descriptor parse node
522 * CurrentByteOffset - Offset into the resource template AML
523 * buffer (to track references to the desc)
525 * RETURN: Completed resource node
527 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
529 ******************************************************************************/
532 RsDoStartDependentNoPriDescriptor (
533 ACPI_PARSE_OBJECT *Op,
534 UINT32 CurrentByteOffset)
536 AML_RESOURCE *Descriptor;
537 ACPI_PARSE_OBJECT *InitializerOp;
538 ASL_RESOURCE_NODE *Rnode;
539 ASL_RESOURCE_NODE *PreviousRnode;
540 ASL_RESOURCE_NODE *NextRnode;
544 InitializerOp = Op->Asl.Child;
545 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
547 Descriptor = Rnode->Buffer;
548 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
549 ASL_RDESC_ST_DEPEND_SIZE;
550 PreviousRnode = Rnode;
552 /* Increment offset past StartDependentNoPri descriptor */
554 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO);
556 /* Process all child initialization nodes */
558 State = ACPI_RSTATE_START_DEPENDENT;
559 while (InitializerOp)
561 NextRnode = RsDoOneResourceDescriptor (InitializerOp,
562 CurrentByteOffset, &State);
565 * Update current byte offset to indicate the number of bytes from the
566 * start of the buffer. Buffer can include multiple descriptors, we
567 * must keep track of the offset of not only each descriptor, but each
568 * element (field) within each descriptor as well.
570 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
572 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
579 /*******************************************************************************
581 * FUNCTION: RsDoVendorSmallDescriptor
583 * PARAMETERS: Op - Parent resource descriptor parse node
584 * CurrentByteOffset - Offset into the resource template AML
585 * buffer (to track references to the desc)
587 * RETURN: Completed resource node
589 * DESCRIPTION: Construct a short "VendorShort" descriptor
591 ******************************************************************************/
594 RsDoVendorSmallDescriptor (
595 ACPI_PARSE_OBJECT *Op,
596 UINT32 CurrentByteOffset)
598 AML_RESOURCE *Descriptor;
599 ACPI_PARSE_OBJECT *InitializerOp;
600 ASL_RESOURCE_NODE *Rnode;
605 InitializerOp = Op->Asl.Child;
607 /* Allocate worst case - 7 vendor bytes */
609 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
611 Descriptor = Rnode->Buffer;
612 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL;
613 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
615 /* Process all child initialization nodes */
617 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
618 for (i = 0; InitializerOp; i++)
620 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
625 /* Maximum 7 vendor data bytes allowed (0-6) */
629 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
631 /* Eat the excess initializers */
633 while (InitializerOp)
635 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
640 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
641 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
644 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
646 Rnode->BufferLength -= (7 - i);
648 /* Set the length in the Type Tag */
650 Descriptor->VendorSmall.DescriptorType |= (UINT8) i;