Skip to content

Commit

Permalink
iASL/NHLT table: add support for optional "Specific Data" field
Browse files Browse the repository at this point in the history
for the optional Linux-specific structure that appears at the end
of an Endpoint Descriptor.
  • Loading branch information
acpibob committed Dec 17, 2021
1 parent 7cbe9a6 commit 26f8c72
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 9 deletions.
49 changes: 46 additions & 3 deletions source/common/dmtbdump2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion source/common/dmtbinfo2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslmessages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
35 changes: 32 additions & 3 deletions source/compiler/dttable2.c
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,8 @@ DtCompileNhlt (
ArrayType = ConfigSpecific->ArrayType;
ConfigType = ConfigSpecific->ConfigType;
break;
}

} /* switch (CapabilitiesSize) */

if (CapabilitiesSize >= 3)
{
Expand Down Expand Up @@ -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))
Expand All @@ -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")))
Expand Down
1 change: 1 addition & 0 deletions source/include/acdisasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
1 change: 1 addition & 0 deletions source/include/actbinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion source/include/actbl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions source/tools/acpisrc/astable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 26f8c72

Please sign in to comment.