1 /******************************************************************************
3 * Module Name: aslrestype1 - Miscellaneous small resource descriptors
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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;
93 /*******************************************************************************
95 * FUNCTION: RsDoEndDependentDescriptor
97 * PARAMETERS: Info - Parse Op and resource template offset
99 * RETURN: Completed resource node
101 * DESCRIPTION: Construct a short "EndDependentFn" descriptor
103 ******************************************************************************/
106 RsDoEndDependentDescriptor (
107 ASL_RESOURCE_INFO *Info)
109 AML_RESOURCE *Descriptor;
110 ASL_RESOURCE_NODE *Rnode;
113 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
115 Descriptor = Rnode->Buffer;
116 Descriptor->EndDpf.DescriptorType =
117 ACPI_RESOURCE_NAME_END_DEPENDENT | ASL_RDESC_END_DEPEND_SIZE;
122 /*******************************************************************************
124 * FUNCTION: RsDoMemory24Descriptor
126 * PARAMETERS: Info - Parse Op and resource template offset
128 * RETURN: Completed resource node
130 * DESCRIPTION: Construct a short "Memory24" descriptor
132 ******************************************************************************/
135 RsDoMemory24Descriptor (
136 ASL_RESOURCE_INFO *Info)
138 AML_RESOURCE *Descriptor;
139 ACPI_PARSE_OBJECT *InitializerOp;
140 ACPI_PARSE_OBJECT *MinOp = NULL;
141 ACPI_PARSE_OBJECT *MaxOp = NULL;
142 ACPI_PARSE_OBJECT *LengthOp = NULL;
143 ASL_RESOURCE_NODE *Rnode;
144 UINT32 CurrentByteOffset;
148 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
149 CurrentByteOffset = Info->CurrentByteOffset;
150 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
152 Descriptor = Rnode->Buffer;
153 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
154 Descriptor->Memory24.ResourceLength = 9;
156 /* Process all child initialization nodes */
158 for (i = 0; InitializerOp; i++)
162 case 0: /* Read/Write type */
164 RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
165 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
166 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
169 case 1: /* Min Address */
171 Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
172 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
173 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
174 MinOp = InitializerOp;
177 case 2: /* Max Address */
179 Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
180 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
181 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
182 MaxOp = InitializerOp;
185 case 3: /* Alignment */
187 Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
188 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
189 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
194 Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
195 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
196 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
197 LengthOp = InitializerOp;
202 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
207 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
211 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
214 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
216 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
217 Descriptor->Memory24.Minimum,
218 Descriptor->Memory24.Maximum,
219 Descriptor->Memory24.AddressLength,
220 Descriptor->Memory24.Alignment,
221 MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp);
227 /*******************************************************************************
229 * FUNCTION: RsDoMemory32Descriptor
231 * PARAMETERS: Info - Parse Op and resource template offset
233 * RETURN: Completed resource node
235 * DESCRIPTION: Construct a short "Memory32" descriptor
237 ******************************************************************************/
240 RsDoMemory32Descriptor (
241 ASL_RESOURCE_INFO *Info)
243 AML_RESOURCE *Descriptor;
244 ACPI_PARSE_OBJECT *InitializerOp;
245 ACPI_PARSE_OBJECT *MinOp = NULL;
246 ACPI_PARSE_OBJECT *MaxOp = NULL;
247 ACPI_PARSE_OBJECT *LengthOp = NULL;
248 ACPI_PARSE_OBJECT *AlignOp = NULL;
249 ASL_RESOURCE_NODE *Rnode;
250 UINT32 CurrentByteOffset;
254 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
255 CurrentByteOffset = Info->CurrentByteOffset;
256 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
258 Descriptor = Rnode->Buffer;
259 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
260 Descriptor->Memory32.ResourceLength = 17;
262 /* Process all child initialization nodes */
264 for (i = 0; InitializerOp; i++)
268 case 0: /* Read/Write type */
270 RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
271 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
272 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
275 case 1: /* Min Address */
277 Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
278 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
279 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
280 MinOp = InitializerOp;
283 case 2: /* Max Address */
285 Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
286 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
287 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
288 MaxOp = InitializerOp;
291 case 3: /* Alignment */
293 Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
294 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
295 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
296 AlignOp = InitializerOp;
301 Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
302 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
303 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
304 LengthOp = InitializerOp;
309 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
314 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
318 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
321 /* Validate the Min/Max/Len/Align values */
323 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
324 Descriptor->Memory32.Minimum,
325 Descriptor->Memory32.Maximum,
326 Descriptor->Memory32.AddressLength,
327 Descriptor->Memory32.Alignment,
328 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
334 /*******************************************************************************
336 * FUNCTION: RsDoMemory32FixedDescriptor
338 * PARAMETERS: Info - Parse Op and resource template offset
340 * RETURN: Completed resource node
342 * DESCRIPTION: Construct a short "Memory32Fixed" descriptor
344 ******************************************************************************/
347 RsDoMemory32FixedDescriptor (
348 ASL_RESOURCE_INFO *Info)
350 AML_RESOURCE *Descriptor;
351 ACPI_PARSE_OBJECT *InitializerOp;
352 ASL_RESOURCE_NODE *Rnode;
353 UINT32 CurrentByteOffset;
357 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
358 CurrentByteOffset = Info->CurrentByteOffset;
359 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
361 Descriptor = Rnode->Buffer;
362 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
363 Descriptor->FixedMemory32.ResourceLength = 9;
365 /* Process all child initialization nodes */
367 for (i = 0; InitializerOp; i++)
371 case 0: /* Read/Write type */
373 RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
374 RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
375 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
378 case 1: /* Address */
380 Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
381 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
382 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
387 Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
388 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
389 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
394 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
399 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
403 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
410 /*******************************************************************************
412 * FUNCTION: RsDoStartDependentDescriptor
414 * PARAMETERS: Info - Parse Op and resource template offset
416 * RETURN: Completed resource node
418 * DESCRIPTION: Construct a short "StartDependentFn" descriptor
420 ******************************************************************************/
423 RsDoStartDependentDescriptor (
424 ASL_RESOURCE_INFO *Info)
426 AML_RESOURCE *Descriptor;
427 ACPI_PARSE_OBJECT *InitializerOp;
428 ASL_RESOURCE_NODE *Rnode;
429 ASL_RESOURCE_NODE *PreviousRnode;
430 ASL_RESOURCE_NODE *NextRnode;
431 ASL_RESOURCE_INFO NextInfo;
432 UINT32 CurrentByteOffset;
437 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
438 CurrentByteOffset = Info->CurrentByteOffset;
439 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
441 PreviousRnode = Rnode;
442 Descriptor = Rnode->Buffer;
444 /* Increment offset past StartDependent descriptor */
446 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT);
448 /* Descriptor has priority byte */
450 Descriptor->StartDpf.DescriptorType =
451 ACPI_RESOURCE_NAME_START_DEPENDENT | (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
453 /* Process all child initialization nodes */
455 State = ACPI_RSTATE_START_DEPENDENT;
456 for (i = 0; InitializerOp; i++)
460 case 0: /* Compatibility Priority */
462 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
464 AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
465 InitializerOp, NULL);
468 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
471 case 1: /* Performance/Robustness Priority */
473 if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
475 AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
476 InitializerOp, NULL);
479 RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
484 NextInfo.CurrentByteOffset = CurrentByteOffset;
485 NextInfo.DescriptorTypeOp = InitializerOp;
487 NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State);
490 * Update current byte offset to indicate the number of bytes from the
491 * start of the buffer. Buffer can include multiple descriptors, we
492 * must keep track of the offset of not only each descriptor, but each
493 * element (field) within each descriptor as well.
495 CurrentByteOffset += RsLinkDescriptorChain (
496 &PreviousRnode, NextRnode);
500 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
507 /*******************************************************************************
509 * FUNCTION: RsDoStartDependentNoPriDescriptor
511 * PARAMETERS: Info - Parse Op and resource template offset
513 * RETURN: Completed resource node
515 * DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
517 ******************************************************************************/
520 RsDoStartDependentNoPriDescriptor (
521 ASL_RESOURCE_INFO *Info)
523 AML_RESOURCE *Descriptor;
524 ACPI_PARSE_OBJECT *InitializerOp;
525 ASL_RESOURCE_NODE *Rnode;
526 ASL_RESOURCE_NODE *PreviousRnode;
527 ASL_RESOURCE_NODE *NextRnode;
528 ASL_RESOURCE_INFO NextInfo;
529 UINT32 CurrentByteOffset;
533 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
534 CurrentByteOffset = Info->CurrentByteOffset;
535 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
537 Descriptor = Rnode->Buffer;
538 Descriptor->StartDpf.DescriptorType =
539 ACPI_RESOURCE_NAME_START_DEPENDENT | ASL_RDESC_ST_DEPEND_SIZE;
540 PreviousRnode = Rnode;
542 /* Increment offset past StartDependentNoPri descriptor */
544 CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO);
546 /* Process all child initialization nodes */
548 State = ACPI_RSTATE_START_DEPENDENT;
549 while (InitializerOp)
551 NextInfo.CurrentByteOffset = CurrentByteOffset;
552 NextInfo.DescriptorTypeOp = InitializerOp;
554 NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State);
557 * Update current byte offset to indicate the number of bytes from the
558 * start of the buffer. Buffer can include multiple descriptors, we
559 * must keep track of the offset of not only each descriptor, but each
560 * element (field) within each descriptor as well.
562 CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
564 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
571 /*******************************************************************************
573 * FUNCTION: RsDoVendorSmallDescriptor
575 * PARAMETERS: Info - Parse Op and resource template offset
577 * RETURN: Completed resource node
579 * DESCRIPTION: Construct a short "VendorShort" descriptor
581 ******************************************************************************/
584 RsDoVendorSmallDescriptor (
585 ASL_RESOURCE_INFO *Info)
587 AML_RESOURCE *Descriptor;
588 ACPI_PARSE_OBJECT *InitializerOp;
589 ASL_RESOURCE_NODE *Rnode;
594 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
596 /* Allocate worst case - 7 vendor bytes */
598 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
600 Descriptor = Rnode->Buffer;
601 Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL;
602 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
604 /* Process all child initialization nodes */
606 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
607 for (i = 0; InitializerOp; i++)
609 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
614 /* Maximum 7 vendor data bytes allowed (0-6) */
618 AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
620 /* Eat the excess initializers */
622 while (InitializerOp)
624 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
629 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
630 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
633 /* Adjust the Rnode buffer size, so correct number of bytes are emitted */
635 Rnode->BufferLength -= (7 - i);
637 /* Set the length in the Type Tag */
639 Descriptor->VendorSmall.DescriptorType |= (UINT8) i;