| Age | Commit message (Collapse) | Author | Files | Lines |
|
Add AmlCodeGenEqual() to create an AML LEqual expression from two
supplied operands.
Use the existing AML_METHOD_PARAM representation for integer, method
argument, and local variable operands. The generated equality expression
can be used as a predicate by control-flow objects.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Add AmlCodeGenIf() to create an AML If object from a supplied
predicate node.
The API takes ownership of the predicate and returns an If node to
which executable statements can subsequently be appended.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Use AmlComputePkgLength() when calculating the package lengths for
Device, ThermalZone, and Scope objects.
The package-length encoding width is included in the encoded length and
can itself increase when that width is added. AmlComputePkgLength()
handles this boundary condition correctly.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Add AmlCodeGenStoreToName() to create an AML Store operation with a
typed source operand and a named target.
Support integer, method argument and local variable sources using the
AML_METHOD_PARAM representation. Append the generated Store node to an
optional parent object.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Add AmlCodeGenFieldElemNamed() to create a named element within an AML
Field list.
The API validates the supplied NameSeg and field length, encodes the
length using the AML FieldPkgLen format, and appends the resulting
NamedField node to its parent Field object.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Add AmlCodeGenFieldElemReserved() to create an AML ReservedField
element and append it to a Field list.
The API accepts the reserved range length in bits and validates that
the parent supports a Field list. ReservedField elements describe
unnamed gaps in Field declarations and can be used when translating
ASL Offset() declarations.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Add AmlCodeGenField() to create an empty AML Field object associated
with an OperationRegion.
Expose access type, lock rule, and update rule through typed public
enumerations and encode them in the Field flags byte. The generated
Field node can be attached directly to a parent or returned so that
field elements can subsequently be appended.
For example, the API can generate:
Field (REG0, DWordAcc, NoLock, Preserve)
{
}
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Add AmlCodeGenOperationRegion() to create an AML OperationRegion
object from a region name, address space, integer offset, and integer
length.
The API creates the OperationRegion object and populates its four fixed
AML operands:
- RegionName
- RegionSpace
- RegionOffset
- RegionLength
RegionOffset and RegionLength are encoded using the smallest suitable
AML integer representation. The generated node can either be attached
directly to a supplied parent or returned to the caller for later use.
For example, the API can generate an object equivalent to:
OperationRegion (
REG0,
SystemMemory,
RegionOffset,
RegionLength
)
This provides generators with a reusable way to describe register
regions without relying on a precompiled ASL template.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Allow AmlCodeGenNotifyNode() to attach a Notify object to any suitable
parent node.
This enables Notify objects to be generated within nested AML scopes,
for example:
Method (_EVT, 1, Serialized)
{
If (LEqual (Arg0, EventId))
{
Notify (\_SB.RAS0, Value)
}
}
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Make AmlCodeGenNotify() public and declare it in AmlLib.h. Add the new
API to the CodeGen documentation group.
Callers currently cannot append an individual Notify operation while
incrementally constructing a method body.
For example, this enables generators to construct _EVT methods
containing conditional register writes and device notifications.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
Ensure AmlCodeGenNotifyNode() consistently owns its operand nodes after
successful input validation.
Track operands as they are attached to the Notify object so error
handling deletes unattached operands directly and attached operands
through their parent. Clear the caller references after ownership is
transferred to prevent double deletion on failure.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
|
|
In AmlCodeGenRdInterrupt(), the IRQ list was copied directly into an
EFI_ACPI_EXTENDED_INTERRUPT_DESCRIPTOR structure allocated on the stack.
Since the structure only contains storage for the first interrupt entry,
copying multiple IRQs would write beyond the allocated buffer and corrupt
the stack.
Fix this issue by allocating the descriptor dynamically with sufficient
space to accommodate the entire IRQ list. This ensures all interrupt entries
are copied safely without overwriting adjacent stack memory.
Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
|
|
Add support for generating AML methods that return a buffer through the
new AmlCodeGenMethodRetBuffer() API.
Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
|
|
There is currently no API available for generating AML methods without
a return value. This change exports the AmlCodeGenMethod API so it can
be used to create non-returning methods when required.
Signed-off-by: Tuan Phan <tuan.phan@oss.qualcomm.com>
|
|
Move the CheckAddressSpaceFields() function to AmlUtility.c
to allow other files to re-use it.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
|
|
Extend AML_METHOD_PARAM_TYPE enum with AmlMethodParamTypeBuffer (= 4)
to allow callers to pass a raw byte Buffer as an AML method argument.
Add a Buffer case to the switch in AmlCodeGenInvokeMethod() that
delegates to the existing AmlCodeGenBuffer() helper, with NULL-pointer
and zero-length guards matching the pattern of the other cases.
AmlCodeGenReturnInvokeMethod() already delegates to AmlCodeGenInvokeMethod()
so it picks up the new case automatically.
Update AML_METHOD_PARAM documentation: clarify that DataSize carries the
byte count when Type is AmlMethodParamTypeBuffer, and update the
union/struct field comments accordingly.
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
CLANG CI shows that ArgCountNode can be used uninitialized. This is
a genuine error, it should be NULL-ed before any `goto exit_handler`.
Fixes: 1774a34cc518b0d337a0a7f4707d944dc78cb95d
Signed-off-by: Mike Beaton <mjsbeaton@gmail.com>
|
|
Introduce AmlCodeGenReturnInvokeMethod(), a new AML code generation API
that creates AML code for methods whose body returns the result of a
method invocation, i.e. Return(MethodName(args...)).
Supported parameter types for method arguments include:
- AmlMethodParamTypeInteger: Integer constants.
- AmlMethodParamTypeString: String literals.
- AmlMethodParamTypeArg: ArgObj references (Arg0-Arg6).
- AmlMethodParamTypeLocal: LocalObj references (Local0-Local7).
The resulting MethodInvocation node is wrapped in a Return statement
via AmlCodeGenReturn() and linked to the specified parent node.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Refactor AmlCodeGenInvokeMethod() to construct a proper
AML_METHOD_INVOC_OP wrapper node instead of attaching the method
name and argument nodes directly as siblings to the parent. This
aligns the implementation with AmlCodeGenReturnInvokeMethod().
The method invocation is now built as a structured node with:
- FixedArg[0]: method name string (NameString data node)
- FixedArg[1]: argument count (UINT8 data node)
- VarList: parameter nodes (integer, string, ArgObj, LocalObj)
Also add an optional OUT NewObjectNode parameter so callers can
retrieve the created MethodInvocation node, and make ParentNode
optional, matching the convention used by other AmlLib CodeGen APIs.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Update AmlCodeGenNotify() to convert ASL names to AML NameString format
using ConvertAslNameToAmlName() and create a EAmlNodeDataTypeNameString
data node. This produces proper unquoted NamePath references in ASL:
Method (_L0B, 0, Serialized) // _Lxx: Level-Triggered GPE, xx=0x00-0xFF
{
Notify (\_SB.PC00.RP81.XHC0, 0x02) // Device Wake
Notify (\_SB.PC02.RP81.XHC0, 0x02) // Device Wake
}
instead of quoted strings:
Method (_L0B, 0, Serialized) // _Lxx: Level-Triggered GPE, xx=0x00-0xFF
{
Notify ("\\_SB.PC00.RP81.XHC0", 0x02) // Device Wake
Notify ("\\_SB.PC02.RP81.XHC0", 0x02) // Device Wake
}
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.
`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.
Compared to macro-based include guards, `#pragma once`:
- Eliminates the risk of macro name collisions or copy/paste errors
where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
(e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
file entirely, rather than re-reading it to find the matching
`#endif` ("multiple-include optimization").
- Note that some compilers may already optimize traditional include
guards, by recognzining the idiomatic pattern.
This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.
However, this is considered acceptable given:
1. edk2 already defines a subset of supported compilers in
BaseTools/Conf/tools_def.template, all of which have supported
`#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
include guard naming and potential macro collisions.
Approximate compiler support dates:
- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
(http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
|
|
Adds APIs to create AML methods with Notify support in the AmlLib library.
New API takes additional parameters for Notify type and Notify value.
Notify type can be one of NameString, Local or Arg.
Notification value is an integer representing the Notify value.
Ref: ACPI spec 6.5 section 19.6.94 Notify (Notify Object of Event)
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
The ACPI specification does not require legacy IRQs (x86) to be
ActiveLow when EdgeTriggered or vice-versa.
Hence the ASSERT checking for ActiveLow when EdgeTriggered is
removed for IRQ macro generation non-ARM architecture.
The IRQNoFlags macro defaults to EdgeTrigger and ActiveHigh
configuration, demonstrating that this combination is valid.
Reference: ACPI Specification 6.5
- Section 19.6.66: IRQ (Interrupt Resource Descriptor Macro)
- Section 19.6.67: IRQNoFlags (Interrupt Resource Descriptor Macro)
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Adds AML code generation for Serial UART resource descriptor.
This commit introduces helper functions to generate
AML resource data for serial UART resource descriptor.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Adds AML code generation for IRQ resource descriptor.
This commit introduces helper functions to generate
AML resource data for IRQ resource descriptors.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
This commit introduces a set of functions designed to facilitate the creation
and management of C-State (_CST, _CSD) and P-State (_PCT, _PSS) ACPI objects.
Detailed Summary:
1) AmlCreateCstNode(): This function is responsible for creating a _CST
(C-State) node, which is essential for defining processor idle states.
2) AmlAddCstState(): This function adds a C-State package to an existing
CST node, allowing for the specification of individual C-State entries.
3) AmlCreateCsdNode(): This function creates a _CSD (C-State Dependency) node,
which is used to describe dependencies between different C-States.
4) AmlCreatePctNode(): This function generates a _PCT (Performance Control) node,
complete with PCT packages, to manage performance state transitions.
5) AmlCreatePssNode(): This function creates a _PSS (Performance Supported States) node,
which lists the supported performance states for a processor.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Clang build breaks with the following error:
| DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c:1441:20:
| error: result of comparison of constant 256 with expression of type 'UINT8'
| (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
| 1441 | (AccessSize > 256)) ||
| | ~~~~~~~~~~ ^ ~~~
| 1 error generated.
AccessSize is UINT8 and the maximum value for UINT8 is 255, so the
comparision is unnecessary. Drop the check to fix the build.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
|
|
The _PSD structure should have nested packages.
The current implementation generates
Name (_PSD, Package()
{
NumEntries // Integer
Revision // Integer (BYTE)
Domain // Integer (DWORD)
CoordType // Integer (DWORD)
NumProcessors // Integer (DWORD)
})
when this should be
Name (_PSD, Package()
{
Package()
{
NumEntries // Integer
Revision // Integer (BYTE)
Domain // Integer (DWORD)
CoordType // Integer (DWORD)
NumProcessors // Integer (DWORD)
}
})
REF: https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html#psd-p-state-dependency
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
|
|
Adds generic creator id as DYNT.
Updates the common ACPI tables with generic CreatorId.
Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
Add helper functions to generate AML resource data
for I/O resource descriptor.
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Corrects the parameters of AmlCodeGenRdWordBusNumber() to
UINT16 to generate word bus number.
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>
|
|
Add helper functions to generate AML resource data
for word I/O.
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>
|
|
AmlCodeGenRdQWordMemory's and AmlCodeGenRdDWordMemory's Cacheable
and MemoryRangeType parameters treat specific values as having
specific meanings as defined by the spec. This change adds enums to map
those meanings to their corresponding values.
Signed-off-by: Jeshua Smith <jeshuas@nvidia.com>
Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
|
|
Add helper functions to generate AML Resource Data describing I/O
ranges of four words long. API AmlCodeGenRdQWordIo () is exposed.
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
For Pcc address space, the AccessSize field of a Register is
used to delcare the Pcc Subspace Id. This Id can be up to 256.
Cf. ACPI 6.4, s14.7 Referencing the PCC address space
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
|
|
commit 691c5f776274 ("DynamicTablesPkg: Deprecate Crs specific methods
in AmlLib")
deprecates some APIs. Finally remove them.
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
|
|
_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>
|