1 /******************************************************************************
3 * Module Name: aslrestype1 - Miscellaneous small resource descriptors
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, 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.
44 #include <contrib/dev/acpica/compiler/aslcompiler.h>
45 #include "aslcompiler.y.h"
47 #define _COMPONENT ACPI_COMPILER
48 ACPI_MODULE_NAME ("aslrestype1")
51 * This module contains miscellaneous small resource descriptors:
59 * StartDependentFnNoPri
63 /*******************************************************************************
65 * FUNCTION: RsDoEndTagDescriptor
67 * PARAMETERS: Info - Parse Op and resource template offset
69 * RETURN: Completed resource node
71 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
73 ******************************************************************************/
76 RsDoEndTagDescriptor (
77 ASL_RESOURCE_INFO *Info)
79 AML_RESOURCE *Descriptor;
80 ASL_RESOURCE_NODE *Rnode;
83 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG));
85 Descriptor = Rnode->Buffer;
86 Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG |
87 ASL_RDESC_END_TAG_SIZE;
88 Descriptor->EndTag.Checksum = 0;
94 /*******************************************************************************
96 * FUNCTION: RsDoEndDependentDescriptor
98 * PARAMETERS: Info - Parse Op and resource template offset
100 * RETURN: Completed resource node
102 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
104 ******************************************************************************/
107 RsDoEndDependentDescriptor (
108 ASL_RESOURCE_INFO *Info)
110 AML_RESOURCE *Descriptor;
111 ASL_RESOURCE_NODE *Rnode;
114 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
116 Descriptor = Rnode->Buffer;
117 Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT |
118 ASL_RDESC_END_DEPEND_SIZE;
123 /*******************************************************************************
125 * FUNCTION: RsDoMemory24Descriptor
127 * PARAMETERS: Info - Parse Op and resource template offset
129 * RETURN: Completed resource node
131 * DESCRIPTION: Construct a short "Memory24" descriptor
133 ******************************************************************************/
136 RsDoMemory24Descriptor (
137 ASL_RESOURCE_INFO *Info)
139 AML_RESOURCE *Descriptor;
140 ACPI_PARSE_OBJECT *InitializerOp;
141 ACPI_PARSE_OBJECT *MinOp = NULL;
142 ACPI_PARSE_OBJECT *MaxOp = NULL;
143 ACPI_PARSE_OBJECT *LengthOp = NULL;
144 ASL_RESOURCE_NODE *Rnode;
145 UINT32 CurrentByteOffset;
149 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
150 CurrentByteOffset = Info->CurrentByteOffset;
151 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
153 Descriptor = Rnode->Buffer;
154 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
155 Descriptor->Memory24.ResourceLength = 9;
157 /* Process all child initialization nodes */
159 for (i = 0; InitializerOp; i++)
163 case 0: /* Read/Write type */
165 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
166 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
167 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
170 case 1: /* Min Address */
172 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
173 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
174 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
175 MinOp = InitializerOp;
178 case 2: /* Max Address */
180 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
181 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
182 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
183 MaxOp = InitializerOp;
186 case 3: /* Alignment */
188 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
189 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
190 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
195 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
196 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
197 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
198 LengthOp = InitializerOp;
203 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
208 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
212 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
215 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
217 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
218 Descriptor->Memory24.Minimum,
219 Descriptor->Memory24.Maximum,
220 Descriptor->Memory24.AddressLength,
221 Descriptor->Memory24.Alignment,
222 MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp);
228 /*******************************************************************************
230 * FUNCTION: RsDoMemory32Descriptor
232 * PARAMETERS: Info - Parse Op and resource template offset
234 * RETURN: Completed resource node
236 * DESCRIPTION: Construct a short "Memory32" descriptor
238 ******************************************************************************/
241 RsDoMemory32Descriptor (
242 ASL_RESOURCE_INFO *Info)
244 AML_RESOURCE *Descriptor;
245 ACPI_PARSE_OBJECT *InitializerOp;
246 ACPI_PARSE_OBJECT *MinOp = NULL;
247 ACPI_PARSE_OBJECT *MaxOp = NULL;
248 ACPI_PARSE_OBJECT *LengthOp = NULL;
249 ACPI_PARSE_OBJECT *AlignOp = NULL;
250 ASL_RESOURCE_NODE *Rnode;
251 UINT32 CurrentByteOffset;
255 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
256 CurrentByteOffset = Info->CurrentByteOffset;
257 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
259 Descriptor = Rnode->Buffer;
260 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
261 Descriptor->Memory32.ResourceLength = 17;
263 /* Process all child initialization nodes */
265 for (i = 0; InitializerOp; i++)
269 case 0: /* Read/Write type */
271 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
272 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
273 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
276 case 1: /* Min Address */
278 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
279 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
280 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
281 MinOp = InitializerOp;
284 case 2: /* Max Address */
286 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
287 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
288 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
289 MaxOp = InitializerOp;
292 case 3: /* Alignment */
294 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
295 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
296 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
297 AlignOp = InitializerOp;
302 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
303 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
304 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
305 LengthOp = InitializerOp;
310 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
315 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
319 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
322 /* Validate the Min/Max/Len/Align values */
324 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
325 Descriptor->Memory32.Minimum,
326 Descriptor->Memory32.Maximum,
327 Descriptor->Memory32.AddressLength,
328 Descriptor->Memory32.Alignment,
329 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
335 /*******************************************************************************
337 * FUNCTION: RsDoMemory32FixedDescriptor
339 * PARAMETERS: Info - Parse Op and resource template offset
341 * RETURN: Completed resource node
343 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
345 ******************************************************************************/
348 RsDoMemory32FixedDescriptor (
349 ASL_RESOURCE_INFO *Info)
351 AML_RESOURCE *Descriptor;
352 ACPI_PARSE_OBJECT *InitializerOp;
353 ASL_RESOURCE_NODE *Rnode;
354 UINT32 CurrentByteOffset;
358 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
359 CurrentByteOffset = Info->CurrentByteOffset;
360 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
362 Descriptor = Rnode->Buffer;
363 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
364 Descriptor->FixedMemory32.ResourceLength = 9;
366 /* Process all child initialization nodes */
368 for (i = 0; InitializerOp; i++)
372 case 0: /* Read/Write type */
374 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
375 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
376 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
379 case 1: /* Address */
381 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
382 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
383 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
388 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
389 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
390 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
395 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
400 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
404 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
411 /*******************************************************************************
413 * FUNCTION: RsDoStartDependentDescriptor
415 * PARAMETERS: Info - Parse Op and resource template offset
417 * RETURN: Completed resource node
419 * DESCRIPTION: Construct a short "StartDependentFn" descriptor
421 ******************************************************************************/
424 RsDoStartDependentDescriptor (
425 ASL_RESOURCE_INFO *Info)
427 AML_RESOURCE *Descriptor;
428 ACPI_PARSE_OBJECT *InitializerOp;
429 ASL_RESOURCE_NODE *Rnode;
430 ASL_RESOURCE_NODE *PreviousRnode;
431 ASL_RESOURCE_NODE *NextRnode;
432 ASL_RESOURCE_INFO NextInfo;
433 UINT32 CurrentByteOffset;
438 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
439 CurrentByteOffset = Info->CurrentByteOffset;
440 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
442 PreviousRnode = Rnode;
443 Descriptor = Rnode->Buffer;
445 /* Increment offset past StartDependent descriptor */
447 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT);
449 /* Descriptor has priority byte */
451 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
452 (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
454 /* Process all child initialization nodes */
456 State = ACPI_RSTATE_START_DEPENDENT;
457 for (i = 0; InitializerOp; i++)
461 case 0: /* Compatibility Priority */
463 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
465 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
466 InitializerOp, NULL);
469 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
472 case 1: /* Performance/Robustness Priority */
474 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
476 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
477 InitializerOp, NULL);
480 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
485 NextInfo.CurrentByteOffset = CurrentByteOffset;
486 NextInfo.DescriptorTypeOp = InitializerOp;
488 NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State);
491 * Update current byte offset to indicate the number of bytes from the
492 * start of the buffer. Buffer can include multiple descriptors, we
493 * must keep track of the offset of not only each descriptor, but each
494 * element (field) within each descriptor as well.
496 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode,
501 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
508 /*******************************************************************************
510 * FUNCTION: RsDoStartDependentNoPriDescriptor
512 * PARAMETERS: Info - Parse Op and resource template offset
514 * RETURN: Completed resource node
516 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
518 ******************************************************************************/
521 RsDoStartDependentNoPriDescriptor (
522 ASL_RESOURCE_INFO *Info)
524 AML_RESOURCE *Descriptor;
525 ACPI_PARSE_OBJECT *InitializerOp;
526 ASL_RESOURCE_NODE *Rnode;
527 ASL_RESOURCE_NODE *PreviousRnode;
528 ASL_RESOURCE_NODE *NextRnode;
529 ASL_RESOURCE_INFO NextInfo;
530 UINT32 CurrentByteOffset;
534 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
535 CurrentByteOffset = Info->CurrentByteOffset;
536 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
538 Descriptor = Rnode->Buffer;
539 Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT |
540 ASL_RDESC_ST_DEPEND_SIZE;
541 PreviousRnode = Rnode;
543 /* Increment offset past StartDependentNoPri descriptor */
545 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO);
547 /* Process all child initialization nodes */
549 State = ACPI_RSTATE_START_DEPENDENT;
550 while (InitializerOp)
552 NextInfo.CurrentByteOffset = CurrentByteOffset;
553 NextInfo.DescriptorTypeOp = InitializerOp;
555 NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State);
558 * Update current byte offset to indicate the number of bytes from the
559 * start of the buffer. Buffer can include multiple descriptors, we
560 * must keep track of the offset of not only each descriptor, but each
561 * element (field) within each descriptor as well.
563 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
565 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
572 /*******************************************************************************
574 * FUNCTION: RsDoVendorSmallDescriptor
576 * PARAMETERS: Info - Parse Op and resource template offset
578 * RETURN: Completed resource node
580 * DESCRIPTION: Construct a short "VendorShort" descriptor
582 ******************************************************************************/
585 RsDoVendorSmallDescriptor (
586 ASL_RESOURCE_INFO *Info)
588 AML_RESOURCE *Descriptor;
589 ACPI_PARSE_OBJECT *InitializerOp;
590 ASL_RESOURCE_NODE *Rnode;
595 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
597 /* Allocate worst case - 7 vendor bytes */
599 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
601 Descriptor = Rnode->Buffer;
602 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL;
603 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
605 /* Process all child initialization nodes */
607 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
608 for (i = 0; InitializerOp; i++)
610 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
615 /* Maximum 7 vendor data bytes allowed (0-6) */
619 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
621 /* Eat the excess initializers */
623 while (InitializerOp)
625 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
630 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
631 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
634 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
636 Rnode->BufferLength -= (7 - i);
638 /* Set the length in the Type Tag */
640 Descriptor->VendorSmall.DescriptorType |= (UINT8) i;