diff options
| author | Jung-uk Kim <jkim@FreeBSD.org> | 2024-01-30 21:43:45 +0000 |
|---|---|---|
| committer | Jung-uk Kim <jkim@FreeBSD.org> | 2024-01-30 21:43:45 +0000 |
| commit | 8e013e1e3b81740266738226667431cf5c28b17a (patch) | |
| tree | 9606f61233a55a4b82a0d4cc5b48e49eb8692bcc /source/compiler | |
| parent | a799bdd9d50e84cd6a36e8f1d2ac4301b2a6b374 (diff) | |
Diffstat (limited to 'source/compiler')
100 files changed, 1040 insertions, 159 deletions
diff --git a/source/compiler/aslallocate.c b/source/compiler/aslallocate.c index d697d059e6d1..d86b5f39b961 100644 --- a/source/compiler/aslallocate.c +++ b/source/compiler/aslallocate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -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/aslanalyze.c b/source/compiler/aslanalyze.c index 9db7d4fbe81a..1941a4655523 100644 --- a/source/compiler/aslanalyze.c +++ b/source/compiler/aslanalyze.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslascii.c b/source/compiler/aslascii.c index 6c0e62c41177..b6b272710fd8 100644 --- a/source/compiler/aslascii.c +++ b/source/compiler/aslascii.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslbtypes.c b/source/compiler/aslbtypes.c index f7b3fb1bec75..e2f72d882415 100644 --- a/source/compiler/aslbtypes.c +++ b/source/compiler/aslbtypes.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -501,10 +501,11 @@ AnGetBtype ( ACPI_PARSE_OBJECT *ReferencedNode; UINT32 ThisNodeBtype = 0; + ACPI_FUNCTION_NAME (AnGetBtype); if (!Op) { - AcpiOsPrintf ("Null Op in AnGetBtype\n"); + AcpiOsPrintf ("Null Op in %s\n", ACPI_GET_FUNCTION_NAME); return (ACPI_UINT32_MAX); } diff --git a/source/compiler/aslcache.c b/source/compiler/aslcache.c index 9cc707e207d3..11ba5f42a46e 100644 --- a/source/compiler/aslcache.c +++ b/source/compiler/aslcache.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c index a0c67424d250..4013398fa834 100644 --- a/source/compiler/aslcodegen.c +++ b/source/compiler/aslcodegen.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index f97cd9d82097..4217182c65df 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index d52f60f2180b..ca20de452efc 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -1566,6 +1566,9 @@ ASL_RESOURCE_NODE * RsDoPinGroupConfigDescriptor ( ASL_RESOURCE_INFO *Info); +ASL_RESOURCE_NODE * +RsDoClockInputDescriptor ( + ASL_RESOURCE_INFO *Info); /* * aslrestype2d - DWord address descriptors diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l index 881096ad5bbf..fbc38a613c39 100644 --- a/source/compiler/aslcompiler.l +++ b/source/compiler/aslcompiler.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -461,6 +461,7 @@ NamePathTail [.]{NameSeg} "PinGroup" { count (1); return (PARSEOP_PINGROUP); } "PinGroupConfig" { count (1); return (PARSEOP_PINGROUPCONFIG); } "PinGroupFunction" { count (1); return (PARSEOP_PINGROUPFUNCTION); } +"ClockInput" { count (1); return (PARSEOP_CLOCKINPUT); } "QWordIO" { count (1); return (PARSEOP_QWORDIO); } "QWordMemory" { count (1); return (PARSEOP_QWORDMEMORY); } "QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); } @@ -665,6 +666,17 @@ NamePathTail [.]{NameSeg} "PullDown" { count (0); return (PARSEOP_PIN_PULLDOWN); } "PullNone" { count (0); return (PARSEOP_PIN_NOPULL); } + /* ClockScaleKeyword: Resource Descriptors (ACPI 6.5) */ + +"Hz" { count (0); return (PARSEOP_CLOCK_HZ); } +"KHz" { count (0); return (PARSEOP_CLOCK_KHZ); } +"MHz" { count (0); return (PARSEOP_CLOCK_MHZ); } + + /* ClockModeKeyword: Resource Descriptors (ACPI 6.5) */ + +"Fixed" { count (0); return (PARSEOP_CLOCK_FIXED); } +"Variable" { count (0); return (PARSEOP_CLOCK_VARIABLE); } + /* PolarityKeyword: Resource Descriptors (ACPI 5.0) */ "PolarityLow" { count (0); return (PARSEOP_DEVICEPOLARITY_LOW); } diff --git a/source/compiler/aslcstyle.y b/source/compiler/aslcstyle.y index b4e9065fee0f..d249b51e8ea9 100644 --- a/source/compiler/aslcstyle.y +++ b/source/compiler/aslcstyle.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asldebug.c b/source/compiler/asldebug.c index 5ac6a4ed6059..928bb206ddb3 100644 --- a/source/compiler/asldebug.c +++ b/source/compiler/asldebug.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 12b2899e4062..fe11d45177a1 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index 3a61bc6e5e8d..54d247e297a2 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslexternal.c b/source/compiler/aslexternal.c index a7d2c9c3d36d..243145ed4ee3 100644 --- a/source/compiler/aslexternal.c +++ b/source/compiler/aslexternal.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslfileio.c b/source/compiler/aslfileio.c index 88b9def907f2..7920de7f1765 100644 --- a/source/compiler/aslfileio.c +++ b/source/compiler/aslfileio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 2479b404ee41..51de2d1e22c8 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index 316890c4ac06..f03d19c518ff 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index ff00b92ef1ea..438d0c5bcb25 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslhelp.c b/source/compiler/aslhelp.c index 1cdbf8a76fc2..137736da7db1 100644 --- a/source/compiler/aslhelp.c +++ b/source/compiler/aslhelp.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslhelpers.y b/source/compiler/aslhelpers.y index 2764bf65b9f7..37cc5844cfab 100644 --- a/source/compiler/aslhelpers.y +++ b/source/compiler/aslhelpers.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslhex.c b/source/compiler/aslhex.c index a6e80fdf57ac..4a711823077c 100644 --- a/source/compiler/aslhex.c +++ b/source/compiler/aslhex.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslkeywords.y b/source/compiler/aslkeywords.y index 661cfc9397b0..d559fd0f43ec 100644 --- a/source/compiler/aslkeywords.y +++ b/source/compiler/aslkeywords.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -462,3 +462,14 @@ XferTypeKeyword | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_8_16);} | PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_16);} ; + +ClockScaleKeyword + : PARSEOP_CLOCK_HZ {$$ = TrCreateLeafOp (PARSEOP_CLOCK_HZ);} + | PARSEOP_CLOCK_KHZ {$$ = TrCreateLeafOp (PARSEOP_CLOCK_KHZ);} + | PARSEOP_CLOCK_MHZ {$$ = TrCreateLeafOp (PARSEOP_CLOCK_MHZ);} + ; + +ClockModeKeyword + : PARSEOP_CLOCK_FIXED {$$ = TrCreateLeafOp (PARSEOP_CLOCK_FIXED);} + | PARSEOP_CLOCK_VARIABLE {$$ = TrCreateLeafOp (PARSEOP_CLOCK_VARIABLE);} + ; diff --git a/source/compiler/asllength.c b/source/compiler/asllength.c index b1c06246411c..f55443537855 100644 --- a/source/compiler/asllength.c +++ b/source/compiler/asllength.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index 290d506210e5..1dd3b39bd24e 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asllistsup.c b/source/compiler/asllistsup.c index b03560d3612a..44a87f0a1726 100644 --- a/source/compiler/asllistsup.c +++ b/source/compiler/asllistsup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslload.c b/source/compiler/aslload.c index 3f827d0ba4d5..3e35d6aa732d 100644 --- a/source/compiler/aslload.c +++ b/source/compiler/aslload.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asllookup.c b/source/compiler/asllookup.c index 44bf9a38667a..ae0729bb50b7 100644 --- a/source/compiler/asllookup.c +++ b/source/compiler/asllookup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 3c2ce58ea0b2..5b8f54e2b9eb 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmap.c b/source/compiler/aslmap.c index 782d0d96cfb4..71fb5f034d13 100644 --- a/source/compiler/aslmap.c +++ b/source/compiler/aslmap.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -462,6 +462,12 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* PIN_PULLDEFAULT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* PIN_PULLDOWN */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0), /* PIN_PULLUP */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), +/* CLOCKINPUT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* CLOCK_HZ */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* CLOCK_KHZ */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), +/* CLOCK_MHZ */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0), +/* CLOCK_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* CLOCK_VARIABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* POWERRESOURCE */ OP_TABLE_ENTRY (AML_POWER_RESOURCE_OP, 0, OP_AML_PACKAGE, 0), /* PROCESSOR */ OP_TABLE_ENTRY (AML_PROCESSOR_OP, 0, OP_AML_PACKAGE, 0), /* QWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER), diff --git a/source/compiler/aslmapenter.c b/source/compiler/aslmapenter.c index 5dae3e9ea86b..b167fb4e96a9 100644 --- a/source/compiler/aslmapenter.c +++ b/source/compiler/aslmapenter.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmapoutput.c b/source/compiler/aslmapoutput.c index 95146ea65fbb..74540f05d846 100644 --- a/source/compiler/aslmapoutput.c +++ b/source/compiler/aslmapoutput.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmaputils.c b/source/compiler/aslmaputils.c index 0b2c7e2615e9..48b67600302b 100644 --- a/source/compiler/aslmaputils.c +++ b/source/compiler/aslmaputils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmessages.c b/source/compiler/aslmessages.c index 990e376f76bd..fe697c854dae 100644 --- a/source/compiler/aslmessages.c +++ b/source/compiler/aslmessages.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 197e9e2276c0..3346c5e0168c 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslmethod.c b/source/compiler/aslmethod.c index 517ba778cd8e..f092a296a45c 100644 --- a/source/compiler/aslmethod.c +++ b/source/compiler/aslmethod.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslnamesp.c b/source/compiler/aslnamesp.c index 60c488db05a0..a3578d3e8cfc 100644 --- a/source/compiler/aslnamesp.c +++ b/source/compiler/aslnamesp.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asloffset.c b/source/compiler/asloffset.c index b0954c70105c..874e6e59d695 100644 --- a/source/compiler/asloffset.c +++ b/source/compiler/asloffset.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index e07910b1f5f6..f6c993e6db1d 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 9330fdfb4244..2c3c6fa96b43 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index 916aebfba1cd..c81e27b2ad87 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 37484f79bdac..ca894a3b70f0 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslparseop.c b/source/compiler/aslparseop.c index ab81ac286e7d..38169fee244f 100644 --- a/source/compiler/aslparseop.c +++ b/source/compiler/aslparseop.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -817,6 +817,8 @@ TrAllocateOp ( ACPI_PARSE_OBJECT *Op; ACPI_PARSE_OBJECT *LatestOp; + ACPI_FUNCTION_NAME (TrAllocateOp); + Op = UtParseOpCacheCalloc (); @@ -861,7 +863,7 @@ TrAllocateOp ( } AslGbl_CommentState.LatestParseOp = Op; - CvDbgPrint ("TrAllocateOp=Set latest parse op to this op.\n"); + CvDbgPrint ("%s=Set latest parse op to this op.\n", ACPI_GET_FUNCTION_NAME); CvDbgPrint (" Op->Asl.ParseOpName = %s\n", AslGbl_CommentState.LatestParseOp->Asl.ParseOpName); CvDbgPrint (" Op->Asl.ParseOpcode = 0x%x\n", ParseOpcode); diff --git a/source/compiler/aslparser.y b/source/compiler/aslparser.y index dff15619283b..3e1c661f4e41 100644 --- a/source/compiler/aslparser.y +++ b/source/compiler/aslparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -208,7 +208,7 @@ AslLocalAllocate ( * These shift/reduce conflicts are expected. There should be zero * reduce/reduce conflicts. */ -%expect 127 +%expect 128 /*! [Begin] no source code translation */ diff --git a/source/compiler/aslpld.c b/source/compiler/aslpld.c index 9faa8c263d6f..eedfaa24695b 100644 --- a/source/compiler/aslpld.c +++ b/source/compiler/aslpld.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslpredef.c b/source/compiler/aslpredef.c index 2804e12da535..925329978df1 100644 --- a/source/compiler/aslpredef.c +++ b/source/compiler/aslpredef.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslprepkg.c b/source/compiler/aslprepkg.c index f562dbe6b820..21fe2db7a08a 100644 --- a/source/compiler/aslprepkg.c +++ b/source/compiler/aslprepkg.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslprimaries.y b/source/compiler/aslprimaries.y index 69565defe405..f70597163578 100644 --- a/source/compiler/aslprimaries.y +++ b/source/compiler/aslprimaries.y @@ -11,7 +11,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslprintf.c b/source/compiler/aslprintf.c index 3f270fec9da8..b2da0035f0e6 100644 --- a/source/compiler/aslprintf.c +++ b/source/compiler/aslprintf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslprune.c b/source/compiler/aslprune.c index 4626a1eef08d..dc1162c45aeb 100644 --- a/source/compiler/aslprune.c +++ b/source/compiler/aslprune.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslresource.c b/source/compiler/aslresource.c index 104a48357372..4d20c5e31d1c 100644 --- a/source/compiler/aslresource.c +++ b/source/compiler/aslresource.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -762,6 +762,12 @@ RsDoOneResourceDescriptor ( switch (Info->DescriptorTypeOp->Asl.ParseOpcode) { + + case PARSEOP_CLOCKINPUT: + + Rnode = RsDoClockInputDescriptor(Info); + break; + case PARSEOP_DMA: Rnode = RsDoDmaDescriptor (Info); diff --git a/source/compiler/aslresources.y b/source/compiler/aslresources.y index a5752b01c04f..52bff9c41a6a 100644 --- a/source/compiler/aslresources.y +++ b/source/compiler/aslresources.y @@ -11,7 +11,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -214,6 +214,7 @@ ResourceMacroTerm | Memory32Term {} | PinConfigTerm {} | PinFunctionTerm {} + | ClockInputTerm {} | PinGroupTerm {} | PinGroupConfigTerm {} | PinGroupFunctionTerm {} @@ -666,6 +667,21 @@ PinFunctionTerm error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} ; +ClockInputTerm + : PARSEOP_CLOCKINPUT + PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_CLOCKINPUT);} + DWordConstExpr /* 04: FrequencyNumerator */ + ',' WordConstExpr /* 06: FrequencyDivisor */ + ',' ClockScaleKeyword /* 08: Scale */ + ',' ClockModeKeyword /* 10: Mode*/ + OptionalStringData /* 11: ResourceSource */ + OptionalByteConstExpr /* 12: ResourceSourceIndex */ + PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($<n>3,6,$4,$6,$8,$10,$11,$12);} + | PARSEOP_CLOCKINPUT + PARSEOP_OPEN_PAREN + error PARSEOP_CLOSE_PAREN {$$ = AslDoError(); yyclearin;} + ; + PinGroupTerm : PARSEOP_PINGROUP PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_PINGROUP);} diff --git a/source/compiler/aslrestype1.c b/source/compiler/aslrestype1.c index a6625c08c9cd..53fa8621bc91 100644 --- a/source/compiler/aslrestype1.c +++ b/source/compiler/aslrestype1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslrestype1i.c b/source/compiler/aslrestype1i.c index 84d5b653fe8b..d352e65f4024 100644 --- a/source/compiler/aslrestype1i.c +++ b/source/compiler/aslrestype1i.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslrestype2.c b/source/compiler/aslrestype2.c index 387e85c80e41..bf6f77ed726d 100644 --- a/source/compiler/aslrestype2.c +++ b/source/compiler/aslrestype2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -337,7 +337,7 @@ RsDoInterruptDescriptor ( Descriptor->ExtendedIrq.InterruptCount = 0; Rover = ACPI_CAST_PTR (AML_RESOURCE, - (&(Descriptor->ExtendedIrq.Interrupts[0]))); + (&(Descriptor->ExtendedIrq.u.Interrupts[0]))); /* Process all child initialization nodes */ @@ -466,7 +466,7 @@ RsDoInterruptDescriptor ( RsCreateDwordField (InitializerOp, ACPI_RESTAG_INTERRUPT, CurrentByteOffset + - ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0])); + ASL_RESDESC_OFFSET (ExtendedIrq.u.Interrupts[0])); } } @@ -494,7 +494,7 @@ RsDoInterruptDescriptor ( } Rnode->BufferLength = - (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) - + (ASL_RESDESC_OFFSET (ExtendedIrq.u.Interrupts[0]) - ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) + OptionIndex + StringLength; return (Rnode); diff --git a/source/compiler/aslrestype2d.c b/source/compiler/aslrestype2d.c index 6b597e257758..45013c2c766b 100644 --- a/source/compiler/aslrestype2d.c +++ b/source/compiler/aslrestype2d.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslrestype2e.c b/source/compiler/aslrestype2e.c index 414b2d23f851..c557f4020ac6 100644 --- a/source/compiler/aslrestype2e.c +++ b/source/compiler/aslrestype2e.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslrestype2q.c b/source/compiler/aslrestype2q.c index ce79659720ee..62866594e6bd 100644 --- a/source/compiler/aslrestype2q.c +++ b/source/compiler/aslrestype2q.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslrestype2s.c b/source/compiler/aslrestype2s.c index ea832da3db2c..054807964cc1 100644 --- a/source/compiler/aslrestype2s.c +++ b/source/compiler/aslrestype2s.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -1550,7 +1550,6 @@ RsDoPinFunctionDescriptor ( UINT16 PinListLength; UINT16 DescriptorSize; UINT32 CurrentByteOffset; - UINT32 PinCount = 0; UINT32 i; InitializerOp = Info->DescriptorTypeOp->Asl.Child; @@ -1668,15 +1667,10 @@ RsDoPinFunctionDescriptor ( default: /* * PINs come through here, repeatedly. Each PIN must be a WORD. - * NOTE: there is no "length" field for this, so from ACPI spec: - * The number of pins in the table can be calculated from: - * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 - * (implies resource source must immediately follow the pin list.) * Name: _PIN */ *PinList = (UINT16) InitializerOp->Asl.Value.Integer; PinList++; - PinCount++; /* Case 8: First pin number in list */ @@ -1708,6 +1702,115 @@ RsDoPinFunctionDescriptor ( return (Rnode); } +/******************************************************************************* + * + * FUNCTION: RsDoClockInputDescriptor + * + * PARAMETERS: Info - Parse Op and resource template offset + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ClockInput" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoClockInputDescriptor ( + ASL_RESOURCE_INFO *Info) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + char *ResourceSourceString = NULL; + UINT8 *ResourceSourceIndex = NULL; + UINT16 ResSourceLength; + UINT16 DescriptorSize; + UINT32 i; + UINT32 CurrentByteOffset; + + InitializerOp = Info->DescriptorTypeOp->Asl.Child; + CurrentByteOffset = Info->CurrentByteOffset; + + /* + * Calculate lengths for fields that have variable length: + * 1) Resource Source string + */ + ResSourceLength = RsGetStringDataLength (InitializerOp); + + DescriptorSize = ACPI_AML_SIZE_LARGE (AML_RESOURCE_CLOCK_INPUT) + ResSourceLength + 1; + + /* Allocate the local resource node and initialize */ + + Rnode = RsAllocateResourceNode (DescriptorSize + + sizeof (AML_RESOURCE_LARGE_HEADER)); + + Descriptor = Rnode->Buffer; + Descriptor->ClockInput.ResourceLength = DescriptorSize; + Descriptor->ClockInput.DescriptorType = ACPI_RESOURCE_NAME_CLOCK_INPUT; + Descriptor->ClockInput.RevisionId = AML_RESOURCE_CLOCK_INPUT_REVISION; + + /* Build pointers to optional areas */ + + if (ResSourceLength){ + ResourceSourceIndex = ACPI_ADD_PTR (UINT8, Descriptor, sizeof (AML_RESOURCE_CLOCK_INPUT)); + ResourceSourceString = ACPI_ADD_PTR (char, Descriptor, sizeof (AML_RESOURCE_CLOCK_INPUT) + 1); + } + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: + Descriptor->ClockInput.FrequencyNumerator = (UINT32)InitializerOp->Asl.Value.Integer; + RsCreateDwordField (InitializerOp, ACPI_RESTAG_FQN, + CurrentByteOffset + ASL_RESDESC_OFFSET (ClockInput.FrequencyNumerator)); + + break; + + case 1: + Descriptor->ClockInput.FrequencyDivisor = (UINT16)InitializerOp->Asl.Value.Integer; + RsCreateWordField (InitializerOp, ACPI_RESTAG_FQD, + CurrentByteOffset + ASL_RESDESC_OFFSET (ClockInput.FrequencyDivisor)); + + break; + + case 2: + RsSetFlagBits16 (&Descriptor->ClockInput.Flags, InitializerOp, 1, 0); + break; + + case 3: + RsSetFlagBits16 (&Descriptor->ClockInput.Flags, InitializerOp, 0, 0); + break; + + case 4: /* ResSource String [Optional Field] */ + + if (ResourceSourceString) + { + /* Copy string to the descriptor */ + + strcpy (ResourceSourceString, InitializerOp->Asl.Value.String); + } + break; + + case 5: /* ResSource Index [Optional Field] */ + if (ResourceSourceIndex) + { + *ResourceSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer; + } + break; + + default: + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + return (Rnode); +} + /******************************************************************************* * @@ -1736,7 +1839,6 @@ RsDoPinConfigDescriptor ( UINT16 PinListLength; UINT16 DescriptorSize; UINT32 CurrentByteOffset; - UINT32 PinCount = 0; UINT32 i; InitializerOp = Info->DescriptorTypeOp->Asl.Child; @@ -1868,15 +1970,10 @@ RsDoPinConfigDescriptor ( default: /* * PINs come through here, repeatedly. Each PIN must be a WORD. - * NOTE: there is no "length" field for this, so from ACPI spec: - * The number of pins in the table can be calculated from: - * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 - * (implies resource source must immediately follow the pin list.) * Name: _PIN */ *PinList = (UINT16) InitializerOp->Asl.Value.Integer; PinList++; - PinCount++; /* Case 8: First pin number in list */ @@ -1936,7 +2033,6 @@ RsDoPinGroupDescriptor ( UINT16 PinListLength; UINT16 DescriptorSize; UINT32 CurrentByteOffset; - UINT32 PinCount = 0; UINT32 i; InitializerOp = Info->DescriptorTypeOp->Asl.Child; @@ -2022,15 +2118,10 @@ RsDoPinGroupDescriptor ( default: /* * PINs come through here, repeatedly. Each PIN must be a WORD. - * NOTE: there is no "length" field for this, so from ACPI spec: - * The number of pins in the table can be calculated from: - * PinCount = (Resource Source Name Offset - Pin Table Offset) / 2 - * (implies resource source must immediately follow the pin list.) * Name: _PIN */ *PinList = (UINT16) InitializerOp->Asl.Value.Integer; PinList++; - PinCount++; /* Case 3: First pin number in list */ diff --git a/source/compiler/aslrestype2w.c b/source/compiler/aslrestype2w.c index a758e0581d38..9908494d364a 100644 --- a/source/compiler/aslrestype2w.c +++ b/source/compiler/aslrestype2w.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y index 79aa2210abb8..2793749bc631 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -11,7 +11,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index 9542a79d3943..8b4e5c7cd249 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslstubs.c b/source/compiler/aslstubs.c index 0e6cd56f48e7..e90115b8ceda 100644 --- a/source/compiler/aslstubs.c +++ b/source/compiler/aslstubs.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index 0daec602e148..8d589a9490b8 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -195,7 +195,7 @@ AslParserCleanup ( * * DESCRIPTION: Handle #line directives emitted by the preprocessor. * - * The #line directive is emitted by the preprocesser, and is used to + * The #line directive is emitted by the preprocessor, and is used to * pass through line numbers from the original source code file to the * preprocessor output file (.i). This allows any compiler-generated * error messages to be displayed with the correct line number. diff --git a/source/compiler/aslsupport.y b/source/compiler/aslsupport.y index 3f19af2f48b1..f742067287fe 100644 --- a/source/compiler/aslsupport.y +++ b/source/compiler/aslsupport.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asltokens.y b/source/compiler/asltokens.y index c43561e7a4a3..48db2e2211fd 100644 --- a/source/compiler/asltokens.y +++ b/source/compiler/asltokens.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -399,6 +399,12 @@ NoEcho(' %token <i> PARSEOP_PIN_PULLDEFAULT %token <i> PARSEOP_PIN_PULLDOWN %token <i> PARSEOP_PIN_PULLUP +%token <i> PARSEOP_CLOCKINPUT +%token <i> PARSEOP_CLOCK_HZ +%token <i> PARSEOP_CLOCK_KHZ +%token <i> PARSEOP_CLOCK_MHZ +%token <i> PARSEOP_CLOCK_FIXED +%token <i> PARSEOP_CLOCK_VARIABLE %token <i> PARSEOP_POWERRESOURCE %token <i> PARSEOP_PROCESSOR %token <i> PARSEOP_QWORDCONST diff --git a/source/compiler/asltransform.c b/source/compiler/asltransform.c index 573ddad1565f..d1fcbed27d5d 100644 --- a/source/compiler/asltransform.c +++ b/source/compiler/asltransform.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index 9cf49269f377..f390c4f6ca89 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -467,6 +467,7 @@ TrLinkOpChildren ( UINT32 i; BOOLEAN FirstChild; + ACPI_FUNCTION_NAME (TrLinkOpChildren); va_start (ap, NumChildren); @@ -624,7 +625,7 @@ TrLinkOpChildren ( if (AcpiGbl_CaptureComments) { AslGbl_CommentState.LatestParseOp = Op; - CvDbgPrint ("TrLinkOpChildren=====Set latest parse op to this op.\n"); + CvDbgPrint ("%s=====Set latest parse op to this op.\n", ACPI_GET_FUNCTION_NAME); } return (Op); diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index d5689dea58b0..577d3b881c1f 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -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/asltypes.y b/source/compiler/asltypes.y index ba98362cd323..d5f020d3282f 100644 --- a/source/compiler/asltypes.y +++ b/source/compiler/asltypes.y @@ -9,7 +9,7 @@ NoEcho(' * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -359,6 +359,8 @@ NoEcho(' %type <n> WireModeKeyword %type <n> XferSizeKeyword %type <n> XferTypeKeyword +%type <n> ClockScaleKeyword +%type <n> ClockModeKeyword /* Types */ @@ -411,6 +413,7 @@ NoEcho(' /* Resource Descriptors */ +%type <n> ClockInputTerm %type <n> ConnectionTerm %type <n> Csi2SerialBusTerm %type <n> DMATerm diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index e91fd4602c26..86b040b98e26 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -610,7 +610,7 @@ UtSetParseOpName ( * * FUNCTION: UtDisplayOneSummary * - * PARAMETERS: FileID - ID of outpout file + * PARAMETERS: FileID - ID of output file * * RETURN: None * @@ -733,7 +733,7 @@ UtDisplayOneSummary ( * * FUNCTION: UtDisplayErrorSummary * - * PARAMETERS: FileID - ID of outpout file + * PARAMETERS: FileID - ID of output file * * RETURN: None * @@ -800,7 +800,7 @@ UtDisplayErrorSummary ( * * FUNCTION: UtDisplaySummary * - * PARAMETERS: FileID - ID of outpout file + * PARAMETERS: FileID - ID of output file * * RETURN: None * diff --git a/source/compiler/asluuid.c b/source/compiler/asluuid.c index 0eb36050e882..fbbf644af8c0 100644 --- a/source/compiler/asluuid.c +++ b/source/compiler/asluuid.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 6e32f0818725..0f7bc94f2355 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslxref.c b/source/compiler/aslxref.c index 3a00f5a92cbc..0e1034ba73a1 100644 --- a/source/compiler/aslxref.c +++ b/source/compiler/aslxref.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/aslxrefout.c b/source/compiler/aslxrefout.c index dd3fe80c275f..04471c63549d 100644 --- a/source/compiler/aslxrefout.c +++ b/source/compiler/aslxrefout.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/cvcompiler.c b/source/compiler/cvcompiler.c index b51a688b3a59..6689ca89581f 100644 --- a/source/compiler/cvcompiler.c +++ b/source/compiler/cvcompiler.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/cvdisasm.c b/source/compiler/cvdisasm.c index 250c009ac315..7561e902fdd7 100644 --- a/source/compiler/cvdisasm.c +++ b/source/compiler/cvdisasm.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/cvparser.c b/source/compiler/cvparser.c index 66b04e9a8597..574cbe8d9c48 100644 --- a/source/compiler/cvparser.c +++ b/source/compiler/cvparser.c @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtcompile.c b/source/compiler/dtcompile.c index 11fcb8b9a6dc..afb4e3427671 100644 --- a/source/compiler/dtcompile.c +++ b/source/compiler/dtcompile.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtcompiler.h b/source/compiler/dtcompiler.h index e85ca539791a..cddc95191f4b 100644 --- a/source/compiler/dtcompiler.h +++ b/source/compiler/dtcompiler.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -578,6 +578,10 @@ DtCompileAsf ( void **PFieldList); ACPI_STATUS +DtCompileAspt ( + void **PFieldList); + +ACPI_STATUS DtCompileCdat ( void **PFieldList); @@ -654,6 +658,10 @@ DtCompileMcfg ( void **PFieldList); ACPI_STATUS +DtCompileMpam ( + void **PFieldList); + +ACPI_STATUS DtCompileMpst ( void **PFieldList); @@ -698,6 +706,10 @@ DtCompileRgrt ( void **PFieldList); ACPI_STATUS +DtCompileRhct ( + void **PFieldList); + +ACPI_STATUS DtCompileRsdt ( void **PFieldList); @@ -773,6 +785,7 @@ extern const unsigned char TemplateAest[]; extern const unsigned char TemplateAgdi[]; extern const unsigned char TemplateApmt[]; extern const unsigned char TemplateAsf[]; +extern const unsigned char TemplateAspt[]; extern const unsigned char TemplateBoot[]; extern const unsigned char TemplateBdat[]; extern const unsigned char TemplateBert[]; @@ -801,6 +814,7 @@ extern const unsigned char TemplateLpit[]; extern const unsigned char TemplateMadt[]; extern const unsigned char TemplateMcfg[]; extern const unsigned char TemplateMchi[]; +extern const unsigned char TemplateMpam[]; extern const unsigned char TemplateMpst[]; extern const unsigned char TemplateMsct[]; extern const unsigned char TemplateMsdm[]; @@ -814,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/dtcompilerparser.l b/source/compiler/dtcompilerparser.l index a00ef56e2481..a4ff02a08fa9 100644 --- a/source/compiler/dtcompilerparser.l +++ b/source/compiler/dtcompilerparser.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtcompilerparser.y b/source/compiler/dtcompilerparser.y index 30ead3afa9ad..f03615ff1c5e 100644 --- a/source/compiler/dtcompilerparser.y +++ b/source/compiler/dtcompilerparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtexpress.c b/source/compiler/dtexpress.c index fd292d8fec76..7d614729e266 100644 --- a/source/compiler/dtexpress.c +++ b/source/compiler/dtexpress.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -480,10 +480,11 @@ static void DtInsertLabelField ( DT_FIELD *Field) { + ACPI_FUNCTION_NAME (DtInsertLabelField); DbgPrint (ASL_DEBUG_OUTPUT, - "DtInsertLabelField: Found Label : %s at output table offset %X\n", - Field->Value, Field->TableOffset); + "%s: Found Label : %s at output table offset %X\n", + ACPI_GET_FUNCTION_NAME, Field->Value, Field->TableOffset); Field->NextLabel = AslGbl_LabelList; AslGbl_LabelList = Field; diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c index f931631955c2..b2ba6693dcaa 100644 --- a/source/compiler/dtfield.c +++ b/source/compiler/dtfield.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -678,7 +678,7 @@ DtCompileFlag ( case ACPI_DMT_FLAGS8_2: - BitPosition = 2; + BitPosition = 2; BitLength = 8; break; diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 9ec18cd1e0f8..7d7fb2b45997 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtparser.l b/source/compiler/dtparser.l index b7cb26e2ba32..0c003ecacfbd 100644 --- a/source/compiler/dtparser.l +++ b/source/compiler/dtparser.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtparser.y b/source/compiler/dtparser.y index fc8275cc209c..df804c916a16 100644 --- a/source/compiler/dtparser.y +++ b/source/compiler/dtparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dtsubtable.c b/source/compiler/dtsubtable.c index 3c2798b64dbd..0bbaa81ca424 100644 --- a/source/compiler/dtsubtable.c +++ b/source/compiler/dtsubtable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index dfc34c134667..1cbd4619ac99 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dttable1.c b/source/compiler/dttable1.c index dc25e9b9f48f..8ffcb40dc44d 100644 --- a/source/compiler/dttable1.c +++ b/source/compiler/dttable1.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -654,6 +654,91 @@ DtCompileAsf ( return (AE_OK); } +/****************************************************************************** + * + * FUNCTION: DtCompileAspt + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile ASPT. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileAspt ( + void **List) +{ + ACPI_ASPT_HEADER *AsptTable; + DT_SUBTABLE *Subtable; + DT_SUBTABLE *ParentTable; + ACPI_DMTABLE_INFO *InfoTable; + ACPI_STATUS Status; + DT_FIELD **PFieldList = (DT_FIELD **) List; + DT_FIELD *SubtableStart; + + Status = DtCompileTable (PFieldList, AcpiDmTableInfoAspt, &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + Status = DtCompileTable (PFieldList, AcpiDmTableInfoAsptHdr, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + AsptTable = ACPI_CAST_PTR (ACPI_ASPT_HEADER, Subtable->Buffer); + + switch (AsptTable->Type) /* Mask off top bit */ + { + case ACPI_ASPT_TYPE_GLOBAL_REGS: + + InfoTable = AcpiDmTableInfoAspt0; + break; + + case ACPI_ASPT_TYPE_SEV_MBOX_REGS: + + InfoTable = AcpiDmTableInfoAspt1; + break; + + case ACPI_ASPT_TYPE_ACPI_MBOX_REGS: + + InfoTable = AcpiDmTableInfoAspt2; + break; + + default: + + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "ASPT"); + return (AE_ERROR); + } + + Status = DtCompileTable (PFieldList, InfoTable, &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPopSubtable (); + } + + return (AE_OK); +} + /****************************************************************************** * @@ -854,7 +939,7 @@ DtCompileCedt ( /* Look in buffer for the number of targets */ offset = (unsigned int) ACPI_OFFSET (ACPI_CEDT_CFMWS, InterleaveWays); dump = (unsigned char *) Subtable->Buffer - 4; /* place at beginning of cedt1 */ - max = 0x01 << dump[offset]; /* 2^max, so 0=1, 1=2, 2=4, 3=8. 8 is MAX */ + max = 0x01 << dump[offset]; /* 2^max, so 0=1, 1=2, 2=4, 3=8. 8 is MAX */ if (max > 8) max=1; /* Error in encoding Interleaving Ways. */ if (max == 1) /* if only one target, then break here. */ break; /* break if only one target. */ @@ -2009,7 +2094,7 @@ DtCompileHmat ( DtInsertSubtable (ParentTable, Subtable); HmatStruct->Length += Subtable->Length; - /* Compile HMAT structure additionals */ + /* Compile HMAT structure additional */ switch (HmatStruct->Type) { diff --git a/source/compiler/dttable2.c b/source/compiler/dttable2.c index 59d578f91959..007b67476319 100644 --- a/source/compiler/dttable2.c +++ b/source/compiler/dttable2.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -425,6 +425,163 @@ DtCompileMcfg ( return (Status); } +/****************************************************************************** + * + * FUNCTION: DtCompileMpam + * + * PARAMETERS: List - Current field list pointer + * + * RETURN: Status + * + * DESCRIPTION: Compile MPAM. + * + *****************************************************************************/ + +ACPI_STATUS +DtCompileMpam ( + void **List) +{ + ACPI_STATUS Status; + DT_SUBTABLE *ParentTable; + DT_SUBTABLE *Subtable; + DT_FIELD *SubtableStart; + DT_FIELD **PFieldList = (DT_FIELD **) List; + ACPI_MPAM_MSC_NODE *MpamMscNode; + ACPI_MPAM_RESOURCE_NODE *MpamResourceNode; + UINT32 FuncDepsCount; + UINT32 RisLength; + ACPI_DMTABLE_INFO *InfoTable; + + ParentTable = DtPeekSubtable (); + + while (*PFieldList) + { + SubtableStart = *PFieldList; + + /* Main MSC Node table */ + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpam0, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + MpamMscNode = ACPI_CAST_PTR (ACPI_MPAM_MSC_NODE, Subtable->Buffer); + + ParentTable = DtPeekSubtable (); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + ParentTable = DtPeekSubtable (); + + /* + * RIS(es) per MSC node have variable lengths depending on how many RISes there and + * any how many functional dependencies per RIS. Calculate it in order + * to properly set the overall MSC length. + */ + RisLength = 0; + + /* Iterate over RIS subtables per MSC node */ + for (UINT32 ris = 0; ris < MpamMscNode->NumResouceNodes; ris++) + { + /* Compile RIS subtable */ + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpam1, + &Subtable); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + MpamResourceNode = ACPI_CAST_PTR (ACPI_MPAM_RESOURCE_NODE, Subtable->Buffer); + DtInsertSubtable (ParentTable, Subtable); + DtPushSubtable (Subtable); + + ParentTable = DtPeekSubtable (); + + switch (MpamResourceNode->LocatorType) + { + case ACPI_MPAM_LOCATION_TYPE_PROCESSOR_CACHE: + InfoTable = AcpiDmTableInfoMpam1A; + break; + case ACPI_MPAM_LOCATION_TYPE_MEMORY: + InfoTable = AcpiDmTableInfoMpam1B; + break; + case ACPI_MPAM_LOCATION_TYPE_SMMU: + InfoTable = AcpiDmTableInfoMpam1C; + break; + case ACPI_MPAM_LOCATION_TYPE_MEMORY_CACHE: + InfoTable = AcpiDmTableInfoMpam1D; + break; + case ACPI_MPAM_LOCATION_TYPE_ACPI_DEVICE: + InfoTable = AcpiDmTableInfoMpam1E; + break; + case ACPI_MPAM_LOCATION_TYPE_INTERCONNECT: + InfoTable = AcpiDmTableInfoMpam1F; + break; + case ACPI_MPAM_LOCATION_TYPE_UNKNOWN: + InfoTable = AcpiDmTableInfoMpam1G; + default: + DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "Resource Locator Type"); + return (AE_ERROR); + } + + /* Compile Resource Locator Table */ + Status = DtCompileTable (PFieldList, InfoTable, + &Subtable); + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + + /* Compile the number of functional dependencies per RIS */ + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpam1Deps, + &Subtable); + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + FuncDepsCount = *ACPI_CAST_PTR (UINT32, Subtable->Buffer); + + RisLength += sizeof(ACPI_MPAM_RESOURCE_NODE) + + FuncDepsCount * sizeof(ACPI_MPAM_FUNC_DEPS); + + /* Iterate over functional dependencies per RIS */ + for (UINT32 funcDep = 0; funcDep < FuncDepsCount; funcDep++) + { + /* Compiler functional dependencies table */ + Status = DtCompileTable (PFieldList, AcpiDmTableInfoMpam2, + &Subtable); + + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + DtPopSubtable (); + } + + /* Check if the length of the MSC is correct and override with the correct length */ + if (MpamMscNode->Length != sizeof(ACPI_MPAM_MSC_NODE) + RisLength) + { + MpamMscNode->Length = (UINT16) (sizeof(ACPI_MPAM_MSC_NODE) + RisLength); + DbgPrint (ASL_DEBUG_OUTPUT, "Overriding MSC->Length: %X\n", MpamMscNode->Length); + } + + DtPopSubtable (); + } + + return (AE_OK); +} + /****************************************************************************** * @@ -1086,7 +1243,7 @@ DtCompileNhlt ( /* * If we are not done with the current Endpoint yet, then there must be - * some non documeneted structure(s) yet to be processed. First, get + * some non documented structure(s) yet to be processed. First, get * the count of such structure(s). */ if (*PFieldList && !(strcmp ((const char *) (*PFieldList)->Name, "Device Info struct count"))) @@ -1800,7 +1957,7 @@ DtCompilePptt ( DtInsertSubtable (ParentTable, Subtable); PpttHeader->Length += (UINT8)(Subtable->Length); - /* Compile PPTT subtable additionals */ + /* Compile PPTT subtable additional */ switch (PpttHeader->Type) { @@ -1971,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.c b/source/compiler/dttemplate.c index 1bcc4a12cbf1..77edbc852582 100644 --- a/source/compiler/dttemplate.c +++ b/source/compiler/dttemplate.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 3ab99978ab07..755da40224e4 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -301,6 +301,27 @@ const unsigned char TemplateAsf[] = 0x01,0x00 /* 00000070 ".." */ }; +const unsigned char TemplateAspt[] = +{ + 0x41,0x53,0x50,0x54,0x88,0x00,0x00,0x00, /* 00000000 "ASPT...." */ + 0x01,0x2D,0x56,0x52,0x54,0x55,0x41,0x4C, /* 00000008 "..VRTUAL" */ + 0x4D,0x49,0x43,0x52,0x4F,0x53,0x46,0x54, /* 00000010 "MICROSFT" */ + 0x01,0x00,0x00,0x00,0x4D,0x53,0x46,0x54, /* 00000018 "....INTL" */ + 0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, /* 00000020 " ." ...." */ + 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00, /* 00000028 ".. ....." */ + 0x00,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000030 "........" */ + 0x04,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x08,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x01,0x00,0x20,0x00,0x01,0x00,0x00,0x00, /* 00000048 ".. ....." */ + 0x10,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x14,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000058 "........" */ + 0x18,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x02,0x00,0x20,0x00,0x00,0x00,0x00,0x00, /* 00000068 ".. ....." */ + 0x20,0x00,0xB0,0xFE,0x00,0x00,0x00,0x00, /* 00000070 " ......." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */ +}; + const unsigned char TemplateBdat[] = { 0x42,0x44,0x41,0x54,0x30,0x00,0x00,0x00, /* 00000000 "BDAT0..." */ @@ -1197,6 +1218,42 @@ const unsigned char TemplateMsdm[] = 0x22,0x23,0x24,0x25 /* 00000060 ""#$%" */ }; +const unsigned char TemplateMpam[] = +{ + 0x4D,0x50,0x41,0x4D,0xFC,0x00,0x00,0x00, /* 00000000 "MPAM...." */ + 0x02,0x34,0x48,0x49,0x53,0x49,0x20,0x20, /* 00000008 ".4HISI " */ + 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */ + 0x02,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x20,0x10,0x22,0x20,0x60,0x00,0x00,0x00, /* 00000020 " ." `..." */ + 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xC0, /* 00000028 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, /* 00000030 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */ + 0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "2......." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */ + 0x01,0x00,0x00,0x00,0x11,0x00,0x00,0x00, /* 00000068 "........" */ + 0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00, /* 00000070 ".... ..." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */ + 0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00, /* 00000080 "....x..." */ + 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xD0, /* 00000088 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "........" */ + 0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "2......." */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */ + 0x02,0x00,0x00,0x00,0x12,0x00,0x00,0x00, /* 000000C8 "........" */ + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000D0 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D8 "........" */ + 0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00, /* 000000E0 "........" */ + 0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00, /* 000000E8 "........" */ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F0 "........" */ + 0x00,0x00,0x00,0x00 /* 000000F8 "...." */ +}; + const unsigned char TemplateMpst[] = { 0x4D,0x50,0x53,0x54,0xB6,0x00,0x00,0x00, /* 00000000 "MPST...." */ @@ -1659,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/dtutils.c b/source/compiler/dtutils.c index 45bff3df5d21..de321e588094 100644 --- a/source/compiler/dtutils.c +++ b/source/compiler/dtutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -584,6 +584,7 @@ DtGetFieldLength ( case ACPI_DMT_IVRS_DE: case ACPI_DMT_GTDT: case ACPI_DMT_MADT: + case ACPI_DMT_MPAM_LOCATOR: case ACPI_DMT_NHLT1: case ACPI_DMT_NHLT1a: case ACPI_DMT_NHLT1b: @@ -614,6 +615,7 @@ DtGetFieldLength ( ByteLength = 1; break; + case ACPI_DMT_ASPT: case ACPI_DMT_UINT16: case ACPI_DMT_DMAR: case ACPI_DMT_HEST: diff --git a/source/compiler/preprocess.h b/source/compiler/preprocess.h index 9c25dd132a74..818eac263fe2 100644 --- a/source/compiler/preprocess.h +++ b/source/compiler/preprocess.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -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/prexpress.c b/source/compiler/prexpress.c index 8ac1fd88767e..88570685865e 100644 --- a/source/compiler/prexpress.c +++ b/source/compiler/prexpress.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/prmacros.c b/source/compiler/prmacros.c index 5b3669784204..6414867b96ef 100644 --- a/source/compiler/prmacros.c +++ b/source/compiler/prmacros.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -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/prparser.l b/source/compiler/prparser.l index 828d81b263f2..c701da4a46fb 100644 --- a/source/compiler/prparser.l +++ b/source/compiler/prparser.l @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/prparser.y b/source/compiler/prparser.y index 3854d989126f..2f4d03279bf5 100644 --- a/source/compiler/prparser.y +++ b/source/compiler/prparser.y @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c index 0d9af86ea475..d29f4e90da90 100644 --- a/source/compiler/prscan.c +++ b/source/compiler/prscan.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -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 eea42f890b00..2eb91a6c0607 100644 --- a/source/compiler/prutils.c +++ b/source/compiler/prutils.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2023, Intel Corp. * All rights reserved. * * 2. License @@ -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); } |
