DynamicTablesPkg: Deprecate Crs specific methods in AmlLib
Some functions in the AmlLib have 'Crs' in their name and can only be applied to '_CRS' AML objects. To re-use them on AML objects that have different names: - Rename them and remove the '_CRS' name check. - Create aliases having of the 'Crs' function prototypes. These aliases are available when DISABLE_NEW_DEPRECATED_INTERFACES is not defined. They will be deprecated in a near future. The deprecated functions are: - AmlNameOpCrsGetFirstRdNode() - AmlNameOpCrsGetNextRdNode() - AmlCodeGenCrsAddRdInterrupt() Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
This commit is contained in:
		
				
					committed by
					
						![mergify[bot]](/avatar/e3df20cd7a67969c41a65f03bea54961?size=40) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							7a8c037e9e
						
					
				
				
					commit
					691c5f7762
				
			| @@ -1,7 +1,7 @@ | |||||||
| /** @file | /** @file | ||||||
|   AML Lib. |   AML Lib. | ||||||
|  |  | ||||||
|   Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR> |   Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR> | ||||||
|  |  | ||||||
|   SPDX-License-Identifier: BSD-2-Clause-Patent |   SPDX-License-Identifier: BSD-2-Clause-Patent | ||||||
| **/ | **/ | ||||||
| @@ -301,7 +301,7 @@ AmlNameOpUpdateString ( | |||||||
|   IN  CONST CHAR8                   * NewName |   IN  CONST CHAR8                   * NewName | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
| /** Get the first Resource Data element contained in a "_CRS" object. | /** Get the first Resource Data element contained in a named object. | ||||||
|  |  | ||||||
|   In the following ASL code, the function will return the Resource Data |   In the following ASL code, the function will return the Resource Data | ||||||
|   node corresponding to the "QWordMemory ()" ASL macro. |   node corresponding to the "QWordMemory ()" ASL macro. | ||||||
| @@ -312,18 +312,17 @@ AmlNameOpUpdateString ( | |||||||
|   ) |   ) | ||||||
|  |  | ||||||
|   Note: |   Note: | ||||||
|    - The "_CRS" object must be declared using ASL "Name (Declare Named Object)". |   "_CRS" names defined as methods are not handled by this function. | ||||||
|    - "_CRS" declared using ASL "Method (Declare Control Method)" is not |   They must be defined as names, using the "Name ()" statement. | ||||||
|      supported. |  | ||||||
|  |  | ||||||
|   @ingroup UserApis |   @ingroup UserApis | ||||||
|  |  | ||||||
|   @param  [in] NameOpCrsNode  NameOp object node defining a "_CRS" object. |   @param  [in] NameOpNode   NameOp object node defining a named object. | ||||||
|                             Must have an OpCode=AML_NAME_OP, SubOpCode=0. |                             Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|                             NameOp object nodes are defined in ASL |                             NameOp object nodes are defined in ASL | ||||||
|                             using the "Name ()" function. |                             using the "Name ()" function. | ||||||
|   @param  [out] OutRdNode   Pointer to the first Resource Data element of |   @param  [out] OutRdNode   Pointer to the first Resource Data element of | ||||||
|                               the "_CRS" object. A Resource Data element |                             the named object. A Resource Data element | ||||||
|                             is stored in a data node. |                             is stored in a data node. | ||||||
|  |  | ||||||
|   @retval EFI_SUCCESS             The function completed successfully. |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
| @@ -331,8 +330,8 @@ AmlNameOpUpdateString ( | |||||||
| **/ | **/ | ||||||
| EFI_STATUS | EFI_STATUS | ||||||
| EFIAPI | EFIAPI | ||||||
| AmlNameOpCrsGetFirstRdNode ( | AmlNameOpGetFirstRdNode ( | ||||||
|   IN  AML_OBJECT_NODE_HANDLE   NameOpCrsNode, |   IN  AML_OBJECT_NODE_HANDLE   NameOpNode, | ||||||
|   OUT AML_DATA_NODE_HANDLE   * OutRdNode |   OUT AML_DATA_NODE_HANDLE   * OutRdNode | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
| @@ -347,13 +346,14 @@ AmlNameOpCrsGetFirstRdNode ( | |||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
|  |  | ||||||
|   The CurrRdNode Resource Data node must be defined in an object named "_CRS" |   Note: | ||||||
|   and defined by a "Name ()" ASL function. |   "_CRS" names defined as methods are not handled by this function. | ||||||
|  |   They must be defined as names, using the "Name ()" statement. | ||||||
|  |  | ||||||
|   @ingroup UserApis |   @ingroup UserApis | ||||||
|  |  | ||||||
|   @param  [in]  CurrRdNode   Pointer to the current Resource Data element of |   @param  [in]  CurrRdNode   Pointer to the current Resource Data element of | ||||||
|                              the "_CRS" variable. |                              the named object. | ||||||
|   @param  [out] OutRdNode    Pointer to the Resource Data element following |   @param  [out] OutRdNode    Pointer to the Resource Data element following | ||||||
|                              the CurrRdNode. |                              the CurrRdNode. | ||||||
|                              Contain a NULL pointer if CurrRdNode is the |                              Contain a NULL pointer if CurrRdNode is the | ||||||
| @@ -366,7 +366,7 @@ AmlNameOpCrsGetFirstRdNode ( | |||||||
| **/ | **/ | ||||||
| EFI_STATUS | EFI_STATUS | ||||||
| EFIAPI | EFIAPI | ||||||
| AmlNameOpCrsGetNextRdNode ( | AmlNameOpGetNextRdNode ( | ||||||
|   IN  AML_DATA_NODE_HANDLE    CurrRdNode, |   IN  AML_DATA_NODE_HANDLE    CurrRdNode, | ||||||
|   OUT AML_DATA_NODE_HANDLE  * OutRdNode |   OUT AML_DATA_NODE_HANDLE  * OutRdNode | ||||||
|   ); |   ); | ||||||
| @@ -423,7 +423,7 @@ AmlUpdateRdQWord ( | |||||||
|   This function creates a Resource Data element corresponding to the |   This function creates a Resource Data element corresponding to the | ||||||
|   "Interrupt ()" ASL function, stores it in an AML Data Node. |   "Interrupt ()" ASL function, stores it in an AML Data Node. | ||||||
|  |  | ||||||
|   It then adds it after the input CurrRdNode in the list of resource data |   It then adds it after the input NameOpNode in the list of resource data | ||||||
|   element. |   element. | ||||||
|  |  | ||||||
|   The Resource Data effectively created is an Extended Interrupt Resource |   The Resource Data effectively created is an Extended Interrupt Resource | ||||||
| @@ -437,14 +437,9 @@ AmlUpdateRdQWord ( | |||||||
|    - attach this node to an AML tree; |    - attach this node to an AML tree; | ||||||
|    - delete this node. |    - delete this node. | ||||||
|  |  | ||||||
|   Note: The _CRS node must be defined using the ASL Name () function. |   @ingroup CodeGenApis | ||||||
|         e.g. Name (_CRS, ResourceTemplate () { |  | ||||||
|                ... |  | ||||||
|              } |  | ||||||
|  |  | ||||||
|   @ingroup UserApis |   @param  [in]  NameOpNode       NameOp object node defining a named object. | ||||||
|  |  | ||||||
|   @param  [in]  NameOpCrsNode    NameOp object node defining a "_CRS" object. |  | ||||||
|                                  Must have an OpCode=AML_NAME_OP, SubOpCode=0. |                                  Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|                                  NameOp object nodes are defined in ASL |                                  NameOp object nodes are defined in ASL | ||||||
|                                  using the "Name ()" function. |                                  using the "Name ()" function. | ||||||
| @@ -465,8 +460,8 @@ AmlUpdateRdQWord ( | |||||||
| **/ | **/ | ||||||
| EFI_STATUS | EFI_STATUS | ||||||
| EFIAPI | EFIAPI | ||||||
| AmlCodeGenCrsAddRdInterrupt ( | AmlCodeGenAddRdInterrupt ( | ||||||
|   IN  AML_OBJECT_NODE_HANDLE  NameOpCrsNode, |   IN  AML_OBJECT_NODE_HANDLE  NameOpNode, | ||||||
|   IN  BOOLEAN                 ResourceConsumer, |   IN  BOOLEAN                 ResourceConsumer, | ||||||
|   IN  BOOLEAN                 EdgeTriggered, |   IN  BOOLEAN                 EdgeTriggered, | ||||||
|   IN  BOOLEAN                 ActiveLow, |   IN  BOOLEAN                 ActiveLow, | ||||||
| @@ -628,4 +623,142 @@ AmlCodeGenScope ( | |||||||
|   OUT       AML_OBJECT_NODE_HANDLE  * NewObjectNode   OPTIONAL |   OUT       AML_OBJECT_NODE_HANDLE  * NewObjectNode   OPTIONAL | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|  | // DEPRECATED APIS | ||||||
|  | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES | ||||||
|  |  | ||||||
|  | /** DEPRECATED API | ||||||
|  |  | ||||||
|  |   Get the first Resource Data element contained in a "_CRS" object. | ||||||
|  |  | ||||||
|  |   In the following ASL code, the function will return the Resource Data | ||||||
|  |   node corresponding to the "QWordMemory ()" ASL macro. | ||||||
|  |   Name (_CRS, ResourceTemplate() { | ||||||
|  |       QWordMemory (...) {...}, | ||||||
|  |       Interrupt (...) {...} | ||||||
|  |     } | ||||||
|  |   ) | ||||||
|  |  | ||||||
|  |   Note: | ||||||
|  |    - The "_CRS" object must be declared using ASL "Name (Declare Named Object)". | ||||||
|  |    - "_CRS" declared using ASL "Method (Declare Control Method)" is not | ||||||
|  |      supported. | ||||||
|  |  | ||||||
|  |   @ingroup UserApis | ||||||
|  |  | ||||||
|  |   @param  [in] NameOpCrsNode  NameOp object node defining a "_CRS" object. | ||||||
|  |                               Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|  |                               NameOp object nodes are defined in ASL | ||||||
|  |                               using the "Name ()" function. | ||||||
|  |   @param  [out] OutRdNode     Pointer to the first Resource Data element of | ||||||
|  |                               the "_CRS" object. A Resource Data element | ||||||
|  |                               is stored in a data node. | ||||||
|  |  | ||||||
|  |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
|  |   @retval EFI_INVALID_PARAMETER   Invalid parameter. | ||||||
|  | **/ | ||||||
|  | EFI_STATUS | ||||||
|  | EFIAPI | ||||||
|  | AmlNameOpCrsGetFirstRdNode ( | ||||||
|  |   IN  AML_OBJECT_NODE_HANDLE   NameOpCrsNode, | ||||||
|  |   OUT AML_DATA_NODE_HANDLE   * OutRdNode | ||||||
|  |   ); | ||||||
|  |  | ||||||
|  | /** DEPRECATED API | ||||||
|  |  | ||||||
|  |   Get the Resource Data element following the CurrRdNode Resource Data. | ||||||
|  |  | ||||||
|  |   In the following ASL code, if CurrRdNode corresponds to the first | ||||||
|  |   "QWordMemory ()" ASL macro, the function will return the Resource Data | ||||||
|  |   node corresponding to the "Interrupt ()" ASL macro. | ||||||
|  |   Name (_CRS, ResourceTemplate() { | ||||||
|  |       QwordMemory (...) {...}, | ||||||
|  |       Interrupt (...) {...} | ||||||
|  |     } | ||||||
|  |   ) | ||||||
|  |  | ||||||
|  |   The CurrRdNode Resource Data node must be defined in an object named "_CRS" | ||||||
|  |   and defined by a "Name ()" ASL function. | ||||||
|  |  | ||||||
|  |   @ingroup UserApis | ||||||
|  |  | ||||||
|  |   @param  [in]  CurrRdNode   Pointer to the current Resource Data element of | ||||||
|  |                              the "_CRS" variable. | ||||||
|  |   @param  [out] OutRdNode    Pointer to the Resource Data element following | ||||||
|  |                              the CurrRdNode. | ||||||
|  |                              Contain a NULL pointer if CurrRdNode is the | ||||||
|  |                              last Resource Data element in the list. | ||||||
|  |                              The "End Tag" is not considered as a resource | ||||||
|  |                              data element and is not returned. | ||||||
|  |  | ||||||
|  |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
|  |   @retval EFI_INVALID_PARAMETER   Invalid parameter. | ||||||
|  | **/ | ||||||
|  | EFI_STATUS | ||||||
|  | EFIAPI | ||||||
|  | AmlNameOpCrsGetNextRdNode ( | ||||||
|  |   IN  AML_DATA_NODE_HANDLE    CurrRdNode, | ||||||
|  |   OUT AML_DATA_NODE_HANDLE  * OutRdNode | ||||||
|  |   ); | ||||||
|  |  | ||||||
|  | /** DEPRECATED API | ||||||
|  |  | ||||||
|  |   Add an Interrupt Resource Data node. | ||||||
|  |  | ||||||
|  |   This function creates a Resource Data element corresponding to the | ||||||
|  |   "Interrupt ()" ASL function, stores it in an AML Data Node. | ||||||
|  |  | ||||||
|  |   It then adds it after the input CurrRdNode in the list of resource data | ||||||
|  |   element. | ||||||
|  |  | ||||||
|  |   The Resource Data effectively created is an Extended Interrupt Resource | ||||||
|  |   Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor" | ||||||
|  |   for more information about Extended Interrupt Resource Data. | ||||||
|  |  | ||||||
|  |   The Extended Interrupt contains one single interrupt. | ||||||
|  |  | ||||||
|  |   This function allocates memory to create a data node. It is the caller's | ||||||
|  |   responsibility to either: | ||||||
|  |    - attach this node to an AML tree; | ||||||
|  |    - delete this node. | ||||||
|  |  | ||||||
|  |   Note: The _CRS node must be defined using the ASL Name () function. | ||||||
|  |         e.g. Name (_CRS, ResourceTemplate () { | ||||||
|  |                ... | ||||||
|  |              } | ||||||
|  |  | ||||||
|  |   @ingroup CodeGenApis | ||||||
|  |  | ||||||
|  |   @param  [in]  NameOpCrsNode    NameOp object node defining a "_CRS" object. | ||||||
|  |                                  Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|  |                                  NameOp object nodes are defined in ASL | ||||||
|  |                                  using the "Name ()" function. | ||||||
|  |   @param  [in]  ResourceConsumer The device consumes the specified interrupt | ||||||
|  |                                  or produces it for use by a child device. | ||||||
|  |   @param  [in]  EdgeTriggered    The interrupt is edge triggered or | ||||||
|  |                                  level triggered. | ||||||
|  |   @param  [in]  ActiveLow        The interrupt is active-high or active-low. | ||||||
|  |   @param  [in]  Shared           The interrupt can be shared with other | ||||||
|  |                                  devices or not (Exclusive). | ||||||
|  |   @param  [in]  IrqList          Interrupt list. Must be non-NULL. | ||||||
|  |   @param  [in]  IrqCount         Interrupt count. Must be non-zero. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
|  |   @retval EFI_INVALID_PARAMETER   Invalid parameter. | ||||||
|  |   @retval EFI_OUT_OF_RESOURCES    Could not allocate memory. | ||||||
|  | **/ | ||||||
|  | EFI_STATUS | ||||||
|  | EFIAPI | ||||||
|  | AmlCodeGenCrsAddRdInterrupt ( | ||||||
|  |   IN  AML_OBJECT_NODE_HANDLE  NameOpCrsNode, | ||||||
|  |   IN  BOOLEAN                 ResourceConsumer, | ||||||
|  |   IN  BOOLEAN                 EdgeTriggered, | ||||||
|  |   IN  BOOLEAN                 ActiveLow, | ||||||
|  |   IN  BOOLEAN                 Shared, | ||||||
|  |   IN  UINT32                * IrqList, | ||||||
|  |   IN  UINT8                   IrqCount | ||||||
|  |   ); | ||||||
|  |  | ||||||
|  | #endif // DISABLE_NEW_DEPRECATED_INTERFACES | ||||||
|  |  | ||||||
| #endif // AML_LIB_H_ | #endif // AML_LIB_H_ | ||||||
|   | |||||||
| @@ -286,7 +286,7 @@ FixupCmn600Info ( | |||||||
|  |  | ||||||
|   // Get the first Rd node in the "_CRS" object. |   // Get the first Rd node in the "_CRS" object. | ||||||
|   // This is the PERIPHBASE node. |   // This is the PERIPHBASE node. | ||||||
|   Status = AmlNameOpCrsGetFirstRdNode (NameOpCrsNode, &CmnPeriphBaseRdNode); |   Status = AmlNameOpGetFirstRdNode (NameOpCrsNode, &CmnPeriphBaseRdNode); | ||||||
|   if (EFI_ERROR (Status)) { |   if (EFI_ERROR (Status)) { | ||||||
|     goto error_handler; |     goto error_handler; | ||||||
|   } |   } | ||||||
| @@ -309,7 +309,7 @@ FixupCmn600Info ( | |||||||
|   // Get the QWord node corresponding to the ROOTNODEBASE. |   // Get the QWord node corresponding to the ROOTNODEBASE. | ||||||
|   // It is the second Resource Data element in the BufferNode's |   // It is the second Resource Data element in the BufferNode's | ||||||
|   // variable list of arguments. |   // variable list of arguments. | ||||||
|   Status = AmlNameOpCrsGetNextRdNode ( |   Status = AmlNameOpGetNextRdNode ( | ||||||
|              CmnPeriphBaseRdNode, |              CmnPeriphBaseRdNode, | ||||||
|              &CmnRootNodeBaseRdNode |              &CmnRootNodeBaseRdNode | ||||||
|              ); |              ); | ||||||
| @@ -338,7 +338,7 @@ FixupCmn600Info ( | |||||||
|   // Resource Data nodes. |   // Resource Data nodes. | ||||||
|   for (Index = 0; Index < Cmn600Info->DtcCount; Index++) { |   for (Index = 0; Index < Cmn600Info->DtcCount; Index++) { | ||||||
|     DtcInt = &Cmn600Info->DtcInterrupt[Index]; |     DtcInt = &Cmn600Info->DtcInterrupt[Index]; | ||||||
|     Status = AmlCodeGenCrsAddRdInterrupt ( |     Status = AmlCodeGenAddRdInterrupt ( | ||||||
|                NameOpCrsNode, |                NameOpCrsNode, | ||||||
|                ((DtcInt->Flags & |                ((DtcInt->Flags & | ||||||
|                  EFI_ACPI_EXTENDED_INTERRUPT_FLAG_PRODUCER_CONSUMER_MASK) != 0), |                  EFI_ACPI_EXTENDED_INTERRUPT_FLAG_PRODUCER_CONSUMER_MASK) != 0), | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /** @file | /** @file | ||||||
|   AML Api. |   AML Api. | ||||||
|  |  | ||||||
|   Copyright (c) 2020, Arm Limited. All rights reserved.<BR> |   Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR> | ||||||
|  |  | ||||||
|   SPDX-License-Identifier: BSD-2-Clause-Patent |   SPDX-License-Identifier: BSD-2-Clause-Patent | ||||||
| **/ | **/ | ||||||
| @@ -222,7 +222,7 @@ AmlNameOpUpdateString ( | |||||||
|   return Status; |   return Status; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** Get the first Resource Data element contained in a "_CRS" object. | /** Get the first Resource Data element contained in a named object. | ||||||
|  |  | ||||||
|   In the following ASL code, the function will return the Resource Data |   In the following ASL code, the function will return the Resource Data | ||||||
|   node corresponding to the "QWordMemory ()" ASL macro. |   node corresponding to the "QWordMemory ()" ASL macro. | ||||||
| @@ -233,16 +233,15 @@ AmlNameOpUpdateString ( | |||||||
|   ) |   ) | ||||||
|  |  | ||||||
|   Note: |   Note: | ||||||
|    - The "_CRS" object must be declared using ASL "Name (Declare Named Object)". |   "_CRS" names defined as methods are not handled by this function. | ||||||
|    - "_CRS" declared using ASL "Method (Declare Control Method)" is not |   They must be defined as names, using the "Name ()" statement. | ||||||
|      supported. |  | ||||||
|  |  | ||||||
|   @param  [in] NameOpCrsNode  NameOp object node defining a "_CRS" object. |   @param  [in] NameOpNode   NameOp object node defining a named object. | ||||||
|                             Must have an OpCode=AML_NAME_OP, SubOpCode=0. |                             Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|                             NameOp object nodes are defined in ASL |                             NameOp object nodes are defined in ASL | ||||||
|                             using the "Name ()" function. |                             using the "Name ()" function. | ||||||
|   @param  [out] OutRdNode   Pointer to the first Resource Data element of |   @param  [out] OutRdNode   Pointer to the first Resource Data element of | ||||||
|                               the "_CRS" object. A Resource Data element |                             the named object. A Resource Data element | ||||||
|                             is stored in a data node. |                             is stored in a data node. | ||||||
|  |  | ||||||
|   @retval EFI_SUCCESS             The function completed successfully. |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
| @@ -250,18 +249,17 @@ AmlNameOpUpdateString ( | |||||||
| **/ | **/ | ||||||
| EFI_STATUS | EFI_STATUS | ||||||
| EFIAPI | EFIAPI | ||||||
| AmlNameOpCrsGetFirstRdNode ( | AmlNameOpGetFirstRdNode ( | ||||||
|   IN  AML_OBJECT_NODE_HANDLE   NameOpCrsNode, |   IN  AML_OBJECT_NODE_HANDLE   NameOpNode, | ||||||
|   OUT AML_DATA_NODE_HANDLE   * OutRdNode |   OUT AML_DATA_NODE_HANDLE   * OutRdNode | ||||||
|   ) |   ) | ||||||
| { | { | ||||||
|   AML_OBJECT_NODE_HANDLE  BufferOpNode; |   AML_OBJECT_NODE_HANDLE  BufferOpNode; | ||||||
|   AML_DATA_NODE_HANDLE    FirstRdNode; |   AML_DATA_NODE_HANDLE    FirstRdNode; | ||||||
|  |  | ||||||
|   if ((NameOpCrsNode == NULL)                                              || |   if ((NameOpNode == NULL)                                              || | ||||||
|       (AmlGetNodeType ((AML_NODE_HANDLE)NameOpCrsNode) != EAmlNodeObject)  || |       (AmlGetNodeType ((AML_NODE_HANDLE)NameOpNode) != EAmlNodeObject)  || | ||||||
|       (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0))                  || |       (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0))                  || | ||||||
|       (!AmlNameOpCompareName (NameOpCrsNode, "_CRS"))                      || |  | ||||||
|       (OutRdNode == NULL)) { |       (OutRdNode == NULL)) { | ||||||
|     ASSERT (0); |     ASSERT (0); | ||||||
|     return EFI_INVALID_PARAMETER; |     return EFI_INVALID_PARAMETER; | ||||||
| @@ -269,10 +267,10 @@ AmlNameOpCrsGetFirstRdNode ( | |||||||
|  |  | ||||||
|   *OutRdNode = NULL; |   *OutRdNode = NULL; | ||||||
|  |  | ||||||
|   // Get the _CRS value which is represented as a BufferOp object node |   // Get the value of the variable which is represented as a BufferOp object | ||||||
|   // which is the 2nd fixed argument (i.e. index 1). |   // node which is the 2nd fixed argument (i.e. index 1). | ||||||
|   BufferOpNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( |   BufferOpNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( | ||||||
|                                            NameOpCrsNode, |                                            NameOpNode, | ||||||
|                                            EAmlParseIndexTerm1 |                                            EAmlParseIndexTerm1 | ||||||
|                                            ); |                                            ); | ||||||
|   if ((BufferOpNode == NULL)                                             || |   if ((BufferOpNode == NULL)                                             || | ||||||
| @@ -310,11 +308,12 @@ AmlNameOpCrsGetFirstRdNode ( | |||||||
|     } |     } | ||||||
|   ) |   ) | ||||||
|  |  | ||||||
|   The CurrRdNode Resource Data node must be defined in an object named "_CRS" |   Note: | ||||||
|   and defined by a "Name ()" ASL function. |   "_CRS" names defined as methods are not handled by this function. | ||||||
|  |   They must be defined as names, using the "Name ()" statement. | ||||||
|  |  | ||||||
|   @param  [in]  CurrRdNode   Pointer to the current Resource Data element of |   @param  [in]  CurrRdNode   Pointer to the current Resource Data element of | ||||||
|                              the "_CRS" object. |                              the named object. | ||||||
|   @param  [out] OutRdNode    Pointer to the Resource Data element following |   @param  [out] OutRdNode    Pointer to the Resource Data element following | ||||||
|                              the CurrRdNode. |                              the CurrRdNode. | ||||||
|                              Contain a NULL pointer if CurrRdNode is the |                              Contain a NULL pointer if CurrRdNode is the | ||||||
| @@ -327,12 +326,12 @@ AmlNameOpCrsGetFirstRdNode ( | |||||||
| **/ | **/ | ||||||
| EFI_STATUS | EFI_STATUS | ||||||
| EFIAPI | EFIAPI | ||||||
| AmlNameOpCrsGetNextRdNode ( | AmlNameOpGetNextRdNode ( | ||||||
|   IN  AML_DATA_NODE_HANDLE    CurrRdNode, |   IN  AML_DATA_NODE_HANDLE    CurrRdNode, | ||||||
|   OUT AML_DATA_NODE_HANDLE  * OutRdNode |   OUT AML_DATA_NODE_HANDLE  * OutRdNode | ||||||
|   ) |   ) | ||||||
| { | { | ||||||
|   AML_OBJECT_NODE_HANDLE     NameOpCrsNode; |   AML_OBJECT_NODE_HANDLE     NameOpNode; | ||||||
|   AML_OBJECT_NODE_HANDLE     BufferOpNode; |   AML_OBJECT_NODE_HANDLE     BufferOpNode; | ||||||
|  |  | ||||||
|   if ((CurrRdNode == NULL)                                              || |   if ((CurrRdNode == NULL)                                              || | ||||||
| @@ -356,12 +355,11 @@ AmlNameOpCrsGetNextRdNode ( | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // The parent of the BufferOpNode must be a NameOp node. |   // The parent of the BufferOpNode must be a NameOp node. | ||||||
|   NameOpCrsNode = (AML_OBJECT_NODE_HANDLE)AmlGetParent ( |   NameOpNode = (AML_OBJECT_NODE_HANDLE)AmlGetParent ( | ||||||
|                                          (AML_NODE_HANDLE)BufferOpNode |                                          (AML_NODE_HANDLE)BufferOpNode | ||||||
|                                          ); |                                          ); | ||||||
|   if ((NameOpCrsNode == NULL)                             || |   if ((NameOpNode == NULL)  || | ||||||
|       (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0)) || |       (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0))) { | ||||||
|       (!AmlNameOpCompareName (NameOpCrsNode, "_CRS"))) { |  | ||||||
|     ASSERT (0); |     ASSERT (0); | ||||||
|     return EFI_INVALID_PARAMETER; |     return EFI_INVALID_PARAMETER; | ||||||
|   } |   } | ||||||
| @@ -380,3 +378,88 @@ AmlNameOpCrsGetNextRdNode ( | |||||||
|  |  | ||||||
|   return EFI_SUCCESS; |   return EFI_SUCCESS; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // DEPRECATED APIS | ||||||
|  | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES | ||||||
|  |  | ||||||
|  | /** DEPRECATED API | ||||||
|  |  | ||||||
|  |   Get the first Resource Data element contained in a "_CRS" object. | ||||||
|  |  | ||||||
|  |   In the following ASL code, the function will return the Resource Data | ||||||
|  |   node corresponding to the "QWordMemory ()" ASL macro. | ||||||
|  |   Name (_CRS, ResourceTemplate() { | ||||||
|  |       QWordMemory (...) {...}, | ||||||
|  |       Interrupt (...) {...} | ||||||
|  |     } | ||||||
|  |   ) | ||||||
|  |  | ||||||
|  |   Note: | ||||||
|  |    - The "_CRS" object must be declared using ASL "Name (Declare Named Object)". | ||||||
|  |    - "_CRS" declared using ASL "Method (Declare Control Method)" is not | ||||||
|  |      supported. | ||||||
|  |  | ||||||
|  |   @ingroup UserApis | ||||||
|  |  | ||||||
|  |   @param  [in] NameOpCrsNode  NameOp object node defining a "_CRS" object. | ||||||
|  |                               Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|  |                               NameOp object nodes are defined in ASL | ||||||
|  |                               using the "Name ()" function. | ||||||
|  |   @param  [out] OutRdNode     Pointer to the first Resource Data element of | ||||||
|  |                               the "_CRS" object. A Resource Data element | ||||||
|  |                               is stored in a data node. | ||||||
|  |  | ||||||
|  |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
|  |   @retval EFI_INVALID_PARAMETER   Invalid parameter. | ||||||
|  | **/ | ||||||
|  | EFI_STATUS | ||||||
|  | EFIAPI | ||||||
|  | AmlNameOpCrsGetFirstRdNode ( | ||||||
|  |   IN  AML_OBJECT_NODE_HANDLE   NameOpCrsNode, | ||||||
|  |   OUT AML_DATA_NODE_HANDLE   * OutRdNode | ||||||
|  |   ) | ||||||
|  | { | ||||||
|  |   return AmlNameOpGetFirstRdNode (NameOpCrsNode, OutRdNode); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** DEPRECATED API | ||||||
|  |  | ||||||
|  |   Get the Resource Data element following the CurrRdNode Resource Data. | ||||||
|  |  | ||||||
|  |   In the following ASL code, if CurrRdNode corresponds to the first | ||||||
|  |   "QWordMemory ()" ASL macro, the function will return the Resource Data | ||||||
|  |   node corresponding to the "Interrupt ()" ASL macro. | ||||||
|  |   Name (_CRS, ResourceTemplate() { | ||||||
|  |       QwordMemory (...) {...}, | ||||||
|  |       Interrupt (...) {...} | ||||||
|  |     } | ||||||
|  |   ) | ||||||
|  |  | ||||||
|  |   The CurrRdNode Resource Data node must be defined in an object named "_CRS" | ||||||
|  |   and defined by a "Name ()" ASL function. | ||||||
|  |  | ||||||
|  |   @ingroup UserApis | ||||||
|  |  | ||||||
|  |   @param  [in]  CurrRdNode   Pointer to the current Resource Data element of | ||||||
|  |                              the "_CRS" variable. | ||||||
|  |   @param  [out] OutRdNode    Pointer to the Resource Data element following | ||||||
|  |                              the CurrRdNode. | ||||||
|  |                              Contain a NULL pointer if CurrRdNode is the | ||||||
|  |                              last Resource Data element in the list. | ||||||
|  |                              The "End Tag" is not considered as a resource | ||||||
|  |                              data element and is not returned. | ||||||
|  |  | ||||||
|  |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
|  |   @retval EFI_INVALID_PARAMETER   Invalid parameter. | ||||||
|  | **/ | ||||||
|  | EFI_STATUS | ||||||
|  | EFIAPI | ||||||
|  | AmlNameOpCrsGetNextRdNode ( | ||||||
|  |   IN  AML_DATA_NODE_HANDLE    CurrRdNode, | ||||||
|  |   OUT AML_DATA_NODE_HANDLE  * OutRdNode | ||||||
|  |   ) | ||||||
|  | { | ||||||
|  |   return AmlNameOpGetNextRdNode (CurrRdNode, OutRdNode); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #endif // DISABLE_NEW_DEPRECATED_INTERFACES | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /** @file | /** @file | ||||||
|   AML Resource Data Code Generation. |   AML Resource Data Code Generation. | ||||||
|  |  | ||||||
|   Copyright (c) 2020, Arm Limited. All rights reserved.<BR> |   Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR> | ||||||
|  |  | ||||||
|   SPDX-License-Identifier: BSD-2-Clause-Patent |   SPDX-License-Identifier: BSD-2-Clause-Patent | ||||||
|  |  | ||||||
| @@ -161,6 +161,109 @@ AmlCodeGenInterrupt ( | |||||||
|   This function creates a Resource Data element corresponding to the |   This function creates a Resource Data element corresponding to the | ||||||
|   "Interrupt ()" ASL function, stores it in an AML Data Node. |   "Interrupt ()" ASL function, stores it in an AML Data Node. | ||||||
|  |  | ||||||
|  |   It then adds it after the input NameOpNode in the list of resource data | ||||||
|  |   element. | ||||||
|  |  | ||||||
|  |   The Resource Data effectively created is an Extended Interrupt Resource | ||||||
|  |   Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor" | ||||||
|  |   for more information about Extended Interrupt Resource Data. | ||||||
|  |  | ||||||
|  |   The Extended Interrupt contains one single interrupt. | ||||||
|  |  | ||||||
|  |   This function allocates memory to create a data node. It is the caller's | ||||||
|  |   responsibility to either: | ||||||
|  |    - attach this node to an AML tree; | ||||||
|  |    - delete this node. | ||||||
|  |  | ||||||
|  |   Note: | ||||||
|  |   The named node must be defined using the ASL "Name ()" statement. | ||||||
|  |   E.g. Name (_CRS, ResourceTemplate () { ... }) | ||||||
|  |   Methods cannot be modified with this function. | ||||||
|  |  | ||||||
|  |   @param  [in]  NameOpNode       NameOp object node defining a named object. | ||||||
|  |                                  Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|  |                                  NameOp object nodes are defined in ASL | ||||||
|  |                                  using the "Name ()" function. | ||||||
|  |   @param  [in]  ResourceConsumer The device consumes the specified interrupt | ||||||
|  |                                  or produces it for use by a child device. | ||||||
|  |   @param  [in]  EdgeTriggered    The interrupt is edge triggered or | ||||||
|  |                                  level triggered. | ||||||
|  |   @param  [in]  ActiveLow        The interrupt is active-high or active-low. | ||||||
|  |   @param  [in]  Shared           The interrupt can be shared with other | ||||||
|  |                                  devices or not (Exclusive). | ||||||
|  |   @param  [in]  IrqList          Interrupt list. Must be non-NULL. | ||||||
|  |   @param  [in]  IrqCount         Interrupt count. Must be non-zero. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   @retval EFI_SUCCESS             The function completed successfully. | ||||||
|  |   @retval EFI_INVALID_PARAMETER   Invalid parameter. | ||||||
|  |   @retval EFI_OUT_OF_RESOURCES    Could not allocate memory. | ||||||
|  | **/ | ||||||
|  | EFI_STATUS | ||||||
|  | EFIAPI | ||||||
|  | AmlCodeGenAddRdInterrupt ( | ||||||
|  |   IN  AML_OBJECT_NODE_HANDLE  NameOpNode, | ||||||
|  |   IN  BOOLEAN                 ResourceConsumer, | ||||||
|  |   IN  BOOLEAN                 EdgeTriggered, | ||||||
|  |   IN  BOOLEAN                 ActiveLow, | ||||||
|  |   IN  BOOLEAN                 Shared, | ||||||
|  |   IN  UINT32                * IrqList, | ||||||
|  |   IN  UINT8                   IrqCount | ||||||
|  |   ) | ||||||
|  | { | ||||||
|  |   EFI_STATUS              Status; | ||||||
|  |  | ||||||
|  |   AML_OBJECT_NODE_HANDLE  BufferOpNode; | ||||||
|  |  | ||||||
|  |   if ((IrqList == NULL)                                   || | ||||||
|  |       (IrqCount == 0)                                     || | ||||||
|  |       (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0))) { | ||||||
|  |     ASSERT (0); | ||||||
|  |     return EFI_INVALID_PARAMETER; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // Get the value which is represented as a BufferOp object node | ||||||
|  |   // which is the 2nd fixed argument (i.e. index 1). | ||||||
|  |   BufferOpNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( | ||||||
|  |                                            NameOpNode, | ||||||
|  |                                            EAmlParseIndexTerm1 | ||||||
|  |                                            ); | ||||||
|  |   if ((BufferOpNode == NULL)                                             || | ||||||
|  |       (AmlGetNodeType ((AML_NODE_HANDLE)BufferOpNode) != EAmlNodeObject) || | ||||||
|  |       (!AmlNodeHasOpCode (BufferOpNode, AML_BUFFER_OP, 0))) { | ||||||
|  |     ASSERT (0); | ||||||
|  |     return EFI_INVALID_PARAMETER; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // Generate the Extended Interrupt Resource Data node, | ||||||
|  |   // and attach it as the last variable argument of the BufferOpNode. | ||||||
|  |   Status = AmlCodeGenInterrupt ( | ||||||
|  |              ResourceConsumer, | ||||||
|  |              EdgeTriggered, | ||||||
|  |              ActiveLow, | ||||||
|  |              Shared, | ||||||
|  |              IrqList, | ||||||
|  |              IrqCount, | ||||||
|  |              BufferOpNode, | ||||||
|  |              NULL | ||||||
|  |              ); | ||||||
|  |   if (EFI_ERROR (Status)) { | ||||||
|  |     ASSERT (0); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   return Status; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // DEPRECATED APIS | ||||||
|  | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES | ||||||
|  |  | ||||||
|  | /** DEPRECATED API | ||||||
|  |  | ||||||
|  |   Add an Interrupt Resource Data node. | ||||||
|  |  | ||||||
|  |   This function creates a Resource Data element corresponding to the | ||||||
|  |   "Interrupt ()" ASL function, stores it in an AML Data Node. | ||||||
|  |  | ||||||
|   It then adds it after the input CurrRdNode in the list of resource data |   It then adds it after the input CurrRdNode in the list of resource data | ||||||
|   element. |   element. | ||||||
|  |  | ||||||
| @@ -180,6 +283,8 @@ AmlCodeGenInterrupt ( | |||||||
|                ... |                ... | ||||||
|              } |              } | ||||||
|  |  | ||||||
|  |   @ingroup UserApis | ||||||
|  |  | ||||||
|   @param  [in]  NameOpCrsNode    NameOp object node defining a "_CRS" object. |   @param  [in]  NameOpCrsNode    NameOp object node defining a "_CRS" object. | ||||||
|                                  Must have an OpCode=AML_NAME_OP, SubOpCode=0. |                                  Must have an OpCode=AML_NAME_OP, SubOpCode=0. | ||||||
|                                  NameOp object nodes are defined in ASL |                                  NameOp object nodes are defined in ASL | ||||||
| @@ -211,46 +316,16 @@ AmlCodeGenCrsAddRdInterrupt ( | |||||||
|   IN  UINT8                   IrqCount |   IN  UINT8                   IrqCount | ||||||
|   ) |   ) | ||||||
| { | { | ||||||
|   EFI_STATUS              Status; |   return AmlCodeGenAddRdInterrupt ( | ||||||
|  |  | ||||||
|   AML_OBJECT_NODE_HANDLE  BufferOpNode; |  | ||||||
|  |  | ||||||
|   if ((IrqList == NULL)                                                   || |  | ||||||
|       (IrqCount == 0)                                                     || |  | ||||||
|       (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0))                 || |  | ||||||
|       (!AmlNameOpCompareName (NameOpCrsNode, "_CRS"))) { |  | ||||||
|     ASSERT (0); |  | ||||||
|     return EFI_INVALID_PARAMETER; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Get the _CRS value which is represented as a BufferOp object node |  | ||||||
|   // which is the 2nd fixed argument (i.e. index 1). |  | ||||||
|   BufferOpNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( |  | ||||||
|            NameOpCrsNode, |            NameOpCrsNode, | ||||||
|                                            EAmlParseIndexTerm1 |            NameOpNode, | ||||||
|                                            ); |  | ||||||
|   if ((BufferOpNode == NULL)                                             || |  | ||||||
|       (AmlGetNodeType ((AML_NODE_HANDLE)BufferOpNode) != EAmlNodeObject) || |  | ||||||
|       (!AmlNodeHasOpCode (BufferOpNode, AML_BUFFER_OP, 0))) { |  | ||||||
|     ASSERT (0); |  | ||||||
|     return EFI_INVALID_PARAMETER; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Generate the Extended Interrupt Resource Data node, |  | ||||||
|   // and attach it as the last variable argument of the BufferOpNode. |  | ||||||
|   Status = AmlCodeGenInterrupt ( |  | ||||||
|            ResourceConsumer, |            ResourceConsumer, | ||||||
|            EdgeTriggered, |            EdgeTriggered, | ||||||
|            ActiveLow, |            ActiveLow, | ||||||
|            Shared, |            Shared, | ||||||
|            IrqList, |            IrqList, | ||||||
|              IrqCount, |            IrqCount | ||||||
|              BufferOpNode, |  | ||||||
|              NULL |  | ||||||
|            ); |            ); | ||||||
|   if (EFI_ERROR (Status)) { |  | ||||||
|     ASSERT (0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return Status; |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #endif // DISABLE_NEW_DEPRECATED_INTERFACES | ||||||
|   | |||||||
| @@ -275,7 +275,7 @@ FixupCrs ( | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Get the first Rd node in the "_CRS" object. |   // Get the first Rd node in the "_CRS" object. | ||||||
|   Status = AmlNameOpCrsGetFirstRdNode (NameOpCrsNode, &QWordRdNode); |   Status = AmlNameOpGetFirstRdNode (NameOpCrsNode, &QWordRdNode); | ||||||
|   if (EFI_ERROR (Status)) { |   if (EFI_ERROR (Status)) { | ||||||
|     return Status; |     return Status; | ||||||
|   } |   } | ||||||
| @@ -298,7 +298,7 @@ FixupCrs ( | |||||||
|   // Get the Interrupt node. |   // Get the Interrupt node. | ||||||
|   // It is the second Resource Data element in the NameOpCrsNode's |   // It is the second Resource Data element in the NameOpCrsNode's | ||||||
|   // variable list of arguments. |   // variable list of arguments. | ||||||
|   Status = AmlNameOpCrsGetNextRdNode (QWordRdNode, &InterruptRdNode); |   Status = AmlNameOpGetNextRdNode (QWordRdNode, &InterruptRdNode); | ||||||
|   if (EFI_ERROR (Status)) { |   if (EFI_ERROR (Status)) { | ||||||
|     return Status; |     return Status; | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user