summaryrefslogtreecommitdiff
path: root/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
AgeCommit message (Collapse)AuthorFilesLines
2024-07-01DynamicTablesPkg: AmlLib CONST cleanupJeshua Smith1-5/+5
Several input strings to AmlLib APIs are treated as CONST but were missing the CONST keyword, requiring their callers to create unnecessary r/w copies of r/o input strings. This change properly marks these input strings as CONST. Signed-off-by: Jeshua Smith <jeshuas@nvidia.com> Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
2024-05-10DynamicTablesPkg: Adds integer to the AML package nodeAbdul Lateef Attar1-0/+67
Adds an AmlAddIntegerToNamedPackage() API to generate AML code, which adds an integer value to the package node. Cc: Pierre Gondois <pierre.gondois@arm.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2024-01-29DynamicTablesPkg: Exempt some _CPC field from checksPierre Gondois1-4/+24
When generating _CPC objects, some fields are mandatory by spec [1]. Some fields cannot be supported by a the Juno platform, which is used to test the _CPC generation. Therefore, rely on the PcdDevelopmentPlatformRelaxations Pcd to either: - warn about the missing fields and and let the OS handle the missing information - consider the missing fields as an error _CPC fields that are exempted from checks when the Pcd is set: - PerformanceLimitedRegister - ReferencePerformanceCounterRegister - DeliveredPerformanceCounterRegister [1] Cf. non-optional fields in: ACPI 6.5, s8.4.6.1 '_CPC (Continuous Performance Control)' Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2024-01-29DynamicTablesPkg: Add AmlCreatePsdNode() to generate _PSDPierre Gondois1-1/+187
Add AmlCreatePsdNode() to the AmlLib to generate _PSD objects. _PSD objects allow to describe 'performance control, P-state or CPPC, logical processor dependency', Cf. ACPI 6.5, s8.4.5.5 _PSD (P-State Dependency). Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2024-01-29DynamicTablesPkg: Rename AmlCpcInfo.h to AcpiObjects.hPierre Gondois1-1/+1
The DynamicTables framework uses the AmlLib to generate some Aml objects. It is done by using structured known by both frameworks, e.g. the AML_CPC_INFO/CM_ARM_CPC_INFO structures. To prepare adding similar structures (e.g. representing _PSD information), rename AmlCpcInfo.h to AcpiObjects.h. This new file will contain all the structures used by the AmlLib and the DynamicTables framework. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2024-01-29DynamicTablesPkg: Use new CPC revision macroPierre Gondois1-1/+1
Make use of the newly added CPC revision macro. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
2024-01-03DynamicTablesPkg: Fix X64 compilation errorsAbdul Lateef Attar1-2/+2
Add the support for X64 compilation to the CI. Fix the compilation errors. Cc: Pierre Gondois <pierre.gondois@arm.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2023-12-22DynamicTablesPkg: AML Code generation to invoke a methodAbdul Lateef Attar1-0/+241
Adds API to generate AML code to invoke/call another method. Also provides ability to pass arguments of type integer, string, ArgObj or LocalObj. Cc: Pierre Gondois <pierre.gondois@arm.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2023-09-22DynamicTablesPkg: Add Aml NameUnicodeString APIJeff Brasen1-0/+86
Add API to generate a Name that contains a Unicode string buffer. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2023-09-22DynamicTablesPkg: Add support to add Strings to packageJeff Brasen1-0/+84
Add API to add a String to a package created with NamedPackage API. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2023-09-22DynamicTablesPkg: Add support for simple method invocation.Jeff Brasen1-0/+238
Add support to add Return objects via AML that pass a single integer argument to the named method. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2023-09-22DynamicTablesPkg: Add ThermalZone CodeGen functionJeff Brasen1-0/+116
Add API to generate a ThermalZone object to AmlLib. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-12-13DynamicTablesPkg: Remove duplicated wordsPierre Gondois1-1/+1
In an effort to clean the documentation of the above package, remove duplicated words. Cc: Sami Mujawar <Sami.Mujawar@arm.com> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-09-23DynamicTablesPkg: AML Code generation to add _CPC entriesJeff Brasen1-0/+475
_CPC entries can describe CPU performance information. The object is described in ACPI 6.4 s8.4.7.1. "_CPC (Continuous Performance Control)". Add AmlCreateCpcNode() helper function to add _CPC entries to an existing CPU object. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-09-01DynamicTablesPkg: Add support to build _DSDJeff Brasen1-0/+250
Add APIs needed to build _DSD with different UUIDs. This is per ACPI specification 6.4 s6.2.5. Adds support for building data packages with format Package {"Name", Integer} Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-02-02DynamicTablesPkg: Add AmlCodeGenMethodRetInteger functionRebecca Cran1-0/+159
Add AmlCodeGenMethodRetInteger function to generate AML code for a Method returning an Integer. Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-02-02DynamicTablesPkg: Remove redundant cast in AmlCodeGenReturnRebecca Cran1-1/+1
In AmlCodeGenReturn, the cast to AML_NODE_HEADER* in the call to AmlSetFixedArgument is redundant because ReturnNode is already a AML_NODE_HEADER* . Signed-off-by: Rebecca Cran <quic_rcran@quicinc.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-02-01DynamicTablesPkg: AmlLib: AmlAddPrtEntry() to handle GSIPierre Gondois1-34/+55
In ACPI 6.4, s6.2.13, _PRT objects describing PCI legacy interrupts can be defined following 2 models. In the first model, _PRT entries reference link devices. Link devices then describe interrupts. This allows to dynamically modify interrupts through _SRS and _PRS objects and to choose exactly the interrupt type (level/edge triggered, active high/low). In the second model, interrupt numbers are described in the _PRT entry. The interrupt type is then assumed by the OS. AmlAddPrtEntry() currently only handles the first model. Make changes to also handle the second model. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-12-13DynamicTablesPkg: AML Code generation to add _PRT entriesPierre Gondois1-0/+214
_PRT entries can describe interrupt mapping for Pci devices. The object is described in ACPI 6.4 s6.2.13 "_PRT (PCI Routing Table)". Add AmlCodeGenPrtEntry() helper function to add _PRT entries to an existing _PRT object. To: Sami Mujawar <sami.mujawar@arm.com> To: Alexei Fedorov <Alexei.Fedorov@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-12-13DynamicTablesPkg: AML Code generation to create a named ResourceTemplate()Pierre Gondois1-0/+56
Add AmlCodeGenNameResourceTemplate() to generate code for a ResourceTemplate(). AmlCodeGenNameResourceTemplate ("REST", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(REST, ResourceTemplate () {}) To: Sami Mujawar <sami.mujawar@arm.com> To: Alexei Fedorov <Alexei.Fedorov@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-12-13DynamicTablesPkg: AML Code generation to create a named Package()Pierre Gondois1-0/+56
Add AmlCodeGenNamePackage() to generate code for a Package(). AmlCodeGenNamePackage ("PACK", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(PACK, Package () {}) To: Sami Mujawar <sami.mujawar@arm.com> To: Alexei Fedorov <Alexei.Fedorov@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-12-07DynamicTablesPkg: Apply uncrustify changesMichael Kubacki1-210/+271
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the DynamicTablesPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-12-07DynamicTablesPkg: Change OPTIONAL keyword usage styleMichael D Kinney1-18/+18
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3760 Update all use of ', OPTIONAL' to ' OPTIONAL,' for function params. Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael Kubacki <michael.kubacki@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-10-08DynamicTablesPkg: AML code generation to add an _LPI statePierre Gondois1-0/+459
Add AmlAddLpiState() to generates AML code to add an _LPI state to an _LPI object created using AmlCreateLpiNode(). AmlAddLpiState increments the count of LPI states in the LPI node by one, and adds the following package: Package() { MinResidency, WorstCaseWakeLatency, Flags, ArchFlags, ResCntFreq, EnableParentState, (GenericRegisterDescriptor != NULL) ? // Entry method. If a ResourceTemplate(GenericRegisterDescriptor) : // Register is given, Integer, // use it. Use the // Integer otherwise ResourceTemplate() { // NULL Residency Register (SystemMemory, 0, 0, 0, 0) // Counter }, ResourceTemplate() { // NULL Usage Counter Register (SystemMemory, 0, 0, 0, 0) }, "" // NULL State Name }, Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: AML code generation for a _LPI objectPierre Gondois1-0/+133
_LPI object provides a method to describe Low Power Idle states that define the local power states for each node in a hierarchical processor topology. Therefore, add AmlCreateLpiNode() to generate code for a _LPI object. AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is equivalent of the following ASL code: Name (_LPI, Package ( 0, // Revision 1, // LevelId 0 // Count )) Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: AML code generation for a Method returning a NSPierre Gondois1-0/+106
Add AmlCodeGenMethodRetNameString() to generate AML code to create a Method returning a NameString (NS). AmlCodeGenMethodRetNameString ( "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode ); is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) { Return (_CRS) } Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: AML code generation to Return a NameStringPierre Gondois1-0/+181
Add AmlCodeGenReturnNameString() to generate AML code for a Return object node, returning the object as a NameString. AmlCodeGenReturn ("NAM1", ParentNode, NewObjectNode) is equivalent of the following ASL code: Return(NAM1) Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: AML code generation for a MethodPierre Gondois1-0/+184
Add AmlCodeGenMethod() to generate code for a control method. AmlCodeGenMethod ("MET0", 1, TRUE, 3, ParentNode, NewObjectNode) is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) {} Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: AML code generation for a ResourceTemplatePierre Gondois1-0/+190
ASL provides a ResourceTemplate macro that creates a Buffer in which resource descriptor macros can be listed. The ResourceTemplate macro automatically generates an End descriptor and calculates the checksum for the resource template. Therefore, add AmlCodeGenResourceTemplate() to generate AML code for the ResourceTemplate() macro. This function generates a Buffer node with an EndTag resource data descriptor, which is similar to the ASL ResourceTemplate() macro. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: AML code generation for a PackagePierre Gondois1-1/+80
Add AmlCodeGenPackage() to generate AML code for declaring a Package() object. This function generates an empty package node. New elements can then be added to the package's variable argument list. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: Update error handling for node creationPierre Gondois1-5/+1
The node creation functions: - AmlCreateRootNode() - AmlCreateObjectNode() - AmlCreateDataNode() are now resetting the input pointer where the created node is stored. Thus, it is not necessary to set some local variables to NULL or check a node value before trying to delete it. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2021-10-08DynamicTablesPkg: Clear pointer in node creation fctsPierre Gondois1-2/+8
The following functions: - AmlCreateRootNode() - AmlCreateObjectNode() - AmlCreateDataNode() create a node and return it by populating a pointer. This pointer should only be considered/used if the function returns successfully. Otherwise, the value stored in this pointer should be ignored. For their error handling, some other functions assume that this pointer is reset to NULL if an error occurs during a node creation. To make this assumption correct, explicitly clear this input pointer. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
2020-10-21DynamicTablesPkg: AmlLib fix ECC errorsSami Mujawar1-2/+2
Fix the following ECC reported errors in AmlLib. - [1008] File has invalid Non-ACSII char. - [9002] The function headers should follow Doxygen special documentation blocks in section 2.3.5 Comment does NOT have tail **/ Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
2020-08-13DynamicTablesPkg: AML CodegenPierre Gondois1-0/+701
AML Codegen is a Dynamic AML technique that facilitates generation of small segments of AML code. The AML code generated using AML Codegen is represented as nodes in the AML Tree. Some examples where AML Codegen can be used are: - AML Codegen APIs can be used to generate a simple AML tree. - An AML template can be parsed to create an AML tree. This AML Tree can be searched to locate a node that needs updating. The AML Codegen APIs can be used to attach new AML nodes. - A combination of AML Fixup and AML Codegen can be used to generate an AML tree. The AML tree can then be serialised as a Definition Block table. Following AML Codegen APIs are implemented: - AmlCodeGenDefinitionBlock() - AmlCodeGenScope() - AmlCodeGenNameString() - AmlCodeGenNameInteger() - AmlCodeGenDevice() These AML Codegen APIs in combination with AML Resource Data Codegen APIs can be used to generate a simple AML tree. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>