iASL: Fix for WPBT table with no command-line arguments

Handle the case where the Command-line Arguments table field
does not exist.
This commit is contained in:
Robert Moore 2021-07-14 13:25:22 -07:00
parent c4ddc96f99
commit d648716449
9 changed files with 43 additions and 17 deletions

View File

@ -1143,6 +1143,12 @@ AcpiDmDumpTable (
ByteLength = 128;
break;
case ACPI_DMT_WPBT_UNICODE:
ByteLength = SubtableLength;
CurrentOffset = sizeof (ACPI_TABLE_WPBT);
break;
case ACPI_DMT_UNICODE:
case ACPI_DMT_BUFFER:
case ACPI_DMT_RAW_BUFFER:
@ -1844,6 +1850,7 @@ AcpiDmDumpTable (
break;
case ACPI_DMT_UNICODE:
case ACPI_DMT_WPBT_UNICODE:
if (ByteLength == 0)
{

View File

@ -833,13 +833,12 @@ AcpiDmDumpWpbt (
{
ACPI_STATUS Status;
ACPI_TABLE_WPBT *Subtable;
UINT32 Length = Table->Length;
UINT16 ArgumentsLength;
/* Dump the main table */
Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt);
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWpbt);
if (ACPI_FAILURE (Status))
{
return;
@ -850,8 +849,11 @@ AcpiDmDumpWpbt (
Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
ArgumentsLength = Subtable->ArgumentsLength;
/* Dump the arguments buffer */
/* Dump the arguments buffer if present */
(void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
AcpiDmTableInfoWpbt0);
if (ArgumentsLength)
{
(void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
AcpiDmTableInfoWpbt0);
}
}

View File

@ -759,7 +759,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt0[] =
{
{ACPI_DMT_UNICODE, sizeof (ACPI_TABLE_WPBT), "Command-line Arguments", 0},
{ACPI_DMT_WPBT_UNICODE, ACPI_WPBT2_OFFSET (UnicodeString), "Command-line Arguments", DT_DESCRIBES_OPTIONAL},
ACPI_DMT_TERMINATOR
};

View File

@ -2678,13 +2678,11 @@ DtCompileWpbt (
DT_SUBTABLE *ParentTable;
ACPI_TABLE_WPBT *Table;
ACPI_STATUS Status;
UINT16 Length;
/* Compile the main table */
Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt,
&Subtable);
Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt, &Subtable);
if (ACPI_FAILURE (Status))
{
return (Status);
@ -2692,11 +2690,23 @@ DtCompileWpbt (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
/*
* Exit now if there are no arguments specified. This is indicated by:
* The "Command-line Arguments" field has not been specified (if specified,
* it will be the last field in the field list -- after the main table).
* Set the Argument Length in the main table to zero.
*/
if (!*PFieldList)
{
Table->ArgumentsLength = 0;
return (AE_OK);
}
/* Compile the argument list subtable */
Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0,
&Subtable);
Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0, &Subtable);
if (ACPI_FAILURE (Status))
{
return (Status);
@ -2704,11 +2714,7 @@ DtCompileWpbt (
/* Extract the length of the Arguments buffer, insert into main table */
Length = (UINT16) Subtable->TotalLength;
Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
Table->ArgumentsLength = Length;
ParentTable = DtPeekSubtable ();
Table->ArgumentsLength = (UINT16) Subtable->TotalLength;
DtInsertSubtable (ParentTable, Subtable);
return (AE_OK);
}

View File

@ -452,6 +452,7 @@ DtGetFieldType (
break;
case ACPI_DMT_UNICODE:
case ACPI_DMT_WPBT_UNICODE:
Type = DT_FIELD_TYPE_UNICODE;
break;
@ -740,12 +741,13 @@ DtGetFieldLength (
break;
case ACPI_DMT_UNICODE:
case ACPI_DMT_WPBT_UNICODE:
Value = DtGetFieldValue (Field);
/* TBD: error if Value is NULL? (as below?) */
ByteLength = (strlen (Value) + 1) * sizeof(UINT16);
ByteLength = (strlen (Value) + 1) * sizeof (UINT16);
break;
default:

View File

@ -289,6 +289,7 @@ typedef enum
ACPI_DMT_SRAT,
ACPI_DMT_TPM2,
ACPI_DMT_VIOT,
ACPI_DMT_WPBT_UNICODE,
/* Special opcodes */

View File

@ -205,6 +205,7 @@
#define ACPI_WDDT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WDDT,f)
#define ACPI_WDRT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WDRT,f)
#define ACPI_WPBT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WPBT,f)
#define ACPI_WPBT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WPBT_UNICODE,f)
#define ACPI_WSMT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WSMT,f)
#define ACPI_XENV_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_XENV,f)

View File

@ -955,6 +955,12 @@ typedef struct acpi_table_wpbt
} ACPI_TABLE_WPBT;
typedef struct acpi_wpbt_unicode
{
UINT16 *UnicodeString;
} ACPI_WPBT_UNICODE;
/*******************************************************************************
*

View File

@ -895,6 +895,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_VIOT_VIRTIO_IOMMU_PCI", SRC_TYPE_STRUCT},
{"ACPI_VIOT_VIRTIO_IOMMU_MMIO", SRC_TYPE_STRUCT},
{"ACPI_WDAT_ENTRY", SRC_TYPE_STRUCT},
{"ACPI_WPBT_UNICODE", SRC_TYPE_STRUCT},
/* Data Table compiler */