iASL/NHLT table: add support for optional "Specific Data" field

for the optional Linux-specific structure that appears at the end
of an Endpoint Descriptor.
This commit is contained in:
Robert Moore 2021-12-17 09:41:35 -08:00
parent 7cbe9a680f
commit 26f8c721fb
8 changed files with 94 additions and 9 deletions

View File

@ -1503,6 +1503,7 @@ AcpiDmDumpNhlt (
ACPI_NHLT_FORMATS_CONFIG *FormatsConfig;
ACPI_NHLT_LINUX_SPECIFIC_COUNT *Count;
ACPI_NHLT_LINUX_SPECIFIC_DATA *LinuxData;
ACPI_NHLT_LINUX_SPECIFIC_DATA_B *LinuxDataB;
/* Main table */
@ -1770,7 +1771,8 @@ AcpiDmDumpNhlt (
Offset += CapabilitiesSize; // + sizeof (ACPI_NHLT_DEVICE_SPECIFIC_CONFIG_B);
}
}
} /* for (j = 0; j < FormatsCount; j++) */
/*
* If we are not done with the current Endpoint yet, then there must be
@ -1789,14 +1791,32 @@ AcpiDmDumpNhlt (
}
Offset += sizeof (ACPI_NHLT_LINUX_SPECIFIC_COUNT);
if (Count->StructureCount > 1)
{
/*
* We currently cannot disassemble more than one
* Linux-Specific section, because we have no way of
* knowing whether the "Specific Data" part is present.
*/
Count->StructureCount = 1;
fprintf (stderr, "%s %s\n", "Feature not supported:",
"Cannot disassemble more than one Linux-Specific structure");
return;
}
/* Variable number of linux-specific structures */
for (j = 0; j < Count->StructureCount; j++)
{
LinuxData = ACPI_ADD_PTR (ACPI_NHLT_LINUX_SPECIFIC_DATA, Table, Offset);
AcpiOsPrintf ("\n /* Linux-specific structure #%u (not part of NHLT spec) */\n", j+1);
/*
* Dump the following Linux-specific fields:
* 1) Device ID
* 2) Device Instance ID
* 3) Device Port ID
*/
Status = AcpiDmDumpTable (TableLength, Offset, LinuxData,
sizeof (ACPI_NHLT_LINUX_SPECIFIC_DATA), AcpiDmTableInfoNhlt7a);
if (ACPI_FAILURE (Status))
@ -1805,11 +1825,34 @@ AcpiDmDumpNhlt (
}
Offset += sizeof (ACPI_NHLT_LINUX_SPECIFIC_DATA);
/*
* Check that the current offset is not beyond the end of
* this endpoint descriptor. If it is not, we assume that
* the "Specific Data" field is present and valid. Note:
* This does not seem to be documented anywhere.
*/
if (Offset < EndpointEndOffset)
{
/* Dump the linux-specific "Specific Data" field */
LinuxDataB = ACPI_ADD_PTR (ACPI_NHLT_LINUX_SPECIFIC_DATA_B, Table, Offset);
Status = AcpiDmDumpTable (TableLength, Offset, LinuxDataB,
sizeof (ACPI_NHLT_LINUX_SPECIFIC_DATA_B), AcpiDmTableInfoNhlt7b);
if (ACPI_FAILURE (Status))
{
return;
}
Offset += sizeof (ACPI_NHLT_LINUX_SPECIFIC_DATA_B);
}
}
/* Should be at the end of the Endpoint structure. */
}
}
} /* for (i = 0; i < EndpointCount; i++) */
/*
* Done with all of the Endpoint Descriptors, Emit the table terminator

View File

@ -1394,7 +1394,12 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt7a[] =
{ACPI_DMT_BUF16, ACPI_NHLT7A_OFFSET (DeviceId), "Device ID", 0},
{ACPI_DMT_UINT8, ACPI_NHLT7A_OFFSET (DeviceInstanceId), "Device Instance ID", 0},
{ACPI_DMT_UINT8, ACPI_NHLT7A_OFFSET (DevicePortId), "Device Port ID", 0},
{ACPI_DMT_BUF18, ACPI_NHLT7A_OFFSET (Filler), "Specific Data", 0},
ACPI_DMT_TERMINATOR
};
ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt7b[] =
{
{ACPI_DMT_BUF18, ACPI_NHLT7B_OFFSET (SpecificData), "Specific Data", 0},
ACPI_DMT_TERMINATOR
};

View File

@ -411,7 +411,7 @@ const char *AslTableCompilerMsgs [] =
/* ASL_MSG_UNKNOWN_FORMAT */ "Unknown format value",
/* ASL_MSG_RESERVED_VALUE */ "Value for field is reserved or unknown",
/* ASL_MSG_TWO_ZERO_VALUES */ "32-bit DSDT Address and 64-bit X_DSDT Address cannot both be zero",
/* ASL_MSG_BAD_PARSE_TREE */ "Parse tree appears to be ill-defined",
/* ASL_MSG_BAD_PARSE_TREE */ "Parse tree appears to be ill-defined"
};
/* Preprocessor */

