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); }
UINT32 DtGetFieldLength ( DT_FIELD *Field, ACPI_DMTABLE_INFO *Info) { UINT32 ByteLength = 0; char *Value; /* Length is based upon the opcode for this field in the info table */ switch (Info->Opcode) { case ACPI_DMT_FLAG0: case ACPI_DMT_FLAG1: case ACPI_DMT_FLAG2: case ACPI_DMT_FLAG3: case ACPI_DMT_FLAG4: case ACPI_DMT_FLAG5: case ACPI_DMT_FLAG6: case ACPI_DMT_FLAG7: case ACPI_DMT_FLAGS0: case ACPI_DMT_FLAGS1: case ACPI_DMT_FLAGS2: case ACPI_DMT_FLAGS4: case ACPI_DMT_LABEL: case ACPI_DMT_EXTRA_TEXT: ByteLength = 0; break; case ACPI_DMT_UINT8: case ACPI_DMT_CHKSUM: case ACPI_DMT_SPACEID: case ACPI_DMT_ACCWIDTH: case ACPI_DMT_IVRS: case ACPI_DMT_GTDT: case ACPI_DMT_MADT: case ACPI_DMT_PCCT: case ACPI_DMT_PMTT: case ACPI_DMT_SRAT: case ACPI_DMT_ASF: case ACPI_DMT_HESTNTYP: case ACPI_DMT_FADTPM: case ACPI_DMT_EINJACT: case ACPI_DMT_EINJINST: case ACPI_DMT_ERSTACT: case ACPI_DMT_ERSTINST: case ACPI_DMT_DMAR_SCOPE: ByteLength = 1; break; case ACPI_DMT_UINT16: case ACPI_DMT_DMAR: case ACPI_DMT_HEST: case ACPI_DMT_NFIT: case ACPI_DMT_PCI_PATH: ByteLength = 2; break; case ACPI_DMT_UINT24: ByteLength = 3; break; case ACPI_DMT_UINT32: case ACPI_DMT_NAME4: case ACPI_DMT_SIG: case ACPI_DMT_LPIT: ByteLength = 4; break; case ACPI_DMT_UINT40: ByteLength = 5; break; case ACPI_DMT_UINT48: case ACPI_DMT_NAME6: ByteLength = 6; break; case ACPI_DMT_UINT56: case ACPI_DMT_BUF7: ByteLength = 7; break; case ACPI_DMT_UINT64: case ACPI_DMT_NAME8: ByteLength = 8; break; case ACPI_DMT_STRING: Value = DtGetFieldValue (Field); if (Value) { ByteLength = strlen (Value) + 1; } else { /* At this point, this is a fatal error */ sprintf (MsgBuffer, "Expected \"%s\"", Info->Name); DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); return (0); } break; case ACPI_DMT_GAS: ByteLength = sizeof (ACPI_GENERIC_ADDRESS); break; case ACPI_DMT_HESTNTFY: ByteLength = sizeof (ACPI_HEST_NOTIFY); break; case ACPI_DMT_IORTMEM: ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS); break; case ACPI_DMT_BUFFER: case ACPI_DMT_RAW_BUFFER: Value = DtGetFieldValue (Field); if (Value) { ByteLength = DtGetBufferLength (Value); } else { /* At this point, this is a fatal error */ sprintf (MsgBuffer, "Expected \"%s\"", Info->Name); DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); return (0); } break; case ACPI_DMT_BUF10: ByteLength = 10; break; case ACPI_DMT_BUF16: case ACPI_DMT_UUID: ByteLength = 16; break; case ACPI_DMT_BUF128: ByteLength = 128; break; case ACPI_DMT_UNICODE: Value = DtGetFieldValue (Field); /* TBD: error if Value is NULL? (as below?) */ ByteLength = (strlen (Value) + 1) * sizeof(UINT16); break; default: DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid table opcode"); return (0); } return (ByteLength); }