aslrestype2s.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: aslrestype2s - Serial Large resource descriptors
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype2s")
static UINT16
static UINT16
static BOOLEAN
/*
* 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
{
UINT16 ExtraDataSize = 0;
/* Find the byte-initializer list */
while (InitializerOp)
{
{
/* First child is the optional length (ignore it here) */
/* Count the data items (each one is a byte of data) */
while (DataList)
{
}
return (ExtraDataSize);
}
}
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
{
UINT32 i;
/* Count the interrupt numbers */
InterruptLength = 0;
for (i = 0; InitializerOp; i++)
{
/* 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
{
UINT16 ActualLength = 0;
/* Vendor Data field is always optional */
{
return (FALSE);
}
if (!BufferOp)
{
return (FALSE);
}
/* First child is the optional buffer length (WORD) */
{
}
/* Insert field tag _VEN */
/* Walk the list of buffer initializers (each is one byte) */
{
while (BufferOp)
{
VendorData++;
ActualLength++;
}
}
/* Length validation. Buffer cannot be of zero length */
if ((SpecifiedLength == 0) ||
{
return (FALSE);
}
if (SpecifiedLength != ACPI_UINT32_MAX)
{
/* ActualLength > SpecifiedLength -> error */
if (ActualLength > SpecifiedLength)
{
return (FALSE);
}
/* ActualLength < SpecifiedLength -> remark */
else if (ActualLength < SpecifiedLength)
{
return (FALSE);
}
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: RsDoGpioIntDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "GpioInt" descriptor
*
******************************************************************************/
{
char *ResourceSource = NULL;
UINT32 i;
/*
* Calculate lengths for fields that have variable length:
* 1) Resource Source string
* 2) Vendor Data buffer
* 3) PIN (interrupt) list
*/
/* Allocate the local resource node and initialize */
/* Build pointers to optional areas */
/* Setup offsets within the descriptor */
"%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n",
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
break;
break;
case 2: /* Share Type - Default: exclusive (0) [Flags] (_SHR) */
break;
case 3: /* Pin Config [BYTE] (_PPI) */
break;
case 4: /* Debounce Timeout [WORD] (_DBT) */
break;
case 5: /* ResSource [Optional Field - STRING] */
if (ResSourceLength)
{
/* Copy string to the descriptor */
}
break;
case 6: /* Resource Index */
{
}
break;
break;
case 8: /* Resource Tag (Descriptor Name) */
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.
*/
{
}
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
*/
PinCount++;
/* Case 10: First interrupt number in list */
if (i == 10)
{
{
/* Must be at least one interrupt */
}
/* Check now for duplicates in list */
/* Create a named field at the start of the list */
}
break;
}
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoGpioIoDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "GpioIo" descriptor
*
******************************************************************************/
{
char *ResourceSource = NULL;
UINT32 i;
/*
* Calculate lengths for fields that have variable length:
* 1) Resource Source string
* 2) Vendor Data buffer
* 3) PIN (interrupt) list
*/
/* Allocate the local resource node and initialize */
/* Build pointers to optional areas */
/* Setup offsets within the descriptor */
"%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, IntLen: %.2X\n",
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Share Type [Flags] (_SHR) */
break;
case 1: /* Pin Config [BYTE] (_PPI) */
break;
case 2: /* Debounce Timeout [WORD] (_DBT) */
break;
case 3: /* Drive Strength [WORD] (_DRS) */
break;
case 4: /* I/O Restriction [Flag] (_IOR) */
break;
case 5: /* ResSource [Optional Field - STRING] */
if (ResSourceLength)
{
/* Copy string to the descriptor */
}
break;
case 6: /* Resource Index */
{
}
break;
break;
case 8: /* Resource Tag (Descriptor Name) */
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.
*/
{
}
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
*/
PinCount++;
/* Case 10: First interrupt number in list */
if (i == 10)
{
{
/* Must be at least one interrupt */
}
/* Check now for duplicates in list */
/* Create a named field at the start of the list */
}
break;
}
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoI2cSerialBusDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "I2cSerialBus" descriptor
*
******************************************************************************/
{
char *ResourceSource = NULL;
UINT32 i;
/*
* Calculate lengths for fields that have variable length:
* 1) Resource Source string
* 2) Vendor Data buffer
*/
/* Allocate the local resource node and initialize */
/* Build pointers to optional areas */
"%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n",
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Slave Address [WORD] (_ADR) */
break;
case 1: /* Slave Mode [Flag] (_SLV) */
break;
case 2: /* Connection Speed [DWORD] (_SPE) */
break;
case 3: /* Addressing Mode [Flag] (_MOD) */
break;
case 4: /* ResSource [Optional Field - STRING] */
if (ResSourceLength)
{
/* Copy string to the descriptor */
}
break;
case 5: /* Resource Index */
{
}
break;
break;
case 7: /* Resource Tag (Descriptor Name) */
break;
case 8: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
CurrentByteOffset + sizeof (AML_RESOURCE_I2C_SERIALBUS));
break;
default: /* Ignore any extra nodes */
break;
}
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoSpiSerialBusDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "SPI Serial Bus" descriptor
*
******************************************************************************/
{
char *ResourceSource = NULL;
UINT32 i;
/*
* Calculate lengths for fields that have variable length:
* 1) Resource Source string
* 2) Vendor Data buffer
*/
/* Allocate the local resource node and initialize */
/* Build pointers to optional areas */
"%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n",
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Device Selection [WORD] (_ADR) */
break;
case 1: /* Device Polarity [Flag] (_DPL) */
break;
case 2: /* Wire Mode [Flag] (_MOD) */
break;
case 3: /* Device Bit Length [BYTE] (_LEN) */
break;
case 4: /* Slave Mode [Flag] (_SLV) */
break;
case 5: /* Connection Speed [DWORD] (_SPE) */
break;
case 6: /* Clock Polarity [BYTE] (_POL) */
break;
case 7: /* Clock Phase [BYTE] (_PHA) */
break;
case 8: /* ResSource [Optional Field - STRING] */
if (ResSourceLength)
{
/* Copy string to the descriptor */
}
break;
case 9: /* Resource Index */
{
}
break;
break;
case 11: /* Resource Tag (Descriptor Name) */
break;
case 12: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
CurrentByteOffset + sizeof (AML_RESOURCE_SPI_SERIALBUS));
break;
default: /* Ignore any extra nodes */
break;
}
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoUartSerialBusDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "UART Serial Bus" descriptor
*
******************************************************************************/
{
char *ResourceSource = NULL;
UINT32 i;
/*
* Calculate lengths for fields that have variable length:
* 1) Resource Source string
* 2) Vendor Data buffer
*/
/* Allocate the local resource node and initialize */
/* Build pointers to optional areas */
"%16s - Actual: %.2X, Base: %.2X, ResLen: %.2X, VendLen: %.2X, TypLen: %.2X\n",
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
break;
case 1: /* Bits Per Byte [Flags] (_LEN) */
break;
case 2: /* Stop Bits [Flags] (_STB) */
break;
case 3: /* Lines In Use [BYTE] (_LIN) */
break;
case 4: /* Endianness [Flag] (_END) */
break;
case 5: /* Parity [BYTE] (_PAR) */
break;
case 6: /* Flow Control [Flags] (_FLC) */
break;
case 7: /* Rx Buffer Size [WORD] (_RXL) */
break;
case 8: /* Tx Buffer Size [WORD] (_TXL) */
break;
case 9: /* ResSource [Optional Field - STRING] */
if (ResSourceLength)
{
/* Copy string to the descriptor */
}
break;
case 10: /* Resource Index */
{
}
break;
/*
* 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.
*/
break;
case 12: /* Resource Tag (Descriptor Name) */
break;
case 13: /* Vendor Data (Optional - Buffer of BYTEs) (_VEN) */
CurrentByteOffset + sizeof (AML_RESOURCE_UART_SERIALBUS));
break;
default: /* Ignore any extra nodes */
break;
}
}
return (Rnode);
}