View File

@ -967,7 +967,8 @@ DtCompileNhlt (
ArrayType = ConfigSpecific->ArrayType;
ConfigType = ConfigSpecific->ConfigType;
break;
}
} /* switch (CapabilitiesSize) */
if (CapabilitiesSize >= 3)
{
@ -1097,6 +1098,12 @@ DtCompileNhlt (
for (j = 0; j < LinuxSpecificCount; j++)
{
/*
* Compile the following Linux-specific fields:
* 1) Device ID
* 2) Device Instance ID
* 3) Device Port ID
*/
Status = DtCompileTable (PFieldList, AcpiDmTableInfoNhlt7a,
&Subtable);
if (ACPI_FAILURE (Status))
@ -1106,14 +1113,36 @@ DtCompileNhlt (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
}
/*
* To have a valid Linux-specific "Specific Data" at this
* point, we need:
* 1) The next field must be named "Specific Data"
*/
if (!strcmp ((const char *) (*PFieldList)->Name, "Specific Data"))
{
/* Compile the "Specific Data" field */
Status = DtCompileTable (PFieldList, AcpiDmTableInfoNhlt7b,
&Subtable);
if (ACPI_FAILURE (Status))
{
return (Status);
}
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
}
} /* for (j = 0; j < LinuxSpecificCount; j++) */
}
DtPopSubtable ();
} /* for (i = 0; i < EndpointCount; i++) */
/*
* All Endpoints are completed.
* All Endpoint Descriptors are completed.
* Do the table terminator structure (not in NHLT spec, optional)
*/
if (*PFieldList && (strcmp ((const char *) (*PFieldList)->Name, "Descriptor Length")))

View File

@ -570,6 +570,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt6a[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt6b[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt7[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt7a[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt7b[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt8[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoNhlt9[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoPhatHdr[];

View File

@ -345,6 +345,7 @@
#define ACPI_NHLT6B_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NHLT_RENDER_FEEDBACK_DEVICE_SPECIFIC_CONFIG,f)
#define ACPI_NHLT7_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NHLT_LINUX_SPECIFIC_COUNT,f)
#define ACPI_NHLT7A_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NHLT_LINUX_SPECIFIC_DATA,f)
#define ACPI_NHLT7B_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NHLT_LINUX_SPECIFIC_DATA_B,f)
#define ACPI_NHLT8_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NHLT_TABLE_TERMINATOR,f)
#define ACPI_NHLT9_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NHLT_MIC_SNR_SENSITIVITY_EXTENSION,f)
#define ACPI_PCCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f)

View File

@ -2115,10 +2115,15 @@ typedef struct acpi_nhlt_linux_specific_data
UINT8 DeviceId[16];
UINT8 DeviceInstanceId;
UINT8 DevicePortId;
UINT8 Filler[18];
} ACPI_NHLT_LINUX_SPECIFIC_DATA;
typedef struct acpi_nhlt_linux_specific_data_b
{
UINT8 SpecificData[18];
} ACPI_NHLT_LINUX_SPECIFIC_DATA_B;
typedef struct acpi_nhlt_table_terminator
{
UINT32 TerminatorValue;

View File

@ -858,6 +858,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_NHLT_FORMATS_CONFIG", SRC_TYPE_STRUCT},
{"ACPI_NHLT_LINUX_SPECIFIC_COUNT", SRC_TYPE_STRUCT},
{"ACPI_NHLT_LINUX_SPECIFIC_DATA", SRC_TYPE_STRUCT},
{"ACPI_NHLT_LINUX_SPECIFIC_DATA_B", SRC_TYPE_STRUCT},
{"ACPI_NHLT_MIC_DEVICE_SPECIFIC_CONFIG", SRC_TYPE_STRUCT},
{"ACPI_NHLT_MIC_SNR_SENSITIVITY_EXTENSION",SRC_TYPE_STRUCT},
{"ACPI_NHLT_RENDER_DEVICE_SPECIFIC_CONFIG", SRC_TYPE_STRUCT},