dtcompile.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: dtcompile.c - Front-end for data table compiler
*
*****************************************************************************/
/*
* 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.
*/
#define _DECLARE_DT_GLOBALS
#define _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dtcompile")
static char VersionString[9];
/* Local prototypes */
static ACPI_STATUS
void);
static ACPI_STATUS
static void
/******************************************************************************
*
* FUNCTION: DtDoCompile
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Main entry point for the data table compiler.
*
* Note: Assumes Gbl_Files[ASL_FILE_INPUT] is initialized and the file is
* open at seek offset zero.
*
*****************************************************************************/
void)
{
/* Initialize globals */
Status = DtInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Preprocessor */
if (Gbl_PreprocessFlag)
{
/* Preprocessor */
PrDoPreprocess ();
UtEndEvent (Event);
if (Gbl_PreprocessOnly)
{
return (AE_OK);
}
}
/*
* Scan the input file (file is already open) and
* build the parse tree
*/
UtEndEvent (Event);
/* Did the parse tree get successfully constructed? */
if (!FieldList)
{
/* TBD: temporary error message. Msgs should come from function above */
"Input file does not appear to be an ASL or data table source file");
goto CleanupAndExit;
}
/*
* Compile the parse tree
*/
UtEndEvent (Event);
if (ACPI_FAILURE (Status))
{
/* TBD: temporary error message. Msgs should come from function above */
"Could not compile input file");
goto CleanupAndExit;
}
if (ACPI_FAILURE (Status))
{
goto CleanupAndExit;
}
/* Write the binary, then the optional hex file */
HxDoHexOutput ();
DtDeleteCaches ();
CmCleanupAndExit ();
return (Status);
}
/******************************************************************************
*
* FUNCTION: DtInitialize
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Initialize data table compiler globals. Enables multiple
* compiles per invocation.
*
*****************************************************************************/
static ACPI_STATUS
void)
{
Status = AcpiOsInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
Status = AcpiUtInitGlobals ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: DtInsertCompilerIds
*
* PARAMETERS: FieldList - Current field list pointer
*
* RETURN: None
*
* DESCRIPTION: Insert the IDs (Name, Version) of the current compiler into
* the original ACPI table header.
*
*****************************************************************************/
static void
{
UINT32 i;
/*
* Don't insert current compiler ID if requested. Used for compiler
* debug/validation only.
*/
{
return;
}
/* Walk to the Compiler fields at the end of the header */
for (i = 0; i < 7; i++)
{
}
}
/******************************************************************************
*
* FUNCTION: DtCompileDataTable
*
* PARAMETERS: FieldList - Current field list pointer
*
* RETURN: Status
*
* DESCRIPTION: Entry point to compile one data table
*
*****************************************************************************/
static ACPI_STATUS
{
const ACPI_DMTABLE_DATA *TableData;
char *Signature;
/* Verify that we at least have a table signature and save it */
if (!Signature)
{
return (AE_ERROR);
}
/*
* Handle tables that don't use the common ACPI table header structure.
* Currently, these are the FACS and RSDP. Also check for an OEMx table,
* these tables have user-defined contents.
*/
{
if (ACPI_FAILURE (Status))
{
return (Status);
}
DtSetTableLength ();
return (Status);
}
else if (ACPI_VALIDATE_RSDP_SIG (Signature))
{
return (Status);
}
{
if (ACPI_FAILURE (Status))
{
return (Status);
}
DtSetTableLength ();
return (Status);
}
/*
* All other tables must use the common ACPI table header. Insert the
* current iASL IDs (name, version), and compile the header now.
*/
&Gbl_RootTable, TRUE);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Validate the signature via the ACPI table list */
if (!TableData || Gbl_CompileGeneric)
{
goto FinishHeader;
}
/* Dispatch to per-table compile */
if (TableData->CmTableHandler)
{
/* Complex table, has a handler */
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
{
/* Simple table, just walk the info table */
if (ACPI_FAILURE (Status))
{
return (Status);
}
DtPopSubtable ();
}
else
{
"Missing table dispatch info");
return (AE_ERROR);
}
/* Set the final table length and then the checksum */
DtSetTableLength ();
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: DtCompileTable
*
* PARAMETERS: Field - Current field list pointer
* Info - Info table for this ACPI table
* RetSubtable - Compile result of table
* Required - If this subtable must exist
*
* RETURN: Status
*
* DESCRIPTION: Compile a subtable
*
*****************************************************************************/
{
UINT32 FieldLength = 0;
char *String;
{
return (AE_BAD_PARAMETER);
}
/* Ignore optional subtable if name does not match */
{
*RetSubtable = NULL;
return (AE_OK);
}
{
return (AE_ERROR);
}
if (Length > 0)
{
}
LocalField = *Field;
/*
* Main loop walks the info table for this ACPI table or subtable
*/
{
{
continue;
}
if (!LocalField)
{
goto Error;
}
/* Maintain table offsets */
switch (FieldType)
{
/*
* Start of the definition of a flags field.
* This master flags integer starts at value zero, in preparation
* to compile and insert the flag fields from the individual bits
*/
*Field = LocalField;
FlagBuffer = Buffer;
break;
case DT_FIELD_TYPE_FLAG:
/* Individual Flag field, can be multiple bits */
if (FlagBuffer)
{
/*
* We must increment the FlagBuffer when we have crossed
* into the next flags byte within the flags field
* of type DT_FIELD_TYPE_FLAGS_INTEGER.
*/
}
else
{
/* TBD - this is an internal error */
}
*Field = LocalField;
break;
/*
* Recursion (one level max): compile GAS (Generic Address)
* or Notify in-line subtable
*/
*Field = LocalField;
{
case ACPI_DMT_GAS:
&InlineSubtable, TRUE);
break;
case ACPI_DMT_HESTNTFY:
&InlineSubtable, TRUE);
break;
case ACPI_DMT_IORTMEM:
&InlineSubtable, TRUE);
break;
default:
break;
}
if (ACPI_FAILURE (Status))
{
goto Error;
}
LocalField = *Field;
break;
case DT_FIELD_TYPE_LABEL:
break;
default:
/* Normal case for most field types (Integer, String, etc.) */
{
/* Field is an Integer that will contain a subtable length */
}
break;
}
Buffer += FieldLength;
}
*Field = LocalField;
*RetSubtable = Subtable;
return (AE_OK);
return (Status);
}
/******************************************************************************
*
* FUNCTION: DtCompilePadding
*
* PARAMETERS: Length - Padding field size
* RetSubtable - Compile result of table
*
* RETURN: Status
*
* DESCRIPTION: Compile a subtable for padding purpose
*
*****************************************************************************/
{
/* UINT8 *Buffer; */
char *String;
if (Length > 0)
{
}
/* Buffer = Subtable->Buffer; */
*RetSubtable = Subtable;
return (AE_OK);
}