diff options
Diffstat (limited to 'source/common')
| -rw-r--r-- | source/common/acfileio.c | 24 | ||||
| -rw-r--r-- | source/common/dmtbdump.c | 184 | ||||
| -rw-r--r-- | source/common/dmtbinfo.c | 28 | 
3 files changed, 147 insertions, 89 deletions
| diff --git a/source/common/acfileio.c b/source/common/acfileio.c index 409e16f0684fb..ffa23a64e25da 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -112,7 +112,7 @@ AcGetAllTablesFromFile (      if (FileSize == ACPI_UINT32_MAX)      {          Status = AE_ERROR; -        goto ErrorExit; +        goto Exit;      }      fprintf (stderr, @@ -124,7 +124,7 @@ AcGetAllTablesFromFile (      if (FileSize < sizeof (ACPI_TABLE_HEADER))      {          Status = AE_BAD_HEADER; -        goto ErrorExit; +        goto Exit;      }      /* Check for an non-binary file */ @@ -134,7 +134,8 @@ AcGetAllTablesFromFile (          fprintf (stderr,              "    %s: File does not appear to contain a valid AML table\n",              Filename); -        return (AE_TYPE); +        Status = AE_TYPE; +        goto Exit;      }      /* Read all tables within the file */ @@ -153,23 +154,31 @@ AcGetAllTablesFromFile (          }          else if (Status == AE_TYPE)          { -            return (AE_OK); +            Status = AE_OK; +            goto Exit;          }          else if (ACPI_FAILURE (Status))          { -            goto ErrorExit; +            goto Exit;          }          /* Print table header for iASL/disassembler only */  #ifdef ACPI_ASL_COMPILER -            AcpiTbPrintTableHeader (0, Table); +        AcpiTbPrintTableHeader (0, Table);  #endif          /* Allocate and link a table descriptor */          TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC)); +        if (!TableDesc) +        { +            AcpiOsFree (Table); +            Status = AE_NO_MEMORY; +            goto Exit; +        } +          TableDesc->Table = Table;          TableDesc->Next = NULL; @@ -204,7 +213,7 @@ AcGetAllTablesFromFile (          *ReturnListHead = ListHead;      } -ErrorExit: +Exit:      fclose(File);      return (Status);  } @@ -262,7 +271,6 @@ AcGetOneTableFromFile (          return (Status);      } -      if (GetOnlyAmlTables)      {          /* diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index 4ef670d0ce9c4..789256c12d3b4 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -52,31 +52,12 @@          ACPI_MODULE_NAME    ("dmtbdump") -/* Table of revision-dependent FADT sizes */ +/* Local prototypes */ -static const UINT32         FadtRevisionLength [ACPI_FADT_MAX_VERSION + 1] = -{ -    0,                      /* 0 - illegal */ -    ACPI_FADT_V1_SIZE,      /* 1 - ACPI 1.0 */ -    0,                      /* 2 - illegal */ -    ACPI_FADT_V3_SIZE,      /* 3 - ACPI 2.0 */ -    ACPI_FADT_V4_SIZE,      /* 4 - ACPI 3.0 and ACPI 4.0 */ -    ACPI_FADT_V5_SIZE,      /* 5 - ACPI 5.0 */ -    ACPI_FADT_V6_SIZE       /* 6 - ACPI 6.0 */ -}; - -/* Table of revision-dependent FADT info tables */ - -ACPI_DMTABLE_INFO           *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1] = -{ -    NULL,                   /* 0 - illegal */ -    AcpiDmTableInfoFadt1,   /* 1 - ACPI 1.0 */ -    NULL,                   /* 2 - illegal */ -    AcpiDmTableInfoFadt3,   /* 3 - ACPI 2.0 */ -    AcpiDmTableInfoFadt4,   /* 4 - ACPI 3.0 and ACPI 4.0 */ -    AcpiDmTableInfoFadt5,   /* 5 - ACPI 5.0 */ -    AcpiDmTableInfoFadt6    /* 6 - ACPI 6.0 */ -}; +static void +AcpiDmValidateFadtLength ( +    UINT32                  Revision, +    UINT32                  Length);  /******************************************************************************* @@ -366,11 +347,6 @@ AcpiDmDumpXsdt (   *   * DESCRIPTION: Format the contents of a FADT   * - *              Check the FADT revision against the expected table length for - *              that revision. Issue a warning if the length is not what was - *              expected. This seems to be such a common BIOS bug that the - *              FADT revision has been rendered virtually meaningless. - *   * NOTE:        We cannot depend on the FADT version to indicate the actual   *              contents of the FADT because of BIOS bugs. The table length   *              is the only reliable indicator. @@ -382,72 +358,142 @@ AcpiDmDumpFadt (      ACPI_TABLE_HEADER       *Table)  {      ACPI_STATUS             Status; -    UINT8                   FadtRevision; -    UINT32                  ExpectedLength; -    UINT32                  i; - -    FadtRevision = Table->Revision; -    /* FADT revision/length validation */ +    /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */ -    if ((FadtRevision == 0) || -        (FadtRevision == 2)) +    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, +        AcpiDmTableInfoFadt1); +    if (ACPI_FAILURE (Status))      { -        AcpiOsPrintf ( -            "// ACPI Warning: Invalid or unsupported FADT revision: %u\n", -            FadtRevision);          return;      } -    if (FadtRevision > ACPI_FADT_MAX_VERSION) -    { -        AcpiOsPrintf ("// ACPI Warning: Revision %u is not fully supported, " -            "disassembling known fields (up to revision %u)\n\n", -            FadtRevision, ACPI_FADT_MAX_VERSION); -    } -    else +    /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */ + +    if ((Table->Length > ACPI_FADT_V1_SIZE) && +        (Table->Length <= ACPI_FADT_V2_SIZE))      { -        ExpectedLength = FadtRevisionLength[FadtRevision]; -        if (Table->Length != ExpectedLength) +        Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, +            AcpiDmTableInfoFadt2); +        if (ACPI_FAILURE (Status))          { -            AcpiOsPrintf ( -                "// ACPI Warning: Input FADT revision %X does not match " -                "expected length: found 0x%X expected 0x%X\n", -                FadtRevision, Table->Length, ExpectedLength); +            return;          }      } -    /* -     * Dump the input table on a per-version basis, but is actually -     * based upon the length of the table. Table length must -     * be larger than the required length of the previous version. -     */ -    for (i = 1; i <= ACPI_FADT_MAX_VERSION; i++) +    /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */ + +    else if (Table->Length > ACPI_FADT_V2_SIZE)      { -        if (!FadtRevisionLength[i]) /* Skip any empty slots */ +        Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, +            AcpiDmTableInfoFadt3); +        if (ACPI_FAILURE (Status))          { -            continue; +            return;          } -        /* Dump the fields specific to FADT revision[i] */ +        /* Check for FADT revision 5 fields and up (ACPI 5.0+) */ -        Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, -            FadtRevisionInfo[i]); -        if (ACPI_FAILURE (Status)) +        if (Table->Length > ACPI_FADT_V3_SIZE)          { -            return; +            Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, +                AcpiDmTableInfoFadt5); +            if (ACPI_FAILURE (Status)) +            { +                return; +            }          } -        if (Table->Length <= FadtRevisionLength[i]) +        /* Check for FADT revision 6 fields and up (ACPI 6.0+) */ + +        if (Table->Length > ACPI_FADT_V3_SIZE)          { -            break;  /* End of table */ +            Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, +                AcpiDmTableInfoFadt6); +            if (ACPI_FAILURE (Status)) +            { +                return; +            }          }      } -    /* Build a local FADT to test some FADT values */ +    /* Validate various fields in the FADT, including length */      AcpiTbCreateLocalFadt (Table, Table->Length); + +    /* Validate FADT length against the revision */ + +    AcpiDmValidateFadtLength (Table->Revision, Table->Length); +} + + +/******************************************************************************* + * + * FUNCTION:    AcpiDmValidateFadtLength + * + * PARAMETERS:  Revision            - FADT revision (Header->Revision) + *              Length              - FADT length (Header->Length + * + * RETURN:      None + * + * DESCRIPTION: Check the FADT revision against the expected table length for + *              that revision. Issue a warning if the length is not what was + *              expected. This seems to be such a common BIOS bug that the + *              FADT revision has been rendered virtually meaningless. + * + ******************************************************************************/ + +static void +AcpiDmValidateFadtLength ( +    UINT32                  Revision, +    UINT32                  Length) +{ +    UINT32                  ExpectedLength; + + +    switch (Revision) +    { +    case 0: + +        AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n"); +        return; + +    case 1: + +        ExpectedLength = ACPI_FADT_V1_SIZE; +        break; + +    case 2: + +        ExpectedLength = ACPI_FADT_V2_SIZE; +        break; + +    case 3: +    case 4: + +        ExpectedLength = ACPI_FADT_V3_SIZE; +        break; + +    case 5: + +        ExpectedLength = ACPI_FADT_V5_SIZE; +        break; + +    default: + +        return; +    } + +    if (Length == ExpectedLength) +    { +        return; +    } + +    AcpiOsPrintf ( +        "\n// ACPI Warning: FADT revision %X does not match length: " +        "found %X expected %X\n", +        Revision, Length, ExpectedLength);  } diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index e0a6070f06a8e..1cc37ef31df56 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -400,7 +400,7 @@ ACPI_DMTABLE_INFO           AcpiDmTableInfoFacs[] =   *   ******************************************************************************/ -/* FADT version 1 (ACPI 1.0) */ +/* ACPI 1.0 FADT (Version 1) */  ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt1[] =  { @@ -486,7 +486,18 @@ ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt1[] =      ACPI_DMT_TERMINATOR  }; -/* FADT version 3 (ACPI 2.0) */ +/* ACPI 1.0 MS Extensions (FADT version 2) */ + +ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt2[] = +{ +    {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (ResetRegister),           "Reset Register", 0}, +    {ACPI_DMT_UINT8,    ACPI_FADT_OFFSET (ResetValue),              "Value to cause reset", 0}, +    {ACPI_DMT_UINT16,   ACPI_FADT_OFFSET (ArmBootFlags),            "Reserved", 0}, +    {ACPI_DMT_UINT8,    ACPI_FADT_OFFSET (MinorRevision),           "Reserved", 0}, +    ACPI_DMT_TERMINATOR +}; + +/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */  ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt3[] =  { @@ -510,23 +521,16 @@ ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt3[] =      ACPI_DMT_TERMINATOR  }; -/* FADT version 4 (ACPI 3.0 and ACPI 4.0) */ - -ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt4[] = -{ -    {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (SleepControl),            "Sleep Control Register", 0}, -    ACPI_DMT_TERMINATOR -}; - -/* FADT version 5 (ACPI 5.0) */ +/* ACPI 5.0 Extensions (FADT version 5) */  ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt5[] =  { +    {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (SleepControl),            "Sleep Control Register", 0},      {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (SleepStatus),             "Sleep Status Register", 0},      ACPI_DMT_TERMINATOR  }; -/* FADT version 6 (ACPI 6.0) */ +/* ACPI 6.0 Extensions (FADT version 6) */  ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt6[] =  { | 
