mirror of
https://github.com/acpica/acpica/
synced 2025-02-25 18:04:08 +03:00
iASL/Templates: Add support for multiple SSDTs in the same file
Extends multiple tables per file support. The number of SSDTs can be specified on the command line.
This commit is contained in:
parent
a074fc6012
commit
c404fc0cba
@ -200,6 +200,7 @@ Usage (
|
||||
ACPI_OPTION ("-@ <file>", "Specify command file");
|
||||
ACPI_OPTION ("-I <dir>", "Specify additional include directory");
|
||||
ACPI_OPTION ("-T <sig list>|ALL", "Create ACPI table template/example files");
|
||||
ACPI_OPTION ("-T <count>", "Emit DSDT and <count> SSDTs to same file");
|
||||
ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files");
|
||||
ACPI_OPTION ("-v", "Display compiler version");
|
||||
ACPI_OPTION ("-vo", "Enable optimization comments");
|
||||
|
@ -521,9 +521,11 @@ UtDisplaySummary (
|
||||
if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
|
||||
{
|
||||
FlPrintFile (FileId,
|
||||
"%-14s %s - %u bytes, %u named objects, %u executable opcodes\n",
|
||||
"%-14s %s - %u bytes, %u named objects, "
|
||||
"%u executable opcodes\n",
|
||||
"AML Output:",
|
||||
Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
|
||||
Gbl_Files[ASL_FILE_AML_OUTPUT].Filename,
|
||||
FlGetFileSize (ASL_FILE_AML_OUTPUT),
|
||||
TotalNamedObjects, TotalExecutableOpcodes);
|
||||
}
|
||||
}
|
||||
|
@ -130,17 +130,26 @@ AcpiUtIsSpecialTable (
|
||||
|
||||
static ACPI_STATUS
|
||||
DtCreateOneTemplateFile (
|
||||
char *Signature);
|
||||
char *Signature,
|
||||
UINT32 TableCount);
|
||||
|
||||
static ACPI_STATUS
|
||||
DtCreateOneTemplate (
|
||||
char *Signature,
|
||||
UINT32 TableCount,
|
||||
const ACPI_DMTABLE_DATA *TableData);
|
||||
|
||||
static ACPI_STATUS
|
||||
DtCreateAllTemplates (
|
||||
void);
|
||||
|
||||
static int
|
||||
DtEmitDefinitionBlock (
|
||||
FILE *File,
|
||||
char *Filename,
|
||||
char *Signature,
|
||||
UINT32 Instance);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
@ -190,11 +199,19 @@ DtCreateTemplates (
|
||||
char **argv)
|
||||
{
|
||||
char *Signature;
|
||||
char *End;
|
||||
unsigned long TableCount;
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
|
||||
|
||||
AslInitializeGlobals ();
|
||||
|
||||
Status = AdInitialize ();
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Special cases for DSDT, ALL, and '*'
|
||||
*/
|
||||
@ -203,7 +220,7 @@ DtCreateTemplates (
|
||||
|
||||
if (AcpiGbl_Optind < 3)
|
||||
{
|
||||
Status = DtCreateOneTemplateFile ("DSDT");
|
||||
Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, 0);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
@ -211,6 +228,27 @@ DtCreateTemplates (
|
||||
Signature = argv[AcpiGbl_Optind];
|
||||
AcpiUtStrupr (Signature);
|
||||
|
||||
/*
|
||||
* Multiple SSDT support (-T <ssdt count>)
|
||||
*/
|
||||
TableCount = strtoul (Signature, &End, 0);
|
||||
if (Signature != End)
|
||||
{
|
||||
/* The count is used for table ID and method name - max is 254(+1) */
|
||||
|
||||
if (TableCount > 254)
|
||||
{
|
||||
fprintf (stderr, "%u SSDTs requested, maximum is 254\n",
|
||||
(unsigned int) TableCount);
|
||||
|
||||
Status = AE_LIMIT;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, TableCount);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if (!strcmp (Signature, "ALL"))
|
||||
{
|
||||
/* Create all available/known templates */
|
||||
@ -227,7 +265,7 @@ DtCreateTemplates (
|
||||
Signature = argv[AcpiGbl_Optind];
|
||||
AcpiUtStrupr (Signature);
|
||||
|
||||
Status = DtCreateOneTemplateFile (Signature);
|
||||
Status = DtCreateOneTemplateFile (Signature, 0);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
goto Exit;
|
||||
@ -260,7 +298,8 @@ Exit:
|
||||
|
||||
static ACPI_STATUS
|
||||
DtCreateOneTemplateFile (
|
||||
char *Signature)
|
||||
char *Signature,
|
||||
UINT32 TableCount)
|
||||
{
|
||||
const ACPI_DMTABLE_DATA *TableData;
|
||||
ACPI_STATUS Status;
|
||||
@ -311,13 +350,7 @@ DtCreateOneTemplateFile (
|
||||
return (AE_ERROR);
|
||||
}
|
||||
|
||||
Status = AdInitialize ();
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = DtCreateOneTemplate (Signature, TableData);
|
||||
Status = DtCreateOneTemplate (Signature, TableCount, TableData);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
@ -342,12 +375,6 @@ DtCreateAllTemplates (
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
Status = AdInitialize ();
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
fprintf (stderr, "Creating all supported Template files\n");
|
||||
|
||||
/* Walk entire ACPI table data structure */
|
||||
@ -359,7 +386,7 @@ DtCreateAllTemplates (
|
||||
if (TableData->Template)
|
||||
{
|
||||
Status = DtCreateOneTemplate (TableData->Signature,
|
||||
TableData);
|
||||
0, TableData);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
@ -372,25 +399,31 @@ DtCreateAllTemplates (
|
||||
* 1) DSDT/SSDT are AML tables, not data tables
|
||||
* 2) FACS and RSDP have non-standard headers
|
||||
*/
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_DSDT, NULL);
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_DSDT, 0, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_SSDT, NULL);
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_SSDT, 0, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_FACS, NULL);
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_OSDT, 0, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = DtCreateOneTemplate (ACPI_RSDP_NAME, NULL);
|
||||
Status = DtCreateOneTemplate (ACPI_SIG_FACS, 0, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = DtCreateOneTemplate (ACPI_RSDP_NAME, 0, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return (Status);
|
||||
@ -405,6 +438,7 @@ DtCreateAllTemplates (
|
||||
* FUNCTION: DtCreateOneTemplate
|
||||
*
|
||||
* PARAMETERS: Signature - ACPI signature, NULL terminated.
|
||||
* TableCount - Used for SSDTs in same file as DSDT
|
||||
* TableData - Entry in ACPI table data structure.
|
||||
* NULL if a special ACPI table.
|
||||
*
|
||||
@ -417,12 +451,14 @@ DtCreateAllTemplates (
|
||||
static ACPI_STATUS
|
||||
DtCreateOneTemplate (
|
||||
char *Signature,
|
||||
UINT32 TableCount,
|
||||
const ACPI_DMTABLE_DATA *TableData)
|
||||
{
|
||||
char *DisasmFilename;
|
||||
FILE *File;
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
ACPI_SIZE Actual;
|
||||
int Actual;
|
||||
UINT32 i;
|
||||
|
||||
|
||||
/* New file will have a .asl suffix */
|
||||
@ -441,7 +477,8 @@ DtCreateOneTemplate (
|
||||
File = fopen (DisasmFilename, "w+");
|
||||
if (!File)
|
||||
{
|
||||
fprintf (stderr, "Could not open output file %s\n", DisasmFilename);
|
||||
fprintf (stderr, "Could not open output file %s\n",
|
||||
DisasmFilename);
|
||||
return (AE_ERROR);
|
||||
}
|
||||
|
||||
@ -452,8 +489,16 @@ DtCreateOneTemplate (
|
||||
AcpiOsPrintf ("/*\n");
|
||||
AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * "));
|
||||
|
||||
AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
|
||||
Signature);
|
||||
if (TableCount == 0)
|
||||
{
|
||||
AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
|
||||
Signature);
|
||||
}
|
||||
else
|
||||
{
|
||||
AcpiOsPrintf (" * Template for [%4.4s] and %u [SSDT] ACPI Tables",
|
||||
Signature, TableCount);
|
||||
}
|
||||
|
||||
/* Dump the actual ACPI table */
|
||||
|
||||
@ -479,45 +524,55 @@ DtCreateOneTemplate (
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Special ACPI tables - DSDT, SSDT, OSDT, FADT, RSDP */
|
||||
/* Special ACPI tables - DSDT, SSDT, OSDT, FACS, RSDP */
|
||||
|
||||
AcpiOsPrintf (" (AML byte code table)\n");
|
||||
|
||||
AcpiOsPrintf (" */\n");
|
||||
|
||||
if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT))
|
||||
{
|
||||
Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File);
|
||||
if (Actual != sizeof (TemplateDsdt) -1)
|
||||
Actual = DtEmitDefinitionBlock (
|
||||
File, DisasmFilename, ACPI_SIG_DSDT, 1);
|
||||
if (Actual < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Could not write to output file %s\n", DisasmFilename);
|
||||
Status = AE_ERROR;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
/* Emit any requested SSDTs into the same file */
|
||||
|
||||
for (i = 1; i <= TableCount; i++)
|
||||
{
|
||||
Actual = DtEmitDefinitionBlock (
|
||||
File, DisasmFilename, ACPI_SIG_SSDT, i + 1);
|
||||
if (Actual < 0)
|
||||
{
|
||||
Status = AE_ERROR;
|
||||
goto Cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT))
|
||||
{
|
||||
Actual = fwrite (TemplateSsdt, 1, sizeof (TemplateSsdt) -1, File);
|
||||
if (Actual != sizeof (TemplateSsdt) -1)
|
||||
Actual = DtEmitDefinitionBlock (
|
||||
File, DisasmFilename, ACPI_SIG_SSDT, 1);
|
||||
if (Actual < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Could not write to output file %s\n", DisasmFilename);
|
||||
Status = AE_ERROR;
|
||||
goto Cleanup;
|
||||
}
|
||||
}
|
||||
else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT))
|
||||
{
|
||||
Actual = fwrite (TemplateOsdt, 1, sizeof (TemplateOsdt) -1, File);
|
||||
if (Actual != sizeof (TemplateOsdt) -1)
|
||||
Actual = DtEmitDefinitionBlock (
|
||||
File, DisasmFilename, ACPI_SIG_OSDT, 1);
|
||||
if (Actual < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Could not write to output file %s\n", DisasmFilename);
|
||||
Status = AE_ERROR;
|
||||
goto Cleanup;
|
||||
}
|
||||
}
|
||||
else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */
|
||||
else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS))
|
||||
{
|
||||
AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER,
|
||||
TemplateFacs));
|
||||
@ -536,12 +591,72 @@ DtCreateOneTemplate (
|
||||
}
|
||||
}
|
||||
|
||||
fprintf (stderr,
|
||||
"Created ACPI table template for [%4.4s], written to \"%s\"\n",
|
||||
Signature, DisasmFilename);
|
||||
if (TableCount == 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Created ACPI table template for [%4.4s], "
|
||||
"written to \"%s\"\n",
|
||||
Signature, DisasmFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Created ACPI table templates for [%4.4s] "
|
||||
"and %u [SSDT], written to \"%s\"\n",
|
||||
Signature, TableCount, DisasmFilename);
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
fclose (File);
|
||||
AcpiOsRedirectOutput (stdout);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: DtEmitDefinitionBlock
|
||||
*
|
||||
* PARAMETERS: File - An open file for the block
|
||||
* Filename - Filename for same, for error msg(s)
|
||||
* Signature - ACPI signature for the block
|
||||
* Instance - Used for multiple SSDTs in the same file
|
||||
*
|
||||
* RETURN: Status from fprintf
|
||||
*
|
||||
* DESCRIPTION: Emit the raw ASL for a complete Definition Block (DSDT or SSDT)
|
||||
*
|
||||
* Note: The AMLFileName parameter for DefinitionBlock is left as a NULL
|
||||
* string. This allows the compiler to create the output AML filename from
|
||||
* the input filename.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static int
|
||||
DtEmitDefinitionBlock (
|
||||
FILE *File,
|
||||
char *Filename,
|
||||
char *Signature,
|
||||
UINT32 Instance)
|
||||
{
|
||||
int Status;
|
||||
|
||||
|
||||
Status = fprintf (File,
|
||||
"DefinitionBlock (\"\", \"%4.4s\", 2, \"Intel\", \"_%4.4s_%.2X\", 0x00000001)\n"
|
||||
"{\n"
|
||||
" Method (%2.2s%.2X)\n"
|
||||
" {\n"
|
||||
" }\n"
|
||||
"}\n\n",
|
||||
Signature, Signature, Instance, Signature, Instance);
|
||||
|
||||
if (Status < 0)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Could not write %4.4s to output file %s\n",
|
||||
Signature, Filename);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
@ -117,36 +117,6 @@
|
||||
#define __DTTEMPLATE_H
|
||||
|
||||
|
||||
/* Special templates for the ASL/AML tables: DSDT, SSDT, and OSDT */
|
||||
|
||||
const char TemplateDsdt[] =
|
||||
"DefinitionBlock (\"\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
|
||||
"{\n"
|
||||
" Method (MAIN, 0, NotSerialized)\n"
|
||||
" {\n"
|
||||
" Return (Zero)\n"
|
||||
" }\n"
|
||||
"}\n\n";
|
||||
|
||||
const char TemplateSsdt[] =
|
||||
"DefinitionBlock (\"\", \"SSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
|
||||
"{\n"
|
||||
" Method (MAIN, 0, NotSerialized)\n"
|
||||
" {\n"
|
||||
" Return (Zero)\n"
|
||||
" }\n"
|
||||
"}\n\n";
|
||||
|
||||
const char TemplateOsdt[] =
|
||||
"DefinitionBlock (\"\", \"OSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
|
||||
"{\n"
|
||||
" Method (MAIN, 0, NotSerialized)\n"
|
||||
" {\n"
|
||||
" Return (Zero)\n"
|
||||
" }\n"
|
||||
"}\n\n";
|
||||
|
||||
|
||||
/* Templates for ACPI data tables */
|
||||
|
||||
const unsigned char TemplateAsf[] =
|
||||
|
Loading…
x
Reference in New Issue
Block a user