Message ID | 1334188256-26566-2-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On Thu, Apr 12, 2012 at 7:50 AM, Colin King <colin.king@canonical.com> wrote: > From: Colin Ian King <colin.king@canonical.com> > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/acpica/source/compiler/aslrestype2s.c | 1259 ++++++++++++++++++++ > src/acpica/source/compiler/aslsupport.l | 854 +++++++++++++ > src/acpica/source/compiler/preprocess.h | 345 ++++++ > src/acpica/source/compiler/prexpress.c | 377 ++++++ > src/acpica/source/compiler/prmacros.c | 646 ++++++++++ > src/acpica/source/compiler/prparser.l | 225 ++++ > src/acpica/source/compiler/prparser.y | 356 ++++++ > src/acpica/source/compiler/prscan.c | 844 +++++++++++++ > src/acpica/source/compiler/prutils.c | 540 +++++++++ > .../source/components/disassembler/dmresrcl2.c | 772 ++++++++++++ > src/acpica/source/components/hardware/hwesleep.c | 349 ++++++ > src/acpica/source/components/hardware/hwxfsleep.c | 550 +++++++++ > src/acpica/source/components/resources/rsserial.c | 497 ++++++++ > src/acpica/source/components/utilities/utaddress.c | 394 ++++++ > src/acpica/source/include/actbl3.h | 722 +++++++++++ > 15 files changed, 8730 insertions(+) > create mode 100644 src/acpica/source/compiler/aslrestype2s.c > create mode 100644 src/acpica/source/compiler/aslsupport.l > create mode 100644 src/acpica/source/compiler/preprocess.h > create mode 100644 src/acpica/source/compiler/prexpress.c > create mode 100644 src/acpica/source/compiler/prmacros.c > create mode 100644 src/acpica/source/compiler/prparser.l > create mode 100644 src/acpica/source/compiler/prparser.y > create mode 100644 src/acpica/source/compiler/prscan.c > create mode 100644 src/acpica/source/compiler/prutils.c > create mode 100644 src/acpica/source/components/disassembler/dmresrcl2.c > create mode 100644 src/acpica/source/components/hardware/hwesleep.c > create mode 100644 src/acpica/source/components/hardware/hwxfsleep.c > create mode 100644 src/acpica/source/components/resources/rsserial.c > create mode 100644 src/acpica/source/components/utilities/utaddress.c > create mode 100644 src/acpica/source/include/actbl3.h > > diff --git a/src/acpica/source/compiler/aslrestype2s.c b/src/acpica/source/compiler/aslrestype2s.c > new file mode 100644 > index 0000000..a9d24cd > --- /dev/null > +++ b/src/acpica/source/compiler/aslrestype2s.c > @@ -0,0 +1,1259 @@ > +/****************************************************************************** > + * > + * Module Name: aslrestype2s - Serial Large resource descriptors > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > + > +#include "aslcompiler.h" > +#include "aslcompiler.y.h" > +#include "amlcode.h" > + > +#define _COMPONENT ACPI_COMPILER > + ACPI_MODULE_NAME ("aslrestype2s") > + > + > +static UINT16 > +RsGetBufferDataLength ( > + ACPI_PARSE_OBJECT *InitializerOp); > + > +static UINT16 > +RsGetInterruptDataLength ( > + ACPI_PARSE_OBJECT *InitializerOp); > + > +static BOOLEAN > +RsGetVendorData ( > + ACPI_PARSE_OBJECT *InitializerOp, > + UINT8 *VendorData, > + ACPI_SIZE DescriptorOffset); > + > +/* > + * This module contains descriptors for serial buses and GPIO: > + * > + * GpioInt > + * GpioIo > + * I2cSerialBus > + * SpiSerialBus > + * UartSerialBus > + */ > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsGetBufferDataLength > + * > + * PARAMETERS: InitializerOp - Current parse op, start of the resource > + * descriptor > + * > + * RETURN: Length of the data buffer > + * > + * DESCRIPTION: Get the length of a RawDataBuffer, used for vendor data. > + * > + ******************************************************************************/ > + > +static UINT16 > +RsGetBufferDataLength ( > + ACPI_PARSE_OBJECT *InitializerOp) > +{ > + UINT16 ExtraDataSize = 0; > + ACPI_PARSE_OBJECT *DataList; > + > + > + /* Find the byte-initializer list */ > + > + while (InitializerOp) > + { > + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DATABUFFER) > + { > + /* First child is the optional length (ignore it here) */ > + > + DataList = InitializerOp->Asl.Child; > + DataList = ASL_GET_PEER_NODE (DataList); > + > + /* Count the data items (each one is a byte of data) */ > + > + while (DataList) > + { > + ExtraDataSize++; > + DataList = ASL_GET_PEER_NODE (DataList); > + } > + > + return (ExtraDataSize); > + } > + > + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); > + } > + > + return (ExtraDataSize); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsGetInterruptDataLength > + * > + * PARAMETERS: InitializerOp - Current parse op, start of the resource > + * descriptor > + * > + * RETURN: Length of the interrupt data list > + * > + * DESCRIPTION: Get the length of a list of interrupt DWORDs for the GPIO > + * descriptors. > + * > + ******************************************************************************/ > + > +static UINT16 > +RsGetInterruptDataLength ( > + ACPI_PARSE_OBJECT *InitializerOp) > +{ > + UINT16 InterruptLength; > + UINT32 i; > + > + > + /* Count the interrupt numbers */ > + > + InterruptLength = 0; > + for (i = 0; InitializerOp; i++) > + { > + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); > + > + /* Interrupt list starts at offset 10 (Gpio descriptors) */ > + > + if (i >= 10) > + { > + InterruptLength += 2; > + } > + } > + > + return (InterruptLength); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsGetVendorData > + * > + * PARAMETERS: InitializerOp - Current parse op, start of the resource > + * descriptor. > + * VendorData - Where the vendor data is returned > + * DescriptorOffset - Where vendor data begins in descriptor > + * > + * RETURN: TRUE if valid vendor data was returned, FALSE otherwise. > + * > + * DESCRIPTION: Extract the vendor data and construct a vendor data buffer. > + * > + ******************************************************************************/ > + > +static BOOLEAN > +RsGetVendorData ( > + ACPI_PARSE_OBJECT *InitializerOp, > + UINT8 *VendorData, > + ACPI_SIZE DescriptorOffset) > +{ > + ACPI_PARSE_OBJECT *BufferOp; > + UINT32 SpecifiedLength = ACPI_UINT32_MAX; > + UINT16 ActualLength = 0; > + > + > + /* Vendor Data field is always optional */ > + > + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) > + { > + return (FALSE); > + } > + > + BufferOp = InitializerOp->Asl.Child; > + if (!BufferOp) > + { > + AslError (ASL_ERROR, ASL_MSG_SYNTAX, InitializerOp, ""); > + return (FALSE); > + } > + > + /* First child is the optional buffer length (WORD) */ > + > + if (BufferOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + SpecifiedLength = (UINT16) BufferOp->Asl.Value.Integer; > + } > + > + /* Insert field tag _VEN */ > + > + RsCreateByteField (InitializerOp, ACPI_RESTAG_VENDORDATA, > + (UINT16) DescriptorOffset); > + > + /* Walk the list of buffer initializers (each is one byte) */ > + > + BufferOp = RsCompleteNodeAndGetNext (BufferOp); > + if (BufferOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + while (BufferOp) > + { > + *VendorData = (UINT8) BufferOp->Asl.Value.Integer; > + VendorData++; > + ActualLength++; > + BufferOp = RsCompleteNodeAndGetNext (BufferOp); > + } > + } > + > + /* Length validation. Buffer cannot be of zero length */ > + > + if ((SpecifiedLength == 0) || > + ((SpecifiedLength == ACPI_UINT32_MAX) && (ActualLength == 0))) > + { > + AslError (ASL_ERROR, ASL_MSG_BUFFER_LENGTH, InitializerOp, NULL); > + return (FALSE); > + } > + > + if (SpecifiedLength != ACPI_UINT32_MAX) > + { > + /* ActualLength > SpecifiedLength -> error */ > + > + if (ActualLength > SpecifiedLength) > + { > + AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG, InitializerOp, NULL); > + return (FALSE); > + } > + > + /* ActualLength < SpecifiedLength -> remark */ > + > + else if (ActualLength < SpecifiedLength) > + { > + AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT, InitializerOp, NULL); > + return (FALSE); > + } > + } > + > + return (TRUE); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsDoGpioIntDescriptor > + * > + * PARAMETERS: Op - Parent resource descriptor parse node > + * CurrentByteOffset - Offset into the resource template AML > + * buffer (to track references to the desc) > + * > + * RETURN: Completed resource node > + * > + * DESCRIPTION: Construct a long "GpioInt" descriptor > + * > + ******************************************************************************/ > + > +ASL_RESOURCE_NODE * > +RsDoGpioIntDescriptor ( > + ACPI_PARSE_OBJECT *Op, > + UINT32 CurrentByteOffset) > +{ > + AML_RESOURCE *Descriptor; > + ACPI_PARSE_OBJECT *InitializerOp; > + ASL_RESOURCE_NODE *Rnode; > + char *ResourceSource = NULL; > + UINT8 *VendorData = NULL; > + UINT16 *InterruptList = NULL; > + UINT16 ResSourceLength; > + UINT16 VendorLength; > + UINT16 InterruptLength; > + UINT16 DescriptorSize; > + UINT32 i; > + > + > + InitializerOp = Op->Asl.Child; > + > + /* > + * Calculate lengths for fields that have variable length: > + * 1) Resource Source string > + * 2) Vendor Data buffer > + * 3) PIN (interrupt) list > + */ > + ResSourceLength = RsGetStringDataLength (InitializerOp); > + VendorLength = RsGetBufferDataLength (InitializerOp); > + InterruptLength = RsGetInterruptDataLength (InitializerOp); > + > + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) + > + ResSourceLength + VendorLength + InterruptLength; > + > + /* Allocate the local resource node and initialize */ > + > + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); > + > + Descriptor = Rnode->Buffer; > + Descriptor->Gpio.ResourceLength = DescriptorSize; > + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; > + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; > + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT; > + > + /* Build pointers to optional areas */ > + > + InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); > + ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); > + VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); > + > + /* Setup offsets within the descriptor */ > + > + Descriptor->Gpio.PinTableOffset = (UINT16) > + ACPI_PTR_DIFF (InterruptList, Descriptor); > + > + Descriptor->Gpio.ResSourceOffset = (UINT16) > + ACPI_PTR_DIFF (ResourceSource, Descriptor); > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", > + "GpioInt", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), > + ResSourceLength, VendorLength, InterruptLength); > + > + /* Process all child initialization nodes */ > + > + for (i = 0; InitializerOp; i++) > + { > + switch (i) > + { > + case 0: /* Interrupt Mode - edge/level [Flag] (_MOD) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0); > + break; > + > + case 1: /* Interrupt Polarity - Active high/low [Flags] (_POL) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 1, 0); > + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_POLARITY, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 1, 2); > + break; > + > + case 2: /* Share Type - Default: exclusive (0) [Flags] (_SHR) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0); > + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3, 2); > + break; > + > + case 3: /* Pin Config [BYTE] (_PPI) */ > + > + Descriptor->Gpio.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig)); > + break; > + > + case 4: /* Debounce Timeout [WORD] (_DBT) */ > + > + Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout)); > + break; > + > + case 5: /* ResSource [Optional Field - STRING] */ > + > + if (ResSourceLength) > + { > + /* Copy string to the descriptor */ > + > + strcpy (ResourceSource, > + InitializerOp->Asl.Value.String); > + } > + break; > + > + case 6: /* Resource Index */ > + > + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; > + } > + break; > + > + case 7: /* Resource Usage (consumer/producer) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1); > + break; > + > + case 8: /* Resource Tag (Descriptor Name) */ > + > + UtAttachNamepathToOwner (Op, InitializerOp); > + break; > + > + case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ > + > + /* > + * Always set the VendorOffset even if there is no Vendor Data. > + * This field is required in order to calculate the length > + * of the ResourceSource at runtime. > + */ > + Descriptor->Gpio.VendorOffset = (UINT16) > + ACPI_PTR_DIFF (VendorData, Descriptor); > + > + if (RsGetVendorData (InitializerOp, VendorData, > + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) > + { > + Descriptor->Gpio.VendorLength = VendorLength; > + } > + break; > + > + default: > + /* > + * PINs come through here, repeatedly. Each PIN must be a DWORD. > + * NOTE: there is no "length" field for this, so from ACPI spec: > + * The number of pins in the table can be calculated from: > + * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 > + * (implies resource source must immediately follow the pin list.) > + * Name: _PIN > + */ > + *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; > + InterruptList++; > + > + /* Case 10: First interrupt number in list */ > + > + if (i == 10) > + { > + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) > + { > + /* Must be at least one interrupt */ > + > + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN, > + InitializerOp, NULL); > + } > + > + /* Check now for duplicates in list */ > + > + RsCheckListForDuplicates (InitializerOp); > + > + /* Create a named field at the start of the list */ > + > + RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, > + CurrentByteOffset + Descriptor->Gpio.PinTableOffset); > + } > + break; > + } > + > + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); > + } > + > + return (Rnode); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsDoGpioIoDescriptor > + * > + * PARAMETERS: Op - Parent resource descriptor parse node > + * CurrentByteOffset - Offset into the resource template AML > + * buffer (to track references to the desc) > + * > + * RETURN: Completed resource node > + * > + * DESCRIPTION: Construct a long "GpioIo" descriptor > + * > + ******************************************************************************/ > + > +ASL_RESOURCE_NODE * > +RsDoGpioIoDescriptor ( > + ACPI_PARSE_OBJECT *Op, > + UINT32 CurrentByteOffset) > +{ > + AML_RESOURCE *Descriptor; > + ACPI_PARSE_OBJECT *InitializerOp; > + ASL_RESOURCE_NODE *Rnode; > + char *ResourceSource = NULL; > + UINT8 *VendorData = NULL; > + UINT16 *InterruptList = NULL; > + UINT16 ResSourceLength; > + UINT16 VendorLength; > + UINT16 InterruptLength; > + UINT16 DescriptorSize; > + UINT32 i; > + > + > + InitializerOp = Op->Asl.Child; > + > + /* > + * Calculate lengths for fields that have variable length: > + * 1) Resource Source string > + * 2) Vendor Data buffer > + * 3) PIN (interrupt) list > + */ > + ResSourceLength = RsGetStringDataLength (InitializerOp); > + VendorLength = RsGetBufferDataLength (InitializerOp); > + InterruptLength = RsGetInterruptDataLength (InitializerOp); > + > + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) + > + ResSourceLength + VendorLength + InterruptLength; > + > + /* Allocate the local resource node and initialize */ > + > + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); > + > + Descriptor = Rnode->Buffer; > + Descriptor->Gpio.ResourceLength = DescriptorSize; > + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; > + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; > + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO; > + > + /* Build pointers to optional areas */ > + > + InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); > + ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); > + VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); > + > + /* Setup offsets within the descriptor */ > + > + Descriptor->Gpio.PinTableOffset = (UINT16) > + ACPI_PTR_DIFF (InterruptList, Descriptor); > + > + Descriptor->Gpio.ResSourceOffset = (UINT16) > + ACPI_PTR_DIFF (ResourceSource, Descriptor); > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", > + "GpioIo", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), > + ResSourceLength, VendorLength, InterruptLength); > + > + /* Process all child initialization nodes */ > + > + for (i = 0; InitializerOp; i++) > + { > + switch (i) > + { > + case 0: /* Share Type [Flags] (_SHR) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3); > + break; > + > + case 1: /* Pin Config [BYTE] (_PPI) */ > + > + Descriptor->Gpio.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig)); > + break; > + > + case 2: /* Debounce Timeout [WORD] (_DBT) */ > + > + Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout)); > + break; > + > + case 3: /* Drive Strength [WORD] (_DRS) */ > + > + Descriptor->Gpio.DriveStrength = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_DRIVESTRENGTH, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DriveStrength)); > + break; > + > + case 4: /* I/O Restriction [Flag] (_IOR) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0); > + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_IORESTRICTION, > + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0, 2); > + break; > + > + case 5: /* ResSource [Optional Field - STRING] */ > + > + if (ResSourceLength) > + { > + /* Copy string to the descriptor */ > + > + strcpy (ResourceSource, > + InitializerOp->Asl.Value.String); > + } > + break; > + > + case 6: /* Resource Index */ > + > + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; > + } > + break; > + > + case 7: /* Resource Usage (consumer/producer) */ > + > + RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1); > + break; > + > + case 8: /* Resource Tag (Descriptor Name) */ > + > + UtAttachNamepathToOwner (Op, InitializerOp); > + break; > + > + case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ > + > + /* > + * Always set the VendorOffset even if there is no Vendor Data. > + * This field is required in order to calculate the length > + * of the ResourceSource at runtime. > + */ > + Descriptor->Gpio.VendorOffset = (UINT16) > + ACPI_PTR_DIFF (VendorData, Descriptor); > + > + if (RsGetVendorData (InitializerOp, VendorData, > + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) > + { > + Descriptor->Gpio.VendorLength = VendorLength; > + } > + break; > + > + default: > + /* > + * PINs come through here, repeatedly. Each PIN must be a DWORD. > + * NOTE: there is no "length" field for this, so from ACPI spec: > + * The number of pins in the table can be calculated from: > + * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 > + * (implies resource source must immediately follow the pin list.) > + * Name: _PIN > + */ > + *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; > + InterruptList++; > + > + /* Case 10: First interrupt number in list */ > + > + if (i == 10) > + { > + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) > + { > + /* Must be at least one interrupt */ > + > + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN, > + InitializerOp, NULL); > + } > + > + /* Check now for duplicates in list */ > + > + RsCheckListForDuplicates (InitializerOp); > + > + /* Create a named field at the start of the list */ > + > + RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, > + CurrentByteOffset + Descriptor->Gpio.PinTableOffset); > + } > + break; > + } > + > + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); > + } > + > + return (Rnode); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsDoI2cSerialBusDescriptor > + * > + * PARAMETERS: Op - Parent resource descriptor parse node > + * CurrentByteOffset - Offset into the resource template AML > + * buffer (to track references to the desc) > + * > + * RETURN: Completed resource node > + * > + * DESCRIPTION: Construct a long "I2cSerialBus" descriptor > + * > + ******************************************************************************/ > + > +ASL_RESOURCE_NODE * > +RsDoI2cSerialBusDescriptor ( > + ACPI_PARSE_OBJECT *Op, > + UINT32 CurrentByteOffset) > +{ > + AML_RESOURCE *Descriptor; > + ACPI_PARSE_OBJECT *InitializerOp; > + ASL_RESOURCE_NODE *Rnode; > + char *ResourceSource = NULL; > + UINT8 *VendorData = NULL; > + UINT16 ResSourceLength; > + UINT16 VendorLength; > + UINT16 DescriptorSize; > + UINT32 i; > + > + > + InitializerOp = Op->Asl.Child; > + > + /* > + * Calculate lengths for fields that have variable length: > + * 1) Resource Source string > + * 2) Vendor Data buffer > + */ > + ResSourceLength = RsGetStringDataLength (InitializerOp); > + VendorLength = RsGetBufferDataLength (InitializerOp); > + > + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS) + > + ResSourceLength + VendorLength; > + > + /* Allocate the local resource node and initialize */ > + > + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); > + > + Descriptor = Rnode->Buffer; > + Descriptor->I2cSerialBus.ResourceLength = DescriptorSize; > + Descriptor->I2cSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; > + Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION; > + Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION; > + Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE; > + Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength; > + > + /* Build pointers to optional areas */ > + > + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_I2C_SERIALBUS)); > + ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", > + "I2cSerialBus", Descriptor->I2cSerialBus.ResourceLength, > + (UINT16) sizeof (AML_RESOURCE_I2C_SERIALBUS), ResSourceLength, > + VendorLength, Descriptor->I2cSerialBus.TypeDataLength); > + > + /* Process all child initialization nodes */ > + > + for (i = 0; InitializerOp; i++) > + { > + switch (i) > + { > + case 0: /* Slave Address [WORD] (_ADR) */ > + > + Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS, > + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress)); > + break; > + > + case 1: /* Slave Mode [Flag] (_SLV) */ > + > + RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 0, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 0); > + break; > + > + case 2: /* Connection Speed [DWORD] (_SPE) */ > + > + Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer; > + RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED, > + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed)); > + break; > + > + case 3: /* Addressing Mode [Flag] (_MOD) */ > + > + RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0); > + break; > + > + case 4: /* ResSource [Optional Field - STRING] */ > + > + if (ResSourceLength) > + { > + /* Copy string to the descriptor */ > + > + strcpy (ResourceSource, > + InitializerOp->Asl.Value.String); > + } > + break; > + > + case 5: /* Resource Index */ > + > + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + Descriptor->I2cSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; > + } > + break; > + > + case 6: /* Resource Usage (consumer/producer) */ > + > + RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 1, 1); > + break; > + > + case 7: /* Resource Tag (Descriptor Name) */ > + > + UtAttachNamepathToOwner (Op, InitializerOp); > + break; > + > + case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ > + > + RsGetVendorData (InitializerOp, VendorData, > + CurrentByteOffset + sizeof (AML_RESOURCE_I2C_SERIALBUS)); > + break; > + > + default: /* Ignore any extra nodes */ > + break; > + } > + > + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); > + } > + > + return (Rnode); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsDoSpiSerialBusDescriptor > + * > + * PARAMETERS: Op - Parent resource descriptor parse node > + * CurrentByteOffset - Offset into the resource template AML > + * buffer (to track references to the desc) > + * > + * RETURN: Completed resource node > + * > + * DESCRIPTION: Construct a long "SPI Serial Bus" descriptor > + * > + ******************************************************************************/ > + > +ASL_RESOURCE_NODE * > +RsDoSpiSerialBusDescriptor ( > + ACPI_PARSE_OBJECT *Op, > + UINT32 CurrentByteOffset) > +{ > + AML_RESOURCE *Descriptor; > + ACPI_PARSE_OBJECT *InitializerOp; > + ASL_RESOURCE_NODE *Rnode; > + char *ResourceSource = NULL; > + UINT8 *VendorData = NULL; > + UINT16 ResSourceLength; > + UINT16 VendorLength; > + UINT16 DescriptorSize; > + UINT32 i; > + > + > + InitializerOp = Op->Asl.Child; > + > + /* > + * Calculate lengths for fields that have variable length: > + * 1) Resource Source string > + * 2) Vendor Data buffer > + */ > + ResSourceLength = RsGetStringDataLength (InitializerOp); > + VendorLength = RsGetBufferDataLength (InitializerOp); > + > + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS) + > + ResSourceLength + VendorLength; > + > + /* Allocate the local resource node and initialize */ > + > + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); > + > + Descriptor = Rnode->Buffer; > + Descriptor->SpiSerialBus.ResourceLength = DescriptorSize; > + Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; > + Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION; > + Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION; > + Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE; > + Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength; > + > + /* Build pointers to optional areas */ > + > + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_SPI_SERIALBUS)); > + ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", > + "SpiSerialBus", Descriptor->SpiSerialBus.ResourceLength, > + (UINT16) sizeof (AML_RESOURCE_SPI_SERIALBUS), ResSourceLength, > + VendorLength, Descriptor->SpiSerialBus.TypeDataLength); > + > + /* Process all child initialization nodes */ > + > + for (i = 0; InitializerOp; i++) > + { > + switch (i) > + { > + case 0: /* Device Selection [WORD] (_ADR) */ > + > + Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection)); > + break; > + > + case 1: /* Device Polarity [Flag] (_DPL) */ > + > + RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1); > + break; > + > + case 2: /* Wire Mode [Flag] (_MOD) */ > + > + RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0); > + break; > + > + case 3: /* Device Bit Length [BYTE] (_LEN) */ > + > + Descriptor->SpiSerialBus.DataBitLength = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DataBitLength)); > + break; > + > + case 4: /* Slave Mode [Flag] (_SLV) */ > + > + RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 0, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 0); > + break; > + > + case 5: /* Connection Speed [DWORD] (_SPE) */ > + > + Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer; > + RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed)); > + break; > + > + case 6: /* Clock Polarity [BYTE] (_POL) */ > + > + Descriptor->SpiSerialBus.ClockPolarity = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_POLARITY, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPolarity)); > + break; > + > + case 7: /* Clock Phase [BYTE] (_PHA) */ > + > + Descriptor->SpiSerialBus.ClockPhase = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_PHASE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPhase)); > + break; > + > + case 8: /* ResSource [Optional Field - STRING] */ > + > + if (ResSourceLength) > + { > + /* Copy string to the descriptor */ > + > + strcpy (ResourceSource, > + InitializerOp->Asl.Value.String); > + } > + break; > + > + case 9: /* Resource Index */ > + > + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + Descriptor->SpiSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; > + } > + break; > + > + case 10: /* Resource Usage (consumer/producer) */ > + > + RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 1, 1); > + break; > + > + case 11: /* Resource Tag (Descriptor Name) */ > + > + UtAttachNamepathToOwner (Op, InitializerOp); > + break; > + > + case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ > + > + RsGetVendorData (InitializerOp, VendorData, > + CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS)); > + break; > + > + default: /* Ignore any extra nodes */ > + break; > + } > + > + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); > + } > + > + return (Rnode); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: RsDoUartSerialBusDescriptor > + * > + * PARAMETERS: Op - Parent resource descriptor parse node > + * CurrentByteOffset - Offset into the resource template AML > + * buffer (to track references to the desc) > + * > + * RETURN: Completed resource node > + * > + * DESCRIPTION: Construct a long "UART Serial Bus" descriptor > + * > + ******************************************************************************/ > + > +ASL_RESOURCE_NODE * > +RsDoUartSerialBusDescriptor ( > + ACPI_PARSE_OBJECT *Op, > + UINT32 CurrentByteOffset) > +{ > + AML_RESOURCE *Descriptor; > + ACPI_PARSE_OBJECT *InitializerOp; > + ASL_RESOURCE_NODE *Rnode; > + char *ResourceSource = NULL; > + UINT8 *VendorData = NULL; > + UINT16 ResSourceLength; > + UINT16 VendorLength; > + UINT16 DescriptorSize; > + UINT32 i; > + > + > + InitializerOp = Op->Asl.Child; > + > + /* > + * Calculate lengths for fields that have variable length: > + * 1) Resource Source string > + * 2) Vendor Data buffer > + */ > + ResSourceLength = RsGetStringDataLength (InitializerOp); > + VendorLength = RsGetBufferDataLength (InitializerOp); > + > + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS) + > + ResSourceLength + VendorLength; > + > + /* Allocate the local resource node and initialize */ > + > + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); > + > + Descriptor = Rnode->Buffer; > + Descriptor->UartSerialBus.ResourceLength = DescriptorSize; > + Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; > + Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION; > + Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION; > + Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE; > + Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength; > + > + /* Build pointers to optional areas */ > + > + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_UART_SERIALBUS)); > + ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", > + "UartSerialBus", Descriptor->UartSerialBus.ResourceLength, > + (UINT16) sizeof (AML_RESOURCE_UART_SERIALBUS), ResSourceLength, > + VendorLength, Descriptor->UartSerialBus.TypeDataLength); > + > + /* Process all child initialization nodes */ > + > + for (i = 0; InitializerOp; i++) > + { > + switch (i) > + { > + case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */ > + > + Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer; > + RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate)); > + break; > + > + case 1: /* Bits Per Byte [Flags] (_LEN) */ > + > + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3); > + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3); > + break; > + > + case 2: /* Stop Bits [Flags] (_STB) */ > + > + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1); > + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2); > + break; > + > + case 3: /* Lines In Use [BYTE] (_LIN) */ > + > + Descriptor->UartSerialBus.LinesEnabled = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_LINE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.LinesEnabled)); > + break; > + > + case 4: /* Endianness [Flag] (_END) */ > + > + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0); > + RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7); > + break; > + > + case 5: /* Parity [BYTE] (_PAR) */ > + > + Descriptor->UartSerialBus.Parity = (UINT8) InitializerOp->Asl.Value.Integer; > + RsCreateByteField (InitializerOp, ACPI_RESTAG_PARITY, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Parity)); > + break; > + > + case 6: /* Flow Control [Flags] (_FLC) */ > + > + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0); > + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2); > + break; > + > + case 7: /* Rx Buffer Size [WORD] (_RXL) */ > + > + Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize)); > + break; > + > + case 8: /* Tx Buffer Size [WORD] (_TXL) */ > + > + Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer; > + RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize)); > + break; > + > + case 9: /* ResSource [Optional Field - STRING] */ > + > + if (ResSourceLength) > + { > + /* Copy string to the descriptor */ > + > + strcpy (ResourceSource, > + InitializerOp->Asl.Value.String); > + } > + break; > + > + case 10: /* Resource Index */ > + > + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) > + { > + Descriptor->UartSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; > + } > + break; > + > + case 11: /* Resource Usage (consumer/producer) */ > + > + RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 1, 1); > + > + /* > + * Slave Mode [Flag] (_SLV) > + * > + * Note: There is no SlaveMode argument to the UartSerialBus macro, but > + * we add this name anyway to allow the flag to be set by ASL in the > + * rare case where there is a slave mode associated with the UART. > + */ > + RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE, > + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 0); > + break; > + > + case 12: /* Resource Tag (Descriptor Name) */ > + > + UtAttachNamepathToOwner (Op, InitializerOp); > + break; > + > + case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ > + > + RsGetVendorData (InitializerOp, VendorData, > + CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS)); > + break; > + > + default: /* Ignore any extra nodes */ > + break; > + } > + > + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); > + } > + > + return (Rnode); > +} > diff --git a/src/acpica/source/compiler/aslsupport.l b/src/acpica/source/compiler/aslsupport.l > new file mode 100644 > index 0000000..cdaf2b8 > --- /dev/null > +++ b/src/acpica/source/compiler/aslsupport.l > @@ -0,0 +1,854 @@ > + > +/****************************************************************************** > + * > + * Module Name: aslsupport.l - Flex/lex scanner C support routines. > + * NOTE: Included into aslcompile.l, not compiled by itself. > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > + > +/* Configuration */ > + > +#define ASL_SPACES_PER_TAB 4 > + > +#define ASL_NORMAL_CHAR 0 > +#define ASL_ESCAPE_SEQUENCE 1 > +#define ASL_OCTAL_CONSTANT 2 > +#define ASL_HEX_CONSTANT 3 > + > + > +/* File node - used for "Include" operator file stack */ > + > +typedef struct asl_file_node > +{ > + FILE *File; > + UINT32 CurrentLineNumber; > + YY_BUFFER_STATE State; > + char *Filename; > + struct asl_file_node *Next; > + > +} ASL_FILE_NODE; > + > +/* File stack for the "Include" operator (NOT #include operator) */ > + > +ASL_FILE_NODE *Gbl_IncludeFileStack = NULL; > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslDoLineDirective > + * > + * PARAMETERS: None. Uses input() to access current source code line > + * > + * RETURN: Updates global line number and filename > + * > + * DESCRIPTION: Handle #line directives emitted by the preprocessor. > + * > + * The #line directive is emitted by the preprocesser, and is used to > + * pass through line numbers from the original source code file to the > + * preprocessor output file (.i). This allows any compiler-generated > + * error messages to be displayed with the correct line number. > + * > + ******************************************************************************/ > + > +static void > +AslDoLineDirective ( > + void) > +{ > + char c; > + char *Token; > + UINT32 LineNumber; > + char *Filename; > + > + > + /* Eat the entire line that contains the #line directive */ > + > + while ((c = (char) input()) != '\n' && c != EOF) > + { > + AslInsertLineBuffer (c); > + } > + AslInsertLineBuffer (0); > + > + /* First argument is the actual line number */ > + > + Token = strtok (Gbl_CurrentLineBuffer, " "); > + if (!Token) > + { > + goto ResetAndExit; > + } > + > + /* Convert line number. Subtract one to handle _this_ line */ > + > + LineNumber = (UINT32) UtDoConstant (Token); > + FlSetLineNumber (LineNumber - 1); > + > + /* Second argument is the optional filename (in double quotes) */ > + > + Token = strtok (NULL, " \""); > + if (Token) > + { > + Filename = ACPI_ALLOCATE_ZEROED (strlen (Token) + 1); > + strcpy (Filename, Token); > + FlSetFilename (Filename); > + } > + > + /* Third argument is not supported at this time */ > + > +ResetAndExit: > + AslResetCurrentLineBuffer (); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslPopInputFileStack > + * > + * PARAMETERS: None > + * > + * RETURN: 0 if a node was popped, -1 otherwise > + * > + * DESCRIPTION: Pop the top of the input file stack and point the parser to > + * the saved parse buffer contained in the fnode. Also, set the > + * global line counters to the saved values. This function is > + * called when an include file reaches EOF. > + * > + ******************************************************************************/ > + > +int > +AslPopInputFileStack ( > + void) > +{ > + ASL_FILE_NODE *Fnode; > + > + > + Fnode = Gbl_IncludeFileStack; > + DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode); > + > + if (!Fnode) > + { > + return (-1); > + } > + > + /* Close the current include file */ > + > + fclose (yyin); > + > + /* Update the top-of-stack */ > + > + Gbl_IncludeFileStack = Fnode->Next; > + > + /* Reset global line counter and filename */ > + > + Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; > + Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; > + > + /* Point the parser to the popped file */ > + > + yy_delete_buffer (YY_CURRENT_BUFFER); > + yy_switch_to_buffer (Fnode->State); > + > + /* All done with this node */ > + > + ACPI_FREE (Fnode); > + return (0); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslPushInputFileStack > + * > + * PARAMETERS: InputFile - Open file pointer > + * Filename - Name of the file > + * > + * RETURN: None > + * > + * DESCRIPTION: Push the InputFile onto the file stack, and point the parser > + * to this file. Called when an include file is successfully > + * opened. > + * > + ******************************************************************************/ > + > +void > +AslPushInputFileStack ( > + FILE *InputFile, > + char *Filename) > +{ > + ASL_FILE_NODE *Fnode; > + YY_BUFFER_STATE State; > + > + > + /* Save the current state in an Fnode */ > + > + Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE)); > + > + Fnode->File = yyin; > + Fnode->Next = Gbl_IncludeFileStack; > + Fnode->State = YY_CURRENT_BUFFER; > + Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; > + Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; > + > + /* Push it on the stack */ > + > + Gbl_IncludeFileStack = Fnode; > + > + /* Point the parser to this file */ > + > + State = yy_create_buffer (InputFile, YY_BUF_SIZE); > + yy_switch_to_buffer (State); > + > + DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile); > + > + /* Reset the global line count and filename */ > + > + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; > + Gbl_CurrentLineNumber = 1; > + yyin = InputFile; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslResetCurrentLineBuffer > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers. > + * > + ******************************************************************************/ > + > +void > +AslResetCurrentLineBuffer ( > + void) > +{ > + > + if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle) > + { > + FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer, > + Gbl_LineBufPtr - Gbl_CurrentLineBuffer); > + } > + > + Gbl_CurrentLineOffset += Gbl_CurrentColumn; > + Gbl_CurrentColumn = 0; > + > + Gbl_CurrentLineNumber++; > + Gbl_LogicalLineNumber++; > + Gbl_LineBufPtr = Gbl_CurrentLineBuffer; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslInsertLineBuffer > + * > + * PARAMETERS: SourceChar - One char from the input ASL source file > + * > + * RETURN: None > + * > + * DESCRIPTION: Put one character of the source file into the temp line buffer > + * > + ******************************************************************************/ > + > +void > +AslInsertLineBuffer ( > + int SourceChar) > +{ > + UINT32 i; > + UINT32 Count = 1; > + > + > + if (SourceChar == EOF) > + { > + return; > + } > + > + Gbl_InputByteCount++; > + > + /* Handle tabs. Convert to spaces */ > + > + if (SourceChar == '\t') > + { > + SourceChar = ' '; > + Count = ASL_SPACES_PER_TAB - > + (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1)); > + } > + > + for (i = 0; i < Count; i++) > + { > + Gbl_CurrentColumn++; > + > + /* Insert the character into the line buffer */ > + > + *Gbl_LineBufPtr = (UINT8) SourceChar; > + Gbl_LineBufPtr++; > + > + if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1))) > + { > +#if 0 > + /* > + * Warning if we have split a long source line. > + * <Probably overkill> > + */ > + sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE); > + AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); > +#endif > + > + AslResetCurrentLineBuffer (); > + } > + else if (SourceChar == '\n') > + { > + /* End of line */ > + > + AslResetCurrentLineBuffer (); > + } > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: count > + * > + * PARAMETERS: yytext - Contains the matched keyword. > + * Type - Keyword/Character type: > + * 0 = anything except a keyword > + * 1 = pseudo-keywords > + * 2 = non-executable ASL keywords > + * 3 = executable ASL keywords > + * > + * RETURN: None > + * > + * DESCRIPTION: Count keywords and put them into the line buffer > + * > + ******************************************************************************/ > + > +static void > +count ( > + int Type) > +{ > + int i; > + > + > + switch (Type) > + { > + case 2: > + TotalKeywords++; > + TotalNamedObjects++; > + break; > + > + case 3: > + TotalKeywords++; > + TotalExecutableOpcodes++; > + break; > + } > + > + for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++) > + { > + AslInsertLineBuffer (yytext[i]); > + *Gbl_LineBufPtr = 0; > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslDoComment > + * > + * PARAMETERS: none > + * > + * RETURN: none > + * > + * DESCRIPTION: Process a standard comment. > + * > + ******************************************************************************/ > + > +static char > +AslDoComment ( > + void) > +{ > + char c; > + char c1 = 0; > + > + > + AslInsertLineBuffer ('/'); > + AslInsertLineBuffer ('*'); > + > +loop: > + > + /* Eat chars until end-of-comment */ > + > + while ((c = (char) input()) != '*' && c != EOF) > + { > + AslInsertLineBuffer (c); > + c1 = c; > + } > + > + if (c == EOF) > + { > + goto EarlyEOF; > + } > + > + /* > + * Check for nested comment -- can help catch cases where a previous > + * comment was accidently left unterminated > + */ > + if ((c1 == '/') && (c == '*')) > + { > + AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_InputByteCount, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + } > + > + /* Comment is closed only if the NEXT character is a slash */ > + > + AslInsertLineBuffer (c); > + > + if ((c1 = (char) input()) != '/' && c1 != EOF) > + { > + unput(c1); > + goto loop; > + } > + > + if (c1 == EOF) > + { > + goto EarlyEOF; > + } > + > + AslInsertLineBuffer (c1); > + return (TRUE); > + > + > +EarlyEOF: > + /* > + * Premature End-Of-File > + */ > + AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + return (FALSE); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslDoCommentType2 > + * > + * PARAMETERS: none > + * > + * RETURN: none > + * > + * DESCRIPTION: Process a new "//" comment. > + * > + ******************************************************************************/ > + > +static char > +AslDoCommentType2 ( > + void) > +{ > + char c; > + > + > + AslInsertLineBuffer ('/'); > + AslInsertLineBuffer ('/'); > + > + while ((c = (char) input()) != '\n' && c != EOF) > + { > + AslInsertLineBuffer (c); > + } > + > + if (c == EOF) > + { > + /* End of file is OK, change to newline. Let parser detect EOF later */ > + > + c = '\n'; > + } > + > + AslInsertLineBuffer (c); > + return (TRUE); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslDoStringLiteral > + * > + * PARAMETERS: none > + * > + * RETURN: none > + * > + * DESCRIPTION: Process a string literal (surrounded by quotes) > + * > + ******************************************************************************/ > + > +static char > +AslDoStringLiteral ( > + void) > +{ > + char *StringBuffer = MsgBuffer; > + char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE; > + char *CleanString; > + char StringChar; > + UINT32 State = ASL_NORMAL_CHAR; > + UINT32 i = 0; > + UINT8 Digit; > + char ConvertBuffer[4]; > + > + > + /* > + * Eat chars until end-of-literal. > + * NOTE: Put back the original surrounding quotes into the > + * source line buffer. > + */ > + AslInsertLineBuffer ('\"'); > + while ((StringChar = (char) input()) != EOF) > + { > + AslInsertLineBuffer (StringChar); > + > +DoCharacter: > + > + switch (State) > + { > + case ASL_NORMAL_CHAR: > + > + switch (StringChar) > + { > + case '\\': > + /* > + * Special handling for backslash-escape sequence. We will > + * toss the backslash and translate the escape char(s). > + */ > + State = ASL_ESCAPE_SEQUENCE; > + continue; > + > + case '\"': > + > + /* String terminator */ > + > + goto CompletedString; > + } > + break; > + > + > + case ASL_ESCAPE_SEQUENCE: > + > + State = ASL_NORMAL_CHAR; > + switch (StringChar) > + { > + case 'a': > + StringChar = 0x07; /* BELL */ > + break; > + > + case 'b': > + StringChar = 0x08; /* BACKSPACE */ > + break; > + > + case 'f': > + StringChar = 0x0C; /* FORMFEED */ > + break; > + > + case 'n': > + StringChar = 0x0A; /* LINEFEED */ > + break; > + > + case 'r': > + StringChar = 0x0D; /* CARRIAGE RETURN*/ > + break; > + > + case 't': > + StringChar = 0x09; /* HORIZONTAL TAB */ > + break; > + > + case 'v': > + StringChar = 0x0B; /* VERTICAL TAB */ > + break; > + > + case 'x': > + State = ASL_HEX_CONSTANT; > + i = 0; > + continue; > + > + case '\'': /* Single Quote */ > + case '\"': /* Double Quote */ > + case '\\': /* Backslash */ > + break; > + > + default: > + > + /* Check for an octal digit (0-7) */ > + > + if (ACPI_IS_OCTAL_DIGIT (StringChar)) > + { > + State = ASL_OCTAL_CONSTANT; > + ConvertBuffer[0] = StringChar; > + i = 1; > + continue; > + } > + > + /* Unknown escape sequence issue warning, but use the character */ > + > + AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + break; > + } > + break; > + > + > + case ASL_OCTAL_CONSTANT: > + > + /* Up to three octal digits allowed */ > + > + if (!ACPI_IS_OCTAL_DIGIT (StringChar) || > + (i > 2)) > + { > + /* > + * Reached end of the constant. Convert the assembled ASCII > + * string and resume processing of the next character > + */ > + ConvertBuffer[i] = 0; > + Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); > + > + /* Check for NULL or non-ascii character (ignore if so) */ > + > + if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) > + { > + AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + } > + else > + { > + *StringBuffer = (char) Digit; > + StringBuffer++; > + if (StringBuffer >= EndBuffer) > + { > + goto BufferOverflow; > + } > + } > + > + State = ASL_NORMAL_CHAR; > + goto DoCharacter; > + break; > + } > + > + /* Append another digit of the constant */ > + > + ConvertBuffer[i] = StringChar; > + i++; > + continue; > + > + > + case ASL_HEX_CONSTANT: > + > + /* Up to two hex digits allowed */ > + > + if (!ACPI_IS_XDIGIT (StringChar) || > + (i > 1)) > + { > + /* > + * Reached end of the constant. Convert the assembled ASCII > + * string and resume processing of the next character > + */ > + ConvertBuffer[i] = 0; > + Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); > + > + /* Check for NULL or non-ascii character (ignore if so) */ > + > + if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) > + { > + AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + } > + else > + { > + *StringBuffer = (char) Digit; > + StringBuffer++; > + if (StringBuffer >= EndBuffer) > + { > + goto BufferOverflow; > + } > + } > + > + State = ASL_NORMAL_CHAR; > + goto DoCharacter; > + break; > + } > + > + /* Append another digit of the constant */ > + > + ConvertBuffer[i] = StringChar; > + i++; > + continue; > + } > + > + /* Save the finished character */ > + > + *StringBuffer = StringChar; > + StringBuffer++; > + if (StringBuffer >= EndBuffer) > + { > + goto BufferOverflow; > + } > + } > + > + /* > + * Premature End-Of-File > + */ > + AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + return (FALSE); > + > + > +CompletedString: > + /* > + * Null terminate the input string and copy string to a new buffer > + */ > + *StringBuffer = 0; > + > + CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); > + if (!CleanString) > + { > + AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); > + return (FALSE); > + } > + > + ACPI_STRCPY (CleanString, MsgBuffer); > + AslCompilerlval.s = CleanString; > + return (TRUE); > + > + > +BufferOverflow: > + > + /* Literal was too long */ > + > + AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH, > + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, > + Gbl_CurrentLineOffset, Gbl_CurrentColumn, > + Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096"); > + return (FALSE); > +} > diff --git a/src/acpica/source/compiler/preprocess.h b/src/acpica/source/compiler/preprocess.h > new file mode 100644 > index 0000000..4281eb4 > --- /dev/null > +++ b/src/acpica/source/compiler/preprocess.h > @@ -0,0 +1,345 @@ > +/****************************************************************************** > + * > + * Module Name: preprocess.h - header for iASL Preprocessor > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#define __PREPROCESS_H__ > + > +#ifndef _PREPROCESS > +#define _PREPROCESS > + > +#undef PR_EXTERN > + > +#ifdef _DECLARE_PR_GLOBALS > +#define PR_EXTERN > +#define PR_INIT_GLOBAL(a,b) (a)=(b) > +#else > +#define PR_EXTERN extern > +#define PR_INIT_GLOBAL(a,b) (a) > +#endif > + > + > +/* > + * Configuration > + */ > +#define PR_MAX_MACRO_ARGS 32 /* Max number of macro args */ > +#define PR_MAX_ARG_INSTANCES 24 /* Max instances of any one arg */ > +#define PR_LINES_PER_BLOCK 4096 /* Max input source lines per block */ > + > + > +/* > + * Local defines and macros > + */ > +#define PR_TOKEN_SEPARATORS " ,(){}\t\n" > +#define PR_MACRO_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n" > +#define PR_MACRO_ARGUMENTS " ,\t\n" > +#define PR_EXPR_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n" > + > +#define PR_PREFIX_ID "Pr(%.4u) - " /* Used for debug output */ > + > +#define THIS_TOKEN_OFFSET(t) ((t-Gbl_MainTokenBuffer) + 1) > + > + > +/* > + * Preprocessor structures > + */ > +typedef struct pr_macro_arg > +{ > + char *Name; > + UINT32 Offset[PR_MAX_ARG_INSTANCES]; > + UINT16 UseCount; > + > +} PR_MACRO_ARG; > + > +typedef struct pr_define_info > +{ > + struct pr_define_info *Previous; > + struct pr_define_info *Next; > + char *Identifier; > + char *Replacement; > + char *Body; /* Macro body */ > + PR_MACRO_ARG *Args; /* Macro arg list */ > + UINT16 ArgCount; /* Macro arg count */ > + BOOLEAN Persist; /* Keep for entire compiler run */ > + > +} PR_DEFINE_INFO; > + > +typedef struct pr_directive_info > +{ > + char *Name; /* Directive name */ > + UINT8 ArgCount; /* Required # of args */ > + > +} PR_DIRECTIVE_INFO; > + > +typedef struct pr_operator_info > +{ > + char *Op; > + > +} PR_OPERATOR_INFO; > + > +typedef struct pr_file_node > +{ > + struct pr_file_node *Next; > + FILE *File; > + char *Filename; > + UINT32 CurrentLineNumber; > + > +} PR_FILE_NODE; > + > + > +/* > + * Globals > + */ > +PR_EXTERN char XXXEvalBuffer[ASL_LINE_BUFFER_SIZE]; > +PR_EXTERN char Gbl_MainTokenBuffer[ASL_LINE_BUFFER_SIZE]; > +PR_EXTERN char Gbl_MacroTokenBuffer[ASL_LINE_BUFFER_SIZE]; > +PR_EXTERN char Gbl_ExpressionTokenBuffer[ASL_LINE_BUFFER_SIZE]; > + > +PR_EXTERN PR_FILE_NODE *Gbl_InputFileList; > +PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL); > +PR_EXTERN UINT32 Gbl_PreprocessorLineNumber; > +PR_EXTERN int Gbl_IfDepth; > +PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_PreprocessorError, FALSE); > + > + > +/* > + * prscan - Preprocessor entry > + */ > +void > +PrInitializePreprocessor ( > + void); > + > +void > +PrInitializeGlobals ( > + void); > + > +void > +PrTerminatePreprocessor ( > + void); > + > +BOOLEAN > +PrDoPreprocess ( > + void); > + > +UINT64 > +PrIsDefined ( > + char *Identifier); > + > +UINT64 > +PrResolveDefine ( > + char *Identifier); > + > +int > +PrInitLexer ( > + char *String); > + > +void > +PrTerminateLexer ( > + void); > + > + > +/* > + * prmacros - Support for #defines and macros > + */ > +void > +PrDumpPredefinedNames ( > + void); > + > +PR_DEFINE_INFO * > +PrAddDefine ( > + char *Token, > + char *Token2, > + BOOLEAN Persist); > + > +void > +PrRemoveDefine ( > + char *DefineName); > + > +PR_DEFINE_INFO * > +PrMatchDefine ( > + char *MatchString); > + > +void > +PrAddMacro ( > + char *Name, > + char **Next); > + > +void > +PrDoMacroInvocation ( > + char *TokenBuffer, > + char *MacroStart, > + PR_DEFINE_INFO *DefineInfo, > + char **Next); > + > + > +/* > + * prexpress - #if expression support > + */ > +ACPI_STATUS > +PrResolveIntegerExpression ( > + char *Line, > + UINT64 *ReturnValue); > + > +char * > +PrPrioritizeExpression ( > + char *OriginalLine); > + > +/* > + * prparser - lex/yacc expression parser > + */ > +UINT64 > +PrEvaluateExpression ( > + char *ExprString); > + > + > +/* > + * prutils - Preprocesor utilities > + */ > +char * > +PrGetNextToken ( > + char *Buffer, > + char *MatchString, > + char **Next); > + > +void > +PrError ( > + UINT8 Level, > + UINT8 MessageId, > + UINT32 Column); > + > +void > +PrReplaceData ( > + char *Buffer, > + UINT32 LengthToRemove, > + char *BufferToAdd, > + UINT32 LengthToAdd); > + > +void > +PrOpenIncludeFile ( > + char *Filename); > + > +FILE * > +PrOpenIncludeWithPrefix ( > + char *PrefixDir, > + char *Filename); > + > +void > +PrPushInputFileStack ( > + FILE *InputFile, > + char *Filename); > + > +BOOLEAN > +PrPopInputFileStack ( > + void); > + > +#endif > diff --git a/src/acpica/source/compiler/prexpress.c b/src/acpica/source/compiler/prexpress.c > new file mode 100644 > index 0000000..f65491e > --- /dev/null > +++ b/src/acpica/source/compiler/prexpress.c > @@ -0,0 +1,377 @@ > +/****************************************************************************** > + * > + * Module Name: prexpress - Preprocessor #if expression support > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "aslcompiler.h" > +#include "dtcompiler.h" > + > + > +#define _COMPONENT ASL_PREPROCESSOR > + ACPI_MODULE_NAME ("prexpress") > + > +/* Local prototypes */ > + > +static char * > +PrExpandMacros ( > + char *Line); > + > + > +#ifdef _UNDER_DEVELOPMENT > +/****************************************************************************** > + * > + * FUNCTION: PrUnTokenize > + * > + * PARAMETERS: Buffer - Token Buffer > + * Next - "Next" buffer from GetNextToken > + * > + * RETURN: None > + * > + * DESCRIPTION: Un-tokenized the current token buffer. The implementation is > + * to simply set the null inserted by GetNextToken to a blank. > + * If Next is NULL, there were no tokens found in the Buffer, > + * so there is nothing to do. > + * > + *****************************************************************************/ > + > +static void > +PrUnTokenize ( > + char *Buffer, > + char *Next) > +{ > + UINT32 Length = strlen (Buffer); > + > + > + if (!Next) > + { > + return; > + } > + if (Buffer[Length] != '\n') > + { > + Buffer[strlen(Buffer)] = ' '; > + } > +} > +#endif > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrExpandMacros > + * > + * PARAMETERS: Line - Pointer into the current line > + * > + * RETURN: Updated pointer into the current line > + * > + * DESCRIPTION: Expand any macros found in the current line buffer. > + * > + *****************************************************************************/ > + > +static char * > +PrExpandMacros ( > + char *Line) > +{ > + char *Token; > + char *ReplaceString; > + PR_DEFINE_INFO *DefineInfo; > + ACPI_SIZE TokenOffset; > + char *Next; > + int OffsetAdjust; > + > + > + strcpy (Gbl_ExpressionTokenBuffer, Gbl_CurrentLineBuffer); > + Token = PrGetNextToken (Gbl_ExpressionTokenBuffer, PR_EXPR_SEPARATORS, &Next); > + OffsetAdjust = 0; > + > + while (Token) > + { > + DefineInfo = PrMatchDefine (Token); > + if (DefineInfo) > + { > + if (DefineInfo->Body) > + { > + /* This is a macro. TBD: Is this allowed? */ > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Matched Macro: %s->%s\n", > + Gbl_CurrentLineNumber, DefineInfo->Identifier, > + DefineInfo->Replacement); > + > + PrDoMacroInvocation (Gbl_ExpressionTokenBuffer, Token, > + DefineInfo, &Next); > + } > + else > + { > + ReplaceString = DefineInfo->Replacement; > + > + /* Replace the name in the original line buffer */ > + > + TokenOffset = Token - Gbl_ExpressionTokenBuffer + OffsetAdjust; > + PrReplaceData ( > + &Gbl_CurrentLineBuffer[TokenOffset], strlen (Token), > + ReplaceString, strlen (ReplaceString)); > + > + /* Adjust for length difference between old and new name length */ > + > + OffsetAdjust += strlen (ReplaceString) - strlen (Token); > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Matched #define within expression: %s->%s\n", > + Gbl_CurrentLineNumber, Token, > + *ReplaceString ? ReplaceString : "(NULL STRING)"); > + } > + } > + > + Token = PrGetNextToken (NULL, PR_EXPR_SEPARATORS, &Next); > + } > + > + return (Line); > +} > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrIsDefined > + * > + * PARAMETERS: Identifier - Name to be resolved > + * > + * RETURN: 64-bit boolean integer value > + * > + * DESCRIPTION: Returns TRUE if the name is defined, FALSE otherwise (0). > + * > + *****************************************************************************/ > + > +UINT64 > +PrIsDefined ( > + char *Identifier) > +{ > + UINT64 Value; > + PR_DEFINE_INFO *DefineInfo; > + > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "**** Is defined?: %s\n", Gbl_CurrentLineNumber, Identifier); > + > + Value = 0; /* Default is "Not defined" -- FALSE */ > + > + DefineInfo = PrMatchDefine (Identifier); > + if (DefineInfo) > + { > + Value = ACPI_UINT64_MAX; /* TRUE */ > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "[#if defined %s] resolved to: %8.8X%8.8X\n", > + Gbl_CurrentLineNumber, Identifier, ACPI_FORMAT_UINT64 (Value)); > + > + return (Value); > +} > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrResolveDefine > + * > + * PARAMETERS: Identifier - Name to be resolved > + * > + * RETURN: A 64-bit boolean integer value > + * > + * DESCRIPTION: Returns TRUE if the name is defined, FALSE otherwise (0). > + * > + *****************************************************************************/ > + > +UINT64 > +PrResolveDefine ( > + char *Identifier) > +{ > + UINT64 Value; > + PR_DEFINE_INFO *DefineInfo; > + > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "**** Resolve #define: %s\n", Gbl_CurrentLineNumber, Identifier); > + > + Value = 0; /* Default is "Not defined" -- FALSE */ > + > + DefineInfo = PrMatchDefine (Identifier); > + if (DefineInfo) > + { > + Value = ACPI_UINT64_MAX; /* TRUE */ > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "[#if defined %s] resolved to: %8.8X%8.8X\n", > + Gbl_CurrentLineNumber, Identifier, ACPI_FORMAT_UINT64 (Value)); > + > + return (Value); > +} > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrResolveIntegerExpression > + * > + * PARAMETERS: Line - Pointer to integer expression > + * ReturnValue - Where the resolved 64-bit integer is > + * returned. > + * > + * RETURN: Status > + * > + * DESCRIPTION: Resolve an integer expression to a single value. Supports > + * both integer constants and labels. > + * > + *****************************************************************************/ > + > +ACPI_STATUS > +PrResolveIntegerExpression ( > + char *Line, > + UINT64 *ReturnValue) > +{ > + UINT64 Result; > + char *ExpandedLine; > + > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "**** Resolve #if: %s\n", Gbl_CurrentLineNumber, Line); > + > + /* Expand all macros within the expression first */ > + > + ExpandedLine = PrExpandMacros (Line); > + > + /* Now we can evaluate the expression */ > + > + Result = PrEvaluateExpression (ExpandedLine); > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "**** Expression Resolved to: %8.8X%8.8X\n", > + Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Result)); > + > + *ReturnValue = Result; > + return (AE_OK); > + > +#if 0 > +InvalidExpression: > + > + ACPI_FREE (EvalBuffer); > + PrError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, 0); > + return (AE_ERROR); > + > + > +NormalExit: > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "**** Expression Resolved to: %8.8X%8.8X\n", > + Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value1)); > + > + *ReturnValue = Value1; > + return (AE_OK); > +#endif > +} > diff --git a/src/acpica/source/compiler/prmacros.c b/src/acpica/source/compiler/prmacros.c > new file mode 100644 > index 0000000..d358f1a > --- /dev/null > +++ b/src/acpica/source/compiler/prmacros.c > @@ -0,0 +1,646 @@ > +/****************************************************************************** > + * > + * Module Name: prmacros - Preprocessor #define macro support > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "aslcompiler.h" > +#include "dtcompiler.h" > + > + > +#define _COMPONENT ASL_PREPROCESSOR > + ACPI_MODULE_NAME ("prmacros") > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrDumpPredefinedNames > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Dump the list of #defines. Used as the preprocessor starts, to > + * display the names that were defined on the command line. > + * Debug information only. > + * > + ******************************************************************************/ > + > +void > +PrDumpPredefinedNames ( > + void) > +{ > + PR_DEFINE_INFO *DefineInfo; > + > + > + DefineInfo = Gbl_DefineList; > + while (DefineInfo) > + { > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Predefined #define: %s->%s\n", > + 0, DefineInfo->Identifier, DefineInfo->Replacement); > + > + DefineInfo = DefineInfo->Next; > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrAddDefine > + * > + * PARAMETERS: Identifier - Name to be replaced > + * Replacement - Replacement for Identifier > + * Persist - Keep define across multiple compiles? > + * > + * RETURN: A new define_info struct. NULL on error. > + * > + * DESCRIPTION: Add a new #define to the global list > + * > + ******************************************************************************/ > + > +PR_DEFINE_INFO * > +PrAddDefine ( > + char *Identifier, > + char *Replacement, > + BOOLEAN Persist) > +{ > + char *IdentifierString; > + char *ReplacementString; > + PR_DEFINE_INFO *DefineInfo; > + > + > + if (!Replacement) > + { > + Replacement = ""; > + } > + > + /* Check for already-defined first */ > + > + DefineInfo = PrMatchDefine (Identifier); > + if (DefineInfo) > + { > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID, > + "#define: name already exists: %s\n", > + Gbl_CurrentLineNumber, Identifier); > + > + /* > + * Name already exists. This is only an error if the target name > + * is different. > + */ > + if (strcmp (Replacement, DefineInfo->Replacement)) > + { > + PrError (ASL_ERROR, ASL_MSG_EXISTING_NAME, > + THIS_TOKEN_OFFSET (Identifier)); > + > + return (NULL); > + } > + > + return (DefineInfo); > + } > + > + /* Copy input strings */ > + > + IdentifierString = UtLocalCalloc (strlen (Identifier) + 1); > + strcpy (IdentifierString, Identifier); > + > + ReplacementString = UtLocalCalloc (strlen (Replacement) + 1); > + strcpy (ReplacementString, Replacement); > + > + /* Init and link new define info struct */ > + > + DefineInfo = UtLocalCalloc (sizeof (PR_DEFINE_INFO)); > + DefineInfo->Replacement = ReplacementString; > + DefineInfo->Identifier = IdentifierString; > + DefineInfo->Persist = Persist; > + > + if (Gbl_DefineList) > + { > + Gbl_DefineList->Previous = DefineInfo; > + } > + > + DefineInfo->Next = Gbl_DefineList; > + Gbl_DefineList = DefineInfo; > + return (DefineInfo); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrRemoveDefine > + * > + * PARAMETERS: DefineName - Name of define to be removed > + * > + * RETURN: None > + * > + * DESCRIPTION: Implements #undef. Remove a #define if found in the global > + * list. No error if the target of the #undef does not exist, > + * as per the C #undef definition. > + * > + ******************************************************************************/ > + > +void > +PrRemoveDefine ( > + char *DefineName) > +{ > + PR_DEFINE_INFO *DefineInfo; > + > + > + /* Match name and delete the node */ > + > + DefineInfo = Gbl_DefineList; > + while (DefineInfo) > + { > + if (!strcmp (DefineName, DefineInfo->Identifier)) > + { > + /* Remove from linked list */ > + > + if (DefineInfo->Previous) > + { > + (DefineInfo->Previous)->Next = DefineInfo->Next; > + } > + else > + { > + Gbl_DefineList = DefineInfo->Next; > + } > + > + if (DefineInfo->Next) > + { > + (DefineInfo->Next)->Previous = DefineInfo->Previous; > + } > + > + free (DefineInfo); > + return; > + } > + > + DefineInfo = DefineInfo->Next; > + } > + > + /* > + * Name was not found. By definition of #undef, this is not > + * an error, however. > + */ > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "#undef: could not find %s\n", > + Gbl_CurrentLineNumber, DefineName); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrMatchDefine > + * > + * PARAMETERS: MatchString - Name associated with the #define > + * > + * RETURN: Matched string if found. NULL otherwise. > + * > + * DESCRIPTION: Find a name in global #define list > + * > + ******************************************************************************/ > + > +PR_DEFINE_INFO * > +PrMatchDefine ( > + char *MatchString) > +{ > + PR_DEFINE_INFO *DefineInfo; > + > + > + DefineInfo = Gbl_DefineList; > + while (DefineInfo) > + { > + if (!strcmp (MatchString, DefineInfo->Identifier)) > + { > + return (DefineInfo); > + } > + > + DefineInfo = DefineInfo->Next; > + } > + > + return (NULL); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrAddMacro > + * > + * PARAMETERS: Name - Start of the macro definition > + * Next - "Next" buffer from GetNextToken > + * > + * RETURN: None > + * > + * DESCRIPTION: Add a new macro to the list of #defines. Handles argument > + * processing. > + * > + ******************************************************************************/ > + > +void > +PrAddMacro ( > + char *Name, > + char **Next) > +{ > + char *Token = NULL; > + ACPI_SIZE TokenOffset; > + ACPI_SIZE MacroBodyOffset; > + PR_DEFINE_INFO *DefineInfo; > + PR_MACRO_ARG *Args; > + char *Body; > + char *BodyInSource; > + UINT32 i; > + UINT16 UseCount = 0; > + UINT16 ArgCount = 0; > + UINT32 Depth = 1; > + UINT32 EndOfArgList; > + char BufferChar; > + > + > + /* Find the end of the arguments list */ > + > + TokenOffset = Name - Gbl_MainTokenBuffer + strlen (Name) + 1; > + while (1) > + { > + BufferChar = Gbl_CurrentLineBuffer[TokenOffset]; > + if (BufferChar == '(') > + { > + Depth++; > + } > + else if (BufferChar == ')') > + { > + Depth--; > + } > + else if (BufferChar == 0) > + { > + PrError (ASL_ERROR, ASL_MSG_MACRO_SYNTAX, TokenOffset); > + return; > + } > + > + if (Depth == 0) > + { > + /* Found arg list end */ > + > + EndOfArgList = TokenOffset; > + break; > + } > + > + TokenOffset++; > + } > + > + /* At this point, we know that we have a reasonable argument list */ > + > + Args = UtLocalCalloc (sizeof (PR_MACRO_ARG) * PR_MAX_MACRO_ARGS); > + > + /* Get the macro argument names */ > + > + for (i = 0; i < PR_MAX_MACRO_ARGS; i++) > + { > + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); > + if (!Token) > + { > + /* This is the case for a NULL macro body */ > + > + BodyInSource = ""; > + goto AddMacroToList; > + } > + > + /* Don't go beyond the argument list */ > + > + TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token); > + if (TokenOffset > EndOfArgList) > + { > + break; > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Macro arg: %s \n", > + Gbl_CurrentLineNumber, Token); > + > + Args[i].Name = UtLocalCalloc (strlen (Token) + 1); > + strcpy (Args[i].Name, Token); > + > + Args[i].UseCount = 0; > + > + ArgCount++; > + if (ArgCount >= PR_MAX_MACRO_ARGS) > + { > + PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, TokenOffset); > + return; > + } > + } > + > + /* Get the macro body. Token now points to start of body */ > + > + MacroBodyOffset = Token - Gbl_MainTokenBuffer; > + > + /* Match each method arg in the macro body for later use */ > + > + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); > + while (Token) > + { > + /* Search the macro arg list for matching arg */ > + > + for (i = 0; Args[i].Name && (i < PR_MAX_MACRO_ARGS); i++) > + { > + /* > + * Save argument offset within macro body. This is the mechanism > + * used to expand the macro upon invocation. > + * > + * Handles multiple instances of the same argument > + */ > + if (!strcmp (Token, Args[i].Name)) > + { > + UseCount = Args[i].UseCount; > + > + Args[i].Offset[UseCount] = (Token - Gbl_MainTokenBuffer) - MacroBodyOffset; > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Macro Arg #%u: %s UseCount %u Offset %u \n", > + Gbl_CurrentLineNumber, i, Token, > + UseCount+1, Args[i].Offset[UseCount]); > + > + Args[i].UseCount++; > + if (Args[i].UseCount >= PR_MAX_ARG_INSTANCES) > + { > + PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, > + THIS_TOKEN_OFFSET (Token)); > + > + return; > + } > + break; > + } > + } > + > + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); > + } > + > + BodyInSource = &Gbl_CurrentLineBuffer[MacroBodyOffset]; > + > + > +AddMacroToList: > + > + /* Check if name is already defined first */ > + > + DefineInfo = PrMatchDefine (Name); > + if (DefineInfo) > + { > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "#define: macro name already exists: %s\n", > + Gbl_CurrentLineNumber, Name); > + > + /* Error only if not exactly the same macro */ > + > + if (strcmp (DefineInfo->Body, BodyInSource) || > + (DefineInfo->ArgCount != ArgCount)) > + { > + PrError (ASL_ERROR, ASL_MSG_EXISTING_NAME, > + THIS_TOKEN_OFFSET (Name)); > + } > + > + return; > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Macro body: %s \n", > + Gbl_CurrentLineNumber, BodyInSource); > + > + /* Add macro to the #define list */ > + > + DefineInfo = PrAddDefine (Name, BodyInSource, FALSE); > + if (DefineInfo) > + { > + Body = UtLocalCalloc (strlen (BodyInSource) + 1); > + strcpy (Body, BodyInSource); > + > + DefineInfo->Body = Body; > + DefineInfo->Args = Args; > + DefineInfo->ArgCount = ArgCount; > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrDoMacroInvocation > + * > + * PARAMETERS: TokenBuffer - Current line buffer > + * MacroStart - Start of the macro invocation within > + * the token buffer > + * DefineInfo - Info for this macro > + * Next - "Next" buffer from GetNextToken > + * > + * RETURN: None > + * > + * DESCRIPTION: Expand a macro invocation > + * > + ******************************************************************************/ > + > +void > +PrDoMacroInvocation ( > + char *TokenBuffer, > + char *MacroStart, > + PR_DEFINE_INFO *DefineInfo, > + char **Next) > +{ > + PR_MACRO_ARG *Args; > + char *Token = NULL; > + UINT32 TokenOffset; > + UINT32 Length; > + UINT32 i; > + > + > + /* Take a copy of the macro body for expansion */ > + > + strcpy (Gbl_MacroTokenBuffer, DefineInfo->Body); > + > + /* Replace each argument within the prototype body */ > + > + Args = DefineInfo->Args; > + if (!Args->Name) > + { > + /* This macro has no arguments */ > + > + Token = PrGetNextToken (NULL, PR_MACRO_ARGUMENTS, Next); > + if (!Token) > + { > + goto BadInvocation; > + } > + > + TokenOffset = (MacroStart - TokenBuffer); > + Length = Token - MacroStart + strlen (Token) + 1; > + > + PrReplaceData ( > + &Gbl_CurrentLineBuffer[TokenOffset], Length, > + Gbl_MacroTokenBuffer, strlen (Gbl_MacroTokenBuffer)); > + return; > + } > + > + while (Args->Name) > + { > + /* Get the next argument from macro invocation */ > + > + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); > + if (!Token) > + { > + goto BadInvocation; > + } > + > + /* Replace all instances of this argument */ > + > + for (i = 0; i < Args->UseCount; i++) > + { > + /* Offset zero indicates "arg not used" */ > + /* TBD: Not really needed now, with UseCount available */ > + > + if (Args->Offset[i] == 0) > + { > + break; > + } > + > + PrReplaceData ( > + &Gbl_MacroTokenBuffer[Args->Offset[i]], strlen (Args->Name), > + Token, strlen (Token)); > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "ExpandArg: %s \n", > + Gbl_CurrentLineNumber, Gbl_MacroTokenBuffer); > + } > + > + Args++; > + } > + > + /* TBD: need to make sure macro was not invoked with too many arguments */ > + > + if (!Token) > + { > + return; > + } > + > + /* Replace the entire macro invocation with the expanded macro */ > + > + TokenOffset = (MacroStart - TokenBuffer); > + Length = Token - MacroStart + strlen (Token) + 1; > + > + PrReplaceData ( > + &Gbl_CurrentLineBuffer[TokenOffset], Length, > + Gbl_MacroTokenBuffer, strlen (Gbl_MacroTokenBuffer)); > + > + return; > + > + > +BadInvocation: > + PrError (ASL_ERROR, ASL_MSG_INVALID_INVOCATION, > + THIS_TOKEN_OFFSET (MacroStart)); > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Bad macro invocation: %s \n", > + Gbl_CurrentLineNumber, Gbl_MacroTokenBuffer); > + return; > +} > diff --git a/src/acpica/source/compiler/prparser.l b/src/acpica/source/compiler/prparser.l > new file mode 100644 > index 0000000..d20ac28 > --- /dev/null > +++ b/src/acpica/source/compiler/prparser.l > @@ -0,0 +1,225 @@ > +%{ > +/****************************************************************************** > + * > + * Module Name: prparser.l - Flex input file for preprocessor lexer > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "aslcompiler.h" > +#include "prparser.y.h" > + > +/* Buffer to pass strings to the parser */ > + > +#define STRING_SETUP strcpy (StringBuffer, PrParsertext);\ > + PrParserlval.str = StringBuffer > + > +#define YY_NO_INPUT /* No file input, we use strings only */ > + > +#define _COMPONENT ACPI_COMPILER > + ACPI_MODULE_NAME ("prscanner") > +%} > + > +%option noyywrap > +%option nounput > + > +Number [0-9a-fA-F]+ > +HexNumber 0[xX][0-9a-fA-F]+ > +WhiteSpace [ \t\v\r]+ > +NewLine [\n] > +Identifier [a-zA-Z][0-9a-zA-Z]* > + > +%% > + > +\( return (EXPOP_PAREN_OPEN); > +\) return (EXPOP_PAREN_CLOSE); > +\~ return (EXPOP_ONES_COMPLIMENT); > +\! return (EXPOP_LOGICAL_NOT); > +\* return (EXPOP_MULTIPLY); > +\/ return (EXPOP_DIVIDE); > +\% return (EXPOP_MODULO); > +\+ return (EXPOP_ADD); > +\- return (EXPOP_SUBTRACT); > +">>" return (EXPOP_SHIFT_RIGHT); > +"<<" return (EXPOP_SHIFT_LEFT); > +\< return (EXPOP_LESS); > +\> return (EXPOP_GREATER); > +"<=" return (EXPOP_LESS_EQUAL); > +">=" return (EXPOP_GREATER_EQUAL); > +"==" return (EXPOP_EQUAL); > +"!=" return (EXPOP_NOT_EQUAL); > +\& return (EXPOP_AND); > +\^ return (EXPOP_XOR); > +\| return (EXPOP_OR); > +"&&" return (EXPOP_LOGICAL_AND); > +"||" return (EXPOP_LOGICAL_OR); > + > +"defined" return (EXPOP_DEFINE); > +{Identifier} {STRING_SETUP; return (EXPOP_IDENTIFIER);} > + > +<<EOF>> return (EXPOP_EOF); /* null end-of-string */ > + > +{Number} return (EXPOP_NUMBER); > +{HexNumber} return (EXPOP_HEX_NUMBER); > +{NewLine} return (EXPOP_NEW_LINE); > +{WhiteSpace} /* Ignore */ > + > +. return (EXPOP_EOF); > +%% > + > +/* > + * Local support functions > + */ > +YY_BUFFER_STATE LexBuffer; > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrInitLexer > + * > + * PARAMETERS: String - Input string to be parsed > + * > + * RETURN: TRUE if parser returns NULL. FALSE otherwise. > + * > + * DESCRIPTION: Initialization routine for lexer. The lexer needs > + * a buffer to handle strings instead of a file. > + * > + *****************************************************************************/ > + > +int > +PrInitLexer ( > + char *String) > +{ > + > + LexBuffer = yy_scan_string (String); > + return (LexBuffer == NULL); > +} > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrTerminateLexer > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Termination routine for thelexer. > + * > + *****************************************************************************/ > + > +void > +PrTerminateLexer ( > + void) > +{ > + > + yy_delete_buffer (LexBuffer); > +} > diff --git a/src/acpica/source/compiler/prparser.y b/src/acpica/source/compiler/prparser.y > new file mode 100644 > index 0000000..3c3e3a7 > --- /dev/null > +++ b/src/acpica/source/compiler/prparser.y > @@ -0,0 +1,356 @@ > +%{ > +/****************************************************************************** > + * > + * Module Name: prparser.y - Bison input file for preprocessor parser > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "aslcompiler.h" > +#include "dtcompiler.h" > + > +#define _COMPONENT ASL_PREPROCESSOR > + ACPI_MODULE_NAME ("prparser") > + > +int PrParserlex (void); > +int PrParserparse (void); > +void PrParsererror (char const *msg); > +extern char *PrParsertext; > + > +UINT64 PrParserResult; /* Expression return value */ > + > +/* Bison/yacc configuration */ > + > +#define yytname PrParsername > +#define YYDEBUG 1 /* Enable debug output */ > +#define YYERROR_VERBOSE 1 /* Verbose error messages */ > +#define YYFLAG -32768 > + > +/* Define YYMALLOC/YYFREE to prevent redefinition errors */ > + > +#define YYMALLOC malloc > +#define YYFREE free > +%} > + > +%union > +{ > + UINT64 value; > + UINT32 op; > + char *str; > +} > + > +/*! [Begin] no source code translation */ > + > +%type <value> Expression > + > +%token <op> EXPOP_EOF > +%token <op> EXPOP_NEW_LINE > +%token <op> EXPOP_NUMBER > +%token <op> EXPOP_HEX_NUMBER > +%token <op> EXPOP_RESERVED1 > +%token <op> EXPOP_RESERVED2 > +%token <op> EXPOP_PAREN_OPEN > +%token <op> EXPOP_PAREN_CLOSE > + > +%left <op> EXPOP_LOGICAL_OR > +%left <op> EXPOP_LOGICAL_AND > +%left <op> EXPOP_OR > +%left <op> EXPOP_XOR > +%left <op> EXPOP_AND > +%left <op> EXPOP_EQUAL EXPOP_NOT_EQUAL > +%left <op> EXPOP_GREATER EXPOP_LESS EXPOP_GREATER_EQUAL EXPOP_LESS_EQUAL > +%left <op> EXPOP_SHIFT_RIGHT EXPOP_SHIFT_LEFT > +%left <op> EXPOP_ADD EXPOP_SUBTRACT > +%left <op> EXPOP_MULTIPLY EXPOP_DIVIDE EXPOP_MODULO > +%right <op> EXPOP_ONES_COMPLIMENT EXPOP_LOGICAL_NOT > + > +/* Tokens above must be kept in synch with dtparser.y */ > + > +%token <op> EXPOP_DEFINE > +%token <op> EXPOP_IDENTIFIER > + > +%% > + > +/* > + * Operator precedence rules (from K&R) > + * > + * 1) ( ) > + * 2) ! ~ (unary operators that are supported here) > + * 3) * / % > + * 4) + - > + * 5) >> << > + * 6) < > <= >= > + * 7) == != > + * 8) & > + * 9) ^ > + * 10) | > + * 11) && > + * 12) || > + */ > + > +/*! [End] no source code translation !*/ > + > +Value > + : Expression EXPOP_NEW_LINE { PrParserResult=$1; return 0; } /* End of line (newline) */ > + | Expression EXPOP_EOF { PrParserResult=$1; return 0; } /* End of string (0) */ > + ; > + > +Expression > + > + /* Unary operators */ > + > + : EXPOP_LOGICAL_NOT Expression { $$ = DtDoOperator ($2, EXPOP_LOGICAL_NOT, $2);} > + | EXPOP_ONES_COMPLIMENT Expression { $$ = DtDoOperator ($2, EXPOP_ONES_COMPLIMENT, $2);} > + > + /* Binary operators */ > + > + | Expression EXPOP_MULTIPLY Expression { $$ = DtDoOperator ($1, EXPOP_MULTIPLY, $3);} > + | Expression EXPOP_DIVIDE Expression { $$ = DtDoOperator ($1, EXPOP_DIVIDE, $3);} > + | Expression EXPOP_MODULO Expression { $$ = DtDoOperator ($1, EXPOP_MODULO, $3);} > + | Expression EXPOP_ADD Expression { $$ = DtDoOperator ($1, EXPOP_ADD, $3);} > + | Expression EXPOP_SUBTRACT Expression { $$ = DtDoOperator ($1, EXPOP_SUBTRACT, $3);} > + | Expression EXPOP_SHIFT_RIGHT Expression { $$ = DtDoOperator ($1, EXPOP_SHIFT_RIGHT, $3);} > + | Expression EXPOP_SHIFT_LEFT Expression { $$ = DtDoOperator ($1, EXPOP_SHIFT_LEFT, $3);} > + | Expression EXPOP_GREATER Expression { $$ = DtDoOperator ($1, EXPOP_GREATER, $3);} > + | Expression EXPOP_LESS Expression { $$ = DtDoOperator ($1, EXPOP_LESS, $3);} > + | Expression EXPOP_GREATER_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_GREATER_EQUAL, $3);} > + | Expression EXPOP_LESS_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_LESS_EQUAL, $3);} > + | Expression EXPOP_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_EQUAL, $3);} > + | Expression EXPOP_NOT_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_NOT_EQUAL, $3);} > + | Expression EXPOP_AND Expression { $$ = DtDoOperator ($1, EXPOP_AND, $3);} > + | Expression EXPOP_XOR Expression { $$ = DtDoOperator ($1, EXPOP_XOR, $3);} > + | Expression EXPOP_OR Expression { $$ = DtDoOperator ($1, EXPOP_OR, $3);} > + | Expression EXPOP_LOGICAL_AND Expression { $$ = DtDoOperator ($1, EXPOP_LOGICAL_AND, $3);} > + | Expression EXPOP_LOGICAL_OR Expression { $$ = DtDoOperator ($1, EXPOP_LOGICAL_OR, $3);} > + > + /* Parentheses: '(' Expression ')' */ > + > + | EXPOP_PAREN_OPEN Expression > + EXPOP_PAREN_CLOSE { $$ = $2;} > + > + /* #if defined (ID) or #if defined ID */ > + > + | EXPOP_DEFINE EXPOP_PAREN_OPEN EXPOP_IDENTIFIER > + EXPOP_PAREN_CLOSE { $$ = PrIsDefined (PrParserlval.str);} > + > + | EXPOP_DEFINE EXPOP_IDENTIFIER { $$ = PrIsDefined (PrParserlval.str);} > + > + | EXPOP_IDENTIFIER { $$ = PrResolveDefine (PrParserlval.str);} > + > + /* Default base for a non-prefixed integer is 10 */ > + > + | EXPOP_NUMBER { UtStrtoul64 (PrParsertext, 10, &$$);} > + > + /* Standard hex number (0x1234) */ > + > + | EXPOP_HEX_NUMBER { UtStrtoul64 (PrParsertext, 16, &$$);} > + ; > +%% > + > +/* > + * Local support functions, including parser entry point > + */ > +#define PR_FIRST_PARSE_OPCODE EXPOP_EOF > +#define PR_YYTNAME_START 3 > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrParsererror > + * > + * PARAMETERS: Message - Parser-generated error message > + * > + * RETURN: None > + * > + * DESCRIPTION: Handler for parser errors > + * > + *****************************************************************************/ > + > +void > +PrParsererror ( > + char const *Message) > +{ > + DtError (ASL_ERROR, ASL_MSG_SYNTAX, > + NULL, (char *) Message); > +} > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrGetOpName > + * > + * PARAMETERS: ParseOpcode - Parser token (EXPOP_*) > + * > + * RETURN: Pointer to the opcode name > + * > + * DESCRIPTION: Get the ascii name of the parse opcode for debug output > + * > + *****************************************************************************/ > + > +char * > +PrGetOpName ( > + UINT32 ParseOpcode) > +{ > +#ifdef ASL_YYTNAME_START > + /* > + * First entries (PR_YYTNAME_START) in yytname are special reserved names. > + * Ignore first 6 characters of name (EXPOP_) > + */ > + return ((char *) yytname > + [(ParseOpcode - PR_FIRST_PARSE_OPCODE) + PR_YYTNAME_START] + 6); > +#else > + return ("[Unknown parser generator]"); > +#endif > +} > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrEvaluateExpression > + * > + * PARAMETERS: ExprString - Expression to be evaluated. Must be > + * terminated by either a newline or a NUL > + * string terminator > + * > + * RETURN: 64-bit value for the expression > + * > + * DESCRIPTION: Main entry point for the DT expression parser > + * > + *****************************************************************************/ > + > +UINT64 > +PrEvaluateExpression ( > + char *ExprString) > +{ > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "**** Input expression: %s\n", ExprString); > + > + /* Point lexer to the input string */ > + > + if (PrInitLexer (ExprString)) > + { > + DtError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, > + NULL, "Could not initialize lexer"); > + return (0); > + } > + > + /* Parse/Evaluate the input string (value returned in PrParserResult) */ > + > + PrParserparse (); > + PrTerminateLexer (); > + > + DbgPrint (ASL_DEBUG_OUTPUT, > + "**** Parser returned value: %u (%8.8X%8.8X)\n", > + (UINT32) PrParserResult, ACPI_FORMAT_UINT64 (PrParserResult)); > + > + return (PrParserResult); > +} > diff --git a/src/acpica/source/compiler/prscan.c b/src/acpica/source/compiler/prscan.c > new file mode 100644 > index 0000000..e98e186 > --- /dev/null > +++ b/src/acpica/source/compiler/prscan.c > @@ -0,0 +1,844 @@ > +/****************************************************************************** > + * > + * Module Name: prscan - Preprocessor start-up and file scan module > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#define _DECLARE_PR_GLOBALS > + > +#include "aslcompiler.h" > +#include "dtcompiler.h" > + > +/* > + * TBDs: > + * > + * No nested macros, maybe never > + * Implement ASL "Include" as well as "#include" here? > + */ > +#define _COMPONENT ASL_PREPROCESSOR > + ACPI_MODULE_NAME ("prscan") > + > + > +/* Local prototypes */ > + > +static void > +PrPreprocessInputFile ( > + void); > + > +static void > +PrDoDirective ( > + char *DirectiveToken, > + char **Next, > + BOOLEAN *IgnoringThisCodeBlock); > + > +static int > +PrMatchDirective ( > + char *Directive); > + > +/* > + * Supported preprocessor directives > + */ > +static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] = > +{ > + {"define", 1}, > + {"elif", 0}, /* Converted to #else..#if internally */ > + {"else", 0}, > + {"endif", 0}, > + {"error", 1}, > + {"if", 1}, > + {"ifdef", 1}, > + {"ifndef", 1}, > + {"include", 0}, /* Argument is not standard format, so 0 */ > + {"line", 1}, > + {"pragma", 1}, > + {"undef", 1}, > + {"warning", 1}, > + {NULL, 0} > +}; > + > +enum Gbl_DirectiveIndexes > +{ > + PR_DIRECTIVE_DEFINE = 0, > + PR_DIRECTIVE_ELIF, > + PR_DIRECTIVE_ELSE, > + PR_DIRECTIVE_ENDIF, > + PR_DIRECTIVE_ERROR, > + PR_DIRECTIVE_IF, > + PR_DIRECTIVE_IFDEF, > + PR_DIRECTIVE_IFNDEF, > + PR_DIRECTIVE_INCLUDE, > + PR_DIRECTIVE_LINE, > + PR_DIRECTIVE_PRAGMA, > + PR_DIRECTIVE_UNDEF, > + PR_DIRECTIVE_WARNING, > +}; > + > +#define ASL_DIRECTIVE_NOT_FOUND -1 > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrInitializePreprocessor > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Startup initialization for the Preprocessor. > + * > + ******************************************************************************/ > + > +void > +PrInitializePreprocessor ( > + void) > +{ > + /* Init globals and the list of #defines */ > + > + PrInitializeGlobals (); > + Gbl_DefineList = NULL; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrInitializeGlobals > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Initialize globals for the Preprocessor. Used for startuup > + * initialization and re-initialization between compiles during > + * a multiple source file compile. > + * > + ******************************************************************************/ > + > +void > +PrInitializeGlobals ( > + void) > +{ > + /* Init globals */ > + > + Gbl_IfDepth = 0; > + Gbl_InputFileList = NULL; > + Gbl_CurrentLineNumber = 0; > + Gbl_PreprocessorLineNumber = 1; > + Gbl_PreprocessorError = FALSE; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrTerminatePreprocessor > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Termination of the preprocessor. Delete lists. Keep any > + * defines that were specified on the command line, in order to > + * support multiple compiles with a single compiler invocation. > + * > + ******************************************************************************/ > + > +void > +PrTerminatePreprocessor ( > + void) > +{ > + PR_DEFINE_INFO *DefineInfo; > + > + > + /* > + * The persistent defines (created on the command line) are always at the > + * end of the list. We save them. > + */ > + while ((Gbl_DefineList) && (!Gbl_DefineList->Persist)) > + { > + DefineInfo = Gbl_DefineList; > + Gbl_DefineList = DefineInfo->Next; > + > + ACPI_FREE (DefineInfo->Replacement); > + ACPI_FREE (DefineInfo->Identifier); > + ACPI_FREE (DefineInfo); > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrDoPreprocess > + * > + * PARAMETERS: None > + * > + * RETURN: Error Status. TRUE if error, FALSE if OK. > + * > + * DESCRIPTION: Main entry point for the iASL Preprocessor. Input file must > + * be already open. Handles multiple input files via the > + * #include directive. > + * > + ******************************************************************************/ > + > +BOOLEAN > +PrDoPreprocess ( > + void) > +{ > + BOOLEAN MoreInputFiles; > + > + > + DbgPrint (ASL_DEBUG_OUTPUT, "Starting preprocessing phase\n\n"); > + > + > + FlSeekFile (ASL_FILE_INPUT, 0); > + PrDumpPredefinedNames (); > + > + /* Main preprocessor loop, handles include files */ > + > + do > + { > + PrPreprocessInputFile (); > + MoreInputFiles = PrPopInputFileStack (); > + > + } while (MoreInputFiles); > + > + > + /* > + * TBD: is this necessary? (Do we abort on any preprocessing errors?) > + */ > + if (Gbl_PreprocessorError) > + { > + /* TBD: can't use source_output file for preprocessor error reporting */ > + > + Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL; > + PrTerminatePreprocessor (); > + return (TRUE); > + } > + > + /* Point compiler input to the new preprocessor file (.i) */ > + > + FlCloseFile (ASL_FILE_INPUT); > + Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle; > + AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle; > + > + /* Reset globals to allow compiler to run */ > + > + FlSeekFile (ASL_FILE_INPUT, 0); > + Gbl_CurrentLineNumber = 1; > + > + DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n"); > + return (FALSE); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrPreprocessInputFile > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Preprocess one entire file, line-by-line. > + * > + * Input: Raw user ASL from ASL_FILE_INPUT > + * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR > + * > + ******************************************************************************/ > + > +static void > +PrPreprocessInputFile ( > + void) > +{ > + UINT32 Offset; > + char *Token; > + char *ReplaceString; > + PR_DEFINE_INFO *DefineInfo; > + ACPI_SIZE TokenOffset; > + BOOLEAN IgnoringThisCodeBlock = FALSE; > + char *Next; > + int OffsetAdjust; > + > + > + /* Scan line-by-line. Comments and blank lines are skipped by this function */ > + > + while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF) > + { > + /* Need a copy of the input line for strok() */ > + > + strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer); > + Token = PrGetNextToken (Gbl_MainTokenBuffer, PR_TOKEN_SEPARATORS, &Next); > + OffsetAdjust = 0; > + > + /* All preprocessor directives must begin with '#' */ > + > + if (Token && (*Token == '#')) > + { > + if (strlen (Token) == 1) > + { > + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); > + } > + else > + { > + Token++; /* Skip leading # */ > + } > + > + /* Execute the directive, do not write line to output file */ > + > + PrDoDirective (Token, &Next, &IgnoringThisCodeBlock); > + continue; > + } > + > + /* > + * If we are currently within the part of an IF/ELSE block that is > + * FALSE, ignore the line and do not write it to the output file. > + * This continues until an #else or #endif is encountered. > + */ > + if (IgnoringThisCodeBlock == TRUE) > + { > + continue; > + } > + > + /* Match and replace all #defined names within this source line */ > + > + while (Token) > + { > + DefineInfo = PrMatchDefine (Token); > + if (DefineInfo) > + { > + if (DefineInfo->Body) > + { > + /* This is a macro */ > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Matched Macro: %s->%s\n", > + Gbl_CurrentLineNumber, DefineInfo->Identifier, > + DefineInfo->Replacement); > + > + PrDoMacroInvocation (Gbl_MainTokenBuffer, Token, > + DefineInfo, &Next); > + } > + else > + { > + ReplaceString = DefineInfo->Replacement; > + > + /* Replace the name in the original line buffer */ > + > + TokenOffset = Token - Gbl_MainTokenBuffer + OffsetAdjust; > + PrReplaceData ( > + &Gbl_CurrentLineBuffer[TokenOffset], strlen (Token), > + ReplaceString, strlen (ReplaceString)); > + > + /* Adjust for length difference between old and new name length */ > + > + OffsetAdjust += strlen (ReplaceString) - strlen (Token); > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Matched #define: %s->%s\n", > + Gbl_CurrentLineNumber, Token, > + *ReplaceString ? ReplaceString : "(NULL STRING)"); > + } > + } > + > + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); > + } > + > +#if 0 > +/* Line prefix */ > + FlPrintFile (ASL_FILE_PREPROCESSOR, "/* %14s %.5u i:%.5u */ ", > + Gbl_Files[ASL_FILE_INPUT].Filename, > + Gbl_CurrentLineNumber, Gbl_PreprocessorLineNumber); > +#endif > + > + /* > + * Emit a #line directive if necessary, to keep the line numbers in > + * the (.i) file synchronized with the original source code file, so > + * that the correct line number appears in any error messages > + * generated by the actual compiler. > + */ > + if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1)) > + { > + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n", > + Gbl_CurrentLineNumber); > + } > + > + Gbl_PreviousLineNumber = Gbl_CurrentLineNumber; > + Gbl_PreprocessorLineNumber++; > + > + /* > + * Now we can write the possibly modified source line to the > + * preprocessor (.i) file > + */ > + FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer, > + strlen (Gbl_CurrentLineBuffer)); > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrDoDirective > + * > + * PARAMETERS: Directive - Pointer to directive name token > + * Next - "Next" buffer from GetNextToken > + * IgnoringThisCodeBlock - Where the "ignore code" flag is > + * returned. > + * > + * RETURN: IgnoringThisCodeBlock: Set to TRUE if we are skipping the FALSE > + * part of an #if or #else block. Set to FALSE when the > + * corresponding #else or #endif is encountered. > + * > + * DESCRIPTION: Main processing for all preprocessor directives > + * > + ******************************************************************************/ > + > +static void > +PrDoDirective ( > + char *DirectiveToken, > + char **Next, > + BOOLEAN *IgnoringThisCodeBlock) > +{ > + char *Token = Gbl_MainTokenBuffer; > + char *Token2; > + char *End; > + UINT64 Value; > + ACPI_SIZE TokenOffset; > + int Directive; > + ACPI_STATUS Status; > + > + > + if (!DirectiveToken) > + { > + goto SyntaxError; > + } > + > + Directive = PrMatchDirective (DirectiveToken); > + if (Directive == ASL_DIRECTIVE_NOT_FOUND) > + { > + PrError (ASL_ERROR, ASL_MSG_UNKNOWN_DIRECTIVE, > + THIS_TOKEN_OFFSET (DirectiveToken)); > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "#%s: Unknown directive\n", > + Gbl_CurrentLineNumber, DirectiveToken); > + return; > + } > + > + /* TBD: Need a faster way to do this: */ > + > + if ((Directive == PR_DIRECTIVE_ELIF) || > + (Directive == PR_DIRECTIVE_ELSE) || > + (Directive == PR_DIRECTIVE_ENDIF)) > + { > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Begin #%s\n", > + Gbl_CurrentLineNumber, Gbl_DirectiveInfo[Directive].Name); > + } > + > + /* > + * Need to always check for #else, #elif, #endif regardless of > + * whether we are ignoring the current code block, since these > + * are conditional code block terminators. > + */ > + switch (Directive) > + { > + case PR_DIRECTIVE_ELIF: > + *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock); > + if (*IgnoringThisCodeBlock == TRUE) > + { > + /* Not executing the ELSE part -- all done here */ > + return; > + } > + > + /* Will execute the ELSE..IF part */ > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "#elif - Executing else block\n", > + Gbl_CurrentLineNumber); > + Directive = PR_DIRECTIVE_IF; > + break; > + > + case PR_DIRECTIVE_ELSE: > + *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock); > + return; > + > + case PR_DIRECTIVE_ENDIF: > + *IgnoringThisCodeBlock = FALSE; > + Gbl_IfDepth--; > + if (Gbl_IfDepth < 0) > + { > + PrError (ASL_ERROR, ASL_MSG_ENDIF_MISMATCH, > + THIS_TOKEN_OFFSET (DirectiveToken)); > + Gbl_IfDepth = 0; > + } > + return; > + > + default: > + break; > + } > + > + /* > + * At this point, if we are ignoring the current code block, > + * do not process any more directives (i.e., ignore them also.) > + */ > + if (*IgnoringThisCodeBlock == TRUE) > + { > + return; > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Begin #%s\n", > + Gbl_CurrentLineNumber, Gbl_DirectiveInfo[Directive].Name); > + > + /* Most directives have at least one argument */ > + > + if (Gbl_DirectiveInfo[Directive].ArgCount == 1) > + { > + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); > + if (!Token) > + { > + goto SyntaxError; > + } > + } > + > + switch (Directive) > + { > + case PR_DIRECTIVE_DEFINE: > + /* > + * By definition, if first char after the name is a paren, > + * this is a function macro. > + */ > + TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token); > + if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(') > + { > +#ifndef MACROS_SUPPORTED > + AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n", > + Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber); > + exit(1); > +#else > + PrAddMacro (Token, Next); > +#endif > + } > + else > + { > + /* Use the remainder of the line for the #define */ > + > + Token2 = *Next; > + if (Token2) > + { > + while ((*Token2 == ' ') || (*Token2 == '\t')) > + { > + Token2++; > + } > + End = Token2; > + while (*End != '\n') > + { > + End++; > + } > + *End = 0; > + } > + else > + { > + Token2 = ""; > + } > +#if 0 > + Token2 = PrGetNextToken (NULL, "\n", /*PR_TOKEN_SEPARATORS,*/ Next); > + if (!Token2) > + { > + Token2 = ""; > + } > +#endif > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "New #define: %s->%s\n", > + Gbl_CurrentLineNumber, Token, Token2); > + > + PrAddDefine (Token, Token2, FALSE); > + } > + break; > + > + case PR_DIRECTIVE_ERROR: > + /* TBD compiler should abort */ > + /* Note: No macro expansion */ > + > + PrError (ASL_ERROR, ASL_MSG_ERROR_DIRECTIVE, > + THIS_TOKEN_OFFSET (Token)); > + break; > + > + case PR_DIRECTIVE_IF: > + TokenOffset = Token - Gbl_MainTokenBuffer; > + > + /* Need to expand #define macros in the expression string first */ > + > + Status = PrResolveIntegerExpression ( > + &Gbl_CurrentLineBuffer[TokenOffset-1], &Value); > + if (ACPI_FAILURE (Status)) > + { > + return; > + } > + > + if (!Value) > + { > + *IgnoringThisCodeBlock = TRUE; > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Resolved #if: %8.8X%8.8X %s\n", > + Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value), > + *IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>"); > + > + Gbl_IfDepth++; > + break; > + > + case PR_DIRECTIVE_IFDEF: > + if (!PrMatchDefine (Token)) > + { > + *IgnoringThisCodeBlock = TRUE; > + } > + > + Gbl_IfDepth++; > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Start #ifdef %s\n", Gbl_CurrentLineNumber, > + *IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>"); > + break; > + > + case PR_DIRECTIVE_IFNDEF: > + if (PrMatchDefine (Token)) > + { > + *IgnoringThisCodeBlock = TRUE; > + } > + > + Gbl_IfDepth++; > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Start #ifndef %2.2X\n", Gbl_CurrentLineNumber, > + *IgnoringThisCodeBlock, Gbl_CurrentLineNumber); > + break; > + > + case PR_DIRECTIVE_INCLUDE: > + Token = PrGetNextToken (NULL, " \"<>", Next); > + if (!Token) > + { > + goto SyntaxError; > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Start #include file %s\n", Gbl_CurrentLineNumber, > + Token, Gbl_CurrentLineNumber); > + > + PrOpenIncludeFile (Token); > + break; > + > + case PR_DIRECTIVE_LINE: > + TokenOffset = Token - Gbl_MainTokenBuffer; > + > + Status = PrResolveIntegerExpression ( > + &Gbl_CurrentLineBuffer[TokenOffset-1], &Value); > + if (ACPI_FAILURE (Status)) > + { > + return; > + } > + > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "User #line invocation %s\n", Gbl_CurrentLineNumber, > + Token); > + > + /* Update local line numbers */ > + > + Gbl_CurrentLineNumber = (UINT32) Value; > + Gbl_PreviousLineNumber = 0; > + > + /* Emit #line into the preprocessor file */ > + > + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", > + Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename); > + break; > + > + case PR_DIRECTIVE_PRAGMA: > + /* Only "#pragma message" supported at this time */ > + > + if (strcmp (Token, "message")) > + { > + PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA, > + THIS_TOKEN_OFFSET (Token)); > + return; > + } > + > + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); > + if (!Token) > + { > + goto SyntaxError; > + } > + > + TokenOffset = Token - Gbl_MainTokenBuffer; > + AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]); > + break; > + > + case PR_DIRECTIVE_UNDEF: > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "#undef: %s\n", Gbl_CurrentLineNumber, Token); > + > + PrRemoveDefine (Token); > + break; > + > + case PR_DIRECTIVE_WARNING: > + PrError (ASL_WARNING, ASL_MSG_ERROR_DIRECTIVE, > + THIS_TOKEN_OFFSET (Token)); > + break; > + > + default: > + /* Should never get here */ > + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID > + "Unrecognized directive: %u\n", > + Gbl_CurrentLineNumber, Directive); > + break; > + } > + > + return; > + > + > +SyntaxError: > + > + PrError (ASL_ERROR, ASL_MSG_DIRECTIVE_SYNTAX, > + THIS_TOKEN_OFFSET (DirectiveToken)); > + return; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrMatchDirective > + * > + * PARAMETERS: Directive - Pointer to directive name token > + * > + * RETURN: Index into command array, -1 if not found > + * > + * DESCRIPTION: Lookup the incoming directive in the known directives table. > + * > + ******************************************************************************/ > + > +static int > +PrMatchDirective ( > + char *Directive) > +{ > + int i; > + > + > + if (!Directive || Directive[0] == 0) > + { > + return (ASL_DIRECTIVE_NOT_FOUND); > + } > + > + for (i = 0; Gbl_DirectiveInfo[i].Name; i++) > + { > + if (!strcmp (Gbl_DirectiveInfo[i].Name, Directive)) > + { > + return (i); > + } > + } > + > + return (ASL_DIRECTIVE_NOT_FOUND); /* Command not recognized */ > +} > diff --git a/src/acpica/source/compiler/prutils.c b/src/acpica/source/compiler/prutils.c > new file mode 100644 > index 0000000..a5fb46a > --- /dev/null > +++ b/src/acpica/source/compiler/prutils.c > @@ -0,0 +1,540 @@ > +/****************************************************************************** > + * > + * Module Name: prutils - Preprocessor utilities > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "aslcompiler.h" > +#include "dtcompiler.h" > + > + > +#define _COMPONENT ASL_PREPROCESSOR > + ACPI_MODULE_NAME ("prutils") > + > + > +/****************************************************************************** > + * > + * FUNCTION: PrGetNextToken > + * > + * PARAMETERS: Buffer - Current line buffer > + * MatchString - String with valid token delimiters > + * Next - Set to next possible token in buffer > + * > + * RETURN: Next token (null-terminated). Modifies the input line. > + * Remainder of line is stored in *Next. > + * > + * DESCRIPTION: Local implementation of strtok() with local storage for the > + * next pointer. Not only thread-safe, but allows multiple > + * parsing of substrings such as expressions. > + * > + *****************************************************************************/ > + > +char * > +PrGetNextToken ( > + char *Buffer, > + char *MatchString, > + char **Next) > +{ > + char *TokenStart; > + > + > + if (!Buffer) > + { > + /* Use Next if it is valid */ > + > + Buffer = *Next; > + if (!(*Next)) > + { > + return (NULL); > + } > + } > + > + /* Skip any leading delimiters */ > + > + while (*Buffer) > + { > + if (strchr (MatchString, *Buffer)) > + { > + Buffer++; > + } > + else > + { > + break; > + } > + } > + > + /* Anything left on the line? */ > + > + if (!(*Buffer)) > + { > + *Next = NULL; > + return (NULL); > + } > + > + TokenStart = Buffer; > + > + /* Find the end of this token */ > + > + while (*Buffer) > + { > + if (strchr (MatchString, *Buffer)) > + { > + *Buffer = 0; > + *Next = Buffer+1; > + if (!**Next) > + { > + *Next = NULL; > + } > + return (TokenStart); > + } > + Buffer++; > + } > + > + *Next = NULL; > + return (TokenStart); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrError > + * > + * PARAMETERS: Level - Seriousness (Warning/error, etc.) > + * MessageId - Index into global message buffer > + * Column - Column in current line > + * > + * RETURN: None > + * > + * DESCRIPTION: Preprocessor error reporting. Front end to AslCommonError2 > + * > + ******************************************************************************/ > + > +void > +PrError ( > + UINT8 Level, > + UINT8 MessageId, > + UINT32 Column) > +{ > +#if 0 > + AcpiOsPrintf ("%s (%u) : %s", Gbl_Files[ASL_FILE_INPUT].Filename, > + Gbl_CurrentLineNumber, Gbl_CurrentLineBuffer); > +#endif > + > + > + if (Column > 120) > + { > + Column = 0; > + } > + > + /* TBD: Need Logical line number? */ > + > + AslCommonError2 (Level, MessageId, > + Gbl_CurrentLineNumber, Column, > + Gbl_CurrentLineBuffer, > + Gbl_Files[ASL_FILE_INPUT].Filename, "Preprocessor"); > + > + Gbl_PreprocessorError = TRUE; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrReplaceData > + * > + * PARAMETERS: Buffer - Original(target) buffer pointer > + * LengthToRemove - Length to be removed from target buffer > + * BufferToAdd - Data to be inserted into target buffer > + * LengthToAdd - Length of BufferToAdd > + * > + * RETURN: None > + * > + * DESCRIPTION: Generic buffer data replacement. > + * > + ******************************************************************************/ > + > +void > +PrReplaceData ( > + char *Buffer, > + UINT32 LengthToRemove, > + char *BufferToAdd, > + UINT32 LengthToAdd) > +{ > + UINT32 BufferLength; > + > + > + /* Buffer is a string, so the length must include the terminating zero */ > + > + BufferLength = strlen (Buffer) + 1; > + > + if (LengthToRemove != LengthToAdd) > + { > + /* > + * Move some of the existing data > + * 1) If adding more bytes than removing, make room for the new data > + * 2) if removing more bytes than adding, delete the extra space > + */ > + if (LengthToRemove > 0) > + { > + memmove ((Buffer + LengthToAdd), (Buffer + LengthToRemove), > + (BufferLength - LengthToRemove)); > + } > + } > + > + /* Now we can move in the new data */ > + > + if (LengthToAdd > 0) > + { > + memmove (Buffer, BufferToAdd, LengthToAdd); > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: PrOpenIncludeFile > + * > + * PARAMETERS: Filename - Filename or pathname for include file > + * > + * RETURN: None. > + * > + * DESCRIPTION: Open an include file and push it on the input file stack. > + * > + ******************************************************************************/ > + > +void > +PrOpenIncludeFile ( > + char *Filename) > +{ > + FILE *IncludeFile; > + ASL_INCLUDE_DIR *NextDir; > + > + > + /* > + * start the actual include file on the next line > + */ > + Gbl_CurrentLineOffset++; > + > + /* Attempt to open the include file */ > + > + /* If the file specifies an absolute path, just open it */ > + > + if ((Filename[0] == '/') || > + (Filename[0] == '\\') || > + (Filename[1] == ':')) > + { > + IncludeFile = PrOpenIncludeWithPrefix ("", Filename); > + if (!IncludeFile) > + { > + goto ErrorExit; > + } > + return; > + } > + > + /* > + * The include filename is not an absolute path. > + * > + * First, search for the file within the "local" directory -- meaning > + * the same directory that contains the source file. > + * > + * Construct the file pathname from the global directory name. > + */ > + IncludeFile = PrOpenIncludeWithPrefix (Gbl_DirectoryPath, Filename); > + if (IncludeFile) > + { > + return; > + } > + > + /* > + * Second, search for the file within the (possibly multiple) > + * directories specified by the -I option on the command line. > + */ > + NextDir = Gbl_IncludeDirList; > + while (NextDir) > + { > + IncludeFile = PrOpenIncludeWithPrefix (NextDir->Dir, Filename); > + if (IncludeFile) > + { > + return; > + } > + > + NextDir = NextDir->Next; > + } > + > + /* We could not open the include file after trying very hard */ > + > +ErrorExit: > + sprintf (Gbl_MainTokenBuffer, "%s, %s", Filename, strerror (errno)); > + PrError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, 0); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: FlOpenIncludeWithPrefix > + * > + * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero > + * length string. > + * Filename - The include filename from the source ASL. > + * > + * RETURN: Valid file descriptor if successful. Null otherwise. > + * > + * DESCRIPTION: Open an include file and push it on the input file stack. > + * > + ******************************************************************************/ > + > +FILE * > +PrOpenIncludeWithPrefix ( > + char *PrefixDir, > + char *Filename) > +{ > + FILE *IncludeFile; > + char *Pathname; > + > + > + /* Build the full pathname to the file */ > + > + Pathname = ACPI_ALLOCATE (strlen (PrefixDir) + strlen (Filename) + 1); > + > + strcpy (Pathname, PrefixDir); > + strcat (Pathname, Filename); > + > + DbgPrint (ASL_PARSE_OUTPUT, "\n" PR_PREFIX_ID > + "Opening include file: path %s\n", > + Gbl_CurrentLineNumber, Pathname); > + > + /* Attempt to open the file, push if successful */ > + > + IncludeFile = fopen (Pathname, "r"); > + if (IncludeFile) > + { > + /* Push the include file on the open input file stack */ > + > + PrPushInputFileStack (IncludeFile, Pathname); > + return (IncludeFile); > + } > + > + ACPI_FREE (Pathname); > + return (NULL); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslPushInputFileStack > + * > + * PARAMETERS: InputFile - Open file pointer > + * Filename - Name of the file > + * > + * RETURN: None > + * > + * DESCRIPTION: Push the InputFile onto the file stack, and point the parser > + * to this file. Called when an include file is successfully > + * opened. > + * > + ******************************************************************************/ > + > +void > +PrPushInputFileStack ( > + FILE *InputFile, > + char *Filename) > +{ > + PR_FILE_NODE *Fnode; > + > + > + /* Save the current state in an Fnode */ > + > + Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE)); > + > + Fnode->File = Gbl_Files[ASL_FILE_INPUT].Handle; > + Fnode->Next = Gbl_InputFileList; > + Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; > + Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; > + > + /* Push it on the stack */ > + > + Gbl_InputFileList = Fnode; > + > + DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID > + "Push InputFile Stack: handle %p\n\n", > + Gbl_CurrentLineNumber, InputFile); > + > + /* Reset the global line count and filename */ > + > + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; > + Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; > + Gbl_PreviousLineNumber = 0; > + Gbl_CurrentLineNumber = 0; > + > + /* Emit a new #line directive for the include file */ > + > + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", > + 1, Filename); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AslPopInputFileStack > + * > + * PARAMETERS: None > + * > + * RETURN: 0 if a node was popped, -1 otherwise > + * > + * DESCRIPTION: Pop the top of the input file stack and point the parser to > + * the saved parse buffer contained in the fnode. Also, set the > + * global line counters to the saved values. This function is > + * called when an include file reaches EOF. > + * > + ******************************************************************************/ > + > +BOOLEAN > +PrPopInputFileStack ( > + void) > +{ > + PR_FILE_NODE *Fnode; > + > + > + Fnode = Gbl_InputFileList; > + DbgPrint (ASL_PARSE_OUTPUT, "\n" PR_PREFIX_ID > + "Pop InputFile Stack, Fnode %p\n\n", > + Gbl_CurrentLineNumber, Fnode); > + > + if (!Fnode) > + { > + return (FALSE); > + } > + > + /* Close the current include file */ > + > + fclose (Gbl_Files[ASL_FILE_INPUT].Handle); > + > + /* Update the top-of-stack */ > + > + Gbl_InputFileList = Fnode->Next; > + > + /* Reset global line counter and filename */ > + > + Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; > + Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File; > + Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; > + Gbl_PreviousLineNumber = 0; > + > + /* Emit a new #line directive after the include file */ > + > + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", > + Gbl_CurrentLineNumber + 1, Fnode->Filename); > + > + /* All done with this node */ > + > + ACPI_FREE (Fnode); > + return (TRUE); > +} > diff --git a/src/acpica/source/components/disassembler/dmresrcl2.c b/src/acpica/source/components/disassembler/dmresrcl2.c > new file mode 100644 > index 0000000..6a263c1 > --- /dev/null > +++ b/src/acpica/source/components/disassembler/dmresrcl2.c > @@ -0,0 +1,772 @@ > +/******************************************************************************* > + * > + * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2) > + * > + ******************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > + > +#include "acpi.h" > +#include "accommon.h" > +#include "acdisasm.h" > + > + > +#ifdef ACPI_DISASSEMBLER > + > +#define _COMPONENT ACPI_CA_DEBUGGER > + ACPI_MODULE_NAME ("dbresrcl2") > + > +/* Local prototypes */ > + > +static void > +AcpiDmI2cSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level); > + > +static void > +AcpiDmSpiSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level); > + > +static void > +AcpiDmUartSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level); > + > +static void > +AcpiDmGpioCommon ( > + AML_RESOURCE *Resource, > + UINT32 Level); > + > +static void > +AcpiDmDumpRawDataBuffer ( > + UINT8 *Buffer, > + UINT32 Length, > + UINT32 Level); > + > + > +/* Dispatch table for the serial bus descriptors */ > + > +static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] = > +{ > + NULL, > + AcpiDmI2cSerialBusDescriptor, > + AcpiDmSpiSerialBusDescriptor, > + AcpiDmUartSerialBusDescriptor > +}; > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmDumpRawDataBuffer > + * > + * PARAMETERS: Buffer - Pointer to the data bytes > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for > + * vendor data bytes. > + * > + ******************************************************************************/ > + > +static void > +AcpiDmDumpRawDataBuffer ( > + UINT8 *Buffer, > + UINT32 Length, > + UINT32 Level) > +{ > + UINT32 Index; > + UINT32 i; > + UINT32 j; > + > + > + if (!Length) > + { > + return; > + } > + > + AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length); > + > + AcpiOsPrintf ("\n"); > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("{\n"); > + AcpiDmIndent (Level + 2); > + > + for (i = 0; i < Length;) > + { > + for (j = 0; j < 8; j++) > + { > + Index = i + j; > + if (Index >= Length) > + { > + goto Finish; > + } > + > + AcpiOsPrintf ("0x%2.2X", Buffer[Index]); > + if ((Index + 1) >= Length) > + { > + goto Finish; > + } > + > + AcpiOsPrintf (", "); > + } > + AcpiOsPrintf ("\n"); > + AcpiDmIndent (Level + 2); > + > + i += 8; > + } > + > +Finish: > + AcpiOsPrintf ("\n"); > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("}"); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmGpioCommon > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor > + * > + ******************************************************************************/ > + > +static void > +AcpiDmGpioCommon ( > + AML_RESOURCE *Resource, > + UINT32 Level) > +{ > + UINT32 PinCount; > + UINT16 *PinList; > + UINT8 *VendorData; > + UINT32 i; > + > + > + /* ResourceSource, ResourceSourceIndex, ResourceType */ > + > + AcpiDmIndent (Level + 1); > + if (Resource->Gpio.ResSourceOffset) > + { > + AcpiUtPrintString ( > + ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), > + ACPI_UINT8_MAX); > + } > + > + AcpiOsPrintf (", "); > + AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex); > + AcpiOsPrintf ("%s, ", > + AcpiGbl_ConsumeDecode [(Resource->Gpio.Flags & 1)]); > + > + /* Insert a descriptor name */ > + > + AcpiDmDescriptorName (); > + AcpiOsPrintf (","); > + > + /* Dump the vendor data */ > + > + if (Resource->Gpio.VendorOffset) > + { > + AcpiOsPrintf ("\n"); > + AcpiDmIndent (Level + 1); > + VendorData = ACPI_ADD_PTR (UINT8, Resource, > + Resource->Gpio.VendorOffset); > + > + AcpiDmDumpRawDataBuffer (VendorData, > + Resource->Gpio.VendorLength, Level); > + } > + > + AcpiOsPrintf (")\n"); > + > + /* Dump the interrupt list */ > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("{ // Pin list\n"); > + > + PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset - > + Resource->Gpio.PinTableOffset)) / > + sizeof (UINT16); > + > + PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource, > + Resource->Gpio.PinTableOffset); > + > + for (i = 0; i < PinCount; i++) > + { > + AcpiDmIndent (Level + 2); > + AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : ""); > + } > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("}\n"); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmGpioIntDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a GPIO Interrupt descriptor > + * > + ******************************************************************************/ > + > +static void > +AcpiDmGpioIntDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + > + /* Dump the GpioInt-specific portion of the descriptor */ > + > + /* EdgeLevel, ActiveLevel, Shared */ > + > + AcpiDmIndent (Level); > + AcpiOsPrintf ("GpioInt (%s, %s, %s, ", > + AcpiGbl_HeDecode [(Resource->Gpio.IntFlags & 1)], > + AcpiGbl_LlDecode [(Resource->Gpio.IntFlags >> 1) & 1], > + AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); > + > + /* PinConfig, DebounceTimeout */ > + > + if (Resource->Gpio.PinConfig <= 3) > + { > + AcpiOsPrintf ("%s, ", > + AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); > + } > + else > + { > + AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); > + } > + AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout); > + > + /* Dump the GpioInt/GpioIo common portion of the descriptor */ > + > + AcpiDmGpioCommon (Resource, Level); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmGpioIoDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a GPIO Interrupt descriptor > + * > + ******************************************************************************/ > + > +static void > +AcpiDmGpioIoDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + > + /* Dump the GpioIo-specific portion of the descriptor */ > + > + /* Shared, PinConfig */ > + > + AcpiDmIndent (Level); > + AcpiOsPrintf ("GpioIo (%s, ", > + AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); > + > + if (Resource->Gpio.PinConfig <= 3) > + { > + AcpiOsPrintf ("%s, ", > + AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); > + } > + else > + { > + AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); > + } > + > + /* DebounceTimeout, DriveStrength, IoRestriction */ > + > + AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout); > + AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength); > + AcpiOsPrintf ("%s,\n", > + AcpiGbl_IorDecode [Resource->Gpio.IntFlags & 3]); > + > + /* Dump the GpioInt/GpioIo common portion of the descriptor */ > + > + AcpiDmGpioCommon (Resource, Level); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmGpioDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor > + * > + ******************************************************************************/ > + > +void > +AcpiDmGpioDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + UINT8 ConnectionType; > + > + > + ConnectionType = Resource->Gpio.ConnectionType; > + > + switch (ConnectionType) > + { > + case AML_RESOURCE_GPIO_TYPE_INT: > + AcpiDmGpioIntDescriptor (Resource, Length, Level); > + break; > + > + case AML_RESOURCE_GPIO_TYPE_IO: > + AcpiDmGpioIoDescriptor (Resource, Length, Level); > + break; > + > + default: > + AcpiOsPrintf ("Unknown GPIO type\n"); > + break; > + } > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmDumpSerialBusVendorData > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * > + * RETURN: None > + * > + * DESCRIPTION: Dump optional serial bus vendor data > + * > + ******************************************************************************/ > + > +static void > +AcpiDmDumpSerialBusVendorData ( > + AML_RESOURCE *Resource, > + UINT32 Level) > +{ > + UINT8 *VendorData; > + UINT32 VendorLength; > + > + > + /* Get the (optional) vendor data and length */ > + > + switch (Resource->CommonSerialBus.Type) > + { > + case AML_RESOURCE_I2C_SERIALBUSTYPE: > + > + VendorLength = Resource->CommonSerialBus.TypeDataLength - > + AML_RESOURCE_I2C_MIN_DATA_LEN; > + > + VendorData = ACPI_ADD_PTR (UINT8, Resource, > + sizeof (AML_RESOURCE_I2C_SERIALBUS)); > + break; > + > + case AML_RESOURCE_SPI_SERIALBUSTYPE: > + > + VendorLength = Resource->CommonSerialBus.TypeDataLength - > + AML_RESOURCE_SPI_MIN_DATA_LEN; > + > + VendorData = ACPI_ADD_PTR (UINT8, Resource, > + sizeof (AML_RESOURCE_SPI_SERIALBUS)); > + break; > + > + case AML_RESOURCE_UART_SERIALBUSTYPE: > + > + VendorLength = Resource->CommonSerialBus.TypeDataLength - > + AML_RESOURCE_UART_MIN_DATA_LEN; > + > + VendorData = ACPI_ADD_PTR (UINT8, Resource, > + sizeof (AML_RESOURCE_UART_SERIALBUS)); > + break; > + > + default: > + return; > + } > + > + /* Dump the vendor bytes as a RawDataBuffer object */ > + > + AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmI2cSerialBusDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a I2C serial bus descriptor > + * > + ******************************************************************************/ > + > +static void > +AcpiDmI2cSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + UINT32 ResourceSourceOffset; > + > + > + /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */ > + > + AcpiDmIndent (Level); > + AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n", > + Resource->I2cSerialBus.SlaveAddress, > + AcpiGbl_SmDecode [(Resource->I2cSerialBus.Flags & 1)], > + Resource->I2cSerialBus.ConnectionSpeed); > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("%s, ", > + AcpiGbl_AmDecode [(Resource->I2cSerialBus.TypeSpecificFlags & 1)]); > + > + /* ResourceSource is a required field */ > + > + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + > + Resource->CommonSerialBus.TypeDataLength; > + > + AcpiUtPrintString ( > + ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), > + ACPI_UINT8_MAX); > + > + /* ResourceSourceIndex, ResourceUsage */ > + > + AcpiOsPrintf (",\n"); > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex); > + > + AcpiOsPrintf ("%s, ", > + AcpiGbl_ConsumeDecode [(Resource->I2cSerialBus.Flags >> 1) & 1]); > + > + /* Insert a descriptor name */ > + > + AcpiDmDescriptorName (); > + AcpiOsPrintf (",\n"); > + > + /* Dump the vendor data */ > + > + AcpiDmIndent (Level + 1); > + AcpiDmDumpSerialBusVendorData (Resource, Level); > + AcpiOsPrintf (")\n"); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmSpiSerialBusDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a SPI serial bus descriptor > + * > + ******************************************************************************/ > + > +static void > +AcpiDmSpiSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + UINT32 ResourceSourceOffset; > + > + > + /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */ > + > + AcpiDmIndent (Level); > + AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n", > + Resource->SpiSerialBus.DeviceSelection, > + AcpiGbl_DpDecode [(Resource->SpiSerialBus.TypeSpecificFlags >> 1) & 1], > + AcpiGbl_WmDecode [(Resource->SpiSerialBus.TypeSpecificFlags & 1)], > + Resource->SpiSerialBus.DataBitLength); > + > + /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */ > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("%s, 0x%8.8X, %s,\n", > + AcpiGbl_SmDecode [(Resource->SpiSerialBus.Flags & 1)], > + Resource->SpiSerialBus.ConnectionSpeed, > + AcpiGbl_CpoDecode [(Resource->SpiSerialBus.ClockPolarity & 1)]); > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("%s, ", > + AcpiGbl_CphDecode [(Resource->SpiSerialBus.ClockPhase & 1)]); > + > + /* ResourceSource is a required field */ > + > + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + > + Resource->CommonSerialBus.TypeDataLength; > + > + AcpiUtPrintString ( > + ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), > + ACPI_UINT8_MAX); > + > + /* ResourceSourceIndex, ResourceUsage */ > + > + AcpiOsPrintf (",\n"); > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex); > + > + AcpiOsPrintf ("%s, ", > + AcpiGbl_ConsumeDecode [(Resource->SpiSerialBus.Flags >> 1) & 1]); > + > + /* Insert a descriptor name */ > + > + AcpiDmDescriptorName (); > + AcpiOsPrintf (",\n"); > + > + /* Dump the vendor data */ > + > + AcpiDmIndent (Level + 1); > + AcpiDmDumpSerialBusVendorData (Resource, Level); > + AcpiOsPrintf (")\n"); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmUartSerialBusDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a UART serial bus descriptor > + * > + ******************************************************************************/ > + > +static void > +AcpiDmUartSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + UINT32 ResourceSourceOffset; > + > + > + /* ConnectionSpeed, BitsPerByte, StopBits */ > + > + AcpiDmIndent (Level); > + AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n", > + Resource->UartSerialBus.DefaultBaudRate, > + AcpiGbl_BpbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 4) & 3], > + AcpiGbl_SbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 2) & 3]); > + > + /* LinesInUse, IsBigEndian, Parity, FlowControl */ > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n", > + Resource->UartSerialBus.LinesEnabled, > + AcpiGbl_EdDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 7) & 1], > + AcpiGbl_PtDecode [Resource->UartSerialBus.Parity & 7], > + AcpiGbl_FcDecode [Resource->UartSerialBus.TypeSpecificFlags & 3]); > + > + /* ReceiveBufferSize, TransmitBufferSize */ > + > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ", > + Resource->UartSerialBus.RxFifoSize, > + Resource->UartSerialBus.TxFifoSize); > + > + /* ResourceSource is a required field */ > + > + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + > + Resource->CommonSerialBus.TypeDataLength; > + > + AcpiUtPrintString ( > + ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), > + ACPI_UINT8_MAX); > + > + /* ResourceSourceIndex, ResourceUsage */ > + > + AcpiOsPrintf (",\n"); > + AcpiDmIndent (Level + 1); > + AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex); > + > + AcpiOsPrintf ("%s, ", > + AcpiGbl_ConsumeDecode [(Resource->UartSerialBus.Flags >> 1) & 1]); > + > + /* Insert a descriptor name */ > + > + AcpiDmDescriptorName (); > + AcpiOsPrintf (",\n"); > + > + /* Dump the vendor data */ > + > + AcpiDmIndent (Level + 1); > + AcpiDmDumpSerialBusVendorData (Resource, Level); > + AcpiOsPrintf (")\n"); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiDmSerialBusDescriptor > + * > + * PARAMETERS: Resource - Pointer to the resource descriptor > + * Length - Length of the descriptor in bytes > + * Level - Current source code indentation level > + * > + * RETURN: None > + * > + * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor > + * > + ******************************************************************************/ > + > +void > +AcpiDmSerialBusDescriptor ( > + AML_RESOURCE *Resource, > + UINT32 Length, > + UINT32 Level) > +{ > + > + SerialBusResourceDispatch [Resource->CommonSerialBus.Type] ( > + Resource, Length, Level); > +} > + > +#endif > + > diff --git a/src/acpica/source/components/hardware/hwesleep.c b/src/acpica/source/components/hardware/hwesleep.c > new file mode 100644 > index 0000000..b137229 > --- /dev/null > +++ b/src/acpica/source/components/hardware/hwesleep.c > @@ -0,0 +1,349 @@ > +/****************************************************************************** > + * > + * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the > + * extended FADT-V5 sleep registers. > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "acpi.h" > +#include "accommon.h" > + > +#define _COMPONENT ACPI_HARDWARE > + ACPI_MODULE_NAME ("hwesleep") > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiHwExecuteSleepMethod > + * > + * PARAMETERS: MethodPathname - Pathname of method to execute > + * IntegerArgument - Argument to pass to the method > + * > + * RETURN: None > + * > + * DESCRIPTION: Execute a sleep/wake related method with one integer argument > + * and no return value. > + * > + ******************************************************************************/ > + > +void > +AcpiHwExecuteSleepMethod ( > + char *MethodPathname, > + UINT32 IntegerArgument) > +{ > + ACPI_OBJECT_LIST ArgList; > + ACPI_OBJECT Arg; > + ACPI_STATUS Status; > + > + > + ACPI_FUNCTION_TRACE (HwExecuteSleepMethod); > + > + > + /* One argument, IntegerArgument; No return value expected */ > + > + ArgList.Count = 1; > + ArgList.Pointer = &Arg; > + Arg.Type = ACPI_TYPE_INTEGER; > + Arg.Integer.Value = (UINT64) IntegerArgument; > + > + Status = AcpiEvaluateObject (NULL, MethodPathname, &ArgList, NULL); > + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) > + { > + ACPI_EXCEPTION ((AE_INFO, Status, "While executing method %s", > + MethodPathname)); > + } > + > + return_VOID; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiHwExtendedSleep > + * > + * PARAMETERS: SleepState - Which sleep state to enter > + * Flags - ACPI_EXECUTE_GTS to run optional method > + * > + * RETURN: Status > + * > + * DESCRIPTION: Enter a system sleep state via the extended FADT sleep > + * registers (V5 FADT). > + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiHwExtendedSleep ( > + UINT8 SleepState, > + UINT8 Flags) > +{ > + ACPI_STATUS Status; > + UINT8 SleepTypeValue; > + UINT64 SleepStatus; > + > + > + ACPI_FUNCTION_TRACE (HwExtendedSleep); > + > + > + /* Extended sleep registers must be valid */ > + > + if (!AcpiGbl_FADT.SleepControl.Address || > + !AcpiGbl_FADT.SleepStatus.Address) > + { > + return_ACPI_STATUS (AE_NOT_EXIST); > + } > + > + /* Clear wake status (WAK_STS) */ > + > + Status = AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + AcpiGbl_SystemAwakeAndRunning = FALSE; > + > + /* Optionally execute _GTS (Going To Sleep) */ > + > + if (Flags & ACPI_EXECUTE_GTS) > + { > + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__GTS, SleepState); > + } > + > + /* Flush caches, as per ACPI specification */ > + > + ACPI_FLUSH_CPU_CACHE (); > + > + /* > + * Set the SLP_TYP and SLP_EN bits. > + * > + * Note: We only use the first value returned by the \_Sx method > + * (AcpiGbl_SleepTypeA) - As per ACPI specification. > + */ > + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, > + "Entering sleep state [S%u]\n", SleepState)); > + > + SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & > + ACPI_X_SLEEP_TYPE_MASK); > + > + Status = AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE), > + &AcpiGbl_FADT.SleepControl); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + /* Wait for transition back to Working State */ > + > + do > + { > + Status = AcpiRead (&SleepStatus, &AcpiGbl_FADT.SleepStatus); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + } while (!(((UINT8) SleepStatus) & ACPI_X_WAKE_STATUS)); > + > + return_ACPI_STATUS (AE_OK); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiHwExtendedWakePrep > + * > + * PARAMETERS: SleepState - Which sleep state we just exited > + * Flags - ACPI_EXECUTE_BFS to run optional method > + * > + * RETURN: Status > + * > + * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after > + * a sleep. Called with interrupts ENABLED. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiHwExtendedWakePrep ( > + UINT8 SleepState, > + UINT8 Flags) > +{ > + ACPI_STATUS Status; > + UINT8 SleepTypeValue; > + > + > + ACPI_FUNCTION_TRACE (HwExtendedWakePrep); > + > + > + Status = AcpiGetSleepTypeData (ACPI_STATE_S0, > + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); > + if (ACPI_SUCCESS (Status)) > + { > + SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & > + ACPI_X_SLEEP_TYPE_MASK); > + > + (void) AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE), > + &AcpiGbl_FADT.SleepControl); > + } > + > + /* Optionally execute _BFS (Back From Sleep) */ > + > + if (Flags & ACPI_EXECUTE_BFS) > + { > + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__BFS, SleepState); > + } > + return_ACPI_STATUS (AE_OK); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiHwExtendedWake > + * > + * PARAMETERS: SleepState - Which sleep state we just exited > + * Flags - Reserved, set to zero > + * > + * RETURN: Status > + * > + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep > + * Called with interrupts ENABLED. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiHwExtendedWake ( > + UINT8 SleepState, > + UINT8 Flags) > +{ > + ACPI_FUNCTION_TRACE (HwExtendedWake); > + > + > + /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ > + > + AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; > + > + /* Execute the wake methods */ > + > + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, ACPI_SST_WAKING); > + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__WAK, SleepState); > + > + /* > + * Some BIOS code assumes that WAK_STS will be cleared on resume > + * and use it to determine whether the system is rebooting or > + * resuming. Clear WAK_STS for compatibility. > + */ > + (void) AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus); > + AcpiGbl_SystemAwakeAndRunning = TRUE; > + > + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, ACPI_SST_WORKING); > + return_ACPI_STATUS (AE_OK); > +} > diff --git a/src/acpica/source/components/hardware/hwxfsleep.c b/src/acpica/source/components/hardware/hwxfsleep.c > new file mode 100644 > index 0000000..631b81e > --- /dev/null > +++ b/src/acpica/source/components/hardware/hwxfsleep.c > @@ -0,0 +1,550 @@ > +/****************************************************************************** > + * > + * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake External Interfaces > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#include "acpi.h" > +#include "accommon.h" > + > +#define _COMPONENT ACPI_HARDWARE > + ACPI_MODULE_NAME ("hwxfsleep") > + > +/* Local prototypes */ > + > +static ACPI_STATUS > +AcpiHwSleepDispatch ( > + UINT8 SleepState, > + UINT8 Flags, > + UINT32 FunctionId); > + > +/* > + * Dispatch table used to efficiently branch to the various sleep > + * functions. > + */ > +#define ACPI_SLEEP_FUNCTION_ID 0 > +#define ACPI_WAKE_PREP_FUNCTION_ID 1 > +#define ACPI_WAKE_FUNCTION_ID 2 > + > +/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */ > + > +static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] = > +{ > + {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacySleep), AcpiHwExtendedSleep}, > + {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWakePrep), AcpiHwExtendedWakePrep}, > + {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWake), AcpiHwExtendedWake} > +}; > + > + > +/* > + * These functions are removed for the ACPI_REDUCED_HARDWARE case: > + * AcpiSetFirmwareWakingVector > + * AcpiSetFirmwareWakingVector64 > + * AcpiEnterSleepStateS4bios > + */ > + > +#if (!ACPI_REDUCED_HARDWARE) > +/******************************************************************************* > + * > + * FUNCTION: AcpiSetFirmwareWakingVector > + * > + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode > + * entry point. > + * > + * RETURN: Status > + * > + * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiSetFirmwareWakingVector ( > + UINT32 PhysicalAddress) > +{ > + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); > + > + > + /* Set the 32-bit vector */ > + > + AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; > + > + /* Clear the 64-bit vector if it exists */ > + > + if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) > + { > + AcpiGbl_FACS->XFirmwareWakingVector = 0; > + } > + > + return_ACPI_STATUS (AE_OK); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) > + > + > +#if ACPI_MACHINE_WIDTH == 64 > +/******************************************************************************* > + * > + * FUNCTION: AcpiSetFirmwareWakingVector64 > + * > + * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected > + * mode entry point. > + * > + * RETURN: Status > + * > + * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if > + * it exists in the table. This function is intended for use with > + * 64-bit host operating systems. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiSetFirmwareWakingVector64 ( > + UINT64 PhysicalAddress) > +{ > + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); > + > + > + /* Determine if the 64-bit vector actually exists */ > + > + if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) > + { > + return_ACPI_STATUS (AE_NOT_EXIST); > + } > + > + /* Clear 32-bit vector, set the 64-bit X_ vector */ > + > + AcpiGbl_FACS->FirmwareWakingVector = 0; > + AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; > + return_ACPI_STATUS (AE_OK); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) > +#endif > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiEnterSleepStateS4bios > + * > + * PARAMETERS: None > + * > + * RETURN: Status > + * > + * DESCRIPTION: Perform a S4 bios request. > + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiEnterSleepStateS4bios ( > + void) > +{ > + UINT32 InValue; > + ACPI_STATUS Status; > + > + > + ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); > + > + > + /* Clear the wake status bit (PM1) */ > + > + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + Status = AcpiHwClearAcpiStatus (); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + /* > + * 1) Disable/Clear all GPEs > + * 2) Enable all wakeup GPEs > + */ > + Status = AcpiHwDisableAllGpes (); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + AcpiGbl_SystemAwakeAndRunning = FALSE; > + > + Status = AcpiHwEnableAllWakeupGpes (); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + ACPI_FLUSH_CPU_CACHE (); > + > + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, > + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); > + > + do { > + AcpiOsStall(1000); > + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + } while (!InValue); > + > + return_ACPI_STATUS (AE_OK); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) > + > +#endif /* !ACPI_REDUCED_HARDWARE */ > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiHwSleepDispatch > + * > + * PARAMETERS: SleepState - Which sleep state to enter/exit > + * FunctionId - Sleep, WakePrep, or Wake > + * > + * RETURN: Status from the invoked sleep handling function. > + * > + * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling > + * function. > + * > + ******************************************************************************/ > + > +static ACPI_STATUS > +AcpiHwSleepDispatch ( > + UINT8 SleepState, > + UINT8 Flags, > + UINT32 FunctionId) > +{ > + ACPI_STATUS Status; > + ACPI_SLEEP_FUNCTIONS *SleepFunctions = &AcpiSleepDispatch[FunctionId]; > + > + > +#if (!ACPI_REDUCED_HARDWARE) > + > + /* > + * If the Hardware Reduced flag is set (from the FADT), we must > + * use the extended sleep registers > + */ > + if (AcpiGbl_ReducedHardware || > + AcpiGbl_FADT.SleepControl.Address) > + { > + Status = SleepFunctions->ExtendedFunction (SleepState, Flags); > + } > + else > + { > + /* Legacy sleep */ > + > + Status = SleepFunctions->LegacyFunction (SleepState, Flags); > + } > + > + return (Status); > + > +#else > + /* > + * For the case where reduced-hardware-only code is being generated, > + * we know that only the extended sleep registers are available > + */ > + Status = SleepFunctions->ExtendedFunction (SleepState, Flags); > + return (Status); > + > +#endif /* !ACPI_REDUCED_HARDWARE */ > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiEnterSleepStatePrep > + * > + * PARAMETERS: SleepState - Which sleep state to enter > + * > + * RETURN: Status > + * > + * DESCRIPTION: Prepare to enter a system sleep state. > + * This function must execute with interrupts enabled. > + * We break sleeping into 2 stages so that OSPM can handle > + * various OS-specific tasks between the two steps. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiEnterSleepStatePrep ( > + UINT8 SleepState) > +{ > + ACPI_STATUS Status; > + ACPI_OBJECT_LIST ArgList; > + ACPI_OBJECT Arg; > + UINT32 SstValue; > + > + > + ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); > + > + > + Status = AcpiGetSleepTypeData (SleepState, > + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); > + if (ACPI_FAILURE (Status)) > + { > + return_ACPI_STATUS (Status); > + } > + > + /* Execute the _PTS method (Prepare To Sleep) */ > + > + ArgList.Count = 1; > + ArgList.Pointer = &Arg; > + Arg.Type = ACPI_TYPE_INTEGER; > + Arg.Integer.Value = SleepState; > + > + Status = AcpiEvaluateObject (NULL, METHOD_PATHNAME__PTS, &ArgList, NULL); > + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) > + { > + return_ACPI_STATUS (Status); > + } > + > + /* Setup the argument to the _SST method (System STatus) */ > + > + switch (SleepState) > + { > + case ACPI_STATE_S0: > + SstValue = ACPI_SST_WORKING; > + break; > + > + case ACPI_STATE_S1: > + case ACPI_STATE_S2: > + case ACPI_STATE_S3: > + SstValue = ACPI_SST_SLEEPING; > + break; > + > + case ACPI_STATE_S4: > + SstValue = ACPI_SST_SLEEP_CONTEXT; > + break; > + > + default: > + SstValue = ACPI_SST_INDICATOR_OFF; /* Default is off */ > + break; > + } > + > + /* > + * Set the system indicators to show the desired sleep state. > + * _SST is an optional method (return no error if not found) > + */ > + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, SstValue); > + return_ACPI_STATUS (AE_OK); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiEnterSleepState > + * > + * PARAMETERS: SleepState - Which sleep state to enter > + * Flags - ACPI_EXECUTE_GTS to run optional method > + * > + * RETURN: Status > + * > + * DESCRIPTION: Enter a system sleep state > + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiEnterSleepState ( > + UINT8 SleepState, > + UINT8 Flags) > +{ > + ACPI_STATUS Status; > + > + > + ACPI_FUNCTION_TRACE (AcpiEnterSleepState); > + > + > + if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || > + (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) > + { > + ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", > + AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); > + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); > + } > + > + Status = AcpiHwSleepDispatch (SleepState, Flags, ACPI_SLEEP_FUNCTION_ID); > + return_ACPI_STATUS (Status); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiLeaveSleepStatePrep > + * > + * PARAMETERS: SleepState - Which sleep state we are exiting > + * Flags - ACPI_EXECUTE_BFS to run optional method > + * > + * RETURN: Status > + * > + * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a > + * sleep. Called with interrupts DISABLED. > + * We break wake/resume into 2 stages so that OSPM can handle > + * various OS-specific tasks between the two steps. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiLeaveSleepStatePrep ( > + UINT8 SleepState, > + UINT8 Flags) > +{ > + ACPI_STATUS Status; > + > + > + ACPI_FUNCTION_TRACE (AcpiLeaveSleepStatePrep); > + > + > + Status = AcpiHwSleepDispatch (SleepState, Flags, ACPI_WAKE_PREP_FUNCTION_ID); > + return_ACPI_STATUS (Status); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepStatePrep) > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiLeaveSleepState > + * > + * PARAMETERS: SleepState - Which sleep state we are exiting > + * > + * RETURN: Status > + * > + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep > + * Called with interrupts ENABLED. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiLeaveSleepState ( > + UINT8 SleepState) > +{ > + ACPI_STATUS Status; > + > + > + ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); > + > + > + Status = AcpiHwSleepDispatch (SleepState, 0, ACPI_WAKE_FUNCTION_ID); > + return_ACPI_STATUS (Status); > +} > + > +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) > diff --git a/src/acpica/source/components/resources/rsserial.c b/src/acpica/source/components/resources/rsserial.c > new file mode 100644 > index 0000000..0bc71e7 > --- /dev/null > +++ b/src/acpica/source/components/resources/rsserial.c > @@ -0,0 +1,497 @@ > +/******************************************************************************* > + * > + * Module Name: rsserial - GPIO/SerialBus resource descriptors > + * > + ******************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#define __RSIRQ_C__ > + > +#include "acpi.h" > +#include "accommon.h" > +#include "acresrc.h" > + > +#define _COMPONENT ACPI_RESOURCES > + ACPI_MODULE_NAME ("rsserial") > + > + > +/******************************************************************************* > + * > + * AcpiRsConvertGpio > + * > + ******************************************************************************/ > + > +ACPI_RSCONVERT_INFO AcpiRsConvertGpio[17] = > +{ > + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO, > + ACPI_RS_SIZE (ACPI_RESOURCE_GPIO), > + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)}, > + > + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO, > + sizeof (AML_RESOURCE_GPIO), > + 0}, > + > + /* > + * These fields are contiguous in both the source and destination: > + * RevisionId > + * ConnectionType > + */ > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.RevisionId), > + AML_OFFSET (Gpio.RevisionId), > + 2}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer), > + AML_OFFSET (Gpio.Flags), > + 0}, > + > + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Sharable), > + AML_OFFSET (Gpio.IntFlags), > + 3}, > + > + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction), > + AML_OFFSET (Gpio.IntFlags), > + 0}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering), > + AML_OFFSET (Gpio.IntFlags), > + 0}, > + > + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity), > + AML_OFFSET (Gpio.IntFlags), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.PinConfig), > + AML_OFFSET (Gpio.PinConfig), > + 1}, > + > + /* > + * These fields are contiguous in both the source and destination: > + * DriveStrength > + * DebounceTimeout > + */ > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Gpio.DriveStrength), > + AML_OFFSET (Gpio.DriveStrength), > + 2}, > + > + /* Pin Table */ > + > + {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength), > + AML_OFFSET (Gpio.PinTableOffset), > + AML_OFFSET (Gpio.ResSourceOffset)}, > + > + {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable), > + AML_OFFSET (Gpio.PinTableOffset), > + 0}, > + > + /* Resource Source */ > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index), > + AML_OFFSET (Gpio.ResSourceIndex), > + 1}, > + > + {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength), > + AML_OFFSET (Gpio.ResSourceOffset), > + AML_OFFSET (Gpio.VendorOffset)}, > + > + {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr), > + AML_OFFSET (Gpio.ResSourceOffset), > + 0}, > + > + /* Vendor Data */ > + > + {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET (Data.Gpio.VendorLength), > + AML_OFFSET (Gpio.VendorLength), > + 1}, > + > + {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.VendorData), > + AML_OFFSET (Gpio.VendorOffset), > + 0}, > +}; > + > + > +/******************************************************************************* > + * > + * AcpiRsConvertI2cSerialBus > + * > + ******************************************************************************/ > + > +ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] = > +{ > + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, > + ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS), > + ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)}, > + > + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, > + sizeof (AML_RESOURCE_I2C_SERIALBUS), > + 0}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), > + AML_OFFSET (CommonSerialBus.RevisionId), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), > + AML_OFFSET (CommonSerialBus.Type), > + 1}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), > + AML_OFFSET (CommonSerialBus.Flags), > + 0}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), > + AML_OFFSET (CommonSerialBus.Flags), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), > + AML_OFFSET (CommonSerialBus.TypeRevisionId), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + 1}, > + > + /* Vendor data */ > + > + {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + AML_RESOURCE_I2C_MIN_DATA_LEN}, > + > + {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), > + 0, > + sizeof (AML_RESOURCE_I2C_SERIALBUS)}, > + > + /* Resource Source */ > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), > + AML_OFFSET (CommonSerialBus.ResSourceIndex), > + 1}, > + > + {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, > + > + {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, > + > + /* I2C bus type specific */ > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode), > + AML_OFFSET (I2cSerialBus.TypeSpecificFlags), > + 0}, > + > + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed), > + AML_OFFSET (I2cSerialBus.ConnectionSpeed), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress), > + AML_OFFSET (I2cSerialBus.SlaveAddress), > + 1}, > +}; > + > + > +/******************************************************************************* > + * > + * AcpiRsConvertSpiSerialBus > + * > + ******************************************************************************/ > + > +ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] = > +{ > + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, > + ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS), > + ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)}, > + > + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, > + sizeof (AML_RESOURCE_SPI_SERIALBUS), > + 0}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), > + AML_OFFSET (CommonSerialBus.RevisionId), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), > + AML_OFFSET (CommonSerialBus.Type), > + 1}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), > + AML_OFFSET (CommonSerialBus.Flags), > + 0}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), > + AML_OFFSET (CommonSerialBus.Flags), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), > + AML_OFFSET (CommonSerialBus.TypeRevisionId), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + 1}, > + > + /* Vendor data */ > + > + {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + AML_RESOURCE_SPI_MIN_DATA_LEN}, > + > + {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), > + 0, > + sizeof (AML_RESOURCE_SPI_SERIALBUS)}, > + > + /* Resource Source */ > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), > + AML_OFFSET (CommonSerialBus.ResSourceIndex), > + 1}, > + > + {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, > + > + {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, > + > + /* Spi bus type specific */ > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode), > + AML_OFFSET (SpiSerialBus.TypeSpecificFlags), > + 0}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity), > + AML_OFFSET (SpiSerialBus.TypeSpecificFlags), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength), > + AML_OFFSET (SpiSerialBus.DataBitLength), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase), > + AML_OFFSET (SpiSerialBus.ClockPhase), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity), > + AML_OFFSET (SpiSerialBus.ClockPolarity), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection), > + AML_OFFSET (SpiSerialBus.DeviceSelection), > + 1}, > + > + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed), > + AML_OFFSET (SpiSerialBus.ConnectionSpeed), > + 1}, > +}; > + > + > +/******************************************************************************* > + * > + * AcpiRsConvertUartSerialBus > + * > + ******************************************************************************/ > + > +ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] = > +{ > + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, > + ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS), > + ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)}, > + > + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, > + sizeof (AML_RESOURCE_UART_SERIALBUS), > + 0}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), > + AML_OFFSET (CommonSerialBus.RevisionId), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), > + AML_OFFSET (CommonSerialBus.Type), > + 1}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), > + AML_OFFSET (CommonSerialBus.Flags), > + 0}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), > + AML_OFFSET (CommonSerialBus.Flags), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), > + AML_OFFSET (CommonSerialBus.TypeRevisionId), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + 1}, > + > + /* Vendor data */ > + > + {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + AML_RESOURCE_UART_MIN_DATA_LEN}, > + > + {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), > + 0, > + sizeof (AML_RESOURCE_UART_SERIALBUS)}, > + > + /* Resource Source */ > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), > + AML_OFFSET (CommonSerialBus.ResSourceIndex), > + 1}, > + > + {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, > + > + {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), > + AML_OFFSET (CommonSerialBus.TypeDataLength), > + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, > + > + /* Uart bus type specific */ > + > + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl), > + AML_OFFSET (UartSerialBus.TypeSpecificFlags), > + 0}, > + > + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits), > + AML_OFFSET (UartSerialBus.TypeSpecificFlags), > + 2}, > + > + {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits), > + AML_OFFSET (UartSerialBus.TypeSpecificFlags), > + 4}, > + > + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian), > + AML_OFFSET (UartSerialBus.TypeSpecificFlags), > + 7}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.Parity), > + AML_OFFSET (UartSerialBus.Parity), > + 1}, > + > + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled), > + AML_OFFSET (UartSerialBus.LinesEnabled), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize), > + AML_OFFSET (UartSerialBus.RxFifoSize), > + 1}, > + > + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize), > + AML_OFFSET (UartSerialBus.TxFifoSize), > + 1}, > + > + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate), > + AML_OFFSET (UartSerialBus.DefaultBaudRate), > + 1}, > +}; > diff --git a/src/acpica/source/components/utilities/utaddress.c b/src/acpica/source/components/utilities/utaddress.c > new file mode 100644 > index 0000000..8cbc8a9 > --- /dev/null > +++ b/src/acpica/source/components/utilities/utaddress.c > @@ -0,0 +1,394 @@ > +/****************************************************************************** > + * > + * Module Name: utaddress - OpRegion address range check > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#define __UTADDRESS_C__ > + > +#include "acpi.h" > +#include "accommon.h" > +#include "acnamesp.h" > + > + > +#define _COMPONENT ACPI_UTILITIES > + ACPI_MODULE_NAME ("utaddress") > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiUtAddAddressRange > + * > + * PARAMETERS: SpaceId - Address space ID > + * Address - OpRegion start address > + * Length - OpRegion length > + * RegionNode - OpRegion namespace node > + * > + * RETURN: Status > + * > + * DESCRIPTION: Add the Operation Region address range to the global list. > + * The only supported Space IDs are Memory and I/O. Called when > + * the OpRegion address/length operands are fully evaluated. > + * > + * MUTEX: Locks the namespace > + * > + * NOTE: Because this interface is only called when an OpRegion argument > + * list is evaluated, there cannot be any duplicate RegionNodes. > + * Duplicate Address/Length values are allowed, however, so that multiple > + * address conflicts can be detected. > + * > + ******************************************************************************/ > + > +ACPI_STATUS > +AcpiUtAddAddressRange ( > + ACPI_ADR_SPACE_TYPE SpaceId, > + ACPI_PHYSICAL_ADDRESS Address, > + UINT32 Length, > + ACPI_NAMESPACE_NODE *RegionNode) > +{ > + ACPI_ADDRESS_RANGE *RangeInfo; > + ACPI_STATUS Status; > + > + > + ACPI_FUNCTION_TRACE (UtAddAddressRange); > + > + > + if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && > + (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) > + { > + return_ACPI_STATUS (AE_OK); > + } > + > + /* Allocate/init a new info block, add it to the appropriate list */ > + > + RangeInfo = ACPI_ALLOCATE (sizeof (ACPI_ADDRESS_RANGE)); > + if (!RangeInfo) > + { > + return_ACPI_STATUS (AE_NO_MEMORY); > + } > + > + RangeInfo->StartAddress = Address; > + RangeInfo->EndAddress = (Address + Length - 1); > + RangeInfo->RegionNode = RegionNode; > + > + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); > + if (ACPI_FAILURE (Status)) > + { > + ACPI_FREE (RangeInfo); > + return_ACPI_STATUS (Status); > + } > + > + RangeInfo->Next = AcpiGbl_AddressRangeList[SpaceId]; > + AcpiGbl_AddressRangeList[SpaceId] = RangeInfo; > + > + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, > + "\nAdded [%4.4s] address range: 0x%p-0x%p\n", > + AcpiUtGetNodeName (RangeInfo->RegionNode), > + ACPI_CAST_PTR (void, Address), > + ACPI_CAST_PTR (void, RangeInfo->EndAddress))); > + > + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); > + return_ACPI_STATUS (AE_OK); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiUtRemoveAddressRange > + * > + * PARAMETERS: SpaceId - Address space ID > + * RegionNode - OpRegion namespace node > + * > + * RETURN: None > + * > + * DESCRIPTION: Remove the Operation Region from the global list. The only > + * supported Space IDs are Memory and I/O. Called when an > + * OpRegion is deleted. > + * > + * MUTEX: Assumes the namespace is locked > + * > + ******************************************************************************/ > + > +void > +AcpiUtRemoveAddressRange ( > + ACPI_ADR_SPACE_TYPE SpaceId, > + ACPI_NAMESPACE_NODE *RegionNode) > +{ > + ACPI_ADDRESS_RANGE *RangeInfo; > + ACPI_ADDRESS_RANGE *Prev; > + > + > + ACPI_FUNCTION_TRACE (UtRemoveAddressRange); > + > + > + if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && > + (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) > + { > + return_VOID; > + } > + > + /* Get the appropriate list head and check the list */ > + > + RangeInfo = Prev = AcpiGbl_AddressRangeList[SpaceId]; > + while (RangeInfo) > + { > + if (RangeInfo->RegionNode == RegionNode) > + { > + if (RangeInfo == Prev) /* Found at list head */ > + { > + AcpiGbl_AddressRangeList[SpaceId] = RangeInfo->Next; > + } > + else > + { > + Prev->Next = RangeInfo->Next; > + } > + > + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, > + "\nRemoved [%4.4s] address range: 0x%p-0x%p\n", > + AcpiUtGetNodeName (RangeInfo->RegionNode), > + ACPI_CAST_PTR (void, RangeInfo->StartAddress), > + ACPI_CAST_PTR (void, RangeInfo->EndAddress))); > + > + ACPI_FREE (RangeInfo); > + return_VOID; > + } > + > + Prev = RangeInfo; > + RangeInfo = RangeInfo->Next; > + } > + > + return_VOID; > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiUtCheckAddressRange > + * > + * PARAMETERS: SpaceId - Address space ID > + * Address - Start address > + * Length - Length of address range > + * Warn - TRUE if warning on overlap desired > + * > + * RETURN: Count of the number of conflicts detected. Zero is always > + * returned for Space IDs other than Memory or I/O. > + * > + * DESCRIPTION: Check if the input address range overlaps any of the > + * ASL operation region address ranges. The only supported > + * Space IDs are Memory and I/O. > + * > + * MUTEX: Assumes the namespace is locked. > + * > + ******************************************************************************/ > + > +UINT32 > +AcpiUtCheckAddressRange ( > + ACPI_ADR_SPACE_TYPE SpaceId, > + ACPI_PHYSICAL_ADDRESS Address, > + UINT32 Length, > + BOOLEAN Warn) > +{ > + ACPI_ADDRESS_RANGE *RangeInfo; > + ACPI_PHYSICAL_ADDRESS EndAddress; > + char *Pathname; > + UINT32 OverlapCount = 0; > + > + > + ACPI_FUNCTION_TRACE (UtCheckAddressRange); > + > + > + if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && > + (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) > + { > + return_UINT32 (0); > + } > + > + RangeInfo = AcpiGbl_AddressRangeList[SpaceId]; > + EndAddress = Address + Length - 1; > + > + /* Check entire list for all possible conflicts */ > + > + while (RangeInfo) > + { > + /* > + * Check if the requested Address/Length overlaps this AddressRange. > + * Four cases to consider: > + * > + * 1) Input address/length is contained completely in the address range > + * 2) Input address/length overlaps range at the range start > + * 3) Input address/length overlaps range at the range end > + * 4) Input address/length completely encompasses the range > + */ > + if ((Address <= RangeInfo->EndAddress) && > + (EndAddress >= RangeInfo->StartAddress)) > + { > + /* Found an address range overlap */ > + > + OverlapCount++; > + if (Warn) /* Optional warning message */ > + { > + Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode); > + > + ACPI_WARNING ((AE_INFO, > + "0x%p-0x%p %s conflicts with Region %s %d", > + ACPI_CAST_PTR (void, Address), > + ACPI_CAST_PTR (void, EndAddress), > + AcpiUtGetRegionName (SpaceId), Pathname, OverlapCount)); > + ACPI_FREE (Pathname); > + } > + } > + > + RangeInfo = RangeInfo->Next; > + } > + > + return_UINT32 (OverlapCount); > +} > + > + > +/******************************************************************************* > + * > + * FUNCTION: AcpiUtDeleteAddressLists > + * > + * PARAMETERS: None > + * > + * RETURN: None > + * > + * DESCRIPTION: Delete all global address range lists (called during > + * subsystem shutdown). > + * > + ******************************************************************************/ > + > +void > +AcpiUtDeleteAddressLists ( > + void) > +{ > + ACPI_ADDRESS_RANGE *Next; > + ACPI_ADDRESS_RANGE *RangeInfo; > + int i; > + > + > + /* Delete all elements in all address range lists */ > + > + for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) > + { > + Next = AcpiGbl_AddressRangeList[i]; > + > + while (Next) > + { > + RangeInfo = Next; > + Next = RangeInfo->Next; > + ACPI_FREE (RangeInfo); > + } > + > + AcpiGbl_AddressRangeList[i] = NULL; > + } > +} > diff --git a/src/acpica/source/include/actbl3.h b/src/acpica/source/include/actbl3.h > new file mode 100644 > index 0000000..6fc9568 > --- /dev/null > +++ b/src/acpica/source/include/actbl3.h > @@ -0,0 +1,722 @@ > +/****************************************************************************** > + * > + * Name: actbl3.h - ACPI Table Definitions > + * > + *****************************************************************************/ > + > +/****************************************************************************** > + * > + * 1. Copyright Notice > + * > + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. > + * All rights reserved. > + * > + * 2. License > + * > + * 2.1. This is your license from Intel Corp. under its intellectual property > + * rights. You may have additional license terms from the party that provided > + * you this software, covering your right to use that party's intellectual > + * property rights. > + * > + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a > + * copy of the source code appearing in this file ("Covered Code") an > + * irrevocable, perpetual, worldwide license under Intel's copyrights in the > + * base code distributed originally by Intel ("Original Intel Code") to copy, > + * make derivatives, distribute, use and display any portion of the Covered > + * Code in any form, with the right to sublicense such rights; and > + * > + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent > + * license (with the right to sublicense), under only those claims of Intel > + * patents that are infringed by the Original Intel Code, to make, use, sell, > + * offer to sell, and import the Covered Code and derivative works thereof > + * solely to the minimum extent necessary to exercise the above copyright > + * license, and in no event shall the patent license extend to any additions > + * to or modifications of the Original Intel Code. No other license or right > + * is granted directly or by implication, estoppel or otherwise; > + * > + * The above copyright and patent license is granted only if the following > + * conditions are met: > + * > + * 3. Conditions > + * > + * 3.1. Redistribution of Source with Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification with rights to further distribute source must include > + * the above Copyright Notice, the above License, this list of Conditions, > + * and the following Disclaimer and Export Compliance provision. In addition, > + * Licensee must cause all Covered Code to which Licensee contributes to > + * contain a file documenting the changes Licensee made to create that Covered > + * Code and the date of any change. Licensee must include in that file the > + * documentation of any changes made by any predecessor Licensee. Licensee > + * must include a prominent statement that the modification is derived, > + * directly or indirectly, from Original Intel Code. > + * > + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. > + * Redistribution of source code of any substantial portion of the Covered > + * Code or modification without rights to further distribute source must > + * include the following Disclaimer and Export Compliance provision in the > + * documentation and/or other materials provided with distribution. In > + * addition, Licensee may not authorize further sublicense of source of any > + * portion of the Covered Code, and must include terms to the effect that the > + * license from Licensee to its licensee is limited to the intellectual > + * property embodied in the software Licensee provides to its licensee, and > + * not to intellectual property embodied in modifications its licensee may > + * make. > + * > + * 3.3. Redistribution of Executable. Redistribution in executable form of any > + * substantial portion of the Covered Code or modification must reproduce the > + * above Copyright Notice, and the following Disclaimer and Export Compliance > + * provision in the documentation and/or other materials provided with the > + * distribution. > + * > + * 3.4. Intel retains all right, title, and interest in and to the Original > + * Intel Code. > + * > + * 3.5. Neither the name Intel nor any other trademark owned or controlled by > + * Intel shall be used in advertising or otherwise to promote the sale, use or > + * other dealings in products derived from or relating to the Covered Code > + * without prior written authorization from Intel. > + * > + * 4. Disclaimer and Export Compliance > + * > + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED > + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE > + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, > + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY > + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY > + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A > + * PARTICULAR PURPOSE. > + * > + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES > + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR > + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, > + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY > + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL > + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS > + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY > + * LIMITED REMEDY. > + * > + * 4.3. Licensee shall not export, either directly or indirectly, any of this > + * software or system incorporating such software without first obtaining any > + * required license or other approval from the U. S. Department of Commerce or > + * any other agency or department of the United States Government. In the > + * event Licensee exports any such software from the United States or > + * re-exports any such software from a foreign destination, Licensee shall > + * ensure that the distribution and export/re-export of the software is in > + * compliance with all laws, regulations, orders, or other restrictions of the > + * U.S. Export Administration Regulations. Licensee agrees that neither it nor > + * any of its subsidiaries will export/re-export any technical data, process, > + * software, or service, directly or indirectly, to any country for which the > + * United States government or any agency thereof requires an export license, > + * other governmental approval, or letter of assurance, without first obtaining > + * such license, approval or letter. > + * > + *****************************************************************************/ > + > +#ifndef __ACTBL3_H__ > +#define __ACTBL3_H__ > + > + > +/******************************************************************************* > + * > + * Additional ACPI Tables (3) > + * > + * These tables are not consumed directly by the ACPICA subsystem, but are > + * included here to support device drivers and the AML disassembler. > + * > + * The tables in this file are fully defined within the ACPI specification. > + * > + ******************************************************************************/ > + > + > +/* > + * Values for description table header signatures for tables defined in this > + * file. Useful because they make it more difficult to inadvertently type in > + * the wrong signature. > + */ > +#define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */ > +#define ACPI_SIG_DRTM "DRTM" /* Dynamic Root of Trust for Measurement table */ > +#define ACPI_SIG_FPDT "FPDT" /* Firmware Performance Data Table */ > +#define ACPI_SIG_GTDT "GTDT" /* Generic Timer Description Table */ > +#define ACPI_SIG_MPST "MPST" /* Memory Power State Table */ > +#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */ > +#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */ > +#define ACPI_SIG_RASF "RASF" /* RAS Feature table */ > + > +#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ > +#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ > + > +/* Reserved table signatures */ > + > +#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */ > +#define ACPI_SIG_DBG2 "DBG2" /* Debug Port table 2 */ > +#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */ > +#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ > +#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ > + > +/* > + * All tables must be byte-packed to match the ACPI specification, since > + * the tables are provided by the system BIOS. > + */ > +#pragma pack(1) > + > +/* > + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. > + * This is the only type that is even remotely portable. Anything else is not > + * portable, so do not use any other bitfield types. > + */ > + > + > +/******************************************************************************* > + * > + * BGRT - Boot Graphics Resource Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_bgrt > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + UINT16 Version; > + UINT8 Status; > + UINT8 ImageType; > + UINT64 ImageAddress; > + UINT32 ImageOffsetX; > + UINT32 ImageOffsetY; > + > +} ACPI_TABLE_BGRT; > + > + > +/******************************************************************************* > + * > + * DRTM - Dynamic Root of Trust for Measurement table > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_drtm > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + UINT64 EntryBaseAddress; > + UINT64 EntryLength; > + UINT32 EntryAddress32; > + UINT64 EntryAddress64; > + UINT64 ExitAddress; > + UINT64 LogAreaAddress; > + UINT32 LogAreaLength; > + UINT64 ArchDependentAddress; > + UINT32 Flags; > + > +} ACPI_TABLE_DRTM; > + > +/* 1) Validated Tables List */ > + > +typedef struct acpi_drtm_vtl_list > +{ > + UINT32 ValidatedTableListCount; > + > +} ACPI_DRTM_VTL_LIST; > + > +/* 2) Resources List */ > + > +typedef struct acpi_drtm_resource_list > +{ > + UINT32 ResourceListCount; > + > +} ACPI_DRTM_RESOURCE_LIST; > + > +/* 3) Platform-specific Identifiers List */ > + > +typedef struct acpi_drtm_id_list > +{ > + UINT32 IdListCount; > + > +} ACPI_DRTM_ID_LIST; > + > + > +/******************************************************************************* > + * > + * FPDT - Firmware Performance Data Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_fpdt > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + > +} ACPI_TABLE_FPDT; > + > + > +/* FPDT subtable header */ > + > +typedef struct acpi_fpdt_header > +{ > + UINT16 Type; > + UINT8 Length; > + UINT8 Revision; > + > +} ACPI_FPDT_HEADER; > + > +/* Values for Type field above */ > + > +enum AcpiFpdtType > +{ > + ACPI_FPDT_TYPE_BOOT = 0, > + ACPI_FPDT_TYPE_S3PERF = 1, > +}; > + > + > +/* > + * FPDT subtables > + */ > + > +/* 0: Firmware Basic Boot Performance Record */ > + > +typedef struct acpi_fpdt_boot > +{ > + ACPI_FPDT_HEADER Header; > + UINT8 Reserved[4]; > + UINT64 ResetEnd; > + UINT64 LoadStart; > + UINT64 StartupStart; > + UINT64 ExitServicesEntry; > + UINT64 ExitServicesExit; > + > +} ACPI_FPDT_BOOT; > + > + > +/* 1: S3 Performance Table Pointer Record */ > + > +typedef struct acpi_fpdt_s3pt_ptr > +{ > + ACPI_FPDT_HEADER Header; > + UINT8 Reserved[4]; > + UINT64 Address; > + > +} ACPI_FPDT_S3PT_PTR; > + > + > +/* > + * S3PT - S3 Performance Table. This table is pointed to by the > + * FPDT S3 Pointer Record above. > + */ > +typedef struct acpi_table_s3pt > +{ > + UINT8 Signature[4]; /* "S3PT" */ > + UINT32 Length; > + > +} ACPI_TABLE_S3PT; > + > + > +/* > + * S3PT Subtables > + */ > +typedef struct acpi_s3pt_header > +{ > + UINT16 Type; > + UINT8 Length; > + UINT8 Revision; > + > +} ACPI_S3PT_HEADER; > + > +/* Values for Type field above */ > + > +enum AcpiS3ptType > +{ > + ACPI_S3PT_TYPE_RESUME = 0, > + ACPI_S3PT_TYPE_SUSPEND = 1, > +}; > + > +typedef struct acpi_s3pt_resume > +{ > + ACPI_S3PT_HEADER Header; > + UINT32 ResumeCount; > + UINT64 FullResume; > + UINT64 AverageResume; > + > +} ACPI_S3PT_RESUME; > + > +typedef struct acpi_s3pt_suspend > +{ > + ACPI_S3PT_HEADER Header; > + UINT64 SuspendStart; > + UINT64 SuspendEnd; > + > +} ACPI_S3PT_SUSPEND; > + > + > +/******************************************************************************* > + * > + * GTDT - Generic Timer Description Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_gtdt > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + UINT64 Address; > + UINT32 Flags; > + UINT32 SecurePl1Interrupt; > + UINT32 SecurePl1Flags; > + UINT32 NonSecurePl1Interrupt; > + UINT32 NonSecurePl1Flags; > + UINT32 VirtualTimerInterrupt; > + UINT32 VirtualTimerFlags; > + UINT32 NonSecurePl2Interrupt; > + UINT32 NonSecurePl2Flags; > + > +} ACPI_TABLE_GTDT; > + > +/* Values for Flags field above */ > + > +#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 > + > +/* Values for all "TimerFlags" fields above */ > + > +#define ACPI_GTDT_INTERRUPT_MODE 1 > +#define ACPI_GTDT_INTERRUPT_POLARITY 2 > + > + > +/******************************************************************************* > + * > + * MPST - Memory Power State Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +#define ACPI_MPST_CHANNEL_INFO \ > + UINT16 Reserved1; \ > + UINT8 ChannelId; \ > + UINT8 Reserved2; \ > + UINT16 PowerNodeCount; > + > +/* Main table */ > + > +typedef struct acpi_table_mpst > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + ACPI_MPST_CHANNEL_INFO /* Platform Communication Channel */ > + > +} ACPI_TABLE_MPST; > + > + > +/* Memory Platform Communication Channel Info */ > + > +typedef struct acpi_mpst_channel > +{ > + ACPI_MPST_CHANNEL_INFO /* Platform Communication Channel */ > + > +} ACPI_MPST_CHANNEL; > + > + > +/* Memory Power Node Structure */ > + > +typedef struct acpi_mpst_power_node > +{ > + UINT8 Flags; > + UINT8 Reserved1; > + UINT16 NodeId; > + UINT32 Length; > + UINT64 RangeAddress; > + UINT64 RangeLength; > + UINT8 NumPowerStates; > + UINT8 NumPhysicalComponents; > + UINT16 Reserved2; > + > +} ACPI_MPST_POWER_NODE; > + > +/* Values for Flags field above */ > + > +#define ACPI_MPST_ENABLED 1 > +#define ACPI_MPST_POWER_MANAGED 2 > +#define ACPI_MPST_HOT_PLUG_CAPABLE 4 > + > + > +/* Memory Power State Structure (follows POWER_NODE above) */ > + > +typedef struct acpi_mpst_power_state > +{ > + UINT8 PowerState; > + UINT8 InfoIndex; > + > +} ACPI_MPST_POWER_STATE; > + > + > +/* Physical Component ID Structure (follows POWER_STATE above) */ > + > +typedef struct acpi_mpst_component > +{ > + UINT16 ComponentId; > + > +} ACPI_MPST_COMPONENT; > + > + > +/* Memory Power State Characteristics Structure (follows all POWER_NODEs) */ > + > +typedef struct acpi_mpst_data_hdr > +{ > + UINT16 CharacteristicsCount; > + > +} ACPI_MPST_DATA_HDR; > + > +typedef struct acpi_mpst_power_data > +{ > + UINT8 Revision; > + UINT8 Flags; > + UINT16 Reserved1; > + UINT32 AveragePower; > + UINT32 PowerSaving; > + UINT64 ExitLatency; > + UINT64 Reserved2; > + > +} ACPI_MPST_POWER_DATA; > + > +/* Values for Flags field above */ > + > +#define ACPI_MPST_PRESERVE 1 > +#define ACPI_MPST_AUTOENTRY 2 > +#define ACPI_MPST_AUTOEXIT 4 > + > + > +/* Shared Memory Region (not part of an ACPI table) */ > + > +typedef struct acpi_mpst_shared > +{ > + UINT32 Signature; > + UINT16 PccCommand; > + UINT16 PccStatus; > + UINT16 CommandRegister; > + UINT16 StatusRegister; > + UINT16 PowerStateId; > + UINT16 PowerNodeId; > + UINT64 EnergyConsumed; > + UINT64 AveragePower; > + > +} ACPI_MPST_SHARED; > + > + > +/******************************************************************************* > + * > + * PCCT - Platform Communications Channel Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_pcct > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + UINT32 Flags; > + UINT32 Latency; > + UINT32 Reserved; > + > +} ACPI_TABLE_PCCT; > + > +/* Values for Flags field above */ > + > +#define ACPI_PCCT_DOORBELL 1 > + > +/* > + * PCCT subtables > + */ > + > +/* 0: Generic Communications Subspace */ > + > +typedef struct acpi_pcct_subspace > +{ > + ACPI_SUBTABLE_HEADER Header; > + UINT8 Reserved[6]; > + UINT64 BaseAddress; > + UINT64 Length; > + ACPI_GENERIC_ADDRESS DoorbellRegister; > + UINT64 PreserveMask; > + UINT64 WriteMask; > + > +} ACPI_PCCT_SUBSPACE; > + > + > +/* > + * PCC memory structures (not part of the ACPI table) > + */ > + > +/* Shared Memory Region */ > + > +typedef struct acpi_pcct_shared_memory > +{ > + UINT32 Signature; > + UINT16 Command; > + UINT16 Status; > + > +} ACPI_PCCT_SHARED_MEMORY; > + > + > +/******************************************************************************* > + * > + * PMTT - Platform Memory Topology Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_pmtt > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + UINT32 Reserved; > + > +} ACPI_TABLE_PMTT; > + > + > +/* Common header for PMTT subtables that follow main table */ > + > +typedef struct acpi_pmtt_header > +{ > + UINT8 Type; > + UINT8 Reserved1; > + UINT16 Length; > + UINT16 Flags; > + UINT16 Reserved2; > + > +} ACPI_PMTT_HEADER; > + > +/* Values for Type field above */ > + > +#define ACPI_PMTT_TYPE_SOCKET 0 > +#define ACPI_PMTT_TYPE_CONTROLLER 1 > +#define ACPI_PMTT_TYPE_DIMM 2 > +#define ACPI_PMTT_TYPE_RESERVED 3 /* 0x03-0xFF are reserved */ > + > +/* Values for Flags field above */ > + > +#define ACPI_PMTT_TOP_LEVEL 0x0001 > +#define ACPI_PMTT_PHYSICAL 0x0002 > +#define ACPI_PMTT_MEMORY_TYPE 0x000C > + > + > +/* > + * PMTT subtables, correspond to Type in acpi_pmtt_header > + */ > + > + > +/* 0: Socket Structure */ > + > +typedef struct acpi_pmtt_socket > +{ > + ACPI_PMTT_HEADER Header; > + UINT16 SocketId; > + UINT16 Reserved; > + > +} ACPI_PMTT_SOCKET; > + > + > +/* 1: Memory Controller subtable */ > + > +typedef struct acpi_pmtt_controller > +{ > + ACPI_PMTT_HEADER Header; > + UINT32 ReadLatency; > + UINT32 WriteLatency; > + UINT32 ReadBandwidth; > + UINT32 WriteBandwidth; > + UINT16 AccessWidth; > + UINT16 Alignment; > + UINT16 Reserved; > + UINT16 DomainCount; > + > +} ACPI_PMTT_CONTROLLER; > + > +/* 1a: Proximity Domain substructure */ > + > +typedef struct acpi_pmtt_domain > +{ > + UINT32 ProximityDomain; > + > +} ACPI_PMTT_DOMAIN; > + > + > +/* 2: Physical Component Identifier (DIMM) */ > + > +typedef struct acpi_pmtt_physical_component > +{ > + ACPI_PMTT_HEADER Header; > + UINT16 ComponentId; > + UINT16 Reserved; > + UINT32 MemorySize; > + UINT32 BiosHandle; > + > +} ACPI_PMTT_PHYSICAL_COMPONENT; > + > + > +/******************************************************************************* > + * > + * RASF - RAS Feature Table (ACPI 5.0) > + * Version 1 > + * > + ******************************************************************************/ > + > +typedef struct acpi_table_rasf > +{ > + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ > + UINT8 ChannelId[12]; > + > +} ACPI_TABLE_RASF; > + > +/* RASF Platform Communication Channel Shared Memory Region */ > + > +typedef struct acpi_rasf_shared_memory > +{ > + UINT32 Signature; > + UINT16 Command; > + UINT16 Status; > + UINT64 RequestedAddress; > + UINT64 RequestedLength; > + UINT64 ActualAddress; > + UINT64 ActualLength; > + UINT16 Flags; > + UINT8 Speed; > + > +} ACPI_RASF_SHARED_MEMORY; > + > +/* Masks for Flags and Speed fields above */ > + > +#define ACPI_RASF_SCRUBBER_RUNNING 1 > +#define ACPI_RASF_SPEED (7<<1) > + > +/* Channel Commands */ > + > +enum AcpiRasfCommands > +{ > + ACPI_RASF_GET_RAS_CAPABILITIES = 1, > + ACPI_RASF_GET_PATROL_PARAMETERS = 2, > + ACPI_RASF_START_PATROL_SCRUBBER = 3, > + ACPI_RASF_STOP_PATROL_SCRUBBER = 4 > +}; > + > +/* Channel Command flags */ > + > +#define ACPI_RASF_GENERATE_SCI (1<<15) > + > +/* Status values */ > + > +enum AcpiRasfStatus > +{ > + ACPI_RASF_SUCCESS = 0, > + ACPI_RASF_NOT_VALID = 1, > + ACPI_RASF_NOT_SUPPORTED = 2, > + ACPI_RASF_BUSY = 3, > + ACPI_RASF_FAILED = 4, > + ACPI_RASF_ABORTED = 5, > + ACPI_RASF_INVALID_DATA = 6 > +}; > + > +/* Status flags */ > + > +#define ACPI_RASF_COMMAND_COMPLETE (1) > +#define ACPI_RASF_SCI_DOORBELL (1<<1) > +#define ACPI_RASF_ERROR (1<<2) > +#define ACPI_RASF_STATUS (0x1F<<3) > + > + > +/* Reset to default packing */ > + > +#pragma pack() > + > +#endif /* __ACTBL3_H__ */ > -- > 1.7.9.5 > Acked-by: Keng-Yu Lin <kengyu@canonical.com>
On 04/12/2012 07:50 AM, Colin King wrote: > From: Colin Ian King<colin.king@canonical.com> > > Signed-off-by: Colin Ian King<colin.king@canonical.com> > --- Acked-by: Alex Hung <alex.hung@canonical.com>
diff --git a/src/acpica/source/compiler/aslrestype2s.c b/src/acpica/source/compiler/aslrestype2s.c new file mode 100644 index 0000000..a9d24cd --- /dev/null +++ b/src/acpica/source/compiler/aslrestype2s.c @@ -0,0 +1,1259 @@ +/****************************************************************************** + * + * Module Name: aslrestype2s - Serial Large resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "aslcompiler.h" +#include "aslcompiler.y.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("aslrestype2s") + + +static UINT16 +RsGetBufferDataLength ( + ACPI_PARSE_OBJECT *InitializerOp); + +static UINT16 +RsGetInterruptDataLength ( + ACPI_PARSE_OBJECT *InitializerOp); + +static BOOLEAN +RsGetVendorData ( + ACPI_PARSE_OBJECT *InitializerOp, + UINT8 *VendorData, + ACPI_SIZE DescriptorOffset); + +/* + * This module contains descriptors for serial buses and GPIO: + * + * GpioInt + * GpioIo + * I2cSerialBus + * SpiSerialBus + * UartSerialBus + */ + + +/******************************************************************************* + * + * FUNCTION: RsGetBufferDataLength + * + * PARAMETERS: InitializerOp - Current parse op, start of the resource + * descriptor + * + * RETURN: Length of the data buffer + * + * DESCRIPTION: Get the length of a RawDataBuffer, used for vendor data. + * + ******************************************************************************/ + +static UINT16 +RsGetBufferDataLength ( + ACPI_PARSE_OBJECT *InitializerOp) +{ + UINT16 ExtraDataSize = 0; + ACPI_PARSE_OBJECT *DataList; + + + /* Find the byte-initializer list */ + + while (InitializerOp) + { + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DATABUFFER) + { + /* First child is the optional length (ignore it here) */ + + DataList = InitializerOp->Asl.Child; + DataList = ASL_GET_PEER_NODE (DataList); + + /* Count the data items (each one is a byte of data) */ + + while (DataList) + { + ExtraDataSize++; + DataList = ASL_GET_PEER_NODE (DataList); + } + + return (ExtraDataSize); + } + + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); + } + + return (ExtraDataSize); +} + + +/******************************************************************************* + * + * FUNCTION: RsGetInterruptDataLength + * + * PARAMETERS: InitializerOp - Current parse op, start of the resource + * descriptor + * + * RETURN: Length of the interrupt data list + * + * DESCRIPTION: Get the length of a list of interrupt DWORDs for the GPIO + * descriptors. + * + ******************************************************************************/ + +static UINT16 +RsGetInterruptDataLength ( + ACPI_PARSE_OBJECT *InitializerOp) +{ + UINT16 InterruptLength; + UINT32 i; + + + /* Count the interrupt numbers */ + + InterruptLength = 0; + for (i = 0; InitializerOp; i++) + { + InitializerOp = ASL_GET_PEER_NODE (InitializerOp); + + /* Interrupt list starts at offset 10 (Gpio descriptors) */ + + if (i >= 10) + { + InterruptLength += 2; + } + } + + return (InterruptLength); +} + + +/******************************************************************************* + * + * FUNCTION: RsGetVendorData + * + * PARAMETERS: InitializerOp - Current parse op, start of the resource + * descriptor. + * VendorData - Where the vendor data is returned + * DescriptorOffset - Where vendor data begins in descriptor + * + * RETURN: TRUE if valid vendor data was returned, FALSE otherwise. + * + * DESCRIPTION: Extract the vendor data and construct a vendor data buffer. + * + ******************************************************************************/ + +static BOOLEAN +RsGetVendorData ( + ACPI_PARSE_OBJECT *InitializerOp, + UINT8 *VendorData, + ACPI_SIZE DescriptorOffset) +{ + ACPI_PARSE_OBJECT *BufferOp; + UINT32 SpecifiedLength = ACPI_UINT32_MAX; + UINT16 ActualLength = 0; + + + /* Vendor Data field is always optional */ + + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + return (FALSE); + } + + BufferOp = InitializerOp->Asl.Child; + if (!BufferOp) + { + AslError (ASL_ERROR, ASL_MSG_SYNTAX, InitializerOp, ""); + return (FALSE); + } + + /* First child is the optional buffer length (WORD) */ + + if (BufferOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + SpecifiedLength = (UINT16) BufferOp->Asl.Value.Integer; + } + + /* Insert field tag _VEN */ + + RsCreateByteField (InitializerOp, ACPI_RESTAG_VENDORDATA, + (UINT16) DescriptorOffset); + + /* Walk the list of buffer initializers (each is one byte) */ + + BufferOp = RsCompleteNodeAndGetNext (BufferOp); + if (BufferOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + while (BufferOp) + { + *VendorData = (UINT8) BufferOp->Asl.Value.Integer; + VendorData++; + ActualLength++; + BufferOp = RsCompleteNodeAndGetNext (BufferOp); + } + } + + /* Length validation. Buffer cannot be of zero length */ + + if ((SpecifiedLength == 0) || + ((SpecifiedLength == ACPI_UINT32_MAX) && (ActualLength == 0))) + { + AslError (ASL_ERROR, ASL_MSG_BUFFER_LENGTH, InitializerOp, NULL); + return (FALSE); + } + + if (SpecifiedLength != ACPI_UINT32_MAX) + { + /* ActualLength > SpecifiedLength -> error */ + + if (ActualLength > SpecifiedLength) + { + AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH_LONG, InitializerOp, NULL); + return (FALSE); + } + + /* ActualLength < SpecifiedLength -> remark */ + + else if (ActualLength < SpecifiedLength) + { + AslError (ASL_REMARK, ASL_MSG_LIST_LENGTH_SHORT, InitializerOp, NULL); + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoGpioIntDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "GpioInt" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoGpioIntDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + char *ResourceSource = NULL; + UINT8 *VendorData = NULL; + UINT16 *InterruptList = NULL; + UINT16 ResSourceLength; + UINT16 VendorLength; + UINT16 InterruptLength; + UINT16 DescriptorSize; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + + /* + * Calculate lengths for fields that have variable length: + * 1) Resource Source string + * 2) Vendor Data buffer + * 3) PIN (interrupt) list + */ + ResSourceLength = RsGetStringDataLength (InitializerOp); + VendorLength = RsGetBufferDataLength (InitializerOp); + InterruptLength = RsGetInterruptDataLength (InitializerOp); + + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) + + ResSourceLength + VendorLength + InterruptLength; + + /* Allocate the local resource node and initialize */ + + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + + Descriptor = Rnode->Buffer; + Descriptor->Gpio.ResourceLength = DescriptorSize; + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT; + + /* Build pointers to optional areas */ + + InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); + VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); + + /* Setup offsets within the descriptor */ + + Descriptor->Gpio.PinTableOffset = (UINT16) + ACPI_PTR_DIFF (InterruptList, Descriptor); + + Descriptor->Gpio.ResSourceOffset = (UINT16) + ACPI_PTR_DIFF (ResourceSource, Descriptor); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", + "GpioInt", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), + ResSourceLength, VendorLength, InterruptLength); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Interrupt Mode - edge/level [Flag] (_MOD) */ + + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0); + break; + + case 1: /* Interrupt Polarity - Active high/low [Flags] (_POL) */ + + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 1, 0); + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_POLARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 1, 2); + break; + + case 2: /* Share Type - Default: exclusive (0) [Flags] (_SHR) */ + + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0); + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3, 2); + break; + + case 3: /* Pin Config [BYTE] (_PPI) */ + + Descriptor->Gpio.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig)); + break; + + case 4: /* Debounce Timeout [WORD] (_DBT) */ + + Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout)); + break; + + case 5: /* ResSource [Optional Field - STRING] */ + + if (ResSourceLength) + { + /* Copy string to the descriptor */ + + strcpy (ResourceSource, + InitializerOp->Asl.Value.String); + } + break; + + case 6: /* Resource Index */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + } + break; + + case 7: /* Resource Usage (consumer/producer) */ + + RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1); + break; + + case 8: /* Resource Tag (Descriptor Name) */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + + /* + * Always set the VendorOffset even if there is no Vendor Data. + * This field is required in order to calculate the length + * of the ResourceSource at runtime. + */ + Descriptor->Gpio.VendorOffset = (UINT16) + ACPI_PTR_DIFF (VendorData, Descriptor); + + if (RsGetVendorData (InitializerOp, VendorData, + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + { + Descriptor->Gpio.VendorLength = VendorLength; + } + break; + + default: + /* + * PINs come through here, repeatedly. Each PIN must be a DWORD. + * NOTE: there is no "length" field for this, so from ACPI spec: + * The number of pins in the table can be calculated from: + * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 + * (implies resource source must immediately follow the pin list.) + * Name: _PIN + */ + *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; + InterruptList++; + + /* Case 10: First interrupt number in list */ + + if (i == 10) + { + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + /* Must be at least one interrupt */ + + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN, + InitializerOp, NULL); + } + + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + + RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, + CurrentByteOffset + Descriptor->Gpio.PinTableOffset); + } + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoGpioIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "GpioIo" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoGpioIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + char *ResourceSource = NULL; + UINT8 *VendorData = NULL; + UINT16 *InterruptList = NULL; + UINT16 ResSourceLength; + UINT16 VendorLength; + UINT16 InterruptLength; + UINT16 DescriptorSize; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + + /* + * Calculate lengths for fields that have variable length: + * 1) Resource Source string + * 2) Vendor Data buffer + * 3) PIN (interrupt) list + */ + ResSourceLength = RsGetStringDataLength (InitializerOp); + VendorLength = RsGetBufferDataLength (InitializerOp); + InterruptLength = RsGetInterruptDataLength (InitializerOp); + + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_GPIO) + + ResSourceLength + VendorLength + InterruptLength; + + /* Allocate the local resource node and initialize */ + + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + + Descriptor = Rnode->Buffer; + Descriptor->Gpio.ResourceLength = DescriptorSize; + Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO; + Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION; + Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO; + + /* Build pointers to optional areas */ + + InterruptList = ACPI_ADD_PTR (UINT16, Descriptor, sizeof (AML_RESOURCE_GPIO)); + ResourceSource = ACPI_ADD_PTR (char, InterruptList, InterruptLength); + VendorData = ACPI_ADD_PTR (UINT8, ResourceSource, ResSourceLength); + + /* Setup offsets within the descriptor */ + + Descriptor->Gpio.PinTableOffset = (UINT16) + ACPI_PTR_DIFF (InterruptList, Descriptor); + + Descriptor->Gpio.ResSourceOffset = (UINT16) + ACPI_PTR_DIFF (ResourceSource, Descriptor); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n", + "GpioIo", Descriptor->Gpio.ResourceLength, (UINT16) sizeof (AML_RESOURCE_GPIO), + ResSourceLength, VendorLength, InterruptLength); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Share Type [Flags] (_SHR) */ + + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3); + break; + + case 1: /* Pin Config [BYTE] (_PPI) */ + + Descriptor->Gpio.PinConfig = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_PINCONFIG, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig)); + break; + + case 2: /* Debounce Timeout [WORD] (_DBT) */ + + Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout)); + break; + + case 3: /* Drive Strength [WORD] (_DRS) */ + + Descriptor->Gpio.DriveStrength = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_DRIVESTRENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DriveStrength)); + break; + + case 4: /* I/O Restriction [Flag] (_IOR) */ + + RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0); + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_IORESTRICTION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0, 2); + break; + + case 5: /* ResSource [Optional Field - STRING] */ + + if (ResSourceLength) + { + /* Copy string to the descriptor */ + + strcpy (ResourceSource, + InitializerOp->Asl.Value.String); + } + break; + + case 6: /* Resource Index */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + Descriptor->Gpio.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + } + break; + + case 7: /* Resource Usage (consumer/producer) */ + + RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1); + break; + + case 8: /* Resource Tag (Descriptor Name) */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 9: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + + /* + * Always set the VendorOffset even if there is no Vendor Data. + * This field is required in order to calculate the length + * of the ResourceSource at runtime. + */ + Descriptor->Gpio.VendorOffset = (UINT16) + ACPI_PTR_DIFF (VendorData, Descriptor); + + if (RsGetVendorData (InitializerOp, VendorData, + (CurrentByteOffset + Descriptor->Gpio.VendorOffset))) + { + Descriptor->Gpio.VendorLength = VendorLength; + } + break; + + default: + /* + * PINs come through here, repeatedly. Each PIN must be a DWORD. + * NOTE: there is no "length" field for this, so from ACPI spec: + * The number of pins in the table can be calculated from: + * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 + * (implies resource source must immediately follow the pin list.) + * Name: _PIN + */ + *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer; + InterruptList++; + + /* Case 10: First interrupt number in list */ + + if (i == 10) + { + if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + /* Must be at least one interrupt */ + + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN, + InitializerOp, NULL); + } + + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + + RsCreateDwordField (InitializerOp, ACPI_RESTAG_PIN, + CurrentByteOffset + Descriptor->Gpio.PinTableOffset); + } + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoI2cSerialBusDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "I2cSerialBus" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoI2cSerialBusDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + char *ResourceSource = NULL; + UINT8 *VendorData = NULL; + UINT16 ResSourceLength; + UINT16 VendorLength; + UINT16 DescriptorSize; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + + /* + * Calculate lengths for fields that have variable length: + * 1) Resource Source string + * 2) Vendor Data buffer + */ + ResSourceLength = RsGetStringDataLength (InitializerOp); + VendorLength = RsGetBufferDataLength (InitializerOp); + + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_I2C_SERIALBUS) + + ResSourceLength + VendorLength; + + /* Allocate the local resource node and initialize */ + + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + + Descriptor = Rnode->Buffer; + Descriptor->I2cSerialBus.ResourceLength = DescriptorSize; + Descriptor->I2cSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; + Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION; + Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION; + Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE; + Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength; + + /* Build pointers to optional areas */ + + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_I2C_SERIALBUS)); + ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", + "I2cSerialBus", Descriptor->I2cSerialBus.ResourceLength, + (UINT16) sizeof (AML_RESOURCE_I2C_SERIALBUS), ResSourceLength, + VendorLength, Descriptor->I2cSerialBus.TypeDataLength); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Slave Address [WORD] (_ADR) */ + + Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS, + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress)); + break; + + case 1: /* Slave Mode [Flag] (_SLV) */ + + RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 0, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 0); + break; + + case 2: /* Connection Speed [DWORD] (_SPE) */ + + Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED, + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed)); + break; + + case 3: /* Addressing Mode [Flag] (_MOD) */ + + RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0); + break; + + case 4: /* ResSource [Optional Field - STRING] */ + + if (ResSourceLength) + { + /* Copy string to the descriptor */ + + strcpy (ResourceSource, + InitializerOp->Asl.Value.String); + } + break; + + case 5: /* Resource Index */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + Descriptor->I2cSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + } + break; + + case 6: /* Resource Usage (consumer/producer) */ + + RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 1, 1); + break; + + case 7: /* Resource Tag (Descriptor Name) */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + + RsGetVendorData (InitializerOp, VendorData, + CurrentByteOffset + sizeof (AML_RESOURCE_I2C_SERIALBUS)); + break; + + default: /* Ignore any extra nodes */ + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoSpiSerialBusDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "SPI Serial Bus" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoSpiSerialBusDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + char *ResourceSource = NULL; + UINT8 *VendorData = NULL; + UINT16 ResSourceLength; + UINT16 VendorLength; + UINT16 DescriptorSize; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + + /* + * Calculate lengths for fields that have variable length: + * 1) Resource Source string + * 2) Vendor Data buffer + */ + ResSourceLength = RsGetStringDataLength (InitializerOp); + VendorLength = RsGetBufferDataLength (InitializerOp); + + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_SPI_SERIALBUS) + + ResSourceLength + VendorLength; + + /* Allocate the local resource node and initialize */ + + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + + Descriptor = Rnode->Buffer; + Descriptor->SpiSerialBus.ResourceLength = DescriptorSize; + Descriptor->SpiSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; + Descriptor->SpiSerialBus.RevisionId = AML_RESOURCE_SPI_REVISION; + Descriptor->SpiSerialBus.TypeRevisionId = AML_RESOURCE_SPI_TYPE_REVISION; + Descriptor->SpiSerialBus.Type = AML_RESOURCE_SPI_SERIALBUSTYPE; + Descriptor->SpiSerialBus.TypeDataLength = AML_RESOURCE_SPI_MIN_DATA_LEN + VendorLength; + + /* Build pointers to optional areas */ + + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_SPI_SERIALBUS)); + ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", + "SpiSerialBus", Descriptor->SpiSerialBus.ResourceLength, + (UINT16) sizeof (AML_RESOURCE_SPI_SERIALBUS), ResSourceLength, + VendorLength, Descriptor->SpiSerialBus.TypeDataLength); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Device Selection [WORD] (_ADR) */ + + Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection)); + break; + + case 1: /* Device Polarity [Flag] (_DPL) */ + + RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1); + break; + + case 2: /* Wire Mode [Flag] (_MOD) */ + + RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0); + break; + + case 3: /* Device Bit Length [BYTE] (_LEN) */ + + Descriptor->SpiSerialBus.DataBitLength = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DataBitLength)); + break; + + case 4: /* Slave Mode [Flag] (_SLV) */ + + RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 0, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 0); + break; + + case 5: /* Connection Speed [DWORD] (_SPE) */ + + Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed)); + break; + + case 6: /* Clock Polarity [BYTE] (_POL) */ + + Descriptor->SpiSerialBus.ClockPolarity = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_POLARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPolarity)); + break; + + case 7: /* Clock Phase [BYTE] (_PHA) */ + + Descriptor->SpiSerialBus.ClockPhase = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_PHASE, + CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ClockPhase)); + break; + + case 8: /* ResSource [Optional Field - STRING] */ + + if (ResSourceLength) + { + /* Copy string to the descriptor */ + + strcpy (ResourceSource, + InitializerOp->Asl.Value.String); + } + break; + + case 9: /* Resource Index */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + Descriptor->SpiSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + } + break; + + case 10: /* Resource Usage (consumer/producer) */ + + RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 1, 1); + break; + + case 11: /* Resource Tag (Descriptor Name) */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + + RsGetVendorData (InitializerOp, VendorData, + CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS)); + break; + + default: /* Ignore any extra nodes */ + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoUartSerialBusDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "UART Serial Bus" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoUartSerialBusDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + char *ResourceSource = NULL; + UINT8 *VendorData = NULL; + UINT16 ResSourceLength; + UINT16 VendorLength; + UINT16 DescriptorSize; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + + /* + * Calculate lengths for fields that have variable length: + * 1) Resource Source string + * 2) Vendor Data buffer + */ + ResSourceLength = RsGetStringDataLength (InitializerOp); + VendorLength = RsGetBufferDataLength (InitializerOp); + + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_UART_SERIALBUS) + + ResSourceLength + VendorLength; + + /* Allocate the local resource node and initialize */ + + Rnode = RsAllocateResourceNode (DescriptorSize + sizeof (AML_RESOURCE_LARGE_HEADER)); + + Descriptor = Rnode->Buffer; + Descriptor->UartSerialBus.ResourceLength = DescriptorSize; + Descriptor->UartSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS; + Descriptor->UartSerialBus.RevisionId = AML_RESOURCE_UART_REVISION; + Descriptor->UartSerialBus.TypeRevisionId = AML_RESOURCE_UART_TYPE_REVISION; + Descriptor->UartSerialBus.Type = AML_RESOURCE_UART_SERIALBUSTYPE; + Descriptor->UartSerialBus.TypeDataLength = AML_RESOURCE_UART_MIN_DATA_LEN + VendorLength; + + /* Build pointers to optional areas */ + + VendorData = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_UART_SERIALBUS)); + ResourceSource = ACPI_ADD_PTR (char, VendorData, VendorLength); + + DbgPrint (ASL_DEBUG_OUTPUT, + "%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n", + "UartSerialBus", Descriptor->UartSerialBus.ResourceLength, + (UINT16) sizeof (AML_RESOURCE_UART_SERIALBUS), ResSourceLength, + VendorLength, Descriptor->UartSerialBus.TypeDataLength); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */ + + Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate)); + break; + + case 1: /* Bits Per Byte [Flags] (_LEN) */ + + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3); + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3); + break; + + case 2: /* Stop Bits [Flags] (_STB) */ + + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1); + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2); + break; + + case 3: /* Lines In Use [BYTE] (_LIN) */ + + Descriptor->UartSerialBus.LinesEnabled = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_LINE, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.LinesEnabled)); + break; + + case 4: /* Endianness [Flag] (_END) */ + + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0); + RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7); + break; + + case 5: /* Parity [BYTE] (_PAR) */ + + Descriptor->UartSerialBus.Parity = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ACPI_RESTAG_PARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Parity)); + break; + + case 6: /* Flow Control [Flags] (_FLC) */ + + RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0); + RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2); + break; + + case 7: /* Rx Buffer Size [WORD] (_RXL) */ + + Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize)); + break; + + case 8: /* Tx Buffer Size [WORD] (_TXL) */ + + Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize)); + break; + + case 9: /* ResSource [Optional Field - STRING] */ + + if (ResSourceLength) + { + /* Copy string to the descriptor */ + + strcpy (ResourceSource, + InitializerOp->Asl.Value.String); + } + break; + + case 10: /* Resource Index */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + Descriptor->UartSerialBus.ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + } + break; + + case 11: /* Resource Usage (consumer/producer) */ + + RsSetFlagBits (&Descriptor->UartSerialBus.Flags, InitializerOp, 1, 1); + + /* + * Slave Mode [Flag] (_SLV) + * + * Note: There is no SlaveMode argument to the UartSerialBus macro, but + * we add this name anyway to allow the flag to be set by ASL in the + * rare case where there is a slave mode associated with the UART. + */ + RsCreateBitField (InitializerOp, ACPI_RESTAG_SLAVEMODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 0); + break; + + case 12: /* Resource Tag (Descriptor Name) */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */ + + RsGetVendorData (InitializerOp, VendorData, + CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS)); + break; + + default: /* Ignore any extra nodes */ + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + return (Rnode); +} diff --git a/src/acpica/source/compiler/aslsupport.l b/src/acpica/source/compiler/aslsupport.l new file mode 100644 index 0000000..cdaf2b8 --- /dev/null +++ b/src/acpica/source/compiler/aslsupport.l @@ -0,0 +1,854 @@ + +/****************************************************************************** + * + * Module Name: aslsupport.l - Flex/lex scanner C support routines. + * NOTE: Included into aslcompile.l, not compiled by itself. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* Configuration */ + +#define ASL_SPACES_PER_TAB 4 + +#define ASL_NORMAL_CHAR 0 +#define ASL_ESCAPE_SEQUENCE 1 +#define ASL_OCTAL_CONSTANT 2 +#define ASL_HEX_CONSTANT 3 + + +/* File node - used for "Include" operator file stack */ + +typedef struct asl_file_node +{ + FILE *File; + UINT32 CurrentLineNumber; + YY_BUFFER_STATE State; + char *Filename; + struct asl_file_node *Next; + +} ASL_FILE_NODE; + +/* File stack for the "Include" operator (NOT #include operator) */ + +ASL_FILE_NODE *Gbl_IncludeFileStack = NULL; + + +/******************************************************************************* + * + * FUNCTION: AslDoLineDirective + * + * PARAMETERS: None. Uses input() to access current source code line + * + * RETURN: Updates global line number and filename + * + * DESCRIPTION: Handle #line directives emitted by the preprocessor. + * + * The #line directive is emitted by the preprocesser, and is used to + * pass through line numbers from the original source code file to the + * preprocessor output file (.i). This allows any compiler-generated + * error messages to be displayed with the correct line number. + * + ******************************************************************************/ + +static void +AslDoLineDirective ( + void) +{ + char c; + char *Token; + UINT32 LineNumber; + char *Filename; + + + /* Eat the entire line that contains the #line directive */ + + while ((c = (char) input()) != '\n' && c != EOF) + { + AslInsertLineBuffer (c); + } + AslInsertLineBuffer (0); + + /* First argument is the actual line number */ + + Token = strtok (Gbl_CurrentLineBuffer, " "); + if (!Token) + { + goto ResetAndExit; + } + + /* Convert line number. Subtract one to handle _this_ line */ + + LineNumber = (UINT32) UtDoConstant (Token); + FlSetLineNumber (LineNumber - 1); + + /* Second argument is the optional filename (in double quotes) */ + + Token = strtok (NULL, " \""); + if (Token) + { + Filename = ACPI_ALLOCATE_ZEROED (strlen (Token) + 1); + strcpy (Filename, Token); + FlSetFilename (Filename); + } + + /* Third argument is not supported at this time */ + +ResetAndExit: + AslResetCurrentLineBuffer (); +} + + +/******************************************************************************* + * + * FUNCTION: AslPopInputFileStack + * + * PARAMETERS: None + * + * RETURN: 0 if a node was popped, -1 otherwise + * + * DESCRIPTION: Pop the top of the input file stack and point the parser to + * the saved parse buffer contained in the fnode. Also, set the + * global line counters to the saved values. This function is + * called when an include file reaches EOF. + * + ******************************************************************************/ + +int +AslPopInputFileStack ( + void) +{ + ASL_FILE_NODE *Fnode; + + + Fnode = Gbl_IncludeFileStack; + DbgPrint (ASL_PARSE_OUTPUT, "\nPop InputFile Stack, Fnode %p\n\n", Fnode); + + if (!Fnode) + { + return (-1); + } + + /* Close the current include file */ + + fclose (yyin); + + /* Update the top-of-stack */ + + Gbl_IncludeFileStack = Fnode->Next; + + /* Reset global line counter and filename */ + + Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; + Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; + + /* Point the parser to the popped file */ + + yy_delete_buffer (YY_CURRENT_BUFFER); + yy_switch_to_buffer (Fnode->State); + + /* All done with this node */ + + ACPI_FREE (Fnode); + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AslPushInputFileStack + * + * PARAMETERS: InputFile - Open file pointer + * Filename - Name of the file + * + * RETURN: None + * + * DESCRIPTION: Push the InputFile onto the file stack, and point the parser + * to this file. Called when an include file is successfully + * opened. + * + ******************************************************************************/ + +void +AslPushInputFileStack ( + FILE *InputFile, + char *Filename) +{ + ASL_FILE_NODE *Fnode; + YY_BUFFER_STATE State; + + + /* Save the current state in an Fnode */ + + Fnode = UtLocalCalloc (sizeof (ASL_FILE_NODE)); + + Fnode->File = yyin; + Fnode->Next = Gbl_IncludeFileStack; + Fnode->State = YY_CURRENT_BUFFER; + Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; + Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; + + /* Push it on the stack */ + + Gbl_IncludeFileStack = Fnode; + + /* Point the parser to this file */ + + State = yy_create_buffer (InputFile, YY_BUF_SIZE); + yy_switch_to_buffer (State); + + DbgPrint (ASL_PARSE_OUTPUT, "\nPush InputFile Stack, returning %p\n\n", InputFile); + + /* Reset the global line count and filename */ + + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_CurrentLineNumber = 1; + yyin = InputFile; +} + + +/******************************************************************************* + * + * FUNCTION: AslResetCurrentLineBuffer + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Reset the Line Buffer to zero, increment global line numbers. + * + ******************************************************************************/ + +void +AslResetCurrentLineBuffer ( + void) +{ + + if (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle) + { + FlWriteFile (ASL_FILE_SOURCE_OUTPUT, Gbl_CurrentLineBuffer, + Gbl_LineBufPtr - Gbl_CurrentLineBuffer); + } + + Gbl_CurrentLineOffset += Gbl_CurrentColumn; + Gbl_CurrentColumn = 0; + + Gbl_CurrentLineNumber++; + Gbl_LogicalLineNumber++; + Gbl_LineBufPtr = Gbl_CurrentLineBuffer; +} + + +/******************************************************************************* + * + * FUNCTION: AslInsertLineBuffer + * + * PARAMETERS: SourceChar - One char from the input ASL source file + * + * RETURN: None + * + * DESCRIPTION: Put one character of the source file into the temp line buffer + * + ******************************************************************************/ + +void +AslInsertLineBuffer ( + int SourceChar) +{ + UINT32 i; + UINT32 Count = 1; + + + if (SourceChar == EOF) + { + return; + } + + Gbl_InputByteCount++; + + /* Handle tabs. Convert to spaces */ + + if (SourceChar == '\t') + { + SourceChar = ' '; + Count = ASL_SPACES_PER_TAB - + (Gbl_CurrentColumn & (ASL_SPACES_PER_TAB-1)); + } + + for (i = 0; i < Count; i++) + { + Gbl_CurrentColumn++; + + /* Insert the character into the line buffer */ + + *Gbl_LineBufPtr = (UINT8) SourceChar; + Gbl_LineBufPtr++; + + if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1))) + { +#if 0 + /* + * Warning if we have split a long source line. + * <Probably overkill> + */ + sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE); + AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, MsgBuffer); +#endif + + AslResetCurrentLineBuffer (); + } + else if (SourceChar == '\n') + { + /* End of line */ + + AslResetCurrentLineBuffer (); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: count + * + * PARAMETERS: yytext - Contains the matched keyword. + * Type - Keyword/Character type: + * 0 = anything except a keyword + * 1 = pseudo-keywords + * 2 = non-executable ASL keywords + * 3 = executable ASL keywords + * + * RETURN: None + * + * DESCRIPTION: Count keywords and put them into the line buffer + * + ******************************************************************************/ + +static void +count ( + int Type) +{ + int i; + + + switch (Type) + { + case 2: + TotalKeywords++; + TotalNamedObjects++; + break; + + case 3: + TotalKeywords++; + TotalExecutableOpcodes++; + break; + } + + for (i = 0; (yytext[i] != 0) && (yytext[i] != EOF); i++) + { + AslInsertLineBuffer (yytext[i]); + *Gbl_LineBufPtr = 0; + } +} + + +/******************************************************************************* + * + * FUNCTION: AslDoComment + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a standard comment. + * + ******************************************************************************/ + +static char +AslDoComment ( + void) +{ + char c; + char c1 = 0; + + + AslInsertLineBuffer ('/'); + AslInsertLineBuffer ('*'); + +loop: + + /* Eat chars until end-of-comment */ + + while ((c = (char) input()) != '*' && c != EOF) + { + AslInsertLineBuffer (c); + c1 = c; + } + + if (c == EOF) + { + goto EarlyEOF; + } + + /* + * Check for nested comment -- can help catch cases where a previous + * comment was accidently left unterminated + */ + if ((c1 == '/') && (c == '*')) + { + AslCommonError (ASL_WARNING, ASL_MSG_NESTED_COMMENT, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_InputByteCount, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + } + + /* Comment is closed only if the NEXT character is a slash */ + + AslInsertLineBuffer (c); + + if ((c1 = (char) input()) != '/' && c1 != EOF) + { + unput(c1); + goto loop; + } + + if (c1 == EOF) + { + goto EarlyEOF; + } + + AslInsertLineBuffer (c1); + return (TRUE); + + +EarlyEOF: + /* + * Premature End-Of-File + */ + AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AslDoCommentType2 + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a new "//" comment. + * + ******************************************************************************/ + +static char +AslDoCommentType2 ( + void) +{ + char c; + + + AslInsertLineBuffer ('/'); + AslInsertLineBuffer ('/'); + + while ((c = (char) input()) != '\n' && c != EOF) + { + AslInsertLineBuffer (c); + } + + if (c == EOF) + { + /* End of file is OK, change to newline. Let parser detect EOF later */ + + c = '\n'; + } + + AslInsertLineBuffer (c); + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AslDoStringLiteral + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Process a string literal (surrounded by quotes) + * + ******************************************************************************/ + +static char +AslDoStringLiteral ( + void) +{ + char *StringBuffer = MsgBuffer; + char *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE; + char *CleanString; + char StringChar; + UINT32 State = ASL_NORMAL_CHAR; + UINT32 i = 0; + UINT8 Digit; + char ConvertBuffer[4]; + + + /* + * Eat chars until end-of-literal. + * NOTE: Put back the original surrounding quotes into the + * source line buffer. + */ + AslInsertLineBuffer ('\"'); + while ((StringChar = (char) input()) != EOF) + { + AslInsertLineBuffer (StringChar); + +DoCharacter: + + switch (State) + { + case ASL_NORMAL_CHAR: + + switch (StringChar) + { + case '\\': + /* + * Special handling for backslash-escape sequence. We will + * toss the backslash and translate the escape char(s). + */ + State = ASL_ESCAPE_SEQUENCE; + continue; + + case '\"': + + /* String terminator */ + + goto CompletedString; + } + break; + + + case ASL_ESCAPE_SEQUENCE: + + State = ASL_NORMAL_CHAR; + switch (StringChar) + { + case 'a': + StringChar = 0x07; /* BELL */ + break; + + case 'b': + StringChar = 0x08; /* BACKSPACE */ + break; + + case 'f': + StringChar = 0x0C; /* FORMFEED */ + break; + + case 'n': + StringChar = 0x0A; /* LINEFEED */ + break; + + case 'r': + StringChar = 0x0D; /* CARRIAGE RETURN*/ + break; + + case 't': + StringChar = 0x09; /* HORIZONTAL TAB */ + break; + + case 'v': + StringChar = 0x0B; /* VERTICAL TAB */ + break; + + case 'x': + State = ASL_HEX_CONSTANT; + i = 0; + continue; + + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + break; + + default: + + /* Check for an octal digit (0-7) */ + + if (ACPI_IS_OCTAL_DIGIT (StringChar)) + { + State = ASL_OCTAL_CONSTANT; + ConvertBuffer[0] = StringChar; + i = 1; + continue; + } + + /* Unknown escape sequence issue warning, but use the character */ + + AslCommonError (ASL_WARNING, ASL_MSG_INVALID_ESCAPE, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + break; + } + break; + + + case ASL_OCTAL_CONSTANT: + + /* Up to three octal digits allowed */ + + if (!ACPI_IS_OCTAL_DIGIT (StringChar) || + (i > 2)) + { + /* + * Reached end of the constant. Convert the assembled ASCII + * string and resume processing of the next character + */ + ConvertBuffer[i] = 0; + Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8); + + /* Check for NULL or non-ascii character (ignore if so) */ + + if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) + { + AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + } + else + { + *StringBuffer = (char) Digit; + StringBuffer++; + if (StringBuffer >= EndBuffer) + { + goto BufferOverflow; + } + } + + State = ASL_NORMAL_CHAR; + goto DoCharacter; + break; + } + + /* Append another digit of the constant */ + + ConvertBuffer[i] = StringChar; + i++; + continue; + + + case ASL_HEX_CONSTANT: + + /* Up to two hex digits allowed */ + + if (!ACPI_IS_XDIGIT (StringChar) || + (i > 1)) + { + /* + * Reached end of the constant. Convert the assembled ASCII + * string and resume processing of the next character + */ + ConvertBuffer[i] = 0; + Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16); + + /* Check for NULL or non-ascii character (ignore if so) */ + + if ((Digit == 0) || (Digit > ACPI_ASCII_MAX)) + { + AslCommonError (ASL_WARNING, ASL_MSG_INVALID_STRING, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + } + else + { + *StringBuffer = (char) Digit; + StringBuffer++; + if (StringBuffer >= EndBuffer) + { + goto BufferOverflow; + } + } + + State = ASL_NORMAL_CHAR; + goto DoCharacter; + break; + } + + /* Append another digit of the constant */ + + ConvertBuffer[i] = StringChar; + i++; + continue; + } + + /* Save the finished character */ + + *StringBuffer = StringChar; + StringBuffer++; + if (StringBuffer >= EndBuffer) + { + goto BufferOverflow; + } + } + + /* + * Premature End-Of-File + */ + AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + return (FALSE); + + +CompletedString: + /* + * Null terminate the input string and copy string to a new buffer + */ + *StringBuffer = 0; + + CleanString = UtGetStringBuffer (strlen (MsgBuffer) + 1); + if (!CleanString) + { + AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + return (FALSE); + } + + ACPI_STRCPY (CleanString, MsgBuffer); + AslCompilerlval.s = CleanString; + return (TRUE); + + +BufferOverflow: + + /* Literal was too long */ + + AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096"); + return (FALSE); +} diff --git a/src/acpica/source/compiler/preprocess.h b/src/acpica/source/compiler/preprocess.h new file mode 100644 index 0000000..4281eb4 --- /dev/null +++ b/src/acpica/source/compiler/preprocess.h @@ -0,0 +1,345 @@ +/****************************************************************************** + * + * Module Name: preprocess.h - header for iASL Preprocessor + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __PREPROCESS_H__ + +#ifndef _PREPROCESS +#define _PREPROCESS + +#undef PR_EXTERN + +#ifdef _DECLARE_PR_GLOBALS +#define PR_EXTERN +#define PR_INIT_GLOBAL(a,b) (a)=(b) +#else +#define PR_EXTERN extern +#define PR_INIT_GLOBAL(a,b) (a) +#endif + + +/* + * Configuration + */ +#define PR_MAX_MACRO_ARGS 32 /* Max number of macro args */ +#define PR_MAX_ARG_INSTANCES 24 /* Max instances of any one arg */ +#define PR_LINES_PER_BLOCK 4096 /* Max input source lines per block */ + + +/* + * Local defines and macros + */ +#define PR_TOKEN_SEPARATORS " ,(){}\t\n" +#define PR_MACRO_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n" +#define PR_MACRO_ARGUMENTS " ,\t\n" +#define PR_EXPR_SEPARATORS " ,(){}~!*/%+-<>=&^|\"\t\n" + +#define PR_PREFIX_ID "Pr(%.4u) - " /* Used for debug output */ + +#define THIS_TOKEN_OFFSET(t) ((t-Gbl_MainTokenBuffer) + 1) + + +/* + * Preprocessor structures + */ +typedef struct pr_macro_arg +{ + char *Name; + UINT32 Offset[PR_MAX_ARG_INSTANCES]; + UINT16 UseCount; + +} PR_MACRO_ARG; + +typedef struct pr_define_info +{ + struct pr_define_info *Previous; + struct pr_define_info *Next; + char *Identifier; + char *Replacement; + char *Body; /* Macro body */ + PR_MACRO_ARG *Args; /* Macro arg list */ + UINT16 ArgCount; /* Macro arg count */ + BOOLEAN Persist; /* Keep for entire compiler run */ + +} PR_DEFINE_INFO; + +typedef struct pr_directive_info +{ + char *Name; /* Directive name */ + UINT8 ArgCount; /* Required # of args */ + +} PR_DIRECTIVE_INFO; + +typedef struct pr_operator_info +{ + char *Op; + +} PR_OPERATOR_INFO; + +typedef struct pr_file_node +{ + struct pr_file_node *Next; + FILE *File; + char *Filename; + UINT32 CurrentLineNumber; + +} PR_FILE_NODE; + + +/* + * Globals + */ +PR_EXTERN char XXXEvalBuffer[ASL_LINE_BUFFER_SIZE]; +PR_EXTERN char Gbl_MainTokenBuffer[ASL_LINE_BUFFER_SIZE]; +PR_EXTERN char Gbl_MacroTokenBuffer[ASL_LINE_BUFFER_SIZE]; +PR_EXTERN char Gbl_ExpressionTokenBuffer[ASL_LINE_BUFFER_SIZE]; + +PR_EXTERN PR_FILE_NODE *Gbl_InputFileList; +PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL); +PR_EXTERN UINT32 Gbl_PreprocessorLineNumber; +PR_EXTERN int Gbl_IfDepth; +PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_PreprocessorError, FALSE); + + +/* + * prscan - Preprocessor entry + */ +void +PrInitializePreprocessor ( + void); + +void +PrInitializeGlobals ( + void); + +void +PrTerminatePreprocessor ( + void); + +BOOLEAN +PrDoPreprocess ( + void); + +UINT64 +PrIsDefined ( + char *Identifier); + +UINT64 +PrResolveDefine ( + char *Identifier); + +int +PrInitLexer ( + char *String); + +void +PrTerminateLexer ( + void); + + +/* + * prmacros - Support for #defines and macros + */ +void +PrDumpPredefinedNames ( + void); + +PR_DEFINE_INFO * +PrAddDefine ( + char *Token, + char *Token2, + BOOLEAN Persist); + +void +PrRemoveDefine ( + char *DefineName); + +PR_DEFINE_INFO * +PrMatchDefine ( + char *MatchString); + +void +PrAddMacro ( + char *Name, + char **Next); + +void +PrDoMacroInvocation ( + char *TokenBuffer, + char *MacroStart, + PR_DEFINE_INFO *DefineInfo, + char **Next); + + +/* + * prexpress - #if expression support + */ +ACPI_STATUS +PrResolveIntegerExpression ( + char *Line, + UINT64 *ReturnValue); + +char * +PrPrioritizeExpression ( + char *OriginalLine); + +/* + * prparser - lex/yacc expression parser + */ +UINT64 +PrEvaluateExpression ( + char *ExprString); + + +/* + * prutils - Preprocesor utilities + */ +char * +PrGetNextToken ( + char *Buffer, + char *MatchString, + char **Next); + +void +PrError ( + UINT8 Level, + UINT8 MessageId, + UINT32 Column); + +void +PrReplaceData ( + char *Buffer, + UINT32 LengthToRemove, + char *BufferToAdd, + UINT32 LengthToAdd); + +void +PrOpenIncludeFile ( + char *Filename); + +FILE * +PrOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename); + +void +PrPushInputFileStack ( + FILE *InputFile, + char *Filename); + +BOOLEAN +PrPopInputFileStack ( + void); + +#endif diff --git a/src/acpica/source/compiler/prexpress.c b/src/acpica/source/compiler/prexpress.c new file mode 100644 index 0000000..f65491e --- /dev/null +++ b/src/acpica/source/compiler/prexpress.c @@ -0,0 +1,377 @@ +/****************************************************************************** + * + * Module Name: prexpress - Preprocessor #if expression support + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "aslcompiler.h" +#include "dtcompiler.h" + + +#define _COMPONENT ASL_PREPROCESSOR + ACPI_MODULE_NAME ("prexpress") + +/* Local prototypes */ + +static char * +PrExpandMacros ( + char *Line); + + +#ifdef _UNDER_DEVELOPMENT +/****************************************************************************** + * + * FUNCTION: PrUnTokenize + * + * PARAMETERS: Buffer - Token Buffer + * Next - "Next" buffer from GetNextToken + * + * RETURN: None + * + * DESCRIPTION: Un-tokenized the current token buffer. The implementation is + * to simply set the null inserted by GetNextToken to a blank. + * If Next is NULL, there were no tokens found in the Buffer, + * so there is nothing to do. + * + *****************************************************************************/ + +static void +PrUnTokenize ( + char *Buffer, + char *Next) +{ + UINT32 Length = strlen (Buffer); + + + if (!Next) + { + return; + } + if (Buffer[Length] != '\n') + { + Buffer[strlen(Buffer)] = ' '; + } +} +#endif + + +/****************************************************************************** + * + * FUNCTION: PrExpandMacros + * + * PARAMETERS: Line - Pointer into the current line + * + * RETURN: Updated pointer into the current line + * + * DESCRIPTION: Expand any macros found in the current line buffer. + * + *****************************************************************************/ + +static char * +PrExpandMacros ( + char *Line) +{ + char *Token; + char *ReplaceString; + PR_DEFINE_INFO *DefineInfo; + ACPI_SIZE TokenOffset; + char *Next; + int OffsetAdjust; + + + strcpy (Gbl_ExpressionTokenBuffer, Gbl_CurrentLineBuffer); + Token = PrGetNextToken (Gbl_ExpressionTokenBuffer, PR_EXPR_SEPARATORS, &Next); + OffsetAdjust = 0; + + while (Token) + { + DefineInfo = PrMatchDefine (Token); + if (DefineInfo) + { + if (DefineInfo->Body) + { + /* This is a macro. TBD: Is this allowed? */ + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Matched Macro: %s->%s\n", + Gbl_CurrentLineNumber, DefineInfo->Identifier, + DefineInfo->Replacement); + + PrDoMacroInvocation (Gbl_ExpressionTokenBuffer, Token, + DefineInfo, &Next); + } + else + { + ReplaceString = DefineInfo->Replacement; + + /* Replace the name in the original line buffer */ + + TokenOffset = Token - Gbl_ExpressionTokenBuffer + OffsetAdjust; + PrReplaceData ( + &Gbl_CurrentLineBuffer[TokenOffset], strlen (Token), + ReplaceString, strlen (ReplaceString)); + + /* Adjust for length difference between old and new name length */ + + OffsetAdjust += strlen (ReplaceString) - strlen (Token); + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Matched #define within expression: %s->%s\n", + Gbl_CurrentLineNumber, Token, + *ReplaceString ? ReplaceString : "(NULL STRING)"); + } + } + + Token = PrGetNextToken (NULL, PR_EXPR_SEPARATORS, &Next); + } + + return (Line); +} + + +/****************************************************************************** + * + * FUNCTION: PrIsDefined + * + * PARAMETERS: Identifier - Name to be resolved + * + * RETURN: 64-bit boolean integer value + * + * DESCRIPTION: Returns TRUE if the name is defined, FALSE otherwise (0). + * + *****************************************************************************/ + +UINT64 +PrIsDefined ( + char *Identifier) +{ + UINT64 Value; + PR_DEFINE_INFO *DefineInfo; + + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "**** Is defined?: %s\n", Gbl_CurrentLineNumber, Identifier); + + Value = 0; /* Default is "Not defined" -- FALSE */ + + DefineInfo = PrMatchDefine (Identifier); + if (DefineInfo) + { + Value = ACPI_UINT64_MAX; /* TRUE */ + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "[#if defined %s] resolved to: %8.8X%8.8X\n", + Gbl_CurrentLineNumber, Identifier, ACPI_FORMAT_UINT64 (Value)); + + return (Value); +} + + +/****************************************************************************** + * + * FUNCTION: PrResolveDefine + * + * PARAMETERS: Identifier - Name to be resolved + * + * RETURN: A 64-bit boolean integer value + * + * DESCRIPTION: Returns TRUE if the name is defined, FALSE otherwise (0). + * + *****************************************************************************/ + +UINT64 +PrResolveDefine ( + char *Identifier) +{ + UINT64 Value; + PR_DEFINE_INFO *DefineInfo; + + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "**** Resolve #define: %s\n", Gbl_CurrentLineNumber, Identifier); + + Value = 0; /* Default is "Not defined" -- FALSE */ + + DefineInfo = PrMatchDefine (Identifier); + if (DefineInfo) + { + Value = ACPI_UINT64_MAX; /* TRUE */ + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "[#if defined %s] resolved to: %8.8X%8.8X\n", + Gbl_CurrentLineNumber, Identifier, ACPI_FORMAT_UINT64 (Value)); + + return (Value); +} + + +/****************************************************************************** + * + * FUNCTION: PrResolveIntegerExpression + * + * PARAMETERS: Line - Pointer to integer expression + * ReturnValue - Where the resolved 64-bit integer is + * returned. + * + * RETURN: Status + * + * DESCRIPTION: Resolve an integer expression to a single value. Supports + * both integer constants and labels. + * + *****************************************************************************/ + +ACPI_STATUS +PrResolveIntegerExpression ( + char *Line, + UINT64 *ReturnValue) +{ + UINT64 Result; + char *ExpandedLine; + + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "**** Resolve #if: %s\n", Gbl_CurrentLineNumber, Line); + + /* Expand all macros within the expression first */ + + ExpandedLine = PrExpandMacros (Line); + + /* Now we can evaluate the expression */ + + Result = PrEvaluateExpression (ExpandedLine); + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "**** Expression Resolved to: %8.8X%8.8X\n", + Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Result)); + + *ReturnValue = Result; + return (AE_OK); + +#if 0 +InvalidExpression: + + ACPI_FREE (EvalBuffer); + PrError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, 0); + return (AE_ERROR); + + +NormalExit: + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "**** Expression Resolved to: %8.8X%8.8X\n", + Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value1)); + + *ReturnValue = Value1; + return (AE_OK); +#endif +} diff --git a/src/acpica/source/compiler/prmacros.c b/src/acpica/source/compiler/prmacros.c new file mode 100644 index 0000000..d358f1a --- /dev/null +++ b/src/acpica/source/compiler/prmacros.c @@ -0,0 +1,646 @@ +/****************************************************************************** + * + * Module Name: prmacros - Preprocessor #define macro support + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "aslcompiler.h" +#include "dtcompiler.h" + + +#define _COMPONENT ASL_PREPROCESSOR + ACPI_MODULE_NAME ("prmacros") + + +/******************************************************************************* + * + * FUNCTION: PrDumpPredefinedNames + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump the list of #defines. Used as the preprocessor starts, to + * display the names that were defined on the command line. + * Debug information only. + * + ******************************************************************************/ + +void +PrDumpPredefinedNames ( + void) +{ + PR_DEFINE_INFO *DefineInfo; + + + DefineInfo = Gbl_DefineList; + while (DefineInfo) + { + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Predefined #define: %s->%s\n", + 0, DefineInfo->Identifier, DefineInfo->Replacement); + + DefineInfo = DefineInfo->Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: PrAddDefine + * + * PARAMETERS: Identifier - Name to be replaced + * Replacement - Replacement for Identifier + * Persist - Keep define across multiple compiles? + * + * RETURN: A new define_info struct. NULL on error. + * + * DESCRIPTION: Add a new #define to the global list + * + ******************************************************************************/ + +PR_DEFINE_INFO * +PrAddDefine ( + char *Identifier, + char *Replacement, + BOOLEAN Persist) +{ + char *IdentifierString; + char *ReplacementString; + PR_DEFINE_INFO *DefineInfo; + + + if (!Replacement) + { + Replacement = ""; + } + + /* Check for already-defined first */ + + DefineInfo = PrMatchDefine (Identifier); + if (DefineInfo) + { + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID, + "#define: name already exists: %s\n", + Gbl_CurrentLineNumber, Identifier); + + /* + * Name already exists. This is only an error if the target name + * is different. + */ + if (strcmp (Replacement, DefineInfo->Replacement)) + { + PrError (ASL_ERROR, ASL_MSG_EXISTING_NAME, + THIS_TOKEN_OFFSET (Identifier)); + + return (NULL); + } + + return (DefineInfo); + } + + /* Copy input strings */ + + IdentifierString = UtLocalCalloc (strlen (Identifier) + 1); + strcpy (IdentifierString, Identifier); + + ReplacementString = UtLocalCalloc (strlen (Replacement) + 1); + strcpy (ReplacementString, Replacement); + + /* Init and link new define info struct */ + + DefineInfo = UtLocalCalloc (sizeof (PR_DEFINE_INFO)); + DefineInfo->Replacement = ReplacementString; + DefineInfo->Identifier = IdentifierString; + DefineInfo->Persist = Persist; + + if (Gbl_DefineList) + { + Gbl_DefineList->Previous = DefineInfo; + } + + DefineInfo->Next = Gbl_DefineList; + Gbl_DefineList = DefineInfo; + return (DefineInfo); +} + + +/******************************************************************************* + * + * FUNCTION: PrRemoveDefine + * + * PARAMETERS: DefineName - Name of define to be removed + * + * RETURN: None + * + * DESCRIPTION: Implements #undef. Remove a #define if found in the global + * list. No error if the target of the #undef does not exist, + * as per the C #undef definition. + * + ******************************************************************************/ + +void +PrRemoveDefine ( + char *DefineName) +{ + PR_DEFINE_INFO *DefineInfo; + + + /* Match name and delete the node */ + + DefineInfo = Gbl_DefineList; + while (DefineInfo) + { + if (!strcmp (DefineName, DefineInfo->Identifier)) + { + /* Remove from linked list */ + + if (DefineInfo->Previous) + { + (DefineInfo->Previous)->Next = DefineInfo->Next; + } + else + { + Gbl_DefineList = DefineInfo->Next; + } + + if (DefineInfo->Next) + { + (DefineInfo->Next)->Previous = DefineInfo->Previous; + } + + free (DefineInfo); + return; + } + + DefineInfo = DefineInfo->Next; + } + + /* + * Name was not found. By definition of #undef, this is not + * an error, however. + */ + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "#undef: could not find %s\n", + Gbl_CurrentLineNumber, DefineName); +} + + +/******************************************************************************* + * + * FUNCTION: PrMatchDefine + * + * PARAMETERS: MatchString - Name associated with the #define + * + * RETURN: Matched string if found. NULL otherwise. + * + * DESCRIPTION: Find a name in global #define list + * + ******************************************************************************/ + +PR_DEFINE_INFO * +PrMatchDefine ( + char *MatchString) +{ + PR_DEFINE_INFO *DefineInfo; + + + DefineInfo = Gbl_DefineList; + while (DefineInfo) + { + if (!strcmp (MatchString, DefineInfo->Identifier)) + { + return (DefineInfo); + } + + DefineInfo = DefineInfo->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: PrAddMacro + * + * PARAMETERS: Name - Start of the macro definition + * Next - "Next" buffer from GetNextToken + * + * RETURN: None + * + * DESCRIPTION: Add a new macro to the list of #defines. Handles argument + * processing. + * + ******************************************************************************/ + +void +PrAddMacro ( + char *Name, + char **Next) +{ + char *Token = NULL; + ACPI_SIZE TokenOffset; + ACPI_SIZE MacroBodyOffset; + PR_DEFINE_INFO *DefineInfo; + PR_MACRO_ARG *Args; + char *Body; + char *BodyInSource; + UINT32 i; + UINT16 UseCount = 0; + UINT16 ArgCount = 0; + UINT32 Depth = 1; + UINT32 EndOfArgList; + char BufferChar; + + + /* Find the end of the arguments list */ + + TokenOffset = Name - Gbl_MainTokenBuffer + strlen (Name) + 1; + while (1) + { + BufferChar = Gbl_CurrentLineBuffer[TokenOffset]; + if (BufferChar == '(') + { + Depth++; + } + else if (BufferChar == ')') + { + Depth--; + } + else if (BufferChar == 0) + { + PrError (ASL_ERROR, ASL_MSG_MACRO_SYNTAX, TokenOffset); + return; + } + + if (Depth == 0) + { + /* Found arg list end */ + + EndOfArgList = TokenOffset; + break; + } + + TokenOffset++; + } + + /* At this point, we know that we have a reasonable argument list */ + + Args = UtLocalCalloc (sizeof (PR_MACRO_ARG) * PR_MAX_MACRO_ARGS); + + /* Get the macro argument names */ + + for (i = 0; i < PR_MAX_MACRO_ARGS; i++) + { + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); + if (!Token) + { + /* This is the case for a NULL macro body */ + + BodyInSource = ""; + goto AddMacroToList; + } + + /* Don't go beyond the argument list */ + + TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token); + if (TokenOffset > EndOfArgList) + { + break; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Macro arg: %s \n", + Gbl_CurrentLineNumber, Token); + + Args[i].Name = UtLocalCalloc (strlen (Token) + 1); + strcpy (Args[i].Name, Token); + + Args[i].UseCount = 0; + + ArgCount++; + if (ArgCount >= PR_MAX_MACRO_ARGS) + { + PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, TokenOffset); + return; + } + } + + /* Get the macro body. Token now points to start of body */ + + MacroBodyOffset = Token - Gbl_MainTokenBuffer; + + /* Match each method arg in the macro body for later use */ + + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); + while (Token) + { + /* Search the macro arg list for matching arg */ + + for (i = 0; Args[i].Name && (i < PR_MAX_MACRO_ARGS); i++) + { + /* + * Save argument offset within macro body. This is the mechanism + * used to expand the macro upon invocation. + * + * Handles multiple instances of the same argument + */ + if (!strcmp (Token, Args[i].Name)) + { + UseCount = Args[i].UseCount; + + Args[i].Offset[UseCount] = (Token - Gbl_MainTokenBuffer) - MacroBodyOffset; + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Macro Arg #%u: %s UseCount %u Offset %u \n", + Gbl_CurrentLineNumber, i, Token, + UseCount+1, Args[i].Offset[UseCount]); + + Args[i].UseCount++; + if (Args[i].UseCount >= PR_MAX_ARG_INSTANCES) + { + PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, + THIS_TOKEN_OFFSET (Token)); + + return; + } + break; + } + } + + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); + } + + BodyInSource = &Gbl_CurrentLineBuffer[MacroBodyOffset]; + + +AddMacroToList: + + /* Check if name is already defined first */ + + DefineInfo = PrMatchDefine (Name); + if (DefineInfo) + { + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "#define: macro name already exists: %s\n", + Gbl_CurrentLineNumber, Name); + + /* Error only if not exactly the same macro */ + + if (strcmp (DefineInfo->Body, BodyInSource) || + (DefineInfo->ArgCount != ArgCount)) + { + PrError (ASL_ERROR, ASL_MSG_EXISTING_NAME, + THIS_TOKEN_OFFSET (Name)); + } + + return; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Macro body: %s \n", + Gbl_CurrentLineNumber, BodyInSource); + + /* Add macro to the #define list */ + + DefineInfo = PrAddDefine (Name, BodyInSource, FALSE); + if (DefineInfo) + { + Body = UtLocalCalloc (strlen (BodyInSource) + 1); + strcpy (Body, BodyInSource); + + DefineInfo->Body = Body; + DefineInfo->Args = Args; + DefineInfo->ArgCount = ArgCount; + } +} + + +/******************************************************************************* + * + * FUNCTION: PrDoMacroInvocation + * + * PARAMETERS: TokenBuffer - Current line buffer + * MacroStart - Start of the macro invocation within + * the token buffer + * DefineInfo - Info for this macro + * Next - "Next" buffer from GetNextToken + * + * RETURN: None + * + * DESCRIPTION: Expand a macro invocation + * + ******************************************************************************/ + +void +PrDoMacroInvocation ( + char *TokenBuffer, + char *MacroStart, + PR_DEFINE_INFO *DefineInfo, + char **Next) +{ + PR_MACRO_ARG *Args; + char *Token = NULL; + UINT32 TokenOffset; + UINT32 Length; + UINT32 i; + + + /* Take a copy of the macro body for expansion */ + + strcpy (Gbl_MacroTokenBuffer, DefineInfo->Body); + + /* Replace each argument within the prototype body */ + + Args = DefineInfo->Args; + if (!Args->Name) + { + /* This macro has no arguments */ + + Token = PrGetNextToken (NULL, PR_MACRO_ARGUMENTS, Next); + if (!Token) + { + goto BadInvocation; + } + + TokenOffset = (MacroStart - TokenBuffer); + Length = Token - MacroStart + strlen (Token) + 1; + + PrReplaceData ( + &Gbl_CurrentLineBuffer[TokenOffset], Length, + Gbl_MacroTokenBuffer, strlen (Gbl_MacroTokenBuffer)); + return; + } + + while (Args->Name) + { + /* Get the next argument from macro invocation */ + + Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next); + if (!Token) + { + goto BadInvocation; + } + + /* Replace all instances of this argument */ + + for (i = 0; i < Args->UseCount; i++) + { + /* Offset zero indicates "arg not used" */ + /* TBD: Not really needed now, with UseCount available */ + + if (Args->Offset[i] == 0) + { + break; + } + + PrReplaceData ( + &Gbl_MacroTokenBuffer[Args->Offset[i]], strlen (Args->Name), + Token, strlen (Token)); + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "ExpandArg: %s \n", + Gbl_CurrentLineNumber, Gbl_MacroTokenBuffer); + } + + Args++; + } + + /* TBD: need to make sure macro was not invoked with too many arguments */ + + if (!Token) + { + return; + } + + /* Replace the entire macro invocation with the expanded macro */ + + TokenOffset = (MacroStart - TokenBuffer); + Length = Token - MacroStart + strlen (Token) + 1; + + PrReplaceData ( + &Gbl_CurrentLineBuffer[TokenOffset], Length, + Gbl_MacroTokenBuffer, strlen (Gbl_MacroTokenBuffer)); + + return; + + +BadInvocation: + PrError (ASL_ERROR, ASL_MSG_INVALID_INVOCATION, + THIS_TOKEN_OFFSET (MacroStart)); + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Bad macro invocation: %s \n", + Gbl_CurrentLineNumber, Gbl_MacroTokenBuffer); + return; +} diff --git a/src/acpica/source/compiler/prparser.l b/src/acpica/source/compiler/prparser.l new file mode 100644 index 0000000..d20ac28 --- /dev/null +++ b/src/acpica/source/compiler/prparser.l @@ -0,0 +1,225 @@ +%{ +/****************************************************************************** + * + * Module Name: prparser.l - Flex input file for preprocessor lexer + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "aslcompiler.h" +#include "prparser.y.h" + +/* Buffer to pass strings to the parser */ + +#define STRING_SETUP strcpy (StringBuffer, PrParsertext);\ + PrParserlval.str = StringBuffer + +#define YY_NO_INPUT /* No file input, we use strings only */ + +#define _COMPONENT ACPI_COMPILER + ACPI_MODULE_NAME ("prscanner") +%} + +%option noyywrap +%option nounput + +Number [0-9a-fA-F]+ +HexNumber 0[xX][0-9a-fA-F]+ +WhiteSpace [ \t\v\r]+ +NewLine [\n] +Identifier [a-zA-Z][0-9a-zA-Z]* + +%% + +\( return (EXPOP_PAREN_OPEN); +\) return (EXPOP_PAREN_CLOSE); +\~ return (EXPOP_ONES_COMPLIMENT); +\! return (EXPOP_LOGICAL_NOT); +\* return (EXPOP_MULTIPLY); +\/ return (EXPOP_DIVIDE); +\% return (EXPOP_MODULO); +\+ return (EXPOP_ADD); +\- return (EXPOP_SUBTRACT); +">>" return (EXPOP_SHIFT_RIGHT); +"<<" return (EXPOP_SHIFT_LEFT); +\< return (EXPOP_LESS); +\> return (EXPOP_GREATER); +"<=" return (EXPOP_LESS_EQUAL); +">=" return (EXPOP_GREATER_EQUAL); +"==" return (EXPOP_EQUAL); +"!=" return (EXPOP_NOT_EQUAL); +\& return (EXPOP_AND); +\^ return (EXPOP_XOR); +\| return (EXPOP_OR); +"&&" return (EXPOP_LOGICAL_AND); +"||" return (EXPOP_LOGICAL_OR); + +"defined" return (EXPOP_DEFINE); +{Identifier} {STRING_SETUP; return (EXPOP_IDENTIFIER);} + +<<EOF>> return (EXPOP_EOF); /* null end-of-string */ + +{Number} return (EXPOP_NUMBER); +{HexNumber} return (EXPOP_HEX_NUMBER); +{NewLine} return (EXPOP_NEW_LINE); +{WhiteSpace} /* Ignore */ + +. return (EXPOP_EOF); +%% + +/* + * Local support functions + */ +YY_BUFFER_STATE LexBuffer; + + +/****************************************************************************** + * + * FUNCTION: PrInitLexer + * + * PARAMETERS: String - Input string to be parsed + * + * RETURN: TRUE if parser returns NULL. FALSE otherwise. + * + * DESCRIPTION: Initialization routine for lexer. The lexer needs + * a buffer to handle strings instead of a file. + * + *****************************************************************************/ + +int +PrInitLexer ( + char *String) +{ + + LexBuffer = yy_scan_string (String); + return (LexBuffer == NULL); +} + + +/****************************************************************************** + * + * FUNCTION: PrTerminateLexer + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Termination routine for thelexer. + * + *****************************************************************************/ + +void +PrTerminateLexer ( + void) +{ + + yy_delete_buffer (LexBuffer); +} diff --git a/src/acpica/source/compiler/prparser.y b/src/acpica/source/compiler/prparser.y new file mode 100644 index 0000000..3c3e3a7 --- /dev/null +++ b/src/acpica/source/compiler/prparser.y @@ -0,0 +1,356 @@ +%{ +/****************************************************************************** + * + * Module Name: prparser.y - Bison input file for preprocessor parser + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "aslcompiler.h" +#include "dtcompiler.h" + +#define _COMPONENT ASL_PREPROCESSOR + ACPI_MODULE_NAME ("prparser") + +int PrParserlex (void); +int PrParserparse (void); +void PrParsererror (char const *msg); +extern char *PrParsertext; + +UINT64 PrParserResult; /* Expression return value */ + +/* Bison/yacc configuration */ + +#define yytname PrParsername +#define YYDEBUG 1 /* Enable debug output */ +#define YYERROR_VERBOSE 1 /* Verbose error messages */ +#define YYFLAG -32768 + +/* Define YYMALLOC/YYFREE to prevent redefinition errors */ + +#define YYMALLOC malloc +#define YYFREE free +%} + +%union +{ + UINT64 value; + UINT32 op; + char *str; +} + +/*! [Begin] no source code translation */ + +%type <value> Expression + +%token <op> EXPOP_EOF +%token <op> EXPOP_NEW_LINE +%token <op> EXPOP_NUMBER +%token <op> EXPOP_HEX_NUMBER +%token <op> EXPOP_RESERVED1 +%token <op> EXPOP_RESERVED2 +%token <op> EXPOP_PAREN_OPEN +%token <op> EXPOP_PAREN_CLOSE + +%left <op> EXPOP_LOGICAL_OR +%left <op> EXPOP_LOGICAL_AND +%left <op> EXPOP_OR +%left <op> EXPOP_XOR +%left <op> EXPOP_AND +%left <op> EXPOP_EQUAL EXPOP_NOT_EQUAL +%left <op> EXPOP_GREATER EXPOP_LESS EXPOP_GREATER_EQUAL EXPOP_LESS_EQUAL +%left <op> EXPOP_SHIFT_RIGHT EXPOP_SHIFT_LEFT +%left <op> EXPOP_ADD EXPOP_SUBTRACT +%left <op> EXPOP_MULTIPLY EXPOP_DIVIDE EXPOP_MODULO +%right <op> EXPOP_ONES_COMPLIMENT EXPOP_LOGICAL_NOT + +/* Tokens above must be kept in synch with dtparser.y */ + +%token <op> EXPOP_DEFINE +%token <op> EXPOP_IDENTIFIER + +%% + +/* + * Operator precedence rules (from K&R) + * + * 1) ( ) + * 2) ! ~ (unary operators that are supported here) + * 3) * / % + * 4) + - + * 5) >> << + * 6) < > <= >= + * 7) == != + * 8) & + * 9) ^ + * 10) | + * 11) && + * 12) || + */ + +/*! [End] no source code translation !*/ + +Value + : Expression EXPOP_NEW_LINE { PrParserResult=$1; return 0; } /* End of line (newline) */ + | Expression EXPOP_EOF { PrParserResult=$1; return 0; } /* End of string (0) */ + ; + +Expression + + /* Unary operators */ + + : EXPOP_LOGICAL_NOT Expression { $$ = DtDoOperator ($2, EXPOP_LOGICAL_NOT, $2);} + | EXPOP_ONES_COMPLIMENT Expression { $$ = DtDoOperator ($2, EXPOP_ONES_COMPLIMENT, $2);} + + /* Binary operators */ + + | Expression EXPOP_MULTIPLY Expression { $$ = DtDoOperator ($1, EXPOP_MULTIPLY, $3);} + | Expression EXPOP_DIVIDE Expression { $$ = DtDoOperator ($1, EXPOP_DIVIDE, $3);} + | Expression EXPOP_MODULO Expression { $$ = DtDoOperator ($1, EXPOP_MODULO, $3);} + | Expression EXPOP_ADD Expression { $$ = DtDoOperator ($1, EXPOP_ADD, $3);} + | Expression EXPOP_SUBTRACT Expression { $$ = DtDoOperator ($1, EXPOP_SUBTRACT, $3);} + | Expression EXPOP_SHIFT_RIGHT Expression { $$ = DtDoOperator ($1, EXPOP_SHIFT_RIGHT, $3);} + | Expression EXPOP_SHIFT_LEFT Expression { $$ = DtDoOperator ($1, EXPOP_SHIFT_LEFT, $3);} + | Expression EXPOP_GREATER Expression { $$ = DtDoOperator ($1, EXPOP_GREATER, $3);} + | Expression EXPOP_LESS Expression { $$ = DtDoOperator ($1, EXPOP_LESS, $3);} + | Expression EXPOP_GREATER_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_GREATER_EQUAL, $3);} + | Expression EXPOP_LESS_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_LESS_EQUAL, $3);} + | Expression EXPOP_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_EQUAL, $3);} + | Expression EXPOP_NOT_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_NOT_EQUAL, $3);} + | Expression EXPOP_AND Expression { $$ = DtDoOperator ($1, EXPOP_AND, $3);} + | Expression EXPOP_XOR Expression { $$ = DtDoOperator ($1, EXPOP_XOR, $3);} + | Expression EXPOP_OR Expression { $$ = DtDoOperator ($1, EXPOP_OR, $3);} + | Expression EXPOP_LOGICAL_AND Expression { $$ = DtDoOperator ($1, EXPOP_LOGICAL_AND, $3);} + | Expression EXPOP_LOGICAL_OR Expression { $$ = DtDoOperator ($1, EXPOP_LOGICAL_OR, $3);} + + /* Parentheses: '(' Expression ')' */ + + | EXPOP_PAREN_OPEN Expression + EXPOP_PAREN_CLOSE { $$ = $2;} + + /* #if defined (ID) or #if defined ID */ + + | EXPOP_DEFINE EXPOP_PAREN_OPEN EXPOP_IDENTIFIER + EXPOP_PAREN_CLOSE { $$ = PrIsDefined (PrParserlval.str);} + + | EXPOP_DEFINE EXPOP_IDENTIFIER { $$ = PrIsDefined (PrParserlval.str);} + + | EXPOP_IDENTIFIER { $$ = PrResolveDefine (PrParserlval.str);} + + /* Default base for a non-prefixed integer is 10 */ + + | EXPOP_NUMBER { UtStrtoul64 (PrParsertext, 10, &$$);} + + /* Standard hex number (0x1234) */ + + | EXPOP_HEX_NUMBER { UtStrtoul64 (PrParsertext, 16, &$$);} + ; +%% + +/* + * Local support functions, including parser entry point + */ +#define PR_FIRST_PARSE_OPCODE EXPOP_EOF +#define PR_YYTNAME_START 3 + + +/****************************************************************************** + * + * FUNCTION: PrParsererror + * + * PARAMETERS: Message - Parser-generated error message + * + * RETURN: None + * + * DESCRIPTION: Handler for parser errors + * + *****************************************************************************/ + +void +PrParsererror ( + char const *Message) +{ + DtError (ASL_ERROR, ASL_MSG_SYNTAX, + NULL, (char *) Message); +} + + +/****************************************************************************** + * + * FUNCTION: PrGetOpName + * + * PARAMETERS: ParseOpcode - Parser token (EXPOP_*) + * + * RETURN: Pointer to the opcode name + * + * DESCRIPTION: Get the ascii name of the parse opcode for debug output + * + *****************************************************************************/ + +char * +PrGetOpName ( + UINT32 ParseOpcode) +{ +#ifdef ASL_YYTNAME_START + /* + * First entries (PR_YYTNAME_START) in yytname are special reserved names. + * Ignore first 6 characters of name (EXPOP_) + */ + return ((char *) yytname + [(ParseOpcode - PR_FIRST_PARSE_OPCODE) + PR_YYTNAME_START] + 6); +#else + return ("[Unknown parser generator]"); +#endif +} + + +/****************************************************************************** + * + * FUNCTION: PrEvaluateExpression + * + * PARAMETERS: ExprString - Expression to be evaluated. Must be + * terminated by either a newline or a NUL + * string terminator + * + * RETURN: 64-bit value for the expression + * + * DESCRIPTION: Main entry point for the DT expression parser + * + *****************************************************************************/ + +UINT64 +PrEvaluateExpression ( + char *ExprString) +{ + + DbgPrint (ASL_DEBUG_OUTPUT, + "**** Input expression: %s\n", ExprString); + + /* Point lexer to the input string */ + + if (PrInitLexer (ExprString)) + { + DtError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, + NULL, "Could not initialize lexer"); + return (0); + } + + /* Parse/Evaluate the input string (value returned in PrParserResult) */ + + PrParserparse (); + PrTerminateLexer (); + + DbgPrint (ASL_DEBUG_OUTPUT, + "**** Parser returned value: %u (%8.8X%8.8X)\n", + (UINT32) PrParserResult, ACPI_FORMAT_UINT64 (PrParserResult)); + + return (PrParserResult); +} diff --git a/src/acpica/source/compiler/prscan.c b/src/acpica/source/compiler/prscan.c new file mode 100644 index 0000000..e98e186 --- /dev/null +++ b/src/acpica/source/compiler/prscan.c @@ -0,0 +1,844 @@ +/****************************************************************************** + * + * Module Name: prscan - Preprocessor start-up and file scan module + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define _DECLARE_PR_GLOBALS + +#include "aslcompiler.h" +#include "dtcompiler.h" + +/* + * TBDs: + * + * No nested macros, maybe never + * Implement ASL "Include" as well as "#include" here? + */ +#define _COMPONENT ASL_PREPROCESSOR + ACPI_MODULE_NAME ("prscan") + + +/* Local prototypes */ + +static void +PrPreprocessInputFile ( + void); + +static void +PrDoDirective ( + char *DirectiveToken, + char **Next, + BOOLEAN *IgnoringThisCodeBlock); + +static int +PrMatchDirective ( + char *Directive); + +/* + * Supported preprocessor directives + */ +static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] = +{ + {"define", 1}, + {"elif", 0}, /* Converted to #else..#if internally */ + {"else", 0}, + {"endif", 0}, + {"error", 1}, + {"if", 1}, + {"ifdef", 1}, + {"ifndef", 1}, + {"include", 0}, /* Argument is not standard format, so 0 */ + {"line", 1}, + {"pragma", 1}, + {"undef", 1}, + {"warning", 1}, + {NULL, 0} +}; + +enum Gbl_DirectiveIndexes +{ + PR_DIRECTIVE_DEFINE = 0, + PR_DIRECTIVE_ELIF, + PR_DIRECTIVE_ELSE, + PR_DIRECTIVE_ENDIF, + PR_DIRECTIVE_ERROR, + PR_DIRECTIVE_IF, + PR_DIRECTIVE_IFDEF, + PR_DIRECTIVE_IFNDEF, + PR_DIRECTIVE_INCLUDE, + PR_DIRECTIVE_LINE, + PR_DIRECTIVE_PRAGMA, + PR_DIRECTIVE_UNDEF, + PR_DIRECTIVE_WARNING, +}; + +#define ASL_DIRECTIVE_NOT_FOUND -1 + + +/******************************************************************************* + * + * FUNCTION: PrInitializePreprocessor + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Startup initialization for the Preprocessor. + * + ******************************************************************************/ + +void +PrInitializePreprocessor ( + void) +{ + /* Init globals and the list of #defines */ + + PrInitializeGlobals (); + Gbl_DefineList = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: PrInitializeGlobals + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Initialize globals for the Preprocessor. Used for startuup + * initialization and re-initialization between compiles during + * a multiple source file compile. + * + ******************************************************************************/ + +void +PrInitializeGlobals ( + void) +{ + /* Init globals */ + + Gbl_IfDepth = 0; + Gbl_InputFileList = NULL; + Gbl_CurrentLineNumber = 0; + Gbl_PreprocessorLineNumber = 1; + Gbl_PreprocessorError = FALSE; +} + + +/******************************************************************************* + * + * FUNCTION: PrTerminatePreprocessor + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Termination of the preprocessor. Delete lists. Keep any + * defines that were specified on the command line, in order to + * support multiple compiles with a single compiler invocation. + * + ******************************************************************************/ + +void +PrTerminatePreprocessor ( + void) +{ + PR_DEFINE_INFO *DefineInfo; + + + /* + * The persistent defines (created on the command line) are always at the + * end of the list. We save them. + */ + while ((Gbl_DefineList) && (!Gbl_DefineList->Persist)) + { + DefineInfo = Gbl_DefineList; + Gbl_DefineList = DefineInfo->Next; + + ACPI_FREE (DefineInfo->Replacement); + ACPI_FREE (DefineInfo->Identifier); + ACPI_FREE (DefineInfo); + } +} + + +/******************************************************************************* + * + * FUNCTION: PrDoPreprocess + * + * PARAMETERS: None + * + * RETURN: Error Status. TRUE if error, FALSE if OK. + * + * DESCRIPTION: Main entry point for the iASL Preprocessor. Input file must + * be already open. Handles multiple input files via the + * #include directive. + * + ******************************************************************************/ + +BOOLEAN +PrDoPreprocess ( + void) +{ + BOOLEAN MoreInputFiles; + + + DbgPrint (ASL_DEBUG_OUTPUT, "Starting preprocessing phase\n\n"); + + + FlSeekFile (ASL_FILE_INPUT, 0); + PrDumpPredefinedNames (); + + /* Main preprocessor loop, handles include files */ + + do + { + PrPreprocessInputFile (); + MoreInputFiles = PrPopInputFileStack (); + + } while (MoreInputFiles); + + + /* + * TBD: is this necessary? (Do we abort on any preprocessing errors?) + */ + if (Gbl_PreprocessorError) + { + /* TBD: can't use source_output file for preprocessor error reporting */ + + Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL; + PrTerminatePreprocessor (); + return (TRUE); + } + + /* Point compiler input to the new preprocessor file (.i) */ + + FlCloseFile (ASL_FILE_INPUT); + Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle; + AslCompilerin = Gbl_Files[ASL_FILE_INPUT].Handle; + + /* Reset globals to allow compiler to run */ + + FlSeekFile (ASL_FILE_INPUT, 0); + Gbl_CurrentLineNumber = 1; + + DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n"); + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: PrPreprocessInputFile + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Preprocess one entire file, line-by-line. + * + * Input: Raw user ASL from ASL_FILE_INPUT + * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR + * + ******************************************************************************/ + +static void +PrPreprocessInputFile ( + void) +{ + UINT32 Offset; + char *Token; + char *ReplaceString; + PR_DEFINE_INFO *DefineInfo; + ACPI_SIZE TokenOffset; + BOOLEAN IgnoringThisCodeBlock = FALSE; + char *Next; + int OffsetAdjust; + + + /* Scan line-by-line. Comments and blank lines are skipped by this function */ + + while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF) + { + /* Need a copy of the input line for strok() */ + + strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer); + Token = PrGetNextToken (Gbl_MainTokenBuffer, PR_TOKEN_SEPARATORS, &Next); + OffsetAdjust = 0; + + /* All preprocessor directives must begin with '#' */ + + if (Token && (*Token == '#')) + { + if (strlen (Token) == 1) + { + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); + } + else + { + Token++; /* Skip leading # */ + } + + /* Execute the directive, do not write line to output file */ + + PrDoDirective (Token, &Next, &IgnoringThisCodeBlock); + continue; + } + + /* + * If we are currently within the part of an IF/ELSE block that is + * FALSE, ignore the line and do not write it to the output file. + * This continues until an #else or #endif is encountered. + */ + if (IgnoringThisCodeBlock == TRUE) + { + continue; + } + + /* Match and replace all #defined names within this source line */ + + while (Token) + { + DefineInfo = PrMatchDefine (Token); + if (DefineInfo) + { + if (DefineInfo->Body) + { + /* This is a macro */ + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Matched Macro: %s->%s\n", + Gbl_CurrentLineNumber, DefineInfo->Identifier, + DefineInfo->Replacement); + + PrDoMacroInvocation (Gbl_MainTokenBuffer, Token, + DefineInfo, &Next); + } + else + { + ReplaceString = DefineInfo->Replacement; + + /* Replace the name in the original line buffer */ + + TokenOffset = Token - Gbl_MainTokenBuffer + OffsetAdjust; + PrReplaceData ( + &Gbl_CurrentLineBuffer[TokenOffset], strlen (Token), + ReplaceString, strlen (ReplaceString)); + + /* Adjust for length difference between old and new name length */ + + OffsetAdjust += strlen (ReplaceString) - strlen (Token); + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Matched #define: %s->%s\n", + Gbl_CurrentLineNumber, Token, + *ReplaceString ? ReplaceString : "(NULL STRING)"); + } + } + + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next); + } + +#if 0 +/* Line prefix */ + FlPrintFile (ASL_FILE_PREPROCESSOR, "/* %14s %.5u i:%.5u */ ", + Gbl_Files[ASL_FILE_INPUT].Filename, + Gbl_CurrentLineNumber, Gbl_PreprocessorLineNumber); +#endif + + /* + * Emit a #line directive if necessary, to keep the line numbers in + * the (.i) file synchronized with the original source code file, so + * that the correct line number appears in any error messages + * generated by the actual compiler. + */ + if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1)) + { + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n", + Gbl_CurrentLineNumber); + } + + Gbl_PreviousLineNumber = Gbl_CurrentLineNumber; + Gbl_PreprocessorLineNumber++; + + /* + * Now we can write the possibly modified source line to the + * preprocessor (.i) file + */ + FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer, + strlen (Gbl_CurrentLineBuffer)); + } +} + + +/******************************************************************************* + * + * FUNCTION: PrDoDirective + * + * PARAMETERS: Directive - Pointer to directive name token + * Next - "Next" buffer from GetNextToken + * IgnoringThisCodeBlock - Where the "ignore code" flag is + * returned. + * + * RETURN: IgnoringThisCodeBlock: Set to TRUE if we are skipping the FALSE + * part of an #if or #else block. Set to FALSE when the + * corresponding #else or #endif is encountered. + * + * DESCRIPTION: Main processing for all preprocessor directives + * + ******************************************************************************/ + +static void +PrDoDirective ( + char *DirectiveToken, + char **Next, + BOOLEAN *IgnoringThisCodeBlock) +{ + char *Token = Gbl_MainTokenBuffer; + char *Token2; + char *End; + UINT64 Value; + ACPI_SIZE TokenOffset; + int Directive; + ACPI_STATUS Status; + + + if (!DirectiveToken) + { + goto SyntaxError; + } + + Directive = PrMatchDirective (DirectiveToken); + if (Directive == ASL_DIRECTIVE_NOT_FOUND) + { + PrError (ASL_ERROR, ASL_MSG_UNKNOWN_DIRECTIVE, + THIS_TOKEN_OFFSET (DirectiveToken)); + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "#%s: Unknown directive\n", + Gbl_CurrentLineNumber, DirectiveToken); + return; + } + + /* TBD: Need a faster way to do this: */ + + if ((Directive == PR_DIRECTIVE_ELIF) || + (Directive == PR_DIRECTIVE_ELSE) || + (Directive == PR_DIRECTIVE_ENDIF)) + { + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Begin #%s\n", + Gbl_CurrentLineNumber, Gbl_DirectiveInfo[Directive].Name); + } + + /* + * Need to always check for #else, #elif, #endif regardless of + * whether we are ignoring the current code block, since these + * are conditional code block terminators. + */ + switch (Directive) + { + case PR_DIRECTIVE_ELIF: + *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock); + if (*IgnoringThisCodeBlock == TRUE) + { + /* Not executing the ELSE part -- all done here */ + return; + } + + /* Will execute the ELSE..IF part */ + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "#elif - Executing else block\n", + Gbl_CurrentLineNumber); + Directive = PR_DIRECTIVE_IF; + break; + + case PR_DIRECTIVE_ELSE: + *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock); + return; + + case PR_DIRECTIVE_ENDIF: + *IgnoringThisCodeBlock = FALSE; + Gbl_IfDepth--; + if (Gbl_IfDepth < 0) + { + PrError (ASL_ERROR, ASL_MSG_ENDIF_MISMATCH, + THIS_TOKEN_OFFSET (DirectiveToken)); + Gbl_IfDepth = 0; + } + return; + + default: + break; + } + + /* + * At this point, if we are ignoring the current code block, + * do not process any more directives (i.e., ignore them also.) + */ + if (*IgnoringThisCodeBlock == TRUE) + { + return; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Begin #%s\n", + Gbl_CurrentLineNumber, Gbl_DirectiveInfo[Directive].Name); + + /* Most directives have at least one argument */ + + if (Gbl_DirectiveInfo[Directive].ArgCount == 1) + { + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); + if (!Token) + { + goto SyntaxError; + } + } + + switch (Directive) + { + case PR_DIRECTIVE_DEFINE: + /* + * By definition, if first char after the name is a paren, + * this is a function macro. + */ + TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token); + if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(') + { +#ifndef MACROS_SUPPORTED + AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n", + Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber); + exit(1); +#else + PrAddMacro (Token, Next); +#endif + } + else + { + /* Use the remainder of the line for the #define */ + + Token2 = *Next; + if (Token2) + { + while ((*Token2 == ' ') || (*Token2 == '\t')) + { + Token2++; + } + End = Token2; + while (*End != '\n') + { + End++; + } + *End = 0; + } + else + { + Token2 = ""; + } +#if 0 + Token2 = PrGetNextToken (NULL, "\n", /*PR_TOKEN_SEPARATORS,*/ Next); + if (!Token2) + { + Token2 = ""; + } +#endif + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "New #define: %s->%s\n", + Gbl_CurrentLineNumber, Token, Token2); + + PrAddDefine (Token, Token2, FALSE); + } + break; + + case PR_DIRECTIVE_ERROR: + /* TBD compiler should abort */ + /* Note: No macro expansion */ + + PrError (ASL_ERROR, ASL_MSG_ERROR_DIRECTIVE, + THIS_TOKEN_OFFSET (Token)); + break; + + case PR_DIRECTIVE_IF: + TokenOffset = Token - Gbl_MainTokenBuffer; + + /* Need to expand #define macros in the expression string first */ + + Status = PrResolveIntegerExpression ( + &Gbl_CurrentLineBuffer[TokenOffset-1], &Value); + if (ACPI_FAILURE (Status)) + { + return; + } + + if (!Value) + { + *IgnoringThisCodeBlock = TRUE; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Resolved #if: %8.8X%8.8X %s\n", + Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value), + *IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>"); + + Gbl_IfDepth++; + break; + + case PR_DIRECTIVE_IFDEF: + if (!PrMatchDefine (Token)) + { + *IgnoringThisCodeBlock = TRUE; + } + + Gbl_IfDepth++; + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Start #ifdef %s\n", Gbl_CurrentLineNumber, + *IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>"); + break; + + case PR_DIRECTIVE_IFNDEF: + if (PrMatchDefine (Token)) + { + *IgnoringThisCodeBlock = TRUE; + } + + Gbl_IfDepth++; + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Start #ifndef %2.2X\n", Gbl_CurrentLineNumber, + *IgnoringThisCodeBlock, Gbl_CurrentLineNumber); + break; + + case PR_DIRECTIVE_INCLUDE: + Token = PrGetNextToken (NULL, " \"<>", Next); + if (!Token) + { + goto SyntaxError; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Start #include file %s\n", Gbl_CurrentLineNumber, + Token, Gbl_CurrentLineNumber); + + PrOpenIncludeFile (Token); + break; + + case PR_DIRECTIVE_LINE: + TokenOffset = Token - Gbl_MainTokenBuffer; + + Status = PrResolveIntegerExpression ( + &Gbl_CurrentLineBuffer[TokenOffset-1], &Value); + if (ACPI_FAILURE (Status)) + { + return; + } + + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "User #line invocation %s\n", Gbl_CurrentLineNumber, + Token); + + /* Update local line numbers */ + + Gbl_CurrentLineNumber = (UINT32) Value; + Gbl_PreviousLineNumber = 0; + + /* Emit #line into the preprocessor file */ + + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", + Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename); + break; + + case PR_DIRECTIVE_PRAGMA: + /* Only "#pragma message" supported at this time */ + + if (strcmp (Token, "message")) + { + PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA, + THIS_TOKEN_OFFSET (Token)); + return; + } + + Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next); + if (!Token) + { + goto SyntaxError; + } + + TokenOffset = Token - Gbl_MainTokenBuffer; + AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]); + break; + + case PR_DIRECTIVE_UNDEF: + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "#undef: %s\n", Gbl_CurrentLineNumber, Token); + + PrRemoveDefine (Token); + break; + + case PR_DIRECTIVE_WARNING: + PrError (ASL_WARNING, ASL_MSG_ERROR_DIRECTIVE, + THIS_TOKEN_OFFSET (Token)); + break; + + default: + /* Should never get here */ + DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID + "Unrecognized directive: %u\n", + Gbl_CurrentLineNumber, Directive); + break; + } + + return; + + +SyntaxError: + + PrError (ASL_ERROR, ASL_MSG_DIRECTIVE_SYNTAX, + THIS_TOKEN_OFFSET (DirectiveToken)); + return; +} + + +/******************************************************************************* + * + * FUNCTION: PrMatchDirective + * + * PARAMETERS: Directive - Pointer to directive name token + * + * RETURN: Index into command array, -1 if not found + * + * DESCRIPTION: Lookup the incoming directive in the known directives table. + * + ******************************************************************************/ + +static int +PrMatchDirective ( + char *Directive) +{ + int i; + + + if (!Directive || Directive[0] == 0) + { + return (ASL_DIRECTIVE_NOT_FOUND); + } + + for (i = 0; Gbl_DirectiveInfo[i].Name; i++) + { + if (!strcmp (Gbl_DirectiveInfo[i].Name, Directive)) + { + return (i); + } + } + + return (ASL_DIRECTIVE_NOT_FOUND); /* Command not recognized */ +} diff --git a/src/acpica/source/compiler/prutils.c b/src/acpica/source/compiler/prutils.c new file mode 100644 index 0000000..a5fb46a --- /dev/null +++ b/src/acpica/source/compiler/prutils.c @@ -0,0 +1,540 @@ +/****************************************************************************** + * + * Module Name: prutils - Preprocessor utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "aslcompiler.h" +#include "dtcompiler.h" + + +#define _COMPONENT ASL_PREPROCESSOR + ACPI_MODULE_NAME ("prutils") + + +/****************************************************************************** + * + * FUNCTION: PrGetNextToken + * + * PARAMETERS: Buffer - Current line buffer + * MatchString - String with valid token delimiters + * Next - Set to next possible token in buffer + * + * RETURN: Next token (null-terminated). Modifies the input line. + * Remainder of line is stored in *Next. + * + * DESCRIPTION: Local implementation of strtok() with local storage for the + * next pointer. Not only thread-safe, but allows multiple + * parsing of substrings such as expressions. + * + *****************************************************************************/ + +char * +PrGetNextToken ( + char *Buffer, + char *MatchString, + char **Next) +{ + char *TokenStart; + + + if (!Buffer) + { + /* Use Next if it is valid */ + + Buffer = *Next; + if (!(*Next)) + { + return (NULL); + } + } + + /* Skip any leading delimiters */ + + while (*Buffer) + { + if (strchr (MatchString, *Buffer)) + { + Buffer++; + } + else + { + break; + } + } + + /* Anything left on the line? */ + + if (!(*Buffer)) + { + *Next = NULL; + return (NULL); + } + + TokenStart = Buffer; + + /* Find the end of this token */ + + while (*Buffer) + { + if (strchr (MatchString, *Buffer)) + { + *Buffer = 0; + *Next = Buffer+1; + if (!**Next) + { + *Next = NULL; + } + return (TokenStart); + } + Buffer++; + } + + *Next = NULL; + return (TokenStart); +} + + +/******************************************************************************* + * + * FUNCTION: PrError + * + * PARAMETERS: Level - Seriousness (Warning/error, etc.) + * MessageId - Index into global message buffer + * Column - Column in current line + * + * RETURN: None + * + * DESCRIPTION: Preprocessor error reporting. Front end to AslCommonError2 + * + ******************************************************************************/ + +void +PrError ( + UINT8 Level, + UINT8 MessageId, + UINT32 Column) +{ +#if 0 + AcpiOsPrintf ("%s (%u) : %s", Gbl_Files[ASL_FILE_INPUT].Filename, + Gbl_CurrentLineNumber, Gbl_CurrentLineBuffer); +#endif + + + if (Column > 120) + { + Column = 0; + } + + /* TBD: Need Logical line number? */ + + AslCommonError2 (Level, MessageId, + Gbl_CurrentLineNumber, Column, + Gbl_CurrentLineBuffer, + Gbl_Files[ASL_FILE_INPUT].Filename, "Preprocessor"); + + Gbl_PreprocessorError = TRUE; +} + + +/******************************************************************************* + * + * FUNCTION: PrReplaceData + * + * PARAMETERS: Buffer - Original(target) buffer pointer + * LengthToRemove - Length to be removed from target buffer + * BufferToAdd - Data to be inserted into target buffer + * LengthToAdd - Length of BufferToAdd + * + * RETURN: None + * + * DESCRIPTION: Generic buffer data replacement. + * + ******************************************************************************/ + +void +PrReplaceData ( + char *Buffer, + UINT32 LengthToRemove, + char *BufferToAdd, + UINT32 LengthToAdd) +{ + UINT32 BufferLength; + + + /* Buffer is a string, so the length must include the terminating zero */ + + BufferLength = strlen (Buffer) + 1; + + if (LengthToRemove != LengthToAdd) + { + /* + * Move some of the existing data + * 1) If adding more bytes than removing, make room for the new data + * 2) if removing more bytes than adding, delete the extra space + */ + if (LengthToRemove > 0) + { + memmove ((Buffer + LengthToAdd), (Buffer + LengthToRemove), + (BufferLength - LengthToRemove)); + } + } + + /* Now we can move in the new data */ + + if (LengthToAdd > 0) + { + memmove (Buffer, BufferToAdd, LengthToAdd); + } +} + + +/******************************************************************************* + * + * FUNCTION: PrOpenIncludeFile + * + * PARAMETERS: Filename - Filename or pathname for include file + * + * RETURN: None. + * + * DESCRIPTION: Open an include file and push it on the input file stack. + * + ******************************************************************************/ + +void +PrOpenIncludeFile ( + char *Filename) +{ + FILE *IncludeFile; + ASL_INCLUDE_DIR *NextDir; + + + /* + * start the actual include file on the next line + */ + Gbl_CurrentLineOffset++; + + /* Attempt to open the include file */ + + /* If the file specifies an absolute path, just open it */ + + if ((Filename[0] == '/') || + (Filename[0] == '\\') || + (Filename[1] == ':')) + { + IncludeFile = PrOpenIncludeWithPrefix ("", Filename); + if (!IncludeFile) + { + goto ErrorExit; + } + return; + } + + /* + * The include filename is not an absolute path. + * + * First, search for the file within the "local" directory -- meaning + * the same directory that contains the source file. + * + * Construct the file pathname from the global directory name. + */ + IncludeFile = PrOpenIncludeWithPrefix (Gbl_DirectoryPath, Filename); + if (IncludeFile) + { + return; + } + + /* + * Second, search for the file within the (possibly multiple) + * directories specified by the -I option on the command line. + */ + NextDir = Gbl_IncludeDirList; + while (NextDir) + { + IncludeFile = PrOpenIncludeWithPrefix (NextDir->Dir, Filename); + if (IncludeFile) + { + return; + } + + NextDir = NextDir->Next; + } + + /* We could not open the include file after trying very hard */ + +ErrorExit: + sprintf (Gbl_MainTokenBuffer, "%s, %s", Filename, strerror (errno)); + PrError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, 0); +} + + +/******************************************************************************* + * + * FUNCTION: FlOpenIncludeWithPrefix + * + * PARAMETERS: PrefixDir - Prefix directory pathname. Can be a zero + * length string. + * Filename - The include filename from the source ASL. + * + * RETURN: Valid file descriptor if successful. Null otherwise. + * + * DESCRIPTION: Open an include file and push it on the input file stack. + * + ******************************************************************************/ + +FILE * +PrOpenIncludeWithPrefix ( + char *PrefixDir, + char *Filename) +{ + FILE *IncludeFile; + char *Pathname; + + + /* Build the full pathname to the file */ + + Pathname = ACPI_ALLOCATE (strlen (PrefixDir) + strlen (Filename) + 1); + + strcpy (Pathname, PrefixDir); + strcat (Pathname, Filename); + + DbgPrint (ASL_PARSE_OUTPUT, "\n" PR_PREFIX_ID + "Opening include file: path %s\n", + Gbl_CurrentLineNumber, Pathname); + + /* Attempt to open the file, push if successful */ + + IncludeFile = fopen (Pathname, "r"); + if (IncludeFile) + { + /* Push the include file on the open input file stack */ + + PrPushInputFileStack (IncludeFile, Pathname); + return (IncludeFile); + } + + ACPI_FREE (Pathname); + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AslPushInputFileStack + * + * PARAMETERS: InputFile - Open file pointer + * Filename - Name of the file + * + * RETURN: None + * + * DESCRIPTION: Push the InputFile onto the file stack, and point the parser + * to this file. Called when an include file is successfully + * opened. + * + ******************************************************************************/ + +void +PrPushInputFileStack ( + FILE *InputFile, + char *Filename) +{ + PR_FILE_NODE *Fnode; + + + /* Save the current state in an Fnode */ + + Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE)); + + Fnode->File = Gbl_Files[ASL_FILE_INPUT].Handle; + Fnode->Next = Gbl_InputFileList; + Fnode->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; + Fnode->CurrentLineNumber = Gbl_CurrentLineNumber; + + /* Push it on the stack */ + + Gbl_InputFileList = Fnode; + + DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID + "Push InputFile Stack: handle %p\n\n", + Gbl_CurrentLineNumber, InputFile); + + /* Reset the global line count and filename */ + + Gbl_Files[ASL_FILE_INPUT].Filename = Filename; + Gbl_Files[ASL_FILE_INPUT].Handle = InputFile; + Gbl_PreviousLineNumber = 0; + Gbl_CurrentLineNumber = 0; + + /* Emit a new #line directive for the include file */ + + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", + 1, Filename); +} + + +/******************************************************************************* + * + * FUNCTION: AslPopInputFileStack + * + * PARAMETERS: None + * + * RETURN: 0 if a node was popped, -1 otherwise + * + * DESCRIPTION: Pop the top of the input file stack and point the parser to + * the saved parse buffer contained in the fnode. Also, set the + * global line counters to the saved values. This function is + * called when an include file reaches EOF. + * + ******************************************************************************/ + +BOOLEAN +PrPopInputFileStack ( + void) +{ + PR_FILE_NODE *Fnode; + + + Fnode = Gbl_InputFileList; + DbgPrint (ASL_PARSE_OUTPUT, "\n" PR_PREFIX_ID + "Pop InputFile Stack, Fnode %p\n\n", + Gbl_CurrentLineNumber, Fnode); + + if (!Fnode) + { + return (FALSE); + } + + /* Close the current include file */ + + fclose (Gbl_Files[ASL_FILE_INPUT].Handle); + + /* Update the top-of-stack */ + + Gbl_InputFileList = Fnode->Next; + + /* Reset global line counter and filename */ + + Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename; + Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File; + Gbl_CurrentLineNumber = Fnode->CurrentLineNumber; + Gbl_PreviousLineNumber = 0; + + /* Emit a new #line directive after the include file */ + + FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", + Gbl_CurrentLineNumber + 1, Fnode->Filename); + + /* All done with this node */ + + ACPI_FREE (Fnode); + return (TRUE); +} diff --git a/src/acpica/source/components/disassembler/dmresrcl2.c b/src/acpica/source/components/disassembler/dmresrcl2.c new file mode 100644 index 0000000..6a263c1 --- /dev/null +++ b/src/acpica/source/components/disassembler/dmresrcl2.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2) + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#include "acpi.h" +#include "accommon.h" +#include "acdisasm.h" + + +#ifdef ACPI_DISASSEMBLER + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("dbresrcl2") + +/* Local prototypes */ + +static void +AcpiDmI2cSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +static void +AcpiDmSpiSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +static void +AcpiDmUartSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +static void +AcpiDmGpioCommon ( + AML_RESOURCE *Resource, + UINT32 Level); + +static void +AcpiDmDumpRawDataBuffer ( + UINT8 *Buffer, + UINT32 Length, + UINT32 Level); + + +/* Dispatch table for the serial bus descriptors */ + +static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] = +{ + NULL, + AcpiDmI2cSerialBusDescriptor, + AcpiDmSpiSerialBusDescriptor, + AcpiDmUartSerialBusDescriptor +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpRawDataBuffer + * + * PARAMETERS: Buffer - Pointer to the data bytes + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for + * vendor data bytes. + * + ******************************************************************************/ + +static void +AcpiDmDumpRawDataBuffer ( + UINT8 *Buffer, + UINT32 Length, + UINT32 Level) +{ + UINT32 Index; + UINT32 i; + UINT32 j; + + + if (!Length) + { + return; + } + + AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length); + + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("{\n"); + AcpiDmIndent (Level + 2); + + for (i = 0; i < Length;) + { + for (j = 0; j < 8; j++) + { + Index = i + j; + if (Index >= Length) + { + goto Finish; + } + + AcpiOsPrintf ("0x%2.2X", Buffer[Index]); + if ((Index + 1) >= Length) + { + goto Finish; + } + + AcpiOsPrintf (", "); + } + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 2); + + i += 8; + } + +Finish: + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("}"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGpioCommon + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor + * + ******************************************************************************/ + +static void +AcpiDmGpioCommon ( + AML_RESOURCE *Resource, + UINT32 Level) +{ + UINT32 PinCount; + UINT16 *PinList; + UINT8 *VendorData; + UINT32 i; + + + /* ResourceSource, ResourceSourceIndex, ResourceType */ + + AcpiDmIndent (Level + 1); + if (Resource->Gpio.ResSourceOffset) + { + AcpiUtPrintString ( + ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), + ACPI_UINT8_MAX); + } + + AcpiOsPrintf (", "); + AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex); + AcpiOsPrintf ("%s, ", + AcpiGbl_ConsumeDecode [(Resource->Gpio.Flags & 1)]); + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + AcpiOsPrintf (","); + + /* Dump the vendor data */ + + if (Resource->Gpio.VendorOffset) + { + AcpiOsPrintf ("\n"); + AcpiDmIndent (Level + 1); + VendorData = ACPI_ADD_PTR (UINT8, Resource, + Resource->Gpio.VendorOffset); + + AcpiDmDumpRawDataBuffer (VendorData, + Resource->Gpio.VendorLength, Level); + } + + AcpiOsPrintf (")\n"); + + /* Dump the interrupt list */ + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("{ // Pin list\n"); + + PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset - + Resource->Gpio.PinTableOffset)) / + sizeof (UINT16); + + PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource, + Resource->Gpio.PinTableOffset); + + for (i = 0; i < PinCount; i++) + { + AcpiDmIndent (Level + 2); + AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : ""); + } + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("}\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGpioIntDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a GPIO Interrupt descriptor + * + ******************************************************************************/ + +static void +AcpiDmGpioIntDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + + /* Dump the GpioInt-specific portion of the descriptor */ + + /* EdgeLevel, ActiveLevel, Shared */ + + AcpiDmIndent (Level); + AcpiOsPrintf ("GpioInt (%s, %s, %s, ", + AcpiGbl_HeDecode [(Resource->Gpio.IntFlags & 1)], + AcpiGbl_LlDecode [(Resource->Gpio.IntFlags >> 1) & 1], + AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); + + /* PinConfig, DebounceTimeout */ + + if (Resource->Gpio.PinConfig <= 3) + { + AcpiOsPrintf ("%s, ", + AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); + } + else + { + AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); + } + AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout); + + /* Dump the GpioInt/GpioIo common portion of the descriptor */ + + AcpiDmGpioCommon (Resource, Level); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGpioIoDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a GPIO Interrupt descriptor + * + ******************************************************************************/ + +static void +AcpiDmGpioIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + + /* Dump the GpioIo-specific portion of the descriptor */ + + /* Shared, PinConfig */ + + AcpiDmIndent (Level); + AcpiOsPrintf ("GpioIo (%s, ", + AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); + + if (Resource->Gpio.PinConfig <= 3) + { + AcpiOsPrintf ("%s, ", + AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); + } + else + { + AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); + } + + /* DebounceTimeout, DriveStrength, IoRestriction */ + + AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout); + AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength); + AcpiOsPrintf ("%s,\n", + AcpiGbl_IorDecode [Resource->Gpio.IntFlags & 3]); + + /* Dump the GpioInt/GpioIo common portion of the descriptor */ + + AcpiDmGpioCommon (Resource, Level); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGpioDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor + * + ******************************************************************************/ + +void +AcpiDmGpioDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + UINT8 ConnectionType; + + + ConnectionType = Resource->Gpio.ConnectionType; + + switch (ConnectionType) + { + case AML_RESOURCE_GPIO_TYPE_INT: + AcpiDmGpioIntDescriptor (Resource, Length, Level); + break; + + case AML_RESOURCE_GPIO_TYPE_IO: + AcpiDmGpioIoDescriptor (Resource, Length, Level); + break; + + default: + AcpiOsPrintf ("Unknown GPIO type\n"); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpSerialBusVendorData + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * + * RETURN: None + * + * DESCRIPTION: Dump optional serial bus vendor data + * + ******************************************************************************/ + +static void +AcpiDmDumpSerialBusVendorData ( + AML_RESOURCE *Resource, + UINT32 Level) +{ + UINT8 *VendorData; + UINT32 VendorLength; + + + /* Get the (optional) vendor data and length */ + + switch (Resource->CommonSerialBus.Type) + { + case AML_RESOURCE_I2C_SERIALBUSTYPE: + + VendorLength = Resource->CommonSerialBus.TypeDataLength - + AML_RESOURCE_I2C_MIN_DATA_LEN; + + VendorData = ACPI_ADD_PTR (UINT8, Resource, + sizeof (AML_RESOURCE_I2C_SERIALBUS)); + break; + + case AML_RESOURCE_SPI_SERIALBUSTYPE: + + VendorLength = Resource->CommonSerialBus.TypeDataLength - + AML_RESOURCE_SPI_MIN_DATA_LEN; + + VendorData = ACPI_ADD_PTR (UINT8, Resource, + sizeof (AML_RESOURCE_SPI_SERIALBUS)); + break; + + case AML_RESOURCE_UART_SERIALBUSTYPE: + + VendorLength = Resource->CommonSerialBus.TypeDataLength - + AML_RESOURCE_UART_MIN_DATA_LEN; + + VendorData = ACPI_ADD_PTR (UINT8, Resource, + sizeof (AML_RESOURCE_UART_SERIALBUS)); + break; + + default: + return; + } + + /* Dump the vendor bytes as a RawDataBuffer object */ + + AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmI2cSerialBusDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a I2C serial bus descriptor + * + ******************************************************************************/ + +static void +AcpiDmI2cSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + UINT32 ResourceSourceOffset; + + + /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */ + + AcpiDmIndent (Level); + AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n", + Resource->I2cSerialBus.SlaveAddress, + AcpiGbl_SmDecode [(Resource->I2cSerialBus.Flags & 1)], + Resource->I2cSerialBus.ConnectionSpeed); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("%s, ", + AcpiGbl_AmDecode [(Resource->I2cSerialBus.TypeSpecificFlags & 1)]); + + /* ResourceSource is a required field */ + + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + + Resource->CommonSerialBus.TypeDataLength; + + AcpiUtPrintString ( + ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), + ACPI_UINT8_MAX); + + /* ResourceSourceIndex, ResourceUsage */ + + AcpiOsPrintf (",\n"); + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex); + + AcpiOsPrintf ("%s, ", + AcpiGbl_ConsumeDecode [(Resource->I2cSerialBus.Flags >> 1) & 1]); + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + AcpiOsPrintf (",\n"); + + /* Dump the vendor data */ + + AcpiDmIndent (Level + 1); + AcpiDmDumpSerialBusVendorData (Resource, Level); + AcpiOsPrintf (")\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmSpiSerialBusDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a SPI serial bus descriptor + * + ******************************************************************************/ + +static void +AcpiDmSpiSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + UINT32 ResourceSourceOffset; + + + /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */ + + AcpiDmIndent (Level); + AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n", + Resource->SpiSerialBus.DeviceSelection, + AcpiGbl_DpDecode [(Resource->SpiSerialBus.TypeSpecificFlags >> 1) & 1], + AcpiGbl_WmDecode [(Resource->SpiSerialBus.TypeSpecificFlags & 1)], + Resource->SpiSerialBus.DataBitLength); + + /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */ + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("%s, 0x%8.8X, %s,\n", + AcpiGbl_SmDecode [(Resource->SpiSerialBus.Flags & 1)], + Resource->SpiSerialBus.ConnectionSpeed, + AcpiGbl_CpoDecode [(Resource->SpiSerialBus.ClockPolarity & 1)]); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("%s, ", + AcpiGbl_CphDecode [(Resource->SpiSerialBus.ClockPhase & 1)]); + + /* ResourceSource is a required field */ + + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + + Resource->CommonSerialBus.TypeDataLength; + + AcpiUtPrintString ( + ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), + ACPI_UINT8_MAX); + + /* ResourceSourceIndex, ResourceUsage */ + + AcpiOsPrintf (",\n"); + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex); + + AcpiOsPrintf ("%s, ", + AcpiGbl_ConsumeDecode [(Resource->SpiSerialBus.Flags >> 1) & 1]); + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + AcpiOsPrintf (",\n"); + + /* Dump the vendor data */ + + AcpiDmIndent (Level + 1); + AcpiDmDumpSerialBusVendorData (Resource, Level); + AcpiOsPrintf (")\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmUartSerialBusDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a UART serial bus descriptor + * + ******************************************************************************/ + +static void +AcpiDmUartSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + UINT32 ResourceSourceOffset; + + + /* ConnectionSpeed, BitsPerByte, StopBits */ + + AcpiDmIndent (Level); + AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n", + Resource->UartSerialBus.DefaultBaudRate, + AcpiGbl_BpbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 4) & 3], + AcpiGbl_SbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 2) & 3]); + + /* LinesInUse, IsBigEndian, Parity, FlowControl */ + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n", + Resource->UartSerialBus.LinesEnabled, + AcpiGbl_EdDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 7) & 1], + AcpiGbl_PtDecode [Resource->UartSerialBus.Parity & 7], + AcpiGbl_FcDecode [Resource->UartSerialBus.TypeSpecificFlags & 3]); + + /* ReceiveBufferSize, TransmitBufferSize */ + + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ", + Resource->UartSerialBus.RxFifoSize, + Resource->UartSerialBus.TxFifoSize); + + /* ResourceSource is a required field */ + + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + + Resource->CommonSerialBus.TypeDataLength; + + AcpiUtPrintString ( + ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), + ACPI_UINT8_MAX); + + /* ResourceSourceIndex, ResourceUsage */ + + AcpiOsPrintf (",\n"); + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex); + + AcpiOsPrintf ("%s, ", + AcpiGbl_ConsumeDecode [(Resource->UartSerialBus.Flags >> 1) & 1]); + + /* Insert a descriptor name */ + + AcpiDmDescriptorName (); + AcpiOsPrintf (",\n"); + + /* Dump the vendor data */ + + AcpiDmIndent (Level + 1); + AcpiDmDumpSerialBusVendorData (Resource, Level); + AcpiOsPrintf (")\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmSerialBusDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor + * + ******************************************************************************/ + +void +AcpiDmSerialBusDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + + SerialBusResourceDispatch [Resource->CommonSerialBus.Type] ( + Resource, Length, Level); +} + +#endif + diff --git a/src/acpica/source/components/hardware/hwesleep.c b/src/acpica/source/components/hardware/hwesleep.c new file mode 100644 index 0000000..b137229 --- /dev/null +++ b/src/acpica/source/components/hardware/hwesleep.c @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the + * extended FADT-V5 sleep registers. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwesleep") + + +/******************************************************************************* + * + * FUNCTION: AcpiHwExecuteSleepMethod + * + * PARAMETERS: MethodPathname - Pathname of method to execute + * IntegerArgument - Argument to pass to the method + * + * RETURN: None + * + * DESCRIPTION: Execute a sleep/wake related method with one integer argument + * and no return value. + * + ******************************************************************************/ + +void +AcpiHwExecuteSleepMethod ( + char *MethodPathname, + UINT32 IntegerArgument) +{ + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwExecuteSleepMethod); + + + /* One argument, IntegerArgument; No return value expected */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = (UINT64) IntegerArgument; + + Status = AcpiEvaluateObject (NULL, MethodPathname, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While executing method %s", + MethodPathname)); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwExtendedSleep + * + * PARAMETERS: SleepState - Which sleep state to enter + * Flags - ACPI_EXECUTE_GTS to run optional method + * + * RETURN: Status + * + * DESCRIPTION: Enter a system sleep state via the extended FADT sleep + * registers (V5 FADT). + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwExtendedSleep ( + UINT8 SleepState, + UINT8 Flags) +{ + ACPI_STATUS Status; + UINT8 SleepTypeValue; + UINT64 SleepStatus; + + + ACPI_FUNCTION_TRACE (HwExtendedSleep); + + + /* Extended sleep registers must be valid */ + + if (!AcpiGbl_FADT.SleepControl.Address || + !AcpiGbl_FADT.SleepStatus.Address) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Clear wake status (WAK_STS) */ + + Status = AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiGbl_SystemAwakeAndRunning = FALSE; + + /* Optionally execute _GTS (Going To Sleep) */ + + if (Flags & ACPI_EXECUTE_GTS) + { + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__GTS, SleepState); + } + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE (); + + /* + * Set the SLP_TYP and SLP_EN bits. + * + * Note: We only use the first value returned by the \_Sx method + * (AcpiGbl_SleepTypeA) - As per ACPI specification. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%u]\n", SleepState)); + + SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & + ACPI_X_SLEEP_TYPE_MASK); + + Status = AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE), + &AcpiGbl_FADT.SleepControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Wait for transition back to Working State */ + + do + { + Status = AcpiRead (&SleepStatus, &AcpiGbl_FADT.SleepStatus); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } while (!(((UINT8) SleepStatus) & ACPI_X_WAKE_STATUS)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwExtendedWakePrep + * + * PARAMETERS: SleepState - Which sleep state we just exited + * Flags - ACPI_EXECUTE_BFS to run optional method + * + * RETURN: Status + * + * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after + * a sleep. Called with interrupts ENABLED. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwExtendedWakePrep ( + UINT8 SleepState, + UINT8 Flags) +{ + ACPI_STATUS Status; + UINT8 SleepTypeValue; + + + ACPI_FUNCTION_TRACE (HwExtendedWakePrep); + + + Status = AcpiGetSleepTypeData (ACPI_STATE_S0, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_SUCCESS (Status)) + { + SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & + ACPI_X_SLEEP_TYPE_MASK); + + (void) AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE), + &AcpiGbl_FADT.SleepControl); + } + + /* Optionally execute _BFS (Back From Sleep) */ + + if (Flags & ACPI_EXECUTE_BFS) + { + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__BFS, SleepState); + } + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwExtendedWake + * + * PARAMETERS: SleepState - Which sleep state we just exited + * Flags - Reserved, set to zero + * + * RETURN: Status + * + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwExtendedWake ( + UINT8 SleepState, + UINT8 Flags) +{ + ACPI_FUNCTION_TRACE (HwExtendedWake); + + + /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ + + AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; + + /* Execute the wake methods */ + + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, ACPI_SST_WAKING); + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__WAK, SleepState); + + /* + * Some BIOS code assumes that WAK_STS will be cleared on resume + * and use it to determine whether the system is rebooting or + * resuming. Clear WAK_STS for compatibility. + */ + (void) AcpiWrite ((UINT64) ACPI_X_WAKE_STATUS, &AcpiGbl_FADT.SleepStatus); + AcpiGbl_SystemAwakeAndRunning = TRUE; + + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, ACPI_SST_WORKING); + return_ACPI_STATUS (AE_OK); +} diff --git a/src/acpica/source/components/hardware/hwxfsleep.c b/src/acpica/source/components/hardware/hwxfsleep.c new file mode 100644 index 0000000..631b81e --- /dev/null +++ b/src/acpica/source/components/hardware/hwxfsleep.c @@ -0,0 +1,550 @@ +/****************************************************************************** + * + * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake External Interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwxfsleep") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwSleepDispatch ( + UINT8 SleepState, + UINT8 Flags, + UINT32 FunctionId); + +/* + * Dispatch table used to efficiently branch to the various sleep + * functions. + */ +#define ACPI_SLEEP_FUNCTION_ID 0 +#define ACPI_WAKE_PREP_FUNCTION_ID 1 +#define ACPI_WAKE_FUNCTION_ID 2 + +/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */ + +static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] = +{ + {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacySleep), AcpiHwExtendedSleep}, + {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWakePrep), AcpiHwExtendedWakePrep}, + {ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWake), AcpiHwExtendedWake} +}; + + +/* + * These functions are removed for the ACPI_REDUCED_HARDWARE case: + * AcpiSetFirmwareWakingVector + * AcpiSetFirmwareWakingVector64 + * AcpiEnterSleepStateS4bios + */ + +#if (!ACPI_REDUCED_HARDWARE) +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector + * + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode + * entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); + + + /* Set the 32-bit vector */ + + AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; + + /* Clear the 64-bit vector if it exists */ + + if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) + { + AcpiGbl_FACS->XFirmwareWakingVector = 0; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) + + +#if ACPI_MACHINE_WIDTH == 64 +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector64 + * + * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected + * mode entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if + * it exists in the table. This function is intended for use with + * 64-bit host operating systems. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); + + + /* Determine if the 64-bit vector actually exists */ + + if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Clear 32-bit vector, set the 64-bit X_ vector */ + + AcpiGbl_FACS->FirmwareWakingVector = 0; + AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStateS4bios + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Perform a S4 bios request. + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void) +{ + UINT32 InValue; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); + + + /* Clear the wake status bit (PM1) */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_FLUSH_CPU_CACHE (); + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); + + do { + AcpiOsStall(1000); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) + +#endif /* !ACPI_REDUCED_HARDWARE */ + + +/******************************************************************************* + * + * FUNCTION: AcpiHwSleepDispatch + * + * PARAMETERS: SleepState - Which sleep state to enter/exit + * FunctionId - Sleep, WakePrep, or Wake + * + * RETURN: Status from the invoked sleep handling function. + * + * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling + * function. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwSleepDispatch ( + UINT8 SleepState, + UINT8 Flags, + UINT32 FunctionId) +{ + ACPI_STATUS Status; + ACPI_SLEEP_FUNCTIONS *SleepFunctions = &AcpiSleepDispatch[FunctionId]; + + +#if (!ACPI_REDUCED_HARDWARE) + + /* + * If the Hardware Reduced flag is set (from the FADT), we must + * use the extended sleep registers + */ + if (AcpiGbl_ReducedHardware || + AcpiGbl_FADT.SleepControl.Address) + { + Status = SleepFunctions->ExtendedFunction (SleepState, Flags); + } + else + { + /* Legacy sleep */ + + Status = SleepFunctions->LegacyFunction (SleepState, Flags); + } + + return (Status); + +#else + /* + * For the case where reduced-hardware-only code is being generated, + * we know that only the extended sleep registers are available + */ + Status = SleepFunctions->ExtendedFunction (SleepState, Flags); + return (Status); + +#endif /* !ACPI_REDUCED_HARDWARE */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStatePrep + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Prepare to enter a system sleep state. + * This function must execute with interrupts enabled. + * We break sleeping into 2 stages so that OSPM can handle + * various OS-specific tasks between the two steps. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + UINT32 SstValue; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); + + + Status = AcpiGetSleepTypeData (SleepState, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _PTS method (Prepare To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_PATHNAME__PTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Setup the argument to the _SST method (System STatus) */ + + switch (SleepState) + { + case ACPI_STATE_S0: + SstValue = ACPI_SST_WORKING; + break; + + case ACPI_STATE_S1: + case ACPI_STATE_S2: + case ACPI_STATE_S3: + SstValue = ACPI_SST_SLEEPING; + break; + + case ACPI_STATE_S4: + SstValue = ACPI_SST_SLEEP_CONTEXT; + break; + + default: + SstValue = ACPI_SST_INDICATOR_OFF; /* Default is off */ + break; + } + + /* + * Set the system indicators to show the desired sleep state. + * _SST is an optional method (return no error if not found) + */ + AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, SstValue); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepState + * + * PARAMETERS: SleepState - Which sleep state to enter + * Flags - ACPI_EXECUTE_GTS to run optional method + * + * RETURN: Status + * + * DESCRIPTION: Enter a system sleep state + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState, + UINT8 Flags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepState); + + + if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || + (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) + { + ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", + AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + Status = AcpiHwSleepDispatch (SleepState, Flags, ACPI_SLEEP_FUNCTION_ID); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) + + +/******************************************************************************* + * + * FUNCTION: AcpiLeaveSleepStatePrep + * + * PARAMETERS: SleepState - Which sleep state we are exiting + * Flags - ACPI_EXECUTE_BFS to run optional method + * + * RETURN: Status + * + * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a + * sleep. Called with interrupts DISABLED. + * We break wake/resume into 2 stages so that OSPM can handle + * various OS-specific tasks between the two steps. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLeaveSleepStatePrep ( + UINT8 SleepState, + UINT8 Flags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLeaveSleepStatePrep); + + + Status = AcpiHwSleepDispatch (SleepState, Flags, ACPI_WAKE_PREP_FUNCTION_ID); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepStatePrep) + + +/******************************************************************************* + * + * FUNCTION: AcpiLeaveSleepState + * + * PARAMETERS: SleepState - Which sleep state we are exiting + * + * RETURN: Status + * + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); + + + Status = AcpiHwSleepDispatch (SleepState, 0, ACPI_WAKE_FUNCTION_ID); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) diff --git a/src/acpica/source/components/resources/rsserial.c b/src/acpica/source/components/resources/rsserial.c new file mode 100644 index 0000000..0bc71e7 --- /dev/null +++ b/src/acpica/source/components/resources/rsserial.c @@ -0,0 +1,497 @@ +/******************************************************************************* + * + * Module Name: rsserial - GPIO/SerialBus resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSIRQ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsserial") + + +/******************************************************************************* + * + * AcpiRsConvertGpio + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertGpio[17] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GPIO, + ACPI_RS_SIZE (ACPI_RESOURCE_GPIO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGpio)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GPIO, + sizeof (AML_RESOURCE_GPIO), + 0}, + + /* + * These fields are contiguous in both the source and destination: + * RevisionId + * ConnectionType + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.RevisionId), + AML_OFFSET (Gpio.RevisionId), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.ProducerConsumer), + AML_OFFSET (Gpio.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Sharable), + AML_OFFSET (Gpio.IntFlags), + 3}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.IoRestriction), + AML_OFFSET (Gpio.IntFlags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Triggering), + AML_OFFSET (Gpio.IntFlags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Gpio.Polarity), + AML_OFFSET (Gpio.IntFlags), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.PinConfig), + AML_OFFSET (Gpio.PinConfig), + 1}, + + /* + * These fields are contiguous in both the source and destination: + * DriveStrength + * DebounceTimeout + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Gpio.DriveStrength), + AML_OFFSET (Gpio.DriveStrength), + 2}, + + /* Pin Table */ + + {ACPI_RSC_COUNT_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTableLength), + AML_OFFSET (Gpio.PinTableOffset), + AML_OFFSET (Gpio.ResSourceOffset)}, + + {ACPI_RSC_MOVE_GPIO_PIN, ACPI_RS_OFFSET (Data.Gpio.PinTable), + AML_OFFSET (Gpio.PinTableOffset), + 0}, + + /* Resource Source */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.Index), + AML_OFFSET (Gpio.ResSourceIndex), + 1}, + + {ACPI_RSC_COUNT_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringLength), + AML_OFFSET (Gpio.ResSourceOffset), + AML_OFFSET (Gpio.VendorOffset)}, + + {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.ResourceSource.StringPtr), + AML_OFFSET (Gpio.ResSourceOffset), + 0}, + + /* Vendor Data */ + + {ACPI_RSC_COUNT_GPIO_VEN, ACPI_RS_OFFSET (Data.Gpio.VendorLength), + AML_OFFSET (Gpio.VendorLength), + 1}, + + {ACPI_RSC_MOVE_GPIO_RES, ACPI_RS_OFFSET (Data.Gpio.VendorData), + AML_OFFSET (Gpio.VendorOffset), + 0}, +}; + + +/******************************************************************************* + * + * AcpiRsConvertI2cSerialBus + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertI2cSerialBus[16] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, + ACPI_RS_SIZE (ACPI_RESOURCE_I2C_SERIALBUS), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertI2cSerialBus)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, + sizeof (AML_RESOURCE_I2C_SERIALBUS), + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), + AML_OFFSET (CommonSerialBus.RevisionId), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), + AML_OFFSET (CommonSerialBus.Type), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), + AML_OFFSET (CommonSerialBus.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), + AML_OFFSET (CommonSerialBus.Flags), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), + AML_OFFSET (CommonSerialBus.TypeRevisionId), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + 1}, + + /* Vendor data */ + + {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + AML_RESOURCE_I2C_MIN_DATA_LEN}, + + {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), + 0, + sizeof (AML_RESOURCE_I2C_SERIALBUS)}, + + /* Resource Source */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), + AML_OFFSET (CommonSerialBus.ResSourceIndex), + 1}, + + {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, + + {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), + AML_OFFSET (CommonSerialBus.TypeDataLength), + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, + + /* I2C bus type specific */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.I2cSerialBus.AccessMode), + AML_OFFSET (I2cSerialBus.TypeSpecificFlags), + 0}, + + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.I2cSerialBus.ConnectionSpeed), + AML_OFFSET (I2cSerialBus.ConnectionSpeed), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.I2cSerialBus.SlaveAddress), + AML_OFFSET (I2cSerialBus.SlaveAddress), + 1}, +}; + + +/******************************************************************************* + * + * AcpiRsConvertSpiSerialBus + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertSpiSerialBus[20] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, + ACPI_RS_SIZE (ACPI_RESOURCE_SPI_SERIALBUS), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertSpiSerialBus)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, + sizeof (AML_RESOURCE_SPI_SERIALBUS), + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), + AML_OFFSET (CommonSerialBus.RevisionId), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), + AML_OFFSET (CommonSerialBus.Type), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), + AML_OFFSET (CommonSerialBus.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), + AML_OFFSET (CommonSerialBus.Flags), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), + AML_OFFSET (CommonSerialBus.TypeRevisionId), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + 1}, + + /* Vendor data */ + + {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + AML_RESOURCE_SPI_MIN_DATA_LEN}, + + {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), + 0, + sizeof (AML_RESOURCE_SPI_SERIALBUS)}, + + /* Resource Source */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), + AML_OFFSET (CommonSerialBus.ResSourceIndex), + 1}, + + {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, + + {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), + AML_OFFSET (CommonSerialBus.TypeDataLength), + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, + + /* Spi bus type specific */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.WireMode), + AML_OFFSET (SpiSerialBus.TypeSpecificFlags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.SpiSerialBus.DevicePolarity), + AML_OFFSET (SpiSerialBus.TypeSpecificFlags), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.DataBitLength), + AML_OFFSET (SpiSerialBus.DataBitLength), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPhase), + AML_OFFSET (SpiSerialBus.ClockPhase), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.SpiSerialBus.ClockPolarity), + AML_OFFSET (SpiSerialBus.ClockPolarity), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.SpiSerialBus.DeviceSelection), + AML_OFFSET (SpiSerialBus.DeviceSelection), + 1}, + + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.SpiSerialBus.ConnectionSpeed), + AML_OFFSET (SpiSerialBus.ConnectionSpeed), + 1}, +}; + + +/******************************************************************************* + * + * AcpiRsConvertUartSerialBus + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertUartSerialBus[22] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_SERIAL_BUS, + ACPI_RS_SIZE (ACPI_RESOURCE_UART_SERIALBUS), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertUartSerialBus)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_SERIAL_BUS, + sizeof (AML_RESOURCE_UART_SERIALBUS), + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.RevisionId), + AML_OFFSET (CommonSerialBus.RevisionId), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.Type), + AML_OFFSET (CommonSerialBus.Type), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.SlaveMode), + AML_OFFSET (CommonSerialBus.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.CommonSerialBus.ProducerConsumer), + AML_OFFSET (CommonSerialBus.Flags), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeRevisionId), + AML_OFFSET (CommonSerialBus.TypeRevisionId), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.CommonSerialBus.TypeDataLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + 1}, + + /* Vendor data */ + + {ACPI_RSC_COUNT_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + AML_RESOURCE_UART_MIN_DATA_LEN}, + + {ACPI_RSC_MOVE_SERIAL_VEN, ACPI_RS_OFFSET (Data.CommonSerialBus.VendorData), + 0, + sizeof (AML_RESOURCE_UART_SERIALBUS)}, + + /* Resource Source */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.Index), + AML_OFFSET (CommonSerialBus.ResSourceIndex), + 1}, + + {ACPI_RSC_COUNT_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringLength), + AML_OFFSET (CommonSerialBus.TypeDataLength), + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, + + {ACPI_RSC_MOVE_SERIAL_RES, ACPI_RS_OFFSET (Data.CommonSerialBus.ResourceSource.StringPtr), + AML_OFFSET (CommonSerialBus.TypeDataLength), + sizeof (AML_RESOURCE_COMMON_SERIALBUS)}, + + /* Uart bus type specific */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.FlowControl), + AML_OFFSET (UartSerialBus.TypeSpecificFlags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.StopBits), + AML_OFFSET (UartSerialBus.TypeSpecificFlags), + 2}, + + {ACPI_RSC_3BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.DataBits), + AML_OFFSET (UartSerialBus.TypeSpecificFlags), + 4}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.UartSerialBus.Endian), + AML_OFFSET (UartSerialBus.TypeSpecificFlags), + 7}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.Parity), + AML_OFFSET (UartSerialBus.Parity), + 1}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.UartSerialBus.LinesEnabled), + AML_OFFSET (UartSerialBus.LinesEnabled), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.RxFifoSize), + AML_OFFSET (UartSerialBus.RxFifoSize), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.UartSerialBus.TxFifoSize), + AML_OFFSET (UartSerialBus.TxFifoSize), + 1}, + + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.UartSerialBus.DefaultBaudRate), + AML_OFFSET (UartSerialBus.DefaultBaudRate), + 1}, +}; diff --git a/src/acpica/source/components/utilities/utaddress.c b/src/acpica/source/components/utilities/utaddress.c new file mode 100644 index 0000000..8cbc8a9 --- /dev/null +++ b/src/acpica/source/components/utilities/utaddress.c @@ -0,0 +1,394 @@ +/****************************************************************************** + * + * Module Name: utaddress - OpRegion address range check + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTADDRESS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utaddress") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAddAddressRange + * + * PARAMETERS: SpaceId - Address space ID + * Address - OpRegion start address + * Length - OpRegion length + * RegionNode - OpRegion namespace node + * + * RETURN: Status + * + * DESCRIPTION: Add the Operation Region address range to the global list. + * The only supported Space IDs are Memory and I/O. Called when + * the OpRegion address/length operands are fully evaluated. + * + * MUTEX: Locks the namespace + * + * NOTE: Because this interface is only called when an OpRegion argument + * list is evaluated, there cannot be any duplicate RegionNodes. + * Duplicate Address/Length values are allowed, however, so that multiple + * address conflicts can be detected. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAddAddressRange ( + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Length, + ACPI_NAMESPACE_NODE *RegionNode) +{ + ACPI_ADDRESS_RANGE *RangeInfo; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtAddAddressRange); + + + if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate/init a new info block, add it to the appropriate list */ + + RangeInfo = ACPI_ALLOCATE (sizeof (ACPI_ADDRESS_RANGE)); + if (!RangeInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + RangeInfo->StartAddress = Address; + RangeInfo->EndAddress = (Address + Length - 1); + RangeInfo->RegionNode = RegionNode; + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (RangeInfo); + return_ACPI_STATUS (Status); + } + + RangeInfo->Next = AcpiGbl_AddressRangeList[SpaceId]; + AcpiGbl_AddressRangeList[SpaceId] = RangeInfo; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "\nAdded [%4.4s] address range: 0x%p-0x%p\n", + AcpiUtGetNodeName (RangeInfo->RegionNode), + ACPI_CAST_PTR (void, Address), + ACPI_CAST_PTR (void, RangeInfo->EndAddress))); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveAddressRange + * + * PARAMETERS: SpaceId - Address space ID + * RegionNode - OpRegion namespace node + * + * RETURN: None + * + * DESCRIPTION: Remove the Operation Region from the global list. The only + * supported Space IDs are Memory and I/O. Called when an + * OpRegion is deleted. + * + * MUTEX: Assumes the namespace is locked + * + ******************************************************************************/ + +void +AcpiUtRemoveAddressRange ( + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_NAMESPACE_NODE *RegionNode) +{ + ACPI_ADDRESS_RANGE *RangeInfo; + ACPI_ADDRESS_RANGE *Prev; + + + ACPI_FUNCTION_TRACE (UtRemoveAddressRange); + + + if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + return_VOID; + } + + /* Get the appropriate list head and check the list */ + + RangeInfo = Prev = AcpiGbl_AddressRangeList[SpaceId]; + while (RangeInfo) + { + if (RangeInfo->RegionNode == RegionNode) + { + if (RangeInfo == Prev) /* Found at list head */ + { + AcpiGbl_AddressRangeList[SpaceId] = RangeInfo->Next; + } + else + { + Prev->Next = RangeInfo->Next; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "\nRemoved [%4.4s] address range: 0x%p-0x%p\n", + AcpiUtGetNodeName (RangeInfo->RegionNode), + ACPI_CAST_PTR (void, RangeInfo->StartAddress), + ACPI_CAST_PTR (void, RangeInfo->EndAddress))); + + ACPI_FREE (RangeInfo); + return_VOID; + } + + Prev = RangeInfo; + RangeInfo = RangeInfo->Next; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCheckAddressRange + * + * PARAMETERS: SpaceId - Address space ID + * Address - Start address + * Length - Length of address range + * Warn - TRUE if warning on overlap desired + * + * RETURN: Count of the number of conflicts detected. Zero is always + * returned for Space IDs other than Memory or I/O. + * + * DESCRIPTION: Check if the input address range overlaps any of the + * ASL operation region address ranges. The only supported + * Space IDs are Memory and I/O. + * + * MUTEX: Assumes the namespace is locked. + * + ******************************************************************************/ + +UINT32 +AcpiUtCheckAddressRange ( + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Length, + BOOLEAN Warn) +{ + ACPI_ADDRESS_RANGE *RangeInfo; + ACPI_PHYSICAL_ADDRESS EndAddress; + char *Pathname; + UINT32 OverlapCount = 0; + + + ACPI_FUNCTION_TRACE (UtCheckAddressRange); + + + if ((SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + return_UINT32 (0); + } + + RangeInfo = AcpiGbl_AddressRangeList[SpaceId]; + EndAddress = Address + Length - 1; + + /* Check entire list for all possible conflicts */ + + while (RangeInfo) + { + /* + * Check if the requested Address/Length overlaps this AddressRange. + * Four cases to consider: + * + * 1) Input address/length is contained completely in the address range + * 2) Input address/length overlaps range at the range start + * 3) Input address/length overlaps range at the range end + * 4) Input address/length completely encompasses the range + */ + if ((Address <= RangeInfo->EndAddress) && + (EndAddress >= RangeInfo->StartAddress)) + { + /* Found an address range overlap */ + + OverlapCount++; + if (Warn) /* Optional warning message */ + { + Pathname = AcpiNsGetExternalPathname (RangeInfo->RegionNode); + + ACPI_WARNING ((AE_INFO, + "0x%p-0x%p %s conflicts with Region %s %d", + ACPI_CAST_PTR (void, Address), + ACPI_CAST_PTR (void, EndAddress), + AcpiUtGetRegionName (SpaceId), Pathname, OverlapCount)); + ACPI_FREE (Pathname); + } + } + + RangeInfo = RangeInfo->Next; + } + + return_UINT32 (OverlapCount); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteAddressLists + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all global address range lists (called during + * subsystem shutdown). + * + ******************************************************************************/ + +void +AcpiUtDeleteAddressLists ( + void) +{ + ACPI_ADDRESS_RANGE *Next; + ACPI_ADDRESS_RANGE *RangeInfo; + int i; + + + /* Delete all elements in all address range lists */ + + for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) + { + Next = AcpiGbl_AddressRangeList[i]; + + while (Next) + { + RangeInfo = Next; + Next = RangeInfo->Next; + ACPI_FREE (RangeInfo); + } + + AcpiGbl_AddressRangeList[i] = NULL; + } +} diff --git a/src/acpica/source/include/actbl3.h b/src/acpica/source/include/actbl3.h new file mode 100644 index 0000000..6fc9568 --- /dev/null +++ b/src/acpica/source/include/actbl3.h @@ -0,0 +1,722 @@ +/****************************************************************************** + * + * Name: actbl3.h - ACPI Table Definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACTBL3_H__ +#define __ACTBL3_H__ + + +/******************************************************************************* + * + * Additional ACPI Tables (3) + * + * These tables are not consumed directly by the ACPICA subsystem, but are + * included here to support device drivers and the AML disassembler. + * + * The tables in this file are fully defined within the ACPI specification. + * + ******************************************************************************/ + + +/* + * Values for description table header signatures for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_BGRT "BGRT" /* Boot Graphics Resource Table */ +#define ACPI_SIG_DRTM "DRTM" /* Dynamic Root of Trust for Measurement table */ +#define ACPI_SIG_FPDT "FPDT" /* Firmware Performance Data Table */ +#define ACPI_SIG_GTDT "GTDT" /* Generic Timer Description Table */ +#define ACPI_SIG_MPST "MPST" /* Memory Power State Table */ +#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */ +#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */ +#define ACPI_SIG_RASF "RASF" /* RAS Feature table */ + +#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */ +#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */ + +/* Reserved table signatures */ + +#define ACPI_SIG_CSRT "CSRT" /* Core System Resources Table */ +#define ACPI_SIG_DBG2 "DBG2" /* Debug Port table 2 */ +#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */ +#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */ +#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */ + +/* + * All tables must be byte-packed to match the ACPI specification, since + * the tables are provided by the system BIOS. + */ +#pragma pack(1) + +/* + * Note about bitfields: The UINT8 type is used for bitfields in ACPI tables. + * This is the only type that is even remotely portable. Anything else is not + * portable, so do not use any other bitfield types. + */ + + +/******************************************************************************* + * + * BGRT - Boot Graphics Resource Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_bgrt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT16 Version; + UINT8 Status; + UINT8 ImageType; + UINT64 ImageAddress; + UINT32 ImageOffsetX; + UINT32 ImageOffsetY; + +} ACPI_TABLE_BGRT; + + +/******************************************************************************* + * + * DRTM - Dynamic Root of Trust for Measurement table + * + ******************************************************************************/ + +typedef struct acpi_table_drtm +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 EntryBaseAddress; + UINT64 EntryLength; + UINT32 EntryAddress32; + UINT64 EntryAddress64; + UINT64 ExitAddress; + UINT64 LogAreaAddress; + UINT32 LogAreaLength; + UINT64 ArchDependentAddress; + UINT32 Flags; + +} ACPI_TABLE_DRTM; + +/* 1) Validated Tables List */ + +typedef struct acpi_drtm_vtl_list +{ + UINT32 ValidatedTableListCount; + +} ACPI_DRTM_VTL_LIST; + +/* 2) Resources List */ + +typedef struct acpi_drtm_resource_list +{ + UINT32 ResourceListCount; + +} ACPI_DRTM_RESOURCE_LIST; + +/* 3) Platform-specific Identifiers List */ + +typedef struct acpi_drtm_id_list +{ + UINT32 IdListCount; + +} ACPI_DRTM_ID_LIST; + + +/******************************************************************************* + * + * FPDT - Firmware Performance Data Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_fpdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + +} ACPI_TABLE_FPDT; + + +/* FPDT subtable header */ + +typedef struct acpi_fpdt_header +{ + UINT16 Type; + UINT8 Length; + UINT8 Revision; + +} ACPI_FPDT_HEADER; + +/* Values for Type field above */ + +enum AcpiFpdtType +{ + ACPI_FPDT_TYPE_BOOT = 0, + ACPI_FPDT_TYPE_S3PERF = 1, +}; + + +/* + * FPDT subtables + */ + +/* 0: Firmware Basic Boot Performance Record */ + +typedef struct acpi_fpdt_boot +{ + ACPI_FPDT_HEADER Header; + UINT8 Reserved[4]; + UINT64 ResetEnd; + UINT64 LoadStart; + UINT64 StartupStart; + UINT64 ExitServicesEntry; + UINT64 ExitServicesExit; + +} ACPI_FPDT_BOOT; + + +/* 1: S3 Performance Table Pointer Record */ + +typedef struct acpi_fpdt_s3pt_ptr +{ + ACPI_FPDT_HEADER Header; + UINT8 Reserved[4]; + UINT64 Address; + +} ACPI_FPDT_S3PT_PTR; + + +/* + * S3PT - S3 Performance Table. This table is pointed to by the + * FPDT S3 Pointer Record above. + */ +typedef struct acpi_table_s3pt +{ + UINT8 Signature[4]; /* "S3PT" */ + UINT32 Length; + +} ACPI_TABLE_S3PT; + + +/* + * S3PT Subtables + */ +typedef struct acpi_s3pt_header +{ + UINT16 Type; + UINT8 Length; + UINT8 Revision; + +} ACPI_S3PT_HEADER; + +/* Values for Type field above */ + +enum AcpiS3ptType +{ + ACPI_S3PT_TYPE_RESUME = 0, + ACPI_S3PT_TYPE_SUSPEND = 1, +}; + +typedef struct acpi_s3pt_resume +{ + ACPI_S3PT_HEADER Header; + UINT32 ResumeCount; + UINT64 FullResume; + UINT64 AverageResume; + +} ACPI_S3PT_RESUME; + +typedef struct acpi_s3pt_suspend +{ + ACPI_S3PT_HEADER Header; + UINT64 SuspendStart; + UINT64 SuspendEnd; + +} ACPI_S3PT_SUSPEND; + + +/******************************************************************************* + * + * GTDT - Generic Timer Description Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_gtdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 Address; + UINT32 Flags; + UINT32 SecurePl1Interrupt; + UINT32 SecurePl1Flags; + UINT32 NonSecurePl1Interrupt; + UINT32 NonSecurePl1Flags; + UINT32 VirtualTimerInterrupt; + UINT32 VirtualTimerFlags; + UINT32 NonSecurePl2Interrupt; + UINT32 NonSecurePl2Flags; + +} ACPI_TABLE_GTDT; + +/* Values for Flags field above */ + +#define ACPI_GTDT_MAPPED_BLOCK_PRESENT 1 + +/* Values for all "TimerFlags" fields above */ + +#define ACPI_GTDT_INTERRUPT_MODE 1 +#define ACPI_GTDT_INTERRUPT_POLARITY 2 + + +/******************************************************************************* + * + * MPST - Memory Power State Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +#define ACPI_MPST_CHANNEL_INFO \ + UINT16 Reserved1; \ + UINT8 ChannelId; \ + UINT8 Reserved2; \ + UINT16 PowerNodeCount; + +/* Main table */ + +typedef struct acpi_table_mpst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_MPST_CHANNEL_INFO /* Platform Communication Channel */ + +} ACPI_TABLE_MPST; + + +/* Memory Platform Communication Channel Info */ + +typedef struct acpi_mpst_channel +{ + ACPI_MPST_CHANNEL_INFO /* Platform Communication Channel */ + +} ACPI_MPST_CHANNEL; + + +/* Memory Power Node Structure */ + +typedef struct acpi_mpst_power_node +{ + UINT8 Flags; + UINT8 Reserved1; + UINT16 NodeId; + UINT32 Length; + UINT64 RangeAddress; + UINT64 RangeLength; + UINT8 NumPowerStates; + UINT8 NumPhysicalComponents; + UINT16 Reserved2; + +} ACPI_MPST_POWER_NODE; + +/* Values for Flags field above */ + +#define ACPI_MPST_ENABLED 1 +#define ACPI_MPST_POWER_MANAGED 2 +#define ACPI_MPST_HOT_PLUG_CAPABLE 4 + + +/* Memory Power State Structure (follows POWER_NODE above) */ + +typedef struct acpi_mpst_power_state +{ + UINT8 PowerState; + UINT8 InfoIndex; + +} ACPI_MPST_POWER_STATE; + + +/* Physical Component ID Structure (follows POWER_STATE above) */ + +typedef struct acpi_mpst_component +{ + UINT16 ComponentId; + +} ACPI_MPST_COMPONENT; + + +/* Memory Power State Characteristics Structure (follows all POWER_NODEs) */ + +typedef struct acpi_mpst_data_hdr +{ + UINT16 CharacteristicsCount; + +} ACPI_MPST_DATA_HDR; + +typedef struct acpi_mpst_power_data +{ + UINT8 Revision; + UINT8 Flags; + UINT16 Reserved1; + UINT32 AveragePower; + UINT32 PowerSaving; + UINT64 ExitLatency; + UINT64 Reserved2; + +} ACPI_MPST_POWER_DATA; + +/* Values for Flags field above */ + +#define ACPI_MPST_PRESERVE 1 +#define ACPI_MPST_AUTOENTRY 2 +#define ACPI_MPST_AUTOEXIT 4 + + +/* Shared Memory Region (not part of an ACPI table) */ + +typedef struct acpi_mpst_shared +{ + UINT32 Signature; + UINT16 PccCommand; + UINT16 PccStatus; + UINT16 CommandRegister; + UINT16 StatusRegister; + UINT16 PowerStateId; + UINT16 PowerNodeId; + UINT64 EnergyConsumed; + UINT64 AveragePower; + +} ACPI_MPST_SHARED; + + +/******************************************************************************* + * + * PCCT - Platform Communications Channel Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_pcct +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Flags; + UINT32 Latency; + UINT32 Reserved; + +} ACPI_TABLE_PCCT; + +/* Values for Flags field above */ + +#define ACPI_PCCT_DOORBELL 1 + +/* + * PCCT subtables + */ + +/* 0: Generic Communications Subspace */ + +typedef struct acpi_pcct_subspace +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Reserved[6]; + UINT64 BaseAddress; + UINT64 Length; + ACPI_GENERIC_ADDRESS DoorbellRegister; + UINT64 PreserveMask; + UINT64 WriteMask; + +} ACPI_PCCT_SUBSPACE; + + +/* + * PCC memory structures (not part of the ACPI table) + */ + +/* Shared Memory Region */ + +typedef struct acpi_pcct_shared_memory +{ + UINT32 Signature; + UINT16 Command; + UINT16 Status; + +} ACPI_PCCT_SHARED_MEMORY; + + +/******************************************************************************* + * + * PMTT - Platform Memory Topology Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_pmtt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Reserved; + +} ACPI_TABLE_PMTT; + + +/* Common header for PMTT subtables that follow main table */ + +typedef struct acpi_pmtt_header +{ + UINT8 Type; + UINT8 Reserved1; + UINT16 Length; + UINT16 Flags; + UINT16 Reserved2; + +} ACPI_PMTT_HEADER; + +/* Values for Type field above */ + +#define ACPI_PMTT_TYPE_SOCKET 0 +#define ACPI_PMTT_TYPE_CONTROLLER 1 +#define ACPI_PMTT_TYPE_DIMM 2 +#define ACPI_PMTT_TYPE_RESERVED 3 /* 0x03-0xFF are reserved */ + +/* Values for Flags field above */ + +#define ACPI_PMTT_TOP_LEVEL 0x0001 +#define ACPI_PMTT_PHYSICAL 0x0002 +#define ACPI_PMTT_MEMORY_TYPE 0x000C + + +/* + * PMTT subtables, correspond to Type in acpi_pmtt_header + */ + + +/* 0: Socket Structure */ + +typedef struct acpi_pmtt_socket +{ + ACPI_PMTT_HEADER Header; + UINT16 SocketId; + UINT16 Reserved; + +} ACPI_PMTT_SOCKET; + + +/* 1: Memory Controller subtable */ + +typedef struct acpi_pmtt_controller +{ + ACPI_PMTT_HEADER Header; + UINT32 ReadLatency; + UINT32 WriteLatency; + UINT32 ReadBandwidth; + UINT32 WriteBandwidth; + UINT16 AccessWidth; + UINT16 Alignment; + UINT16 Reserved; + UINT16 DomainCount; + +} ACPI_PMTT_CONTROLLER; + +/* 1a: Proximity Domain substructure */ + +typedef struct acpi_pmtt_domain +{ + UINT32 ProximityDomain; + +} ACPI_PMTT_DOMAIN; + + +/* 2: Physical Component Identifier (DIMM) */ + +typedef struct acpi_pmtt_physical_component +{ + ACPI_PMTT_HEADER Header; + UINT16 ComponentId; + UINT16 Reserved; + UINT32 MemorySize; + UINT32 BiosHandle; + +} ACPI_PMTT_PHYSICAL_COMPONENT; + + +/******************************************************************************* + * + * RASF - RAS Feature Table (ACPI 5.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_rasf +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT8 ChannelId[12]; + +} ACPI_TABLE_RASF; + +/* RASF Platform Communication Channel Shared Memory Region */ + +typedef struct acpi_rasf_shared_memory +{ + UINT32 Signature; + UINT16 Command; + UINT16 Status; + UINT64 RequestedAddress; + UINT64 RequestedLength; + UINT64 ActualAddress; + UINT64 ActualLength; + UINT16 Flags; + UINT8 Speed; + +} ACPI_RASF_SHARED_MEMORY; + +/* Masks for Flags and Speed fields above */ + +#define ACPI_RASF_SCRUBBER_RUNNING 1 +#define ACPI_RASF_SPEED (7<<1) + +/* Channel Commands */ + +enum AcpiRasfCommands +{ + ACPI_RASF_GET_RAS_CAPABILITIES = 1, + ACPI_RASF_GET_PATROL_PARAMETERS = 2, + ACPI_RASF_START_PATROL_SCRUBBER = 3, + ACPI_RASF_STOP_PATROL_SCRUBBER = 4 +}; + +/* Channel Command flags */ + +#define ACPI_RASF_GENERATE_SCI (1<<15) + +/* Status values */ + +enum AcpiRasfStatus +{ + ACPI_RASF_SUCCESS = 0, + ACPI_RASF_NOT_VALID = 1, + ACPI_RASF_NOT_SUPPORTED = 2, + ACPI_RASF_BUSY = 3, + ACPI_RASF_FAILED = 4, + ACPI_RASF_ABORTED = 5, + ACPI_RASF_INVALID_DATA = 6 +}; + +/* Status flags */ + +#define ACPI_RASF_COMMAND_COMPLETE (1) +#define ACPI_RASF_SCI_DOORBELL (1<<1) +#define ACPI_RASF_ERROR (1<<2) +#define ACPI_RASF_STATUS (0x1F<<3) + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL3_H__ */