static ACPI_STATUS DtCreateOneTemplateFile ( char *Signature, UINT32 TableCount) { const ACPI_DMTABLE_DATA *TableData; ACPI_STATUS 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 */ if (strlen (Signature) != ACPI_NAME_SIZE) { fprintf (stderr, "%s: Invalid ACPI table signature " "(length must be 4 characters)\n", Signature); return (AE_ERROR); } /* * Some slack for the two strange tables whose name is different than * their signatures: MADT->APIC and FADT->FACP. */ if (!strcmp (Signature, "MADT")) { Signature = "APIC"; } else if (!strcmp (Signature, "FADT")) { Signature = "FACP"; } /* TableData will point to the template */ TableData = AcpiDmGetTableData (Signature); if (TableData) { if (!TableData->Template) { fprintf (stderr, "%4.4s: No template available\n", Signature); return (AE_ERROR); } } else if (!AcpiUtIsSpecialTable (Signature)) { fprintf (stderr, "%4.4s: Unrecognized ACPI table signature\n", Signature); return (AE_ERROR); } Status = DtCreateOneTemplate (Signature, TableCount, TableData); return (Status); }
static ACPI_STATUS DtCompileDataTable ( DT_FIELD **FieldList) { ACPI_DMTABLE_DATA *TableData; DT_SUBTABLE *Subtable; char *Signature; ACPI_TABLE_HEADER *AcpiTableHeader; ACPI_STATUS Status; DT_FIELD *RootField = *FieldList; /* Verify that we at least have a table signature and save it */ Signature = DtGetFieldValue (*FieldList); if (!Signature) { sprintf (MsgBuffer, "Expected \"%s\"", "Signature"); DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, *FieldList, MsgBuffer); return (AE_ERROR); } Gbl_Signature = UtLocalCalloc (ACPI_STRLEN (Signature) + 1); strcpy (Gbl_Signature, Signature); /* * 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_COMPARE_NAME (Signature, ACPI_SIG_FACS)) { Status = DtCompileFacs (FieldList); if (ACPI_FAILURE (Status)) { return (Status); } DtSetTableLength (); return (Status); } else if (ACPI_VALIDATE_RSDP_SIG (Signature)) { Status = DtCompileRsdp (FieldList); return (Status); } else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_S3PT)) { Status = DtCompileS3pt (FieldList); 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. */ DtInsertCompilerIds (*FieldList); Status = DtCompileTable (FieldList, AcpiDmTableInfoHeader, &Gbl_RootTable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); } DtPushSubtable (Gbl_RootTable); /* Validate the signature via the ACPI table list */ TableData = AcpiDmGetTableData (Signature); if (!TableData || Gbl_CompileGeneric) { DtCompileGeneric ((void **) FieldList); goto FinishHeader; } /* Dispatch to per-table compile */ if (TableData->CmTableHandler) { /* Complex table, has a handler */ Status = TableData->CmTableHandler ((void **) FieldList); if (ACPI_FAILURE (Status)) { return (Status); } } else if (TableData->TableInfo) { /* Simple table, just walk the info table */ Subtable = NULL; Status = DtCompileTable (FieldList, TableData->TableInfo, &Subtable, TRUE); if (ACPI_FAILURE (Status)) { return (Status); } DtInsertSubtable (Gbl_RootTable, Subtable); DtPopSubtable (); } else { DtFatal (ASL_MSG_COMPILER_INTERNAL, *FieldList, "Missing table dispatch info"); return (AE_ERROR); } FinishHeader: /* Set the final table length and then the checksum */ DtSetTableLength (); AcpiTableHeader = ACPI_CAST_PTR ( ACPI_TABLE_HEADER, Gbl_RootTable->Buffer); DtSetTableChecksum (&AcpiTableHeader->Checksum); DtDumpFieldList (RootField); DtDumpSubtableList (); return (AE_OK); }
ACPI_STATUS DtCreateTemplates ( char *Signature) { ACPI_DMTABLE_DATA *TableData; ACPI_STATUS Status; AslInitializeGlobals (); /* Default (no signature) is DSDT */ if (!Signature) { Signature = "DSDT"; goto GetTemplate; } AcpiUtStrupr (Signature); if (!ACPI_STRCMP (Signature, "ALL") || !ACPI_STRCMP (Signature, "*")) { /* Create all available/known templates */ 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 */ if (strlen (Signature) != ACPI_NAME_SIZE) { fprintf (stderr, "%s: Invalid ACPI table signature (length must be 4 characters)\n", Signature); return (AE_ERROR); } /* * Some slack for the two strange tables whose name is different than * their signatures: MADT->APIC and FADT->FACP. */ if (!strcmp (Signature, "MADT")) { Signature = "APIC"; } else if (!strcmp (Signature, "FADT")) { Signature = "FACP"; } GetTemplate: TableData = AcpiDmGetTableData (Signature); if (TableData) { if (!TableData->Template) { fprintf (stderr, "%4.4s: No template available\n", Signature); return (AE_ERROR); } } else if (!AcpiUtIsSpecialTable (Signature)) { fprintf (stderr, "%4.4s: Unrecognized ACPI table signature\n", Signature); return (AE_ERROR); } Status = AdInitialize (); if (ACPI_FAILURE (Status)) { return (Status); } Status = DtCreateOneTemplate (Signature, TableData); return (Status); }