summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgenerate/msvc2017/AcpiBin.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AcpiDump.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AcpiExec.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AcpiHelp.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AcpiSrc.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AcpiXtract.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AslCompiler.vcxproj1
-rwxr-xr-xgenerate/msvc2017/AslCompiler.vcxproj.user5
-rwxr-xr-xgenerate/msvc2017/Examples.vcxproj1
-rw-r--r--source/common/adisasm.c1
-rw-r--r--source/common/ahtable.c1
-rw-r--r--source/common/dmtable.c2
-rw-r--r--source/common/dmtbdump2.c122
-rw-r--r--source/common/dmtbinfo2.c61
-rw-r--r--source/compiler/aslallocate.c6
-rw-r--r--source/compiler/aslbtypes.c1
-rw-r--r--source/compiler/aslparseop.c2
-rw-r--r--source/compiler/asltree.c1
-rw-r--r--source/compiler/asltypes.h2
-rw-r--r--source/compiler/dtcompiler.h5
-rw-r--r--source/compiler/dtexpress.c1
-rw-r--r--source/compiler/dttable2.c122
-rw-r--r--source/compiler/dttemplate.h20
-rw-r--r--source/compiler/preprocess.h9
-rw-r--r--source/compiler/prmacros.c48
-rw-r--r--source/compiler/prscan.c7
-rw-r--r--source/compiler/prutils.c238
-rw-r--r--source/components/debugger/dbnames.c3
-rw-r--r--source/components/resources/rsaddr.c10
-rw-r--r--source/components/resources/rscalc.c18
-rw-r--r--source/components/resources/rslist.c9
-rw-r--r--source/components/resources/rsmisc.c9
-rw-r--r--source/components/utilities/utresrc.c11
-rw-r--r--source/include/acdisasm.h11
-rw-r--r--source/include/acrestyp.h25
-rw-r--r--source/include/actbinfo.h4
-rw-r--r--source/include/actbl1.h11
-rw-r--r--source/include/actbl2.h90
-rw-r--r--source/include/actypes.h4
-rw-r--r--source/include/amlresrc.h5
-rw-r--r--source/include/platform/acefiex.h2
-rw-r--r--source/include/platform/acgcc.h11
42 files changed, 811 insertions, 74 deletions
diff --git a/generate/msvc2017/AcpiBin.vcxproj b/generate/msvc2017/AcpiBin.vcxproj
index 42d0f8c7c..1de38d074 100755
--- a/generate/msvc2017/AcpiBin.vcxproj
+++ b/generate/msvc2017/AcpiBin.vcxproj
@@ -98,7 +98,6 @@
<IgnoreSpecificDefaultLibraries>advapi32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<OutputFile>.\AcpiBin\AcpiBin.exe</OutputFile>
<AdditionalDependencies>kernel32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
diff --git a/generate/msvc2017/AcpiDump.vcxproj b/generate/msvc2017/AcpiDump.vcxproj
index 80e3bb804..5c57dc55a 100755
--- a/generate/msvc2017/AcpiDump.vcxproj
+++ b/generate/msvc2017/AcpiDump.vcxproj
@@ -108,7 +108,6 @@
<SubSystem>Console</SubSystem>
<OutputFile>.\AcpiDump\AcpiDump.exe</OutputFile>
<AdditionalDependencies>kernel32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
diff --git a/generate/msvc2017/AcpiExec.vcxproj b/generate/msvc2017/AcpiExec.vcxproj
index 38d408a80..34b166992 100755
--- a/generate/msvc2017/AcpiExec.vcxproj
+++ b/generate/msvc2017/AcpiExec.vcxproj
@@ -114,7 +114,6 @@
<SubSystem>Console</SubSystem>
<OutputFile>.\AcpiExec\AcpiExec.exe</OutputFile>
<AdditionalDependencies>setargv.obj;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
diff --git a/generate/msvc2017/AcpiHelp.vcxproj b/generate/msvc2017/AcpiHelp.vcxproj
index 215392bb6..6eac63453 100755
--- a/generate/msvc2017/AcpiHelp.vcxproj
+++ b/generate/msvc2017/AcpiHelp.vcxproj
@@ -157,7 +157,6 @@
<SubSystem>Console</SubSystem>
<OutputFile>.\AcpiHelp\AcpiHelp.exe</OutputFile>
<AdditionalDependencies>kernel32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
diff --git a/generate/msvc2017/AcpiSrc.vcxproj b/generate/msvc2017/AcpiSrc.vcxproj
index 8a58687f4..075493a85 100755
--- a/generate/msvc2017/AcpiSrc.vcxproj
+++ b/generate/msvc2017/AcpiSrc.vcxproj
@@ -108,7 +108,6 @@
<SubSystem>Console</SubSystem>
<OutputFile>.\AcpiSrc\AcpiSrc.exe</OutputFile>
<AdditionalDependencies>kernel32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
diff --git a/generate/msvc2017/AcpiXtract.vcxproj b/generate/msvc2017/AcpiXtract.vcxproj
index a6cd5f713..8cd341366 100755
--- a/generate/msvc2017/AcpiXtract.vcxproj
+++ b/generate/msvc2017/AcpiXtract.vcxproj
@@ -156,7 +156,6 @@
<OutputFile>.\AcpiXtract\AcpiXtract.exe</OutputFile>
<AdditionalDependencies>kernel32.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
diff --git a/generate/msvc2017/AslCompiler.vcxproj b/generate/msvc2017/AslCompiler.vcxproj
index 5738c630b..6dfa860f0 100755
--- a/generate/msvc2017/AslCompiler.vcxproj
+++ b/generate/msvc2017/AslCompiler.vcxproj
@@ -121,7 +121,6 @@
<AdditionalDependencies>setargv.obj;%(AdditionalDependencies)</AdditionalDependencies>
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
<GenerateDebugInformation>false</GenerateDebugInformation>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
diff --git a/generate/msvc2017/AslCompiler.vcxproj.user b/generate/msvc2017/AslCompiler.vcxproj.user
index c6140842d..6b58a03dc 100755
--- a/generate/msvc2017/AslCompiler.vcxproj.user
+++ b/generate/msvc2017/AslCompiler.vcxproj.user
@@ -5,4 +5,9 @@
<LocalDebuggerWorkingDirectory>C:\0acpi-bugs\CDAT</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LocalDebuggerCommandArguments>dsdt.asl</LocalDebuggerCommandArguments>
+ <LocalDebuggerWorkingDirectory>C:\0acpi-features\macros</LocalDebuggerWorkingDirectory>
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ </PropertyGroup>
</Project> \ No newline at end of file
diff --git a/generate/msvc2017/Examples.vcxproj b/generate/msvc2017/Examples.vcxproj
index 8977e41cd..d34e0d81f 100755
--- a/generate/msvc2017/Examples.vcxproj
+++ b/generate/msvc2017/Examples.vcxproj
@@ -104,7 +104,6 @@
<IgnoreSpecificDefaultLibraries>LIBCMTD;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<OutputFile>.\Examples\Examples.exe</OutputFile>
<AdditionalDependencies>odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalOptions>/INTEGRITYCHECK %(AdditionalOptions)</AdditionalOptions>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
diff --git a/source/common/adisasm.c b/source/common/adisasm.c
index 5feb501a7..ccb98bfe0 100644
--- a/source/common/adisasm.c
+++ b/source/common/adisasm.c
@@ -789,6 +789,7 @@ AdDoExternalFileList (
AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
AcpiGbl_RootNode, OwnerId);
AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
+ AcpiGbl_ParseOpRoot = NULL;
ExternalListHead = ExternalListHead->Next;
}
diff --git a/source/common/ahtable.c b/source/common/ahtable.c
index 23a65d49c..6013b9413 100644
--- a/source/common/ahtable.c
+++ b/source/common/ahtable.c
@@ -246,6 +246,7 @@ const AH_TABLE AcpiGbl_SupportedTables[] =
{ACPI_SIG_PPTT, "Processor Properties Topology Table"},
{ACPI_SIG_PRMT, "Platform Runtime Mechanism Table"},
{ACPI_SIG_RASF, "RAS Features Table"},
+ {ACPI_SIG_RHCT, "RISC-V Hart Capabilities Table"},
{ACPI_SIG_RGRT, "Regulatory Graphics Resource Table"},
{ACPI_RSDP_NAME,"Root System Description Pointer"},
{ACPI_SIG_RSDT, "Root System Description Table"},
diff --git a/source/common/dmtable.c b/source/common/dmtable.c
index e77b05bb7..5b9fe6ef9 100644
--- a/source/common/dmtable.c
+++ b/source/common/dmtable.c
@@ -429,6 +429,7 @@ static const char *AcpiDmMadtSubnames[] =
"MSI Interrupt Controller", /* ACPI_MADT_TYPE_MSI_PIC */
"Bridge I/O Interrupt Controller", /* ACPI_MADT_TYPE_BIO_PIC */
"LPC Interrupt Controller", /* ACPI_MADT_TYPE_LPC_PIC */
+ "RISC-V Interrupt Controller", /* ACPI_MADT_TYPE_RINTC */
"Unknown Subtable Type", /* Reserved */
"Types 80-FF are used for OEM data" /* Reserved for OEM data */
};
@@ -734,6 +735,7 @@ const ACPI_DMTABLE_DATA AcpiDmTableData[] =
{ACPI_SIG_PRMT, NULL, AcpiDmDumpPrmt, DtCompilePrmt, TemplatePrmt},
{ACPI_SIG_RASF, AcpiDmTableInfoRasf, NULL, NULL, TemplateRasf},
{ACPI_SIG_RGRT, NULL, AcpiDmDumpRgrt, DtCompileRgrt, TemplateRgrt},
+ {ACPI_SIG_RHCT, NULL, AcpiDmDumpRhct, DtCompileRhct, TemplateRhct},
{ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt},
{ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt},
{ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst},
diff --git a/source/common/dmtbdump2.c b/source/common/dmtbdump2.c
index 353979e8f..958ecce8f 100644
--- a/source/common/dmtbdump2.c
+++ b/source/common/dmtbdump2.c
@@ -1538,7 +1538,7 @@ AcpiDmDumpNfit (
/* Has a variable number of 64-bit addresses at the end */
InfoTable = AcpiDmTableInfoNfit6;
- FieldOffset = sizeof (ACPI_NFIT_FLUSH_ADDRESS) - sizeof (UINT64);
+ FieldOffset = sizeof (ACPI_NFIT_FLUSH_ADDRESS);
break;
case ACPI_NFIT_TYPE_CAPABILITIES: /* ACPI 6.0A */
@@ -1592,12 +1592,12 @@ AcpiDmDumpNfit (
case ACPI_NFIT_TYPE_SMBIOS:
Length = Subtable->Length -
- sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8);
+ sizeof (ACPI_NFIT_SMBIOS);
if (Length)
{
Status = AcpiDmDumpTable (Table->Length,
- sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8),
+ sizeof (ACPI_NFIT_SMBIOS),
SmbiosInfo,
Length, AcpiDmTableInfoNfit3a);
if (ACPI_FAILURE (Status))
@@ -2747,6 +2747,122 @@ AcpiDmDumpRgrt (
/*******************************************************************************
*
+ * FUNCTION: AcpiDmDumpRhct
+ *
+ * PARAMETERS: Table - A RHCT table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Format the contents of a RHCT.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpRhct (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ ACPI_RHCT_NODE_HEADER *Subtable;
+ ACPI_RHCT_HART_INFO *RhctHartInfo;
+ ACPI_RHCT_ISA_STRING *RhctIsaString;
+ UINT32 Length = Table->Length;
+ UINT8 SubtableOffset, IsaPadOffset;
+ UINT32 Offset = sizeof (ACPI_TABLE_RHCT);
+ UINT32 i;
+
+ /* Main table */
+
+ Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRhct);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* Subtables */
+
+ while (Offset < Table->Length)
+ {
+ AcpiOsPrintf ("\n");
+
+ /* Common subtable header */
+
+ Subtable = ACPI_ADD_PTR (ACPI_RHCT_NODE_HEADER, Table, Offset);
+ if (Subtable->Length < sizeof (ACPI_RHCT_NODE_HEADER))
+ {
+ AcpiOsPrintf ("Invalid subtable length\n");
+ return;
+ }
+ Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
+ Subtable->Length, AcpiDmTableInfoRhctNodeHdr);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ Length = sizeof (ACPI_RHCT_NODE_HEADER);
+
+ if (Subtable->Length < Length)
+ {
+ AcpiOsPrintf ("Invalid subtable length\n");
+ return;
+ }
+ SubtableOffset = Length;
+
+ switch (Subtable->Type)
+ {
+ case ACPI_RHCT_NODE_TYPE_HART_INFO:
+ Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
+ ACPI_ADD_PTR (ACPI_RHCT_HART_INFO, Subtable, SubtableOffset),
+ sizeof (ACPI_RHCT_HART_INFO), AcpiDmTableInfoRhctHartInfo1);
+
+ RhctHartInfo = ACPI_ADD_PTR (ACPI_RHCT_HART_INFO, Subtable, SubtableOffset);
+
+ if ((UINT16)(Subtable->Length - SubtableOffset) <
+ (UINT16)(RhctHartInfo->NumOffsets * 4))
+ {
+ AcpiOsPrintf ("Invalid number of offsets\n");
+ return;
+ }
+ SubtableOffset += sizeof (ACPI_RHCT_HART_INFO);
+ for (i = 0; i < RhctHartInfo->NumOffsets; i++)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
+ ACPI_ADD_PTR (UINT32, Subtable, SubtableOffset),
+ 4, AcpiDmTableInfoRhctHartInfo2);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ SubtableOffset += 4;
+ }
+ break;
+
+ case ACPI_RHCT_NODE_TYPE_ISA_STRING:
+ RhctIsaString = ACPI_ADD_PTR (ACPI_RHCT_ISA_STRING, Subtable, SubtableOffset);
+ IsaPadOffset = SubtableOffset + 2 + RhctIsaString->IsaLength;
+ Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
+ RhctIsaString, RhctIsaString->IsaLength, AcpiDmTableInfoRhctIsa1);
+ if (Subtable->Length > IsaPadOffset)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
+ ACPI_ADD_PTR (UINT8, Subtable, IsaPadOffset),
+ (Subtable->Length - IsaPadOffset), AcpiDmTableInfoRhctIsaPad);
+ }
+
+ default:
+ break;
+ }
+
+ /* Point to next subtable */
+
+ Offset += Subtable->Length;
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmDumpS3pt
*
* PARAMETERS: Table - A S3PT table
diff --git a/source/common/dmtbinfo2.c b/source/common/dmtbinfo2.c
index 1dd3d696f..214206add 100644
--- a/source/common/dmtbinfo2.c
+++ b/source/common/dmtbinfo2.c
@@ -2074,6 +2074,67 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt0[] =
/*******************************************************************************
*
+ * RHCT - RISC-V Hart Capabilities Table
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoRhct[] =
+{
+ {ACPI_DMT_UINT32, ACPI_RHCT_OFFSET (Reserved), "Reserved", 0},
+ {ACPI_DMT_UINT64, ACPI_RHCT_OFFSET (TimeBaseFreq), "Timer Base Frequency", 0},
+ {ACPI_DMT_UINT32, ACPI_RHCT_OFFSET (NodeCount), "Number of nodes", 0},
+ {ACPI_DMT_UINT32, ACPI_RHCT_OFFSET (NodeOffset), "Offset to the node array", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/* Common Subtable header (one per Subtable) */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoRhctNodeHdr[] =
+{
+ {ACPI_DMT_UINT16, ACPI_RHCTH_OFFSET (Type), "Subtable Type", 0},
+ {ACPI_DMT_UINT16, ACPI_RHCTH_OFFSET (Length), "Length", 0},
+ {ACPI_DMT_UINT16, ACPI_RHCTH_OFFSET (Revision), "Revision", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 0: ISA string type */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoRhctIsa1[] =
+{
+ {ACPI_DMT_UINT16, ACPI_RHCT0_OFFSET (IsaLength), "ISA string length", 0},
+ {ACPI_DMT_STRING, ACPI_RHCT0_OFFSET (Isa[0]), "ISA string", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/* Optional padding field */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoRhctIsaPad[] =
+{
+ {ACPI_DMT_RAW_BUFFER, 0, "Optional Padding", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 0xFFFF: Hart Info type */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoRhctHartInfo1[] =
+{
+ {ACPI_DMT_UINT16, ACPI_RHCTFFFF_OFFSET (NumOffsets), "Number of offsets", 0},
+ {ACPI_DMT_UINT32, ACPI_RHCTFFFF_OFFSET (Uid), "Processor UID", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoRhctHartInfo2[] =
+{
+ {ACPI_DMT_UINT32, 0, "Nodes", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/*******************************************************************************
+ *
* S3PT - S3 Performance Table
*
******************************************************************************/
diff --git a/source/compiler/aslallocate.c b/source/compiler/aslallocate.c
index 97b7e2311..d86b5f39b 100644
--- a/source/compiler/aslallocate.c
+++ b/source/compiler/aslallocate.c
@@ -295,9 +295,13 @@ void
UtFreeLineBuffers (
void)
{
-
free (AslGbl_CurrentLineBuffer);
+
free (AslGbl_MainTokenBuffer);
+
free (AslGbl_MacroTokenBuffer);
+
+ free (AslGbl_MacroTokenReplaceBuffer);
+
free (AslGbl_ExpressionTokenBuffer);
}
diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c
index 4faba97ff..e2f72d882 100644
--- a/source/compiler/aslbtypes.c
+++ b/source/compiler/aslbtypes.c
@@ -501,6 +501,7 @@ AnGetBtype (
ACPI_PARSE_OBJECT *ReferencedNode;
UINT32 ThisNodeBtype = 0;
+ ACPI_FUNCTION_NAME (AnGetBtype);
if (!Op)
{
diff --git a/source/compiler/aslparseop.c b/source/compiler/aslparseop.c
index c2f6f3de7..38169fee2 100644
--- a/source/compiler/aslparseop.c
+++ b/source/compiler/aslparseop.c
@@ -817,6 +817,8 @@ TrAllocateOp (
ACPI_PARSE_OBJECT *Op;
ACPI_PARSE_OBJECT *LatestOp;
+ ACPI_FUNCTION_NAME (TrAllocateOp);
+
Op = UtParseOpCacheCalloc ();
diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c
index 41811f5da..f390c4f6c 100644
--- a/source/compiler/asltree.c
+++ b/source/compiler/asltree.c
@@ -467,6 +467,7 @@ TrLinkOpChildren (
UINT32 i;
BOOLEAN FirstChild;
+ ACPI_FUNCTION_NAME (TrLinkOpChildren);
va_start (ap, NumChildren);
diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h
index 30cd7b789..577d3b881 100644
--- a/source/compiler/asltypes.h
+++ b/source/compiler/asltypes.h
@@ -336,7 +336,7 @@ typedef struct asl_file_desc
typedef struct asl_cache_info
{
void *Next;
- char Buffer[1];
+ char Buffer[];
} ASL_CACHE_INFO;
diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h
index 8be3765aa..cddc95191 100644
--- a/source/compiler/dtcompiler.h
+++ b/source/compiler/dtcompiler.h
@@ -706,6 +706,10 @@ DtCompileRgrt (
void **PFieldList);
ACPI_STATUS
+DtCompileRhct (
+ void **PFieldList);
+
+ACPI_STATUS
DtCompileRsdt (
void **PFieldList);
@@ -824,6 +828,7 @@ extern const unsigned char TemplatePptt[];
extern const unsigned char TemplatePrmt[];
extern const unsigned char TemplateRasf[];
extern const unsigned char TemplateRgrt[];
+extern const unsigned char TemplateRhct[];
extern const unsigned char TemplateRsdt[];
extern const unsigned char TemplateS3pt[];
extern const unsigned char TemplateSbst[];
diff --git a/source/compiler/dtexpress.c b/source/compiler/dtexpress.c
index b2664bc4d..7d614729e 100644
--- a/source/compiler/dtexpress.c
+++ b/source/compiler/dtexpress.c
@@ -480,6 +480,7 @@ static void
DtInsertLabelField (
DT_FIELD *Field)
{
+ ACPI_FUNCTION_NAME (DtInsertLabelField);
DbgPrint (ASL_DEBUG_OUTPUT,
"%s: Found Label : %s at output table offset %X\n",
diff --git a/source/compiler/dttable2.c b/source/compiler/dttable2.c
index 0d68cdbca..007b67476 100644
--- a/source/compiler/dttable2.c
+++ b/source/compiler/dttable2.c
@@ -2128,6 +2128,128 @@ DtCompileRgrt (
/******************************************************************************
*
+ * FUNCTION: DtCompileRhct
+ *
+ * PARAMETERS: List - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile RHCT.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileRhct (
+ void **List)
+{
+ ACPI_STATUS Status;
+ ACPI_RHCT_NODE_HEADER *RhctHeader;
+ ACPI_RHCT_HART_INFO *RhctHartInfo = NULL;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ ACPI_DMTABLE_INFO *InfoTable;
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ DT_FIELD *SubtableStart;
+
+
+ /* Compile the main table */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoRhct,
+ &Subtable);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ while (*PFieldList)
+ {
+ SubtableStart = *PFieldList;
+
+ /* Compile RHCT subtable header */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoRhctNodeHdr,
+ &Subtable);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ RhctHeader = ACPI_CAST_PTR (ACPI_RHCT_NODE_HEADER, Subtable->Buffer);
+ RhctHeader->Length = (UINT16)(Subtable->Length);
+
+ switch (RhctHeader->Type)
+ {
+ case ACPI_RHCT_NODE_TYPE_ISA_STRING:
+
+ InfoTable = AcpiDmTableInfoRhctIsa1;
+ break;
+
+ case ACPI_RHCT_NODE_TYPE_HART_INFO:
+
+ InfoTable = AcpiDmTableInfoRhctHartInfo1;
+ break;
+
+ default:
+
+ DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "RHCT");
+ return (AE_ERROR);
+ }
+
+ /* Compile RHCT subtable body */
+
+ Status = DtCompileTable (PFieldList, InfoTable, &Subtable);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ RhctHeader->Length += (UINT16)(Subtable->Length);
+
+ /* Compile RHCT subtable additionals */
+
+ switch (RhctHeader->Type)
+ {
+ case ACPI_RHCT_NODE_TYPE_HART_INFO:
+
+ RhctHartInfo = ACPI_SUB_PTR (ACPI_RHCT_HART_INFO,
+ Subtable->Buffer, sizeof (ACPI_RHCT_NODE_HEADER));
+ if (RhctHartInfo)
+ {
+
+ RhctHartInfo->NumOffsets = 0;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList,
+ AcpiDmTableInfoRhctHartInfo2, &Subtable);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+
+ DtInsertSubtable (ParentTable, Subtable);
+ RhctHeader->Length += (UINT16)(Subtable->Length);
+ RhctHartInfo->NumOffsets++;
+ }
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: DtCompileRsdt
*
* PARAMETERS: List - Current field list pointer
diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h
index e69bb29ba..755da4022 100644
--- a/source/compiler/dttemplate.h
+++ b/source/compiler/dttemplate.h
@@ -1716,6 +1716,26 @@ const unsigned char TemplateRgrt[] =
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27 /* 00000048 " !"#$%&'" */
};
+const unsigned char TemplateRhct[] =
+{
+ 0x52,0x48,0x43,0x54,0x7C,0x00,0x00,0x00, /* 00000000 "RHCT|..." */
+ 0x01,0x7D,0x4F,0x45,0x4D,0x43,0x41,0x00, /* 00000008 "..OEMCA." */
+ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x28,0x09,0x22,0x20,0x00,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x80,0x96,0x98,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */
+ 0x02,0x00,0x00,0x00,0x38,0x00,0x00,0x00, /* 00000030 "....8..." */
+ 0x00,0x00,0x34,0x00,0x01,0x00,0x2B,0x00, /* 00000038 "..4...*." */
+ 0x72,0x76,0x36,0x34,0x69,0x6D,0x61,0x66, /* 00000040 "rv64imaf" */
+ 0x64,0x63,0x68,0x5F,0x7A,0x69,0x63,0x73, /* 00000048 "dch_zics" */
+ 0x72,0x5F,0x7A,0x69,0x66,0x65,0x6E,0x63, /* 00000050 "r_zifenc" */
+ 0x65,0x69,0x5F,0x7A,0x62,0x61,0x5F,0x7A, /* 00000058 "ei_zba_z" */
+ 0x62,0x62,0x5F,0x7A,0x62,0x63,0x5F,0x7A, /* 00000060 "bb_zbc_z" */
+ 0x62,0x73,0x00,0x00,0xFF,0xFF,0x10,0x00, /* 00000068 "bs......" */
+ 0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */
+ 0x38,0x00,0x00,0x00 /* 00000078 "........" */
+};
+
const unsigned char TemplateRsdp[] =
{
0x52,0x53,0x44,0x20,0x50,0x54,0x52,0x20, /* 00000000 "RSD PTR " */
diff --git a/source/compiler/preprocess.h b/source/compiler/preprocess.h
index 3ad4d16d0..818eac263 100644
--- a/source/compiler/preprocess.h
+++ b/source/compiler/preprocess.h
@@ -249,6 +249,7 @@ typedef struct directive_info
*/
PR_EXTERN char PR_INIT_GLOBAL (*AslGbl_MainTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
PR_EXTERN char PR_INIT_GLOBAL (*AslGbl_MacroTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
+PR_EXTERN char PR_INIT_GLOBAL (*AslGbl_MacroTokenReplaceBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
PR_EXTERN char PR_INIT_GLOBAL (*AslGbl_ExpressionTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
PR_EXTERN UINT32 AslGbl_PreprocessorLineNumber;
@@ -370,6 +371,14 @@ PrError (
UINT32 Column);
void
+PrReplaceResizeSubstring(
+ PR_MACRO_ARG *Args,
+ UINT32 Diff1,
+ UINT32 Diff2,
+ UINT32 i,
+ char *Token);
+
+char *
PrReplaceData (
char *Buffer,
UINT32 LengthToRemove,
diff --git a/source/compiler/prmacros.c b/source/compiler/prmacros.c
index 8a1049331..6414867b9 100644
--- a/source/compiler/prmacros.c
+++ b/source/compiler/prmacros.c
@@ -393,10 +393,10 @@ PrAddMacro (
UINT16 UseCount = 0;
UINT16 ArgCount = 0;
UINT32 Depth = 1;
+ /*UINT32 Depth = 1;*/
UINT32 EndOfArgList;
char BufferChar;
-
/* Find the end of the arguments list */
TokenOffset = Name - AslGbl_MainTokenBuffer + strlen (Name) + 1;
@@ -437,6 +437,7 @@ PrAddMacro (
for (i = 0; i < PR_MAX_MACRO_ARGS; i++)
{
Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next);
+
if (!Token)
{
/* This is the case for a NULL macro body */
@@ -454,14 +455,13 @@ PrAddMacro (
}
DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
- "Macro arg: %s \n",
+ "Macro param: %s \n",
AslGbl_CurrentLineNumber, Token);
Args[i].Name = UtLocalCalloc (strlen (Token) + 1);
strcpy (Args[i].Name, Token);
Args[i].UseCount = 0;
-
ArgCount++;
if (ArgCount >= PR_MAX_MACRO_ARGS)
{
@@ -476,7 +476,6 @@ PrAddMacro (
/* Match each method arg in the macro body for later use */
- Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next);
while (Token)
{
/* Search the macro arg list for matching arg */
@@ -496,12 +495,14 @@ PrAddMacro (
Args[i].Offset[UseCount] =
(Token - AslGbl_MainTokenBuffer) - MacroBodyOffset;
+
DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
"Macro Arg #%u: %s UseCount %u Offset %u \n",
AslGbl_CurrentLineNumber, i, Token,
UseCount+1, Args[i].Offset[UseCount]);
Args[i].UseCount++;
+
if (Args[i].UseCount >= PR_MAX_ARG_INSTANCES)
{
PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS,
@@ -596,7 +597,8 @@ PrDoMacroInvocation (
UINT32 TokenOffset;
UINT32 Length;
UINT32 i;
-
+ UINT32 Diff1;
+ UINT32 Diff2;
/* Take a copy of the macro body for expansion */
@@ -610,6 +612,7 @@ PrDoMacroInvocation (
/* This macro has no arguments */
Token = PrGetNextToken (NULL, PR_MACRO_ARGUMENTS, Next);
+
if (!Token)
{
goto BadInvocation;
@@ -634,21 +637,35 @@ PrDoMacroInvocation (
goto BadInvocation;
}
+ /*
+ * Avoid optimizing using just 1 signed int due to specific
+ * non-portable implementations of signed ints
+ */
+ Diff1 = strlen (Args->Name) > strlen (Token) ? strlen (Args->Name) -
+ strlen (Token) : 0;
+
+ Diff2 = strlen (Args->Name) < strlen (Token) ? strlen (Token) -
+ strlen (Args->Name) : 0;
+
/* Replace all instances of this argument */
for (i = 0; i < Args->UseCount; i++)
{
- /* Offset zero indicates "arg not used" */
- /* TBD: Not really needed now, with UseCount available */
+ /*
+ * To test the output of the preprocessed macro function that
+ * is passed to the compiler
+ */
- if (Args->Offset[i] == 0)
- {
- break;
- }
+ /*
+ * fprintf (stderr, "Current token = %s \t Current arg_name = %s \
+ * \t strlen (Token) = %u \t strlen (Args->Name) = %u \t Offset = %u \
+ * \t UseCount = %u \t", Token, Args->Name, strlen (Token), \
+ * strlen (Args->Name), Args->Offset[i], Args->UseCount);
+ */
+
+ AslGbl_MacroTokenReplaceBuffer = (char *) calloc ((strlen (AslGbl_MacroTokenBuffer)), sizeof (char));
- PrReplaceData (
- &AslGbl_MacroTokenBuffer[Args->Offset[i]], strlen (Args->Name),
- Token, strlen (Token));
+ PrReplaceResizeSubstring (Args, Diff1, Diff2, i, Token);
DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
"ExpandArg: %s \n",
@@ -658,8 +675,6 @@ PrDoMacroInvocation (
Args++;
}
- /* TBD: need to make sure macro was not invoked with too many arguments */
-
if (!Token)
{
return;
@@ -676,7 +691,6 @@ PrDoMacroInvocation (
return;
-
BadInvocation:
PrError (ASL_ERROR, ASL_MSG_INVALID_INVOCATION,
THIS_TOKEN_OFFSET (MacroStart));
diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c
index 7ca364e23..d29f4e90d 100644
--- a/source/compiler/prscan.c
+++ b/source/compiler/prscan.c
@@ -780,8 +780,9 @@ PrDoDirective (
TokenOffset = Token - AslGbl_MainTokenBuffer + strlen (Token);
if (*(&AslGbl_CurrentLineBuffer[TokenOffset]) == '(')
{
-#ifndef MACROS_SUPPORTED
- AcpiOsPrintf (
+
+#ifdef MACROS_SUPPORTED
+ AcpiOsPrintf(
"%s ERROR - line %u: #define macros are not supported yet\n",
AslGbl_CurrentLineBuffer, AslGbl_LogicalLineNumber);
exit(1);
@@ -789,6 +790,8 @@ PrDoDirective (
PrAddMacro (Token, Next);
#endif
}
+
+
else
{
/* Use the remainder of the line for the #define */
diff --git a/source/compiler/prutils.c b/source/compiler/prutils.c
index 907ca3ae9..2eb91a6c0 100644
--- a/source/compiler/prutils.c
+++ b/source/compiler/prutils.c
@@ -284,6 +284,238 @@ PrError (
/*******************************************************************************
*
+ * FUNCTION: PrReplaceResizeSubstring
+ *
+ * PARAMETERS: Args - Struct containing name, offset & usecount
+ * Diff1 - Difference in lengths when new < old
+ * Diff2 - Difference in lengths when new > old
+* i - The curr. no. of iteration of replacement
+ * Token - Substring that replaces Args->Name
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Advanced substring replacement in a string using resized buffer.
+ *
+ ******************************************************************************/
+
+void
+PrReplaceResizeSubstring(
+ PR_MACRO_ARG *Args,
+ UINT32 Diff1,
+ UINT32 Diff2,
+ UINT32 i,
+ char *Token)
+{
+ UINT32 b, PrevOffset;
+ char *temp;
+ char macro_sep[64];
+
+
+ AslGbl_MacroTokenReplaceBuffer = (char *) realloc (AslGbl_MacroTokenReplaceBuffer,
+ (2 * (strlen (AslGbl_MacroTokenBuffer))));
+
+ strcpy (macro_sep, "~,() {}!*/%+-<>=&^|\"\t\n");
+
+ /*
+ * When the replacement argument (during invocation) length
+ * < replaced parameter (in the macro function definition
+ * and its expansion) length
+ */
+ if (Diff1 != 0)
+ {
+ /*
+ * We save the offset value to reset it after replacing each
+ * instance of each arg and setting the offset value to
+ * the start of the arg to be replaced since it changes
+ * with each iteration when arg length != token length
+ */
+ PrevOffset = Args->Offset[i];
+ temp = strstr (AslGbl_MacroTokenBuffer, Args->Name);
+
+ResetHere1:
+ temp = strstr (temp, Args->Name);
+ Args->Offset[i] = strlen (AslGbl_MacroTokenBuffer) -
+ strlen (temp);
+ if (Args->Offset[i] == 0)
+ {
+ goto JumpHere1;
+ }
+ if ((strchr (macro_sep, AslGbl_MacroTokenBuffer[(Args->Offset[i] - 1)])) &&
+ (strchr (macro_sep, AslGbl_MacroTokenBuffer[(Args->Offset[i] + strlen (Args->Name))])))
+ {
+ Args->Offset[i] += 0;
+ }
+ else
+ {
+ temp += strlen (Args->Name);
+ goto ResetHere1;
+ }
+
+ /*
+ * For now, we simply set the extra char positions (generated
+ * due to longer name replaced by shorter name) to whitespace
+ * chars so it will be ignored during compilation
+ */
+JumpHere1:
+ b = strlen (Token) + Args->Offset[i];
+ memset (&AslGbl_MacroTokenBuffer[b], ' ', Diff1);
+
+# if 0
+
+ /* Work in progress as of 03/08/2023 - experimental 'if' block
+ * to test code for removing extra whitespaces from the macro
+ * replacement when replacement arg < replaced param
+ */
+ char Buff[8192];
+ /* char* Replace; */
+ /* Replace = Buff; */
+
+ for (j = 0; j < strlen (AslGbl_MacroTokenBuffer); j++)
+ {
+ Buff[j] = AslGbl_MacroTokenBuffer[j];
+ }
+ Buff[strlen (AslGbl_MacroTokenBuffer)] = '\0';
+ //fprintf (stderr, "Buff: %s\n", Buff);
+
+ UINT32 len = strlen (Buff);
+
+ for (j = 0; j < len; j++)
+ {
+ if (Buff[0] == ' ')
+ {
+ for (j = 0; j < (len - 1); j++)
+ {
+ Buff[j] = Buff[j + 1];
+ }
+ Buff[j] = '\0';
+ len--;
+ j = -1;
+ continue;
+ }
+
+ if (Buff[j] == ' ' && Buff[j + 1] == ' ')
+ {
+ for (k = 0; k < (len - 1); k++)
+ {
+ Buff[j] = Buff[j + 1];
+ }
+ Buff[j] = '\0';
+ len--;
+ j--;
+ }
+ }
+ //fprintf(stderr, "Buff: %s\n", Buff);
+
+ for (k = 0; k < strlen (Buff); k++)
+ {
+ AslGbl_MacroTokenBuffer[k] = Buff[k];
+ }
+#endif
+
+ PrReplaceData (
+ &AslGbl_MacroTokenBuffer[Args->Offset[i]],
+ strlen (Token), Token, strlen (Token));
+
+ temp = NULL;
+ Args->Offset[i] = PrevOffset;
+ }
+
+ /*
+ * When the replacement argument (during invocation) length
+ * > replaced parameter (in the macro function definition
+ * and its expansion) length
+ */
+ else if (Diff2 != 0)
+ {
+ /* Doing the same thing with offset value as for prev case */
+
+ PrevOffset = Args->Offset[i];
+ temp = strstr (AslGbl_MacroTokenBuffer, Args->Name);
+
+ResetHere2:
+ temp = strstr (temp, Args->Name);
+ Args->Offset[i] = strlen (AslGbl_MacroTokenBuffer) -
+ strlen (temp);
+ if (Args->Offset[i] == 0)
+ {
+ goto JumpHere2;
+ }
+ if ((strchr (macro_sep, AslGbl_MacroTokenBuffer[(Args->Offset[i] - 1)])) &&
+ (strchr (macro_sep, AslGbl_MacroTokenBuffer[(Args->Offset[i] + strlen (Args->Name))])))
+ {
+ Args->Offset[i] += 0;
+ }
+ else
+ {
+ temp+= strlen (Args->Name);
+ goto ResetHere2;
+ }
+
+ /*
+ * We will need to allocate some extra space in our buffer to
+ * accommodate the increase in the replacement string length
+ * over the shorter outgoing arg string and do the replacement
+ * at the correct offset value which is resetted every iteration
+ */
+JumpHere2:
+ strncpy (AslGbl_MacroTokenReplaceBuffer, AslGbl_MacroTokenBuffer, Args->Offset[i]);
+ strcat (AslGbl_MacroTokenReplaceBuffer, Token);
+ strcat (AslGbl_MacroTokenReplaceBuffer, (AslGbl_MacroTokenBuffer +
+ (Args->Offset[i] + strlen (Args->Name))));
+
+ strcpy (AslGbl_MacroTokenBuffer, AslGbl_MacroTokenReplaceBuffer);
+
+ temp = NULL;
+ Args->Offset[i] = PrevOffset;
+ }
+
+ /*
+ * When the replacement argument (during invocation) length =
+ * replaced parameter (in the macro function definition and
+ * its expansion) length
+ */
+ else
+ {
+
+ /*
+ * We still need to reset the offset for each iteration even when
+ * arg and param lengths are same since any macro func invocation
+ * could use various cases for each separate arg-param pair
+ */
+ PrevOffset = Args->Offset[i];
+ temp = strstr (AslGbl_MacroTokenBuffer, Args->Name);
+
+ResetHere3:
+ temp = strstr (temp, Args->Name);
+ Args->Offset[i] = strlen (AslGbl_MacroTokenBuffer) -
+ strlen (temp);
+ if (Args->Offset[i] == 0)
+ {
+ goto JumpHere3;
+ }
+ if ((strchr (macro_sep, AslGbl_MacroTokenBuffer[(Args->Offset[i] - 1)])) &&
+ (strchr (macro_sep, AslGbl_MacroTokenBuffer[(Args->Offset[i] + strlen (Args->Name))])))
+ {
+ Args->Offset[i] += 0;
+ }
+ else
+ {
+ temp += strlen (Args->Name);
+ goto ResetHere3;
+ }
+
+JumpHere3:
+ PrReplaceData (
+ &AslGbl_MacroTokenBuffer[Args->Offset[i]],
+ strlen (Args->Name), Token, strlen (Token));
+ temp = NULL;
+ Args->Offset[i] = PrevOffset;
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: PrReplaceData
*
* PARAMETERS: Buffer - Original(target) buffer pointer
@@ -291,13 +523,13 @@ PrError (
* BufferToAdd - Data to be inserted into target buffer
* LengthToAdd - Length of BufferToAdd
*
- * RETURN: None
+ * RETURN: Pointer to where the buffer is replaced with data
*
* DESCRIPTION: Generic buffer data replacement.
*
******************************************************************************/
-void
+char *
PrReplaceData (
char *Buffer,
UINT32 LengthToRemove,
@@ -325,12 +557,14 @@ PrReplaceData (
}
}
+
/* Now we can move in the new data */
if (LengthToAdd > 0)
{
memmove (Buffer, BufferToAdd, LengthToAdd);
}
+ return (Buffer + LengthToAdd);
}
diff --git a/source/components/debugger/dbnames.c b/source/components/debugger/dbnames.c
index ae4a10ca5..084a25287 100644
--- a/source/components/debugger/dbnames.c
+++ b/source/components/debugger/dbnames.c
@@ -883,6 +883,9 @@ AcpiDbDisplayObjects (
if (!ObjTypeArg)
{
ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO));
+
+ if (!ObjectInfo)
+ return (AE_NO_MEMORY);
/* Walk the namespace from the root */
diff --git a/source/components/resources/rsaddr.c b/source/components/resources/rsaddr.c
index 08cea5c49..46f38bc7b 100644
--- a/source/components/resources/rsaddr.c
+++ b/source/components/resources/rsaddr.c
@@ -433,11 +433,15 @@ AcpiRsGetAddressCommon (
{
ACPI_FUNCTION_ENTRY ();
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_ADDRESS Address;
+ memcpy(&Address, Aml, sizeof(Address));
/* Validate the Resource Type */
- if ((Aml->Address.ResourceType > 2) &&
- (Aml->Address.ResourceType < 0xC0))
+ if ((Address.ResourceType > 2) &&
+ (Address.ResourceType < 0xC0))
{
return (FALSE);
}
@@ -464,7 +468,7 @@ AcpiRsGetAddressCommon (
/* Generic resource type, just grab the TypeSpecific byte */
Resource->Data.Address.Info.TypeSpecific =
- Aml->Address.SpecificFlags;
+ Address.SpecificFlags;
}
return (TRUE);
diff --git a/source/components/resources/rscalc.c b/source/components/resources/rscalc.c
index 623364b10..55694f1ec 100644
--- a/source/components/resources/rscalc.c
+++ b/source/components/resources/rscalc.c
@@ -740,14 +740,19 @@ AcpiRsGetListLength (
}
break;
- case ACPI_RESOURCE_NAME_SERIAL_BUS:
+ case ACPI_RESOURCE_NAME_SERIAL_BUS: {
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
MinimumAmlResourceLength = AcpiGbl_ResourceAmlSerialBusSizes[
- AmlResource->CommonSerialBus.Type];
+ CommonSerialBus.Type];
ExtraStructBytes +=
- AmlResource->CommonSerialBus.ResourceLength -
+ CommonSerialBus.ResourceLength -
MinimumAmlResourceLength;
break;
+ }
case ACPI_RESOURCE_NAME_PIN_CONFIG:
@@ -816,8 +821,13 @@ AcpiRsGetListLength (
if (AcpiUtGetResourceType (AmlBuffer) ==
ACPI_RESOURCE_NAME_SERIAL_BUS)
{
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
+
BufferSize = AcpiGbl_ResourceStructSerialBusSizes[
- AmlResource->CommonSerialBus.Type] + ExtraStructBytes;
+ CommonSerialBus.Type] + ExtraStructBytes;
}
else
{
diff --git a/source/components/resources/rslist.c b/source/components/resources/rslist.c
index bce499170..cb408197e 100644
--- a/source/components/resources/rslist.c
+++ b/source/components/resources/rslist.c
@@ -209,7 +209,12 @@ AcpiRsConvertAmlToResources (
if (AcpiUtGetResourceType (Aml) ==
ACPI_RESOURCE_NAME_SERIAL_BUS)
{
- if (AmlResource->CommonSerialBus.Type >
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
+
+ if (CommonSerialBus.Type >
AML_RESOURCE_MAX_SERIALBUSTYPE)
{
ConversionTable = NULL;
@@ -219,7 +224,7 @@ AcpiRsConvertAmlToResources (
/* This is an I2C, SPI, UART, or CSI2 SerialBus descriptor */
ConversionTable = AcpiGbl_ConvertResourceSerialBusDispatch [
- AmlResource->CommonSerialBus.Type];
+ CommonSerialBus.Type];
}
}
else
diff --git a/source/components/resources/rsmisc.c b/source/components/resources/rsmisc.c
index 52358421c..6d11442d9 100644
--- a/source/components/resources/rsmisc.c
+++ b/source/components/resources/rsmisc.c
@@ -349,7 +349,8 @@ AcpiRsConvertAmlToResource (
case ACPI_RSC_COUNT_SERIAL_VEN:
- ItemCount = ACPI_GET16 (Source) - Info->Value;
+ ACPI_MOVE_16_TO_16(&Temp16, Source);
+ ItemCount = Temp16 - Info->Value;
Resource->Length = Resource->Length + ItemCount;
ACPI_SET16 (Destination, ItemCount);
@@ -357,9 +358,10 @@ AcpiRsConvertAmlToResource (
case ACPI_RSC_COUNT_SERIAL_RES:
+ ACPI_MOVE_16_TO_16(&Temp16, Source);
ItemCount = (AmlResourceLength +
sizeof (AML_RESOURCE_LARGE_HEADER)) -
- ACPI_GET16 (Source) - Info->Value;
+ Temp16 - Info->Value;
Resource->Length = Resource->Length + ItemCount;
ACPI_SET16 (Destination, ItemCount);
@@ -437,8 +439,9 @@ AcpiRsConvertAmlToResource (
/* Copy the ResourceSource string */
+ ACPI_MOVE_16_TO_16 (&Temp16, Source);
Source = ACPI_ADD_PTR (
- void, Aml, (ACPI_GET16 (Source) + Info->Value));
+ void, Aml, (Temp16 + Info->Value));
AcpiRsMoveData (Target, Source, ItemCount, Info->Opcode);
break;
diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c
index 7898e9929..f47b29246 100644
--- a/source/components/utilities/utresrc.c
+++ b/source/components/utilities/utresrc.c
@@ -532,16 +532,21 @@ AcpiUtValidateResource (
AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
{
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
+
/* Validate the BusType field */
- if ((AmlResource->CommonSerialBus.Type == 0) ||
- (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
+ if ((CommonSerialBus.Type == 0) ||
+ (CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
{
if (WalkState)
{
ACPI_ERROR ((AE_INFO,
"Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
- AmlResource->CommonSerialBus.Type));
+ CommonSerialBus.Type));
}
return (AE_AML_INVALID_RESOURCE_TYPE);
}
diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h
index 8ec4885b3..afc9034b8 100644
--- a/source/include/acdisasm.h
+++ b/source/include/acdisasm.h
@@ -296,6 +296,7 @@ typedef enum
ACPI_DMT_PMTT_VENDOR,
ACPI_DMT_PPTT,
ACPI_DMT_RGRT,
+ ACPI_DMT_RHCT,
ACPI_DMT_SDEI,
ACPI_DMT_SDEV,
ACPI_DMT_SLIC,
@@ -641,6 +642,12 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoPrmtHandler[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRasf[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRgrt0[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoRhct[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoRhctNodeHdr[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoRhctIsa1[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoRhctIsaPad[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoRhctHartInfo1[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoRhctHartInfo2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoS3pt[];
@@ -908,6 +915,10 @@ void
AcpiDmDumpRgrt (
ACPI_TABLE_HEADER *Table);
+void
+AcpiDmDumpRhct (
+ ACPI_TABLE_HEADER *Table);
+
UINT32
AcpiDmDumpRsdp (
ACPI_TABLE_HEADER *Table);
diff --git a/source/include/acrestyp.h b/source/include/acrestyp.h
index 10e8ff89f..0dab6ec7b 100644
--- a/source/include/acrestyp.h
+++ b/source/include/acrestyp.h
@@ -290,7 +290,10 @@ typedef struct acpi_resource_irq
UINT8 Shareable;
UINT8 WakeCapable;
UINT8 InterruptCount;
- UINT8 Interrupts[1];
+ union {
+ UINT8 Interrupt;
+ ACPI_FLEX_ARRAY(UINT8, Interrupts);
+ };
} ACPI_RESOURCE_IRQ;
@@ -300,7 +303,10 @@ typedef struct acpi_resource_dma
UINT8 BusMaster;
UINT8 Transfer;
UINT8 ChannelCount;
- UINT8 Channels[1];
+ union {
+ UINT8 Channel;
+ ACPI_FLEX_ARRAY(UINT8, Channels);
+ };
} ACPI_RESOURCE_DMA;
@@ -357,7 +363,7 @@ typedef struct acpi_resource_fixed_dma
typedef struct acpi_resource_vendor
{
UINT16 ByteLength;
- UINT8 ByteData[1];
+ UINT8 ByteData[];
} ACPI_RESOURCE_VENDOR;
@@ -368,7 +374,7 @@ typedef struct acpi_resource_vendor_typed
UINT16 ByteLength;
UINT8 UuidSubtype;
UINT8 Uuid[ACPI_UUID_LENGTH];
- UINT8 ByteData[1];
+ UINT8 ByteData[];
} ACPI_RESOURCE_VENDOR_TYPED;
@@ -538,7 +544,10 @@ typedef struct acpi_resource_extended_irq
UINT8 WakeCapable;
UINT8 InterruptCount;
ACPI_RESOURCE_SOURCE ResourceSource;
- UINT32 Interrupts[1];
+ union {
+ UINT32 Interrupt;
+ ACPI_FLEX_ARRAY(UINT32, Interrupts);
+ };
} ACPI_RESOURCE_EXTENDED_IRQ;
@@ -939,8 +948,10 @@ typedef struct acpi_pci_routing_table
UINT32 Pin;
UINT64 Address; /* here for 64-bit alignment */
UINT32 SourceIndex;
- char Source[4]; /* pad to 64 bits so sizeof() works in all cases */
-
+ union {
+ char Pad[4]; /* pad to 64 bits so sizeof() works in all cases */
+ ACPI_FLEX_ARRAY(char, Source);
+ };
} ACPI_PCI_ROUTING_TABLE;
#endif /* __ACRESTYP_H__ */
diff --git a/source/include/actbinfo.h b/source/include/actbinfo.h
index 5900c7b6c..5417aff4a 100644
--- a/source/include/actbinfo.h
+++ b/source/include/actbinfo.h
@@ -189,6 +189,7 @@
#define ACPI_PMTT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_PMTT,f)
#define ACPI_RASF_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_RASF,f)
#define ACPI_RGRT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_RGRT,f)
+#define ACPI_RHCT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_RHCT,f)
#define ACPI_S3PT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_S3PT,f)
#define ACPI_SBST_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SBST,f)
#define ACPI_SDEI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SDEI,f)
@@ -400,6 +401,9 @@
#define ACPI_PRMTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_PRMT_HEADER,f)
#define ACPI_PRMT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PRMT_MODULE_INFO,f)
#define ACPI_PRMT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PRMT_HANDLER_INFO,f)
+#define ACPI_RHCTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_RHCT_NODE_HEADER,f)
+#define ACPI_RHCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_RHCT_ISA_STRING,f)
+#define ACPI_RHCTFFFF_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_RHCT_HART_INFO,f)
#define ACPI_S3PTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f)
#define ACPI_S3PT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_RESUME,f)
#define ACPI_S3PT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_S3PT_SUSPEND,f)
diff --git a/source/include/actbl1.h b/source/include/actbl1.h
index 2e400b526..cecd7edbe 100644
--- a/source/include/actbl1.h
+++ b/source/include/actbl1.h
@@ -1219,7 +1219,10 @@ typedef struct acpi_dmar_andd
ACPI_DMAR_HEADER Header;
UINT8 Reserved[3];
UINT8 DeviceNumber;
- char DeviceName[1];
+ union {
+ char __pad;
+ ACPI_FLEX_ARRAY(char, DeviceName);
+ };
} ACPI_DMAR_ANDD;
@@ -1272,7 +1275,7 @@ typedef struct acpi_table_drtm
typedef struct acpi_drtm_vtable_list
{
UINT32 ValidatedTableCount;
- UINT64 ValidatedTables[1];
+ UINT64 ValidatedTables[];
} ACPI_DRTM_VTABLE_LIST;
@@ -1291,7 +1294,7 @@ typedef struct acpi_drtm_resource
typedef struct acpi_drtm_resource_list
{
UINT32 ResourceCount;
- ACPI_DRTM_RESOURCE Resources[1];
+ ACPI_DRTM_RESOURCE Resources[];
} ACPI_DRTM_RESOURCE_LIST;
@@ -1319,7 +1322,7 @@ typedef struct acpi_table_ecdt
ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */
UINT32 Uid; /* Unique ID - must be same as the EC _UID method */
UINT8 Gpe; /* The GPE for the EC */
- UINT8 Id[1]; /* Full namepath of the EC in the ACPI namespace */
+ UINT8 Id[]; /* Full namepath of the EC in the ACPI namespace */
} ACPI_TABLE_ECDT;
diff --git a/source/include/actbl2.h b/source/include/actbl2.h
index 6dc2efd0c..9b2812a0f 100644
--- a/source/include/actbl2.h
+++ b/source/include/actbl2.h
@@ -192,6 +192,7 @@
#define ACPI_SIG_PRMT "PRMT" /* Platform Runtime Mechanism Table */
#define ACPI_SIG_RASF "RASF" /* RAS Feature table */
#define ACPI_SIG_RGRT "RGRT" /* Regulatory Graphics Resource Table */
+#define ACPI_SIG_RHCT "RHCT" /* RISC-V Hart Capabilities Table */
#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */
#define ACPI_SIG_SDEI "SDEI" /* Software Delegated Exception Interface Table */
#define ACPI_SIG_SDEV "SDEV" /* Secure Devices table */
@@ -230,7 +231,6 @@
typedef struct acpi_table_aest
{
ACPI_TABLE_HEADER Header;
- void *NodeArray[];
} ACPI_TABLE_AEST;
@@ -572,7 +572,7 @@ typedef struct acpi_iort_node
UINT32 Identifier;
UINT32 MappingCount;
UINT32 MappingOffset;
- char NodeData[1];
+ char NodeData[];
} ACPI_IORT_NODE;
@@ -638,7 +638,7 @@ typedef struct acpi_iort_memory_access
typedef struct acpi_iort_its_group
{
UINT32 ItsCount;
- UINT32 Identifiers[1]; /* GIC ITS identifier array */
+ UINT32 Identifiers[]; /* GIC ITS identifier array */
} ACPI_IORT_ITS_GROUP;
@@ -648,7 +648,7 @@ typedef struct acpi_iort_named_component
UINT32 NodeFlags;
UINT64 MemoryProperties; /* Memory access properties */
UINT8 MemoryAddressLimit; /* Memory address size limit */
- char DeviceName[1]; /* Path of namespace object */
+ char DeviceName[]; /* Path of namespace object */
} ACPI_IORT_NAMED_COMPONENT;
@@ -664,7 +664,7 @@ typedef struct acpi_iort_root_complex
UINT32 PciSegmentNumber;
UINT8 MemoryAddressLimit; /* Memory address size limit */
UINT16 PasidCapabilities; /* PASID Capabilities */
- UINT8 Reserved[1]; /* Reserved, must be zero */
+ UINT8 Reserved[]; /* Reserved, must be zero */
} ACPI_IORT_ROOT_COMPLEX;
@@ -688,7 +688,7 @@ typedef struct acpi_iort_smmu
UINT32 ContextInterruptOffset;
UINT32 PmuInterruptCount;
UINT32 PmuInterruptOffset;
- UINT64 Interrupts[1]; /* Interrupt array */
+ UINT64 Interrupts[]; /* Interrupt array */
} ACPI_IORT_SMMU;
@@ -1135,7 +1135,8 @@ enum AcpiMadtType
ACPI_MADT_TYPE_MSI_PIC = 21,
ACPI_MADT_TYPE_BIO_PIC = 22,
ACPI_MADT_TYPE_LPC_PIC = 23,
- ACPI_MADT_TYPE_RESERVED = 24, /* 24 to 0x7F are reserved */
+ ACPI_MADT_TYPE_RINTC = 24,
+ ACPI_MADT_TYPE_RESERVED = 25, /* 25 to 0x7F are reserved */
ACPI_MADT_TYPE_OEM_RESERVED = 0x80 /* 0x80 to 0xFF are reserved for OEM use */
};
@@ -1240,7 +1241,7 @@ typedef struct acpi_madt_local_sapic
UINT8 Reserved[3]; /* Reserved, must be zero */
UINT32 LapicFlags;
UINT32 Uid; /* Numeric UID - ACPI 3.0 */
- char UidString[1]; /* String UID - ACPI 3.0 */
+ char UidString[]; /* String UID - ACPI 3.0 */
} ACPI_MADT_LOCAL_SAPIC;
@@ -1548,11 +1549,29 @@ enum AcpiMadtLpcPicVersion {
ACPI_MADT_LPC_PIC_VERSION_RESERVED = 2 /* 2 and greater are reserved */
};
+/* 24: RISC-V INTC */
+struct acpi_madt_rintc {
+ ACPI_SUBTABLE_HEADER Header;
+ UINT8 Version;
+ UINT8 Reserved;
+ UINT32 Flags;
+ UINT64 HartId;
+ UINT32 Uid; /* ACPI processor UID */
+};
+
+/* Values for RISC-V INTC Version field above */
+
+enum AcpiMadtRintcVersion {
+ ACPI_MADT_RINTC_VERSION_NONE = 0,
+ ACPI_MADT_RINTC_VERSION_V1 = 1,
+ ACPI_MADT_RINTC_VERSION_RESERVED = 2 /* 2 and greater are reserved */
+};
+
/* 80: OEM data */
typedef struct acpi_madt_oem_data
{
- UINT8 OemData[0];
+ ACPI_FLEX_ARRAY(UINT8, OemData);
} ACPI_MADT_OEM_DATA;
@@ -2045,7 +2064,7 @@ typedef struct acpi_nfit_interleave
UINT16 Reserved; /* Reserved, must be zero */
UINT32 LineCount;
UINT32 LineSize;
- UINT32 LineOffset[1]; /* Variable length */
+ UINT32 LineOffset[]; /* Variable length */
} ACPI_NFIT_INTERLEAVE;
@@ -2056,7 +2075,7 @@ typedef struct acpi_nfit_smbios
{
ACPI_NFIT_HEADER Header;
UINT32 Reserved; /* Reserved, must be zero */
- UINT8 Data[1]; /* Variable length */
+ UINT8 Data[]; /* Variable length */
} ACPI_NFIT_SMBIOS;
@@ -2122,7 +2141,7 @@ typedef struct acpi_nfit_flush_address
UINT32 DeviceHandle;
UINT16 HintCount;
UINT8 Reserved[6]; /* Reserved, must be zero */
- UINT64 HintAddress[1]; /* Variable length */
+ UINT64 HintAddress[]; /* Variable length */
} ACPI_NFIT_FLUSH_ADDRESS;
@@ -3259,6 +3278,53 @@ enum AcpiRgrtImageType
/*******************************************************************************
*
+ * RHCT - RISC-V Hart Capabilities Table
+ * Version 1
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_rhct {
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT32 Reserved;
+ UINT64 TimeBaseFreq;
+ UINT32 NodeCount;
+ UINT32 NodeOffset;
+} ACPI_TABLE_RHCT;
+
+/*
+ * RHCT subtables
+ */
+typedef struct acpi_rhct_node_header {
+ UINT16 Type;
+ UINT16 Length;
+ UINT16 Revision;
+} ACPI_RHCT_NODE_HEADER;
+
+/* Values for RHCT subtable Type above */
+
+enum acpi_rhct_node_type {
+ ACPI_RHCT_NODE_TYPE_ISA_STRING = 0x0000,
+ ACPI_RHCT_NODE_TYPE_HART_INFO = 0xFFFF,
+};
+
+/*
+ * RHCT node specific subtables
+ */
+
+/* ISA string node structure */
+typedef struct acpi_rhct_isa_string {
+ UINT16 IsaLength;
+ char Isa[];
+} ACPI_RHCT_ISA_STRING;
+
+/* Hart Info node structure */
+typedef struct acpi_rhct_hart_info {
+ UINT16 NumOffsets;
+ UINT32 Uid; /* ACPI processor UID */
+} ACPI_RHCT_HART_INFO;
+
+/*******************************************************************************
+ *
* SBST - Smart Battery Specification Table
* Version 1
*
diff --git a/source/include/actypes.h b/source/include/actypes.h
index 52d2d6dcf..c0f0a87f4 100644
--- a/source/include/actypes.h
+++ b/source/include/actypes.h
@@ -1574,4 +1574,8 @@ typedef enum
#define ACPI_FALLTHROUGH do {} while(0)
#endif
+#ifndef ACPI_FLEX_ARRAY
+#define ACPI_FLEX_ARRAY(TYPE, NAME) TYPE NAME[0]
+#endif
+
#endif /* __ACTYPES_H__ */
diff --git a/source/include/amlresrc.h b/source/include/amlresrc.h
index 1ad70d171..05fa1505d 100644
--- a/source/include/amlresrc.h
+++ b/source/include/amlresrc.h
@@ -503,7 +503,10 @@ typedef struct aml_resource_extended_irq
AML_RESOURCE_LARGE_HEADER_COMMON
UINT8 Flags;
UINT8 InterruptCount;
- UINT32 Interrupts[1];
+ union {
+ UINT32 Interrupt;
+ ACPI_FLEX_ARRAY(UINT32, Interrupts);
+ };
/* ResSourceIndex, ResSource optional fields follow */
} AML_RESOURCE_EXTENDED_IRQ;
diff --git a/source/include/platform/acefiex.h b/source/include/platform/acefiex.h
index dce3518be..8df422b44 100644
--- a/source/include/platform/acefiex.h
+++ b/source/include/platform/acefiex.h
@@ -508,7 +508,7 @@ typedef struct {
ACPI_EFI_TIME LastAccessTime;
ACPI_EFI_TIME ModificationTime;
UINT64 Attribute;
- CHAR16 FileName[1];
+ CHAR16 FileName[];
} ACPI_EFI_FILE_INFO;
#define SIZE_OF_ACPI_EFI_FILE_INFO ACPI_OFFSET(ACPI_EFI_FILE_INFO, FileName)
diff --git a/source/include/platform/acgcc.h b/source/include/platform/acgcc.h
index 81e29f90d..55a66c6da 100644
--- a/source/include/platform/acgcc.h
+++ b/source/include/platform/acgcc.h
@@ -211,4 +211,15 @@ typedef __builtin_va_list va_list;
#define ACPI_FALLTHROUGH __attribute__((__fallthrough__))
#endif
+/*
+ * Flexible array members are not allowed to be part of a union under
+ * C99, but this is not for any technical reason. Work around the
+ * limitation.
+ */
+#define ACPI_FLEX_ARRAY(TYPE, NAME) \
+ struct { \
+ struct { } __Empty_ ## NAME; \
+ TYPE NAME[]; \
+ }
+
#endif /* __ACGCC_H__ */