1 /******************************************************************************
3 * Module Name: aslrestype2 - Miscellaneous Large resource descriptors
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2017, 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: Info - Parse Op and resource template offset
65 * RETURN: Completed resource node
67 * DESCRIPTION: Construct a long "Register" descriptor
69 ******************************************************************************/
72 RsDoGeneralRegisterDescriptor (
73 ASL_RESOURCE_INFO *Info)
75 AML_RESOURCE *Descriptor;
76 ACPI_PARSE_OBJECT *InitializerOp;
77 ASL_RESOURCE_NODE *Rnode;
78 UINT32 CurrentByteOffset;
82 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
83 CurrentByteOffset = Info->CurrentByteOffset;
84 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER));
86 Descriptor = Rnode->Buffer;
87 Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
88 Descriptor->GenericReg.ResourceLength = 12;
90 /* Process all child initialization nodes */
92 for (i = 0; InitializerOp; i++)
96 case 0: /* Address space */
98 Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer;
99 RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE,
100 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId));
103 case 1: /* Register Bit Width */
105 Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer;
106 RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH,
107 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth));
110 case 2: /* Register Bit Offset */
112 Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer;
113 RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET,
114 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset));
117 case 3: /* Register Address */
119 Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
120 RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
121 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
124 case 4: /* Access Size (ACPI 3.0) */
126 Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer;
127 RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE,
128 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize));
130 if (Descriptor->GenericReg.AddressSpaceId == ACPI_ADR_SPACE_PLATFORM_COMM)
135 if (Descriptor->GenericReg.AccessSize > AML_FIELD_ACCESS_QWORD)
137 AslError (ASL_ERROR, ASL_MSG_INVALID_ACCESS_SIZE,
138 InitializerOp, NULL);
142 case 5: /* ResourceTag (ACPI 3.0b) */
144 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
149 AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
153 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
160 /*******************************************************************************
162 * FUNCTION: RsDoInterruptDescriptor
164 * PARAMETERS: Info - Parse Op and resource template offset
166 * RETURN: Completed resource node
168 * DESCRIPTION: Construct a long "Interrupt" descriptor
170 ******************************************************************************/
173 RsDoInterruptDescriptor (
174 ASL_RESOURCE_INFO *Info)
176 AML_RESOURCE *Descriptor;
177 AML_RESOURCE *Rover = NULL;
178 ACPI_PARSE_OBJECT *InitializerOp;
179 ASL_RESOURCE_NODE *Rnode;
180 UINT16 StringLength = 0;
181 UINT32 OptionIndex = 0;
182 UINT32 CurrentByteOffset;
184 BOOLEAN HasResSourceIndex = FALSE;
185 UINT8 ResSourceIndex = 0;
186 UINT8 *ResSourceString = NULL;
189 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
190 CurrentByteOffset = Info->CurrentByteOffset;
191 StringLength = RsGetStringDataLength (InitializerOp);
193 /* Count the interrupt numbers */
195 for (i = 0; InitializerOp; i++)
197 InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
202 InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
205 * ResourceSourceIndex was specified, always make room for
206 * it, even if the ResourceSource was omitted.
217 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
218 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_EXTENDED_IRQ) +
219 1 + OptionIndex + StringLength);
221 Descriptor = Rnode->Buffer;
222 Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ;
225 * Initial descriptor length -- may be enlarged if there are
226 * optional fields present
228 Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */
229 Descriptor->ExtendedIrq.InterruptCount = 0;
231 Rover = ACPI_CAST_PTR (AML_RESOURCE,
232 (&(Descriptor->ExtendedIrq.Interrupts[0])));
234 /* Process all child initialization nodes */
236 for (i = 0; InitializerOp; i++)
240 case 0: /* Resource Usage (Default: consumer (1) */
242 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 0, 1);
245 case 1: /* Interrupt Type (or Mode - edge/level) */
247 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 1, 0);
248 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
249 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 1);
252 case 2: /* Interrupt Level (or Polarity - Active high/low) */
254 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 2, 0);
255 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
256 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 2);
259 case 3: /* Share Type - Default: exclusive (0) */
261 RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 3, 0);
262 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
263 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 3);
266 case 4: /* ResSourceIndex [Optional Field - BYTE] */
268 if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
270 HasResSourceIndex = TRUE;
271 ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
275 case 5: /* ResSource [Optional Field - STRING] */
277 if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
278 (InitializerOp->Asl.Value.String))
282 ResSourceString = (UINT8 *) InitializerOp->Asl.Value.String;
285 /* ResourceSourceIndex must also be valid */
287 if (!HasResSourceIndex)
289 AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
290 InitializerOp, NULL);
296 * Not a valid ResourceSource, ResourceSourceIndex must also
299 else if (HasResSourceIndex)
301 AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
302 InitializerOp, NULL);
307 case 6: /* ResourceTag */
309 UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
314 * Interrupt Numbers come through here, repeatedly
317 /* Maximum 255 interrupts allowed for this descriptor */
319 if (Descriptor->ExtendedIrq.InterruptCount == 255)
321 AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST,
322 InitializerOp, NULL);
326 /* Each interrupt number must be a 32-bit value */
328 if (InitializerOp->Asl.Value.Integer > ACPI_UINT32_MAX)
330 AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_NUMBER,
331 InitializerOp, NULL);
334 /* Save the integer and move pointer to the next one */
336 Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
337 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
338 Descriptor->ExtendedIrq.InterruptCount++;
339 Descriptor->ExtendedIrq.ResourceLength += 4;
341 /* Case 7: First interrupt number in list */
345 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
347 /* Must be at least one interrupt */
349 AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
350 InitializerOp, NULL);
353 /* Check now for duplicates in list */
355 RsCheckListForDuplicates (InitializerOp);
357 /* Create a named field at the start of the list */
359 RsCreateDwordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
361 ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]));
365 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
369 /* Add optional ResSourceIndex if present */
371 if (HasResSourceIndex)
373 Rover->ByteItem = ResSourceIndex;
374 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->ByteItem), 1);
375 Descriptor->ExtendedIrq.ResourceLength += 1;
378 /* Add optional ResSource string if present */
380 if (StringLength && ResSourceString)
383 strcpy ((char *) Rover, (char *) ResSourceString);
384 Rover = ACPI_ADD_PTR (
385 AML_RESOURCE, &(Rover->ByteItem), StringLength);
387 Descriptor->ExtendedIrq.ResourceLength = (UINT16)
388 (Descriptor->ExtendedIrq.ResourceLength + StringLength);
391 Rnode->BufferLength =
392 (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
393 ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType))
394 + OptionIndex + StringLength;
399 /*******************************************************************************
401 * FUNCTION: RsDoVendorLargeDescriptor
403 * PARAMETERS: Info - Parse Op and resource template offset
405 * RETURN: Completed resource node
407 * DESCRIPTION: Construct a long "VendorLong" descriptor
409 ******************************************************************************/
412 RsDoVendorLargeDescriptor (
413 ASL_RESOURCE_INFO *Info)
415 AML_RESOURCE *Descriptor;
416 ACPI_PARSE_OBJECT *InitializerOp;
417 ASL_RESOURCE_NODE *Rnode;
422 /* Count the number of data bytes */
424 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
425 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
427 for (i = 0; InitializerOp; i++)
429 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
433 InitializerOp = InitializerOp->Asl.Next;
436 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
437 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
438 Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i);
440 Descriptor = Rnode->Buffer;
441 Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
442 Descriptor->VendorLarge.ResourceLength = (UINT16) i;
444 /* Point to end-of-descriptor for vendor data */
446 VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_LARGE_HEADER);
448 /* Process all child initialization nodes */
450 for (i = 0; InitializerOp; i++)
452 if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
457 VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
458 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);