1 /******************************************************************************
3 * Module Name: aslrestype2 - Miscellaneous Large resource descriptors
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, 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 "aslcompiler.h"
45 #include "aslcompiler.y.h"
48 #define _COMPONENT ACPI_COMPILER
49 ACPI_MODULE_NAME ("aslrestype2")
52 * This module contains miscellaneous large resource descriptors:
59 /*******************************************************************************
61 * FUNCTION: RsDoGeneralRegisterDescriptor
63 * PARAMETERS: Op - Parent resource descriptor parse node
64 * CurrentByteOffset - Offset into the resource template AML
65 * buffer (to track references to the desc)
67 * RETURN: Completed resource node
69 * DESCRIPTION: Construct a long "Register" descriptor
71 ******************************************************************************/
74 RsDoGeneralRegisterDescriptor (
75 ACPI_PARSE_OBJECT *Op,
76 UINT32 CurrentByteOffset)
78 AML_RESOURCE *Descriptor;
79 ACPI_PARSE_OBJECT *InitializerOp;
80 ASL_RESOURCE_NODE *Rnode;
84 InitializerOp = Op->Asl.Child;
85 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER));
87 Descriptor = Rnode->Buffer;
88 Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
89 Descriptor->GenericReg.ResourceLength = 12;
91 /* Process all child initialization nodes */
93 for (i = 0; InitializerOp; i++)
97 case 0: /* Address space */
99 Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer;
100 RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE,
101 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId));
104 case 1: /* Register Bit Width */
106 Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer;
107 RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH,
108 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth));
111 case 2: /* Register Bit Offset */
113 Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer;
114 RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET,
115 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset));
118 case 3: /* Register Address */
120 Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
121 RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
122 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
125 case 4: /* Access Size (ACPI 3.0) */
127 Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer;
128 RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE,
129 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize));
131 if (Descriptor->GenericReg.AccessSize > AML_FIELD_ACCESS_QWORD)
133 AslError (ASL_ERROR, ASL_MSG_INVALID_ACCESS_SIZE,
134 InitializerOp, NULL);
138 case 5: /* ResourceTag (ACPI 3.0b) */
140 UtAttachNamepathToOwner (Op, InitializerOp);
145 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
149 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
155 /*******************************************************************************
157 * FUNCTION: RsDoInterruptDescriptor
159 * PARAMETERS: Op - Parent resource descriptor parse node
160 * CurrentByteOffset - Offset into the resource template AML
161 * buffer (to track references to the desc)
163 * RETURN: Completed resource node
165 * DESCRIPTION: Construct a long "Interrupt" descriptor
167 ******************************************************************************/
170 RsDoInterruptDescriptor (
171 ACPI_PARSE_OBJECT *Op,
172 UINT32 CurrentByteOffset)
174 AML_RESOURCE *Descriptor;
175 AML_RESOURCE *Rover = NULL;
176 ACPI_PARSE_OBJECT *InitializerOp;
177 ASL_RESOURCE_NODE *Rnode;
178 UINT16 StringLength = 0;
179 UINT32 OptionIndex = 0;
181 BOOLEAN HasResSourceIndex = FALSE;
182 UINT8 ResSourceIndex = 0;
183 UINT8 *ResSourceString = NULL;
186 InitializerOp = Op->Asl.Child;
187 StringLength = RsGetStringDataLength (InitializerOp);
189 /* Count the interrupt numbers */
191 for (i = 0; InitializerOp; i++)
193 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
198 InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
201 * ResourceSourceIndex was specified, always make room for
202 * it, even if the ResourceSource was omitted.
213 InitializerOp = Op->Asl.Child;
214 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_EXTENDED_IRQ) +
215 1 + OptionIndex + StringLength);
217 Descriptor = Rnode->Buffer;
218 Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ;
221 * Initial descriptor length -- may be enlarged if there are
222 * optional fields present
224 Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */
225 Descriptor->ExtendedIrq.InterruptCount = 0;
227 Rover = ACPI_CAST_PTR (AML_RESOURCE,
228 (&(Descriptor->ExtendedIrq.Interrupts[0])));
230 /* Process all child initialization nodes */
232 for (i = 0; InitializerOp; i++)
236 case 0: /* Resource Usage (Default: consumer (1) */
238 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 0, 1);
241 case 1: /* Interrupt Type (or Mode - edge/level) */
243 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 1, 0);
244 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
245 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 1);
248 case 2: /* Interrupt Level (or Polarity - Active high/low) */
250 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 2, 0);
251 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
252 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 2);
255 case 3: /* Share Type - Default: exclusive (0) */
257 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 3, 0);
258 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
259 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 3);
262 case 4: /* ResSourceIndex [Optional Field - BYTE] */
264 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
266 HasResSourceIndex = TRUE;
267 ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
271 case 5: /* ResSource [Optional Field - STRING] */
273 if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
274 (InitializerOp->Asl.Value.String))
278 ResSourceString = (UINT8 *) InitializerOp->Asl.Value.String;
281 /* ResourceSourceIndex must also be valid */
283 if (!HasResSourceIndex)
285 AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
286 InitializerOp, NULL);
292 * Not a valid ResourceSource, ResourceSourceIndex must also
295 else if (HasResSourceIndex)
297 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
298 InitializerOp, NULL);
303 case 6: /* ResourceTag */
305 UtAttachNamepathToOwner (Op, InitializerOp);
310 * Interrupt Numbers come through here, repeatedly
313 /* Maximum 255 interrupts allowed for this descriptor */
315 if (Descriptor->ExtendedIrq.InterruptCount == 255)
317 AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST,
318 InitializerOp, NULL);
322 /* Each interrupt number must be a 32-bit value */
324 if (InitializerOp->Asl.Value.Integer > ACPI_UINT32_MAX)
326 AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_NUMBER,
327 InitializerOp, NULL);
330 /* Save the integer and move pointer to the next one */
332 Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
333 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
334 Descriptor->ExtendedIrq.InterruptCount++;
335 Descriptor->ExtendedIrq.ResourceLength += 4;
337 /* Case 7: First interrupt number in list */
341 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
343 /* Must be at least one interrupt */
345 AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
346 InitializerOp, NULL);
349 /* Check now for duplicates in list */
351 RsCheckListForDuplicates (InitializerOp);
353 /* Create a named field at the start of the list */
355 RsCreateDwordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
357 ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]));
361 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
365 /* Add optional ResSourceIndex if present */
367 if (HasResSourceIndex)
369 Rover->ByteItem = ResSourceIndex;
370 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->ByteItem), 1);
371 Descriptor->ExtendedIrq.ResourceLength += 1;
374 /* Add optional ResSource string if present */
376 if (StringLength && ResSourceString)
379 strcpy ((char *) Rover, (char *) ResSourceString);
380 Rover = ACPI_ADD_PTR (
381 AML_RESOURCE, &(Rover->ByteItem), StringLength);
383 Descriptor->ExtendedIrq.ResourceLength = (UINT16)
384 (Descriptor->ExtendedIrq.ResourceLength + StringLength);
387 Rnode->BufferLength = (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
388 ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType))
389 + OptionIndex + StringLength;
394 /*******************************************************************************
396 * FUNCTION: RsDoVendorLargeDescriptor
398 * PARAMETERS: Op - Parent resource descriptor parse node
399 * CurrentByteOffset - Offset into the resource template AML
400 * buffer (to track references to the desc)
402 * RETURN: Completed resource node
404 * DESCRIPTION: Construct a long "VendorLong" descriptor
406 ******************************************************************************/
409 RsDoVendorLargeDescriptor (
410 ACPI_PARSE_OBJECT *Op,
411 UINT32 CurrentByteOffset)
413 AML_RESOURCE *Descriptor;
414 ACPI_PARSE_OBJECT *InitializerOp;
415 ASL_RESOURCE_NODE *Rnode;
420 /* Count the number of data bytes */
422 InitializerOp = Op->Asl.Child;
423 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
425 for (i = 0; InitializerOp; i++)
427 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
431 InitializerOp = InitializerOp->Asl.Next;
434 InitializerOp = Op->Asl.Child;
435 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
436 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i);
438 Descriptor = Rnode->Buffer;
439 Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
440 Descriptor->VendorLarge.ResourceLength = (UINT16) i;
442 /* Point to end-of-descriptor for vendor data */
444 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_LARGE_HEADER);
446 /* Process all child initialization nodes */
448 for (i = 0; InitializerOp; i++)
450 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
455 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
456 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);