dttemplate.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: dttemplate - ACPI table template generation
*
*****************************************************************************/
/*
* 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 _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dttemplate")
/* Local prototypes */
static BOOLEAN
char *Signature);
static ACPI_STATUS
char *Signature,
const ACPI_DMTABLE_DATA *TableData);
static ACPI_STATUS
void);
/*******************************************************************************
*
* FUNCTION: AcpiUtIsSpecialTable
*
* PARAMETERS: Signature - ACPI table signature
*
* RETURN: TRUE if signature is a special ACPI table
*
* DESCRIPTION: Check for valid ACPI tables that are not in the main ACPI
* table data structure (AcpiDmTableData).
*
******************************************************************************/
static BOOLEAN
char *Signature)
{
{
return (TRUE);
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: DtCreateTemplates
*
* PARAMETERS: Signature - ACPI table signature
*
* RETURN: Status
*
* DESCRIPTION: Create one or more template files.
*
******************************************************************************/
char *Signature)
{
const ACPI_DMTABLE_DATA *TableData;
/* Default (no signature) is DSDT */
if (!Signature)
{
Signature = "DSDT";
goto GetTemplate;
}
{
Status = DtCreateAllTemplates ();
return (Status);
}
/*
* Validate signature and get the template data:
* 1) Signature must be 4 characters
* 2) Signature must be a recognized ACPI table
* 3) There must be a template associated with the signature
*/
{
"%s: Invalid ACPI table signature (length must be 4 characters)\n",
return (AE_ERROR);
}
/*
* Some slack for the two strange tables whose name is different than
* their signatures: MADT->APIC and FADT->FACP.
*/
{
Signature = "APIC";
}
{
Signature = "FACP";
}
if (TableData)
{
{
return (AE_ERROR);
}
}
else if (!AcpiUtIsSpecialTable (Signature))
{
"%4.4s: Unrecognized ACPI table signature\n", Signature);
return (AE_ERROR);
}
Status = AdInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Shutdown ACPICA subsystem */
(void) AcpiTerminate ();
CmDeleteCaches ();
return (Status);
}
/*******************************************************************************
*
* FUNCTION: DtCreateAllTemplates
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Create all currently defined template files
*
******************************************************************************/
static ACPI_STATUS
void)
{
const ACPI_DMTABLE_DATA *TableData;
Status = AdInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Walk entire ACPI table data structure */
{
/* If table has a template, create the template file */
{
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
}
/*
* Create the special ACPI tables:
* 2) FACS and RSDP have non-standard headers
*/
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (ACPI_FAILURE (Status))
{
return (Status);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: DtCreateOneTemplate
*
* PARAMETERS: Signature - ACPI signature, NULL terminated.
* TableData - Entry in ACPI table data structure.
* NULL if a special ACPI table.
*
* RETURN: Status
*
* DESCRIPTION: Create one template source file for the requested ACPI table.
*
******************************************************************************/
static ACPI_STATUS
char *Signature,
const ACPI_DMTABLE_DATA *TableData)
{
char *DisasmFilename;
/* New file will have a .asl suffix */
if (!DisasmFilename)
{
return (AE_ERROR);
}
/* Probably should prompt to overwrite the file */
if (!File)
{
return (AE_ERROR);
}
/* Emit the common file header */
AcpiOsPrintf ("/*\n");
AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
/* Dump the actual ACPI table */
if (TableData)
{
/* Normal case, tables that appear in AcpiDmTableData */
AcpiOsPrintf (" (static data table)\n");
if (Gbl_VerboseTemplates)
{
AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]"
" FieldName : HexFieldValue\n */\n\n");
}
else
{
AcpiOsPrintf (" * Format: [ByteLength]"
" FieldName : HexFieldValue\n */\n");
}
}
else
{
/* Special ACPI tables - DSDT, SSDT, OSDT, FADT, RSDP */
AcpiOsPrintf (" (AML byte code table)\n");
AcpiOsPrintf (" */\n");
{
{
"Could not write to output file %s\n", DisasmFilename);
goto Cleanup;
}
}
{
{
"Could not write to output file %s\n", DisasmFilename);
goto Cleanup;
}
}
{
{
"Could not write to output file %s\n", DisasmFilename);
goto Cleanup;
}
}
{
TemplateFacs));
}
{
TemplateRsdp));
}
else
{
"%4.4s, Unrecognized ACPI table signature\n", Signature);
goto Cleanup;
}
}
"Created ACPI table template for [%4.4s], written to \"%s\"\n",
return (Status);
}