Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-09-21 Thread Jeff Brasen via groups.io
Anything else needed to get this merged?

> -Original Message-
> From: Ard Biesheuvel 
> Sent: Thursday, September 8, 2022 9:55 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [edk2-devel] [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> 
> External email: Use caution opening links or attachments
> 
> 
> On Thu, 8 Sept 2022 at 17:39, Jeff Brasen  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: Ard Biesheuvel 
> > > Sent: Monday, August 15, 2022 8:42 AM
> > > To: devel@edk2.groups.io; Jeff Brasen 
> > > Cc: hao.a...@intel.com; ray...@intel.com; quic_llind...@quicinc.com;
> > > ardb+tianoc...@kernel.org
> > > Subject: Re: [edk2-devel] [PATCH v2]
> > > MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > On Fri, 5 Aug 2022 at 18:56, Jeff Brasen via groups.io
> > >  wrote:
> > > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Ard Biesheuvel 
> > > > > Sent: Tuesday, August 2, 2022 10:51 AM
> > > > > To: Jeff Brasen 
> > > > > Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> > > > > quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> > > > > Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > > > Allow partial FreeBuffer
> > > > >
> > > > > External email: Use caution opening links or attachments
> > > > >
> > > > >
> > > > > On Tue, 2 Aug 2022 at 17:32, Jeff Brasen  wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > > -Original Message-
> > > > > > > From: Ard Biesheuvel 
> > > > > > > Sent: Friday, July 29, 2022 9:48 AM
> > > > > > > To: Jeff Brasen 
> > > > > > > Cc: devel@edk2.groups.io; hao.a...@intel.com;
> > > > > > > ray...@intel.com; quic_llind...@quicinc.com;
> > > > > > > ardb+tianoc...@kernel.org
> > > > > > > Subject: Re: [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > > > > > Allow partial FreeBuffer
> > > > > > >
> > > > > > > External email: Use caution opening links or attachments
> > > > > > >
> > > > > > >
> > > > > > > On Thu, 28 Jul 2022 at 13:25, Jeff Brasen 
> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > Adding Leif/Ard to CC incase they have any comments on this 
> > > > > > > > patch.
> > > > > > > >
> > > > > > >
> > > > > > > This generally looks ok to me. I just wonder if it wouldn't
> > > > > > > be simpler to reuse the existing allocation descriptor if it
> > > > > > > is not being freed entirely. Given the [presumably] the most
> > > > > > > common case is to allocate and then free some pages at the
> > > > > > > end, lowering the page count on the existing descriptor
> > > > > > > would cover most cases, and we'd only need to allocate new
> > > > > > > ones if pages are being freed at the start or in
> > > > > the middle.
> > > > > >
> > > > > > There is often freeing at the beginning as well as this is
> > > > > > being used to create
> > > > > a 64K aligned section of memory in the case. So it over
> > > > > allocates and the free's some at the beginning and the end. I
> > > > > could probably make it detect and use that but figured this code
> > > > > would support all cases and required less case specific detection.
> > > > > >
> > > > >
> > > > > Ah interesting. Would it help if the allocate routine aligned
> > > > > allocations to their size?
> > > >
> > > > The PciIo->AllocateBuffer function doesn't support passing the
> > > > request in so
> > > we would need to know that info beforehand. The current calling in
> &g

Re: [edk2-devel] [PATCH v4 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-20 Thread Jeff Brasen via groups.io
Thanks will fix those in v5. Will see if Sami has any other comments before 
pushing these.


-Jeff


> -Original Message-
> From: Pierre Gondois 
> Sent: Tuesday, September 20, 2022 8:54 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: ardb+tianoc...@kernel.org; alexei.fedo...@arm.com; n...@arm.com;
> sami.muja...@arm.com
> Subject: Re: [PATCH v4 2/3] DynamicTablesPkg: AML Code generation to add
> _CPC entries
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> Just 2 minors comments. Maybe Sami will have more.
> Otherwise, for the 3 patches:
> Reviewed-by: Pierre Gondois 
> 
> Regards,
> Pierre
> 
> On 9/20/22 00:01, Jeff Brasen wrote:
> > _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 
> > ---
> >   .../Include/Library/AmlLib/AmlLib.h   |  54 ++
> >   .../Common/AmlLib/CodeGen/AmlCodeGen.c| 476
> ++
> >   2 files changed, 530 insertions(+)
> >
> > diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > index 39968660f2..ebaccba811 100644
> > --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> > +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> 
> [snip]
> 
> > +
> > +/** Adds an integer or register to the package
> > +
> > +  @ingroup CodeGenApis
> > +
> > +  @param [in]  Register If provided, register that will be added to
> package
> > +  @param [in]  Integer  If Register is NULL, integer that will be 
> > added to
> the package
> > +  @param [in]  PackageNode  Package to add value to
> > +
> > +  @retval EFI_SUCCESS The function completed successfully.
> > +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> > +  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +EFIAPI
> > +AmlAddRegisterOrIntegerToPackage (
> > +  IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  *Register OPTIONAL,
> > +  IN UINT32  Integer,
> > +  IN AML_OBJECT_NODE_HANDLE  PackageNode
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  AML_OBJECT_NODE_HANDLE  IntegerNode;
> > +
> > +  IntegerNode = NULL;
> > +
> 
> I think that with IsNullGenericAddress(), the first
>   (Register != NULL)
> is not necessary.
> 
> > +  if ((Register != NULL) && !IsNullGenericAddress (Register)) {
> > +Status = AmlAddRegisterToPackage (Register, PackageNode);  } else
> > + {
> > +Status = AmlCodeGenInteger (Integer, &IntegerNode);
> > +if (EFI_ERROR (Status)) {
> > +  ASSERT_EFI_ERROR (Status);
> > +  return Status;
> > +}
> > +
> > +Status = AmlVarListAddTail (
> > +   (AML_NODE_HANDLE)PackageNode,
> > +   (AML_NODE_HANDLE)IntegerNode
> > +   );
> > +  }
> > +
> > +  if (EFI_ERROR (Status)) {
> > +ASSERT_EFI_ERROR (Status);
> > +if (IntegerNode != NULL) {
> > +  AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode);
> > +}
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +/** Create a _CPC node.
> > +
> > +  Creates and optionally adds the following node
> > +   Name(_CPC, Package()
> > +   {
> > +NumEntries,  // Integer
> > +Revision,// Integer
> > +HighestPerformance,  // Integer or Buffer (Resource
> Descriptor)
> > +NominalPerformance,  // Integer or Buffer (Resource
> Descriptor)
> > +LowestNonlinearPerformance,  // Integer or Buffer (Resource
> Descriptor)
> > +LowestPerformance,   // Integer or Buffer (Resource
> Descriptor)
> > +GuaranteedPerformanceRegister,   // Buffer (Resource 
> > Descriptor)
> > +DesiredPerformanceRegister , // Buffer (Resource 
> > Descriptor)
> > +MinimumPerformanceRegister , // Buffer (Resource 
> > Descriptor)
> > +MaximumPerformanceRegister , // Buffer (Resource 
> > Descriptor)
> > +PerformanceReductionToleranceRegister,   // Buffer (Resource
> Descriptor)
> > +TimeWindowRegister,  // Buffer (Resource 
> > Descriptor)
> > +CounterWraparoundTime,   // Integer or Buffer (Resource
> Descriptor)
> > +ReferencePerformanceCounterRegister, // Buffer (Resource
> Descriptor)
> > +DeliveredPerformanceCounterRegister, // Buffer (Resource
> Descriptor)
> > +PerformanceLimitedRegister,  // Buffer (Resource 
> > Descriptor)
> > +CPPCEnableRegister   // Buffer (Resource 
> > Descriptor)
> > +AutonomousSelectionEnable,   // Integer or Buffer (Resource
> Descriptor)
> > +AutonomousActivityWindowRegister,// Buff

[edk2-devel] [PATCH v4 3/3] DynamicTablesPkg: SSDT CPU _CPC generator

2022-09-19 Thread Jeff Brasen via groups.io
Add code to use a token attached to GICC to generate _CPC object on cpus.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 133 +-

 1 file changed, 127 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 8561f48e1f..22422aef75 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -76,6 +76,16 @@ GET_OBJECT_LIST (

   CM_ARM_LPI_INFO

   );

 

+/**

+  This macro expands to a function that retrieves the CPC

+  information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceArm,

+  EArmObjCpcInfo,

+  CM_ARM_CPC_INFO

+  );

+

 /** Initialize the TokenTable.

 

   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO

@@ -229,6 +239,93 @@ WriteAslName (

   return EFI_SUCCESS;

 }

 

+/** Create and add an _CPC Node to Cpu Node.

+

+  For instance, transform an AML node from:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  }

+

+  To:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  Name(_CPC, Package()

+  {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer 
(Resource Descriptor)

+NominalPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestPerformance,   // Integer or Buffer 
(Resource Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource 
Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource 
Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource 
Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource 
Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource 
Descriptor)

+TimeWindowRegister,  // Buffer (Resource 
Descriptor)

+CounterWraparoundTime,   // Integer or Buffer 
(Resource Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource 
Descriptor)

+CPPCEnableRegister   // Buffer (Resource 
Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer 
(Resource Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource 
Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource 
Descriptor)

+ReferencePerformance // Integer or Buffer 
(Resource Descriptor)

+LowestFrequency, // Integer or Buffer 
(Resource Descriptor)

+NominalFrequency // Integer or Buffer 
(Resource Descriptor)

+  })

+  }

+

+  @param [in]  Generator  The SSDT Cpu Topology generator.

+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

+  Protocol Interface.

+  @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

+  the Cpu.

+  @param [in]  Node   CPU Node to which the _CPC node is

+  attached.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+CreateAmlCpcNode (

+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  INCM_ARM_GICC_INFO  *GicCInfo,

+  IN  AML_OBJECT_NODE_HANDLE  *Node

+  )

+{

+  EFI_STATUS   Status;

+  CM_ARM_CPC_INFO  *CpcInfo;

+

+  Status = GetEArmObjCpcInfo (

+ CfgMgrProtocol,

+ GicCInfo->CpcToken,

+ &CpcInfo,

+ NULL

+ );

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = AmlCreateCpcNode (

+ CpcInfo,

+ Node,

+ NULL

+ );

+  ASSERT_EFI_ERROR (Status);

+  return Status;

+}

+

 /** Create and add an _LPI method to Cpu/Cluster Node.

 

   For instance, transform 

[edk2-devel] [PATCH v4 0/3] DynamicTablesPkg: _CPC support

2022-09-19 Thread Jeff Brasen via groups.io
Add generator for creating the _CPC object for CPU nodes.

If viewing this review by a pull request is helpful one exists here:
https://github.com/NVIDIA/edk2/pull/12

Change Log:
v1 - Initial Revision
v2 - Added revision to object, improved error handling, changed to ACPI 6.4 
structures.
v3 - Minor review feedback
v4 - Convert CpcInfo to structure and use that for APIs

Jeff Brasen (3):
  DynamicTablesPkg: Add CM_ARM_CPC_INFO object
  DynamicTablesPkg: AML Code generation to add _CPC entries
  DynamicTablesPkg: SSDT CPU _CPC generator

 .../Include/ArmNameSpaceObjects.h |  60 ++-
 DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 +
 .../Include/Library/AmlLib/AmlLib.h   |  54 ++
 .../SsdtCpuTopologyGenerator.c| 133 -
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 476 ++
 .../ConfigurationManagerObjectParser.c|  80 +++
 6 files changed, 904 insertions(+), 23 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93969): https://edk2.groups.io/g/devel/message/93969
Mute This Topic: https://groups.io/mt/93792019/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-19 Thread Jeff Brasen via groups.io
_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 

---

 .../Include/Library/AmlLib/AmlLib.h   |  54 ++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 476 ++

 2 files changed, 530 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 39968660f2..ebaccba811 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -37,6 +37,7 @@

 */

 

 #include 

+#include 

 

 #ifndef AML_HANDLE

 

@@ -1336,6 +1337,59 @@ AmlAddNameIntegerPackage (

   IN AML_OBJECT_NODE_HANDLE  PackageNode

   );

 

+/** Create a _CPC node.

+

+  Creates and optionally adds the following node

+   Name(_CPC, Package()

+   {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer (Resource 
Descriptor)

+NominalPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestPerformance,   // Integer or Buffer (Resource 
Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource Descriptor)

+TimeWindowRegister,  // Buffer (Resource Descriptor)

+CounterWraparoundTime,   // Integer or Buffer (Resource 
Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource Descriptor)

+CPPCEnableRegister   // Buffer (Resource Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer (Resource 
Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)

+ReferencePerformance // Integer or Buffer (Resource 
Descriptor)

+LowestFrequency, // Integer or Buffer (Resource 
Descriptor)

+NominalFrequency // Integer or Buffer (Resource 
Descriptor)

+  })

+

+  If resource buffer is NULL then integer will be used.

+

+  Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)

+

+  @ingroup CodeGenApis

+

+  @param [in]  CpcInfo   CpcInfo object

+  @param [in]  ParentNodeIf provided, set ParentNode as the parent

+ of the node created.

+  @param [out] NewCpcNodeIf success and provided, contains the 
created node.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlCreateCpcNode (

+  IN  AML_CPC_INFO*CpcInfo,

+  IN  AML_NODE_HANDLE ParentNode   OPTIONAL,

+  OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL

+  );

+

 // DEPRECATED APIS

 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES

 

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index 5fb39d077b..fc85c467ec 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -14,6 +14,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 #include 

 #include 

@@ -2850,3 +2851,478 @@ error_handler:

 

   return Status;

 }

+

+/** Adds a register to the package

+

+  @ingroup CodeGenApis

+

+  @param [in]  Register If provided, register that will be added to 
package.

+otherwise NULL register will be added

+  @param [in]  PackageNode  Package to add value to

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+AmlAddRegisterToPackage (

+  IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  *Register OPTIONAL,

+  IN AML_OBJECT_NODE_HANDLE  PackageNode

+  )

+{

+  EFI_STATUS  Status;

+  AM

[edk2-devel] [PATCH v4 1/3] DynamicTablesPkg: Add CM_ARM_CPC_INFO object

2022-09-19 Thread Jeff Brasen via groups.io
Introduce the CM_ARM_CPC_INFO CmObj in the ArmNameSpaceObjects.

This allows to describe CPC information, as described in ACPI 6.4,

s8.4.7.1 "_CPC (Continuous Performance Control)".



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h |  60 ++---

 DynamicTablesPkg/Include/Library/AmlCpcInfo.h | 124 ++

 .../ConfigurationManagerObjectParser.c|  80 +++

 3 files changed, 247 insertions(+), 17 deletions(-)

 create mode 100644 DynamicTablesPkg/Include/Library/AmlCpcInfo.h



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 102e0f96be..ea5bf81070 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -14,6 +14,7 @@

 #define ARM_NAMESPACE_OBJECTS_H_

 

 #include 

+#include 

 

 #pragma pack(1)

 

@@ -63,6 +64,7 @@ typedef enum ArmObjectID {

   EArmObjPciInterruptMapInfo,  ///< 39 - Pci Interrupt Map Info

   EArmObjRmr,  ///< 40 - Reserved Memory Range Node

   EArmObjMemoryRangeDescriptor,///< 41 - Memory Range Descriptor

+  EArmObjCpcInfo,  ///< 42 - Continuous Performance 
Control Info

   EArmObjMax

 } EARM_OBJECT_ID;

 

@@ -97,99 +99,105 @@ typedef struct CmArmPowerManagementProfileInfo {

 */

 typedef struct CmArmGicCInfo {

   /// The GIC CPU Interface number.

-  UINT32CPUInterfaceNumber;

+  UINT32 CPUInterfaceNumber;

 

   /** The ACPI Processor UID. This must match the

   _UID of the CPU Device object information described

   in the DSDT/SSDT for the CPU.

   */

-  UINT32AcpiProcessorUid;

+  UINT32 AcpiProcessorUid;

 

   /** The flags field as described by the GICC structure

   in the ACPI Specification.

   */

-  UINT32Flags;

+  UINT32 Flags;

 

   /** The parking protocol version field as described by

 the GICC structure in the ACPI Specification.

   */

-  UINT32ParkingProtocolVersion;

+  UINT32 ParkingProtocolVersion;

 

   /** The Performance Interrupt field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT32PerformanceInterruptGsiv;

+  UINT32 PerformanceInterruptGsiv;

 

   /** The CPU Parked address field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT64ParkedAddress;

+  UINT64 ParkedAddress;

 

   /** The base address for the GIC CPU Interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64PhysicalBaseAddress;

+  UINT64 PhysicalBaseAddress;

 

   /** The base address for GICV interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICV;

+  UINT64 GICV;

 

   /** The base address for GICH interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICH;

+  UINT64 GICH;

 

   /** The GICV maintenance interrupt

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT32VGICMaintenanceInterrupt;

+  UINT32 VGICMaintenanceInterrupt;

 

   /** The base address for GICR interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICRBaseAddress;

+  UINT64 GICRBaseAddress;

 

   /** The MPIDR for the CPU

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64MPIDR;

+  UINT64 MPIDR;

 

   /** The Processor Power Efficiency class

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT8 ProcessorPowerEfficiencyClass;

+  UINT8  ProcessorPowerEfficiencyClass;

 

   /** Statistical Profiling Extension buffer overflow GSIV. Zero if

   unsupported by this processor. This field was introduced in

   ACPI 6.3 (MADT revision 5) and is therefore ignored when

   generating MADT revision 4 or lower.

   */

-  UINT16SpeOverflowInterrupt;

+  UINT16 SpeOverflowInterrupt;

 

   /** The proximity domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ProximityDomain;

+  UINT32 ProximityDomain;

 

   /** The clock domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ClockDomain;

+  UINT32 ClockDomain;

 

   /** The GICC Affinity flags field as described by the GICC Affinity structure

   in the SRAT table.

   */

-  UINT32AffinityFlags;

+  UINT32 AffinityFlags;

+

+  /** Optional field: Reference Token for the Cpc info of this processor.

+ 

[edk2-devel] [PATCH v3 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-15 Thread Jeff Brasen via groups.io
_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 

---

 .../Include/Library/AmlLib/AmlLib.h   | 156 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 543 ++

 2 files changed, 699 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 39968660f2..3fafa6b0e8 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1336,6 +1336,162 @@ AmlAddNameIntegerPackage (

   IN AML_OBJECT_NODE_HANDLE  PackageNode

   );

 

+/** Create a _CPC node.

+

+  Creates and optionally adds the following node

+   Name(_CPC, Package()

+   {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer (Resource 
Descriptor)

+NominalPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestPerformance,   // Integer or Buffer (Resource 
Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource Descriptor)

+TimeWindowRegister,  // Buffer (Resource Descriptor)

+CounterWraparoundTime,   // Integer or Buffer (Resource 
Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource Descriptor)

+CPPCEnableRegister   // Buffer (Resource Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer (Resource 
Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)

+ReferencePerformance // Integer or Buffer (Resource 
Descriptor)

+LowestFrequency, // Integer or Buffer (Resource 
Descriptor)

+NominalFrequency // Integer or Buffer (Resource 
Descriptor)

+  })

+

+  If resource buffer is NULL then integer will be used.

+

+  Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)

+

+  @ingroup CodeGenApis

+

+  @param [in]  HighestPerformanceBuffer   If provided, buffer that 
indicates the highest level

+  of performance the 
processor.

+  @param [in]  HighestPerformanceInteger  Indicates the highest 
level of performance the processor,

+  used if buffer is NULL.

+  @param [in]  NominalPerformanceBuffer   If provided buffer that 
indicates the highest sustained

+  performance level of the 
processor.

+  @param [in]  NominalPerformanceInteger  Indicates the highest 
sustained performance level

+  of the processor, used 
if buffer is NULL.

+  @param [in]  LowestNonlinearPerformanceBuffer   If provided, buffer that 
indicates the lowest performance level

+  of the processor with 
non-linear power savings.

+  @param [in]  LowestNonlinearPerformanceInteger  Indicates the lowest 
performance level of the processor with

+  non-linear power 
savings, used if buffer is NULL.

+  @param [in]  LowestPerformanceBufferIf provided, buffer that 
indicates the

+  lowest performance level 
of the processor.

+  @param [in]  LowestPerformanceInteger   Indicates the lowest 
performance level of the processor,

+  used if buffer is NULL.

+  @param [in]  GuaranteedPerformanceRegister  If provided, Guaranteed 
Performance Register Buffer.

+  @param [in]  DesiredPerformanceRegister If provided, Desired 
Performance Register Buffer.

+  @param [in]  MinimumPerformanceRegister If provided, Minimum 
Performance Register Buffer.

+  @param [in]  MaximumPerformanceRegister 

[edk2-devel] [PATCH v3 0/3] DynamicTablesPkg: _CPC support

2022-09-15 Thread Jeff Brasen via groups.io
Add generator for creating the _CPC object for CPU nodes.

If viewing this review by a pull request is helpful one exists here:
https://github.com/NVIDIA/edk2/pull/12

Change Log:
v1 - Initial Revision
v2 - Added revision to object, improved error handling, changed to ACPI 6.4 
structures.
v3 - Minor review feedback

Jeff Brasen (3):
  DynamicTablesPkg: Add CM_ARM_CPC_INFO object
  DynamicTablesPkg: AML Code generation to add _CPC entries
  DynamicTablesPkg: SSDT CPU _CPC generator

 .../Include/ArmNameSpaceObjects.h | 148 -
 .../Include/Library/AmlLib/AmlLib.h   | 156 +
 .../SsdtCpuTopologyGenerator.c| 223 ++-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 543 ++
 .../ConfigurationManagerObjectParser.c|  80 +++
 5 files changed, 1127 insertions(+), 23 deletions(-)

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93828): https://edk2.groups.io/g/devel/message/93828
Mute This Topic: https://groups.io/mt/93699442/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 3/3] DynamicTablesPkg: SSDT CPU _CPC generator

2022-09-15 Thread Jeff Brasen via groups.io
Add code to use a token attached to GICC to generate _CPC object on cpus.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 223 +-

 1 file changed, 217 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 8561f48e1f..5d41d57064 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -76,6 +76,16 @@ GET_OBJECT_LIST (

   CM_ARM_LPI_INFO

   );

 

+/**

+  This macro expands to a function that retrieves the CPC

+  information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceArm,

+  EArmObjCpcInfo,

+  CM_ARM_CPC_INFO

+  );

+

 /** Initialize the TokenTable.

 

   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO

@@ -229,6 +239,183 @@ WriteAslName (

   return EFI_SUCCESS;

 }

 

+/** Utility function to check if generic address points to NULL

+

+  @param [in]  Address  Pointer to the Generic address

+

+  @retval TRUE  Address is system memory with an Address of 0.

+  @retval FALSE Address does not point to NULL.

+**/

+STATIC

+BOOLEAN

+EFIAPI

+IsNullGenericAddress (

+  IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  *Address

+  )

+{

+  if ((Address == NULL) ||

+  ((Address->AddressSpaceId == EFI_ACPI_6_4_SYSTEM_MEMORY) &&

+   (Address->Address == 0x0)))

+  {

+return TRUE;

+  }

+

+  return FALSE;

+}

+

+/** Create and add an _CPC Node to Cpu Node.

+

+  For instance, transform an AML node from:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  }

+

+  To:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  Name(_CPC, Package()

+  {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer 
(Resource Descriptor)

+NominalPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestPerformance,   // Integer or Buffer 
(Resource Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource 
Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource 
Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource 
Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource 
Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource 
Descriptor)

+TimeWindowRegister,  // Buffer (Resource 
Descriptor)

+CounterWraparoundTime,   // Integer or Buffer 
(Resource Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource 
Descriptor)

+CPPCEnableRegister   // Buffer (Resource 
Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer 
(Resource Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource 
Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource 
Descriptor)

+ReferencePerformance // Integer or Buffer 
(Resource Descriptor)

+LowestFrequency, // Integer or Buffer 
(Resource Descriptor)

+NominalFrequency // Integer or Buffer 
(Resource Descriptor)

+  })

+  }

+

+  @param [in]  Generator  The SSDT Cpu Topology generator.

+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

+  Protocol Interface.

+  @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

+  the Cpu.

+  @param [in]  Node   CPU Node to which the _CPC node is

+  attached.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+CreateAmlCpcNode (

+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  INCM_ARM_GICC_INFO  *GicCInfo,

+  IN  AML_OBJECT_NODE_HANDLE  

[edk2-devel] [PATCH v3 1/3] DynamicTablesPkg: Add CM_ARM_CPC_INFO object

2022-09-15 Thread Jeff Brasen via groups.io
Introduce the CM_ARM_CPC_INFO CmObj in the ArmNameSpaceObjects.

This allows to describe CPC information, as described in ACPI 6.4,

s8.4.7.1 "_CPC (Continuous Performance Control)".



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h | 148 --

 .../ConfigurationManagerObjectParser.c|  80 ++

 2 files changed, 211 insertions(+), 17 deletions(-)



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 102e0f96be..d76cc08e14 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -63,6 +63,7 @@ typedef enum ArmObjectID {

   EArmObjPciInterruptMapInfo,  ///< 39 - Pci Interrupt Map Info

   EArmObjRmr,  ///< 40 - Reserved Memory Range Node

   EArmObjMemoryRangeDescriptor,///< 41 - Memory Range Descriptor

+  EArmObjCpcInfo,  ///< 42 - Continuous Performance 
Control Info

   EArmObjMax

 } EARM_OBJECT_ID;

 

@@ -97,99 +98,105 @@ typedef struct CmArmPowerManagementProfileInfo {

 */

 typedef struct CmArmGicCInfo {

   /// The GIC CPU Interface number.

-  UINT32CPUInterfaceNumber;

+  UINT32 CPUInterfaceNumber;

 

   /** The ACPI Processor UID. This must match the

   _UID of the CPU Device object information described

   in the DSDT/SSDT for the CPU.

   */

-  UINT32AcpiProcessorUid;

+  UINT32 AcpiProcessorUid;

 

   /** The flags field as described by the GICC structure

   in the ACPI Specification.

   */

-  UINT32Flags;

+  UINT32 Flags;

 

   /** The parking protocol version field as described by

 the GICC structure in the ACPI Specification.

   */

-  UINT32ParkingProtocolVersion;

+  UINT32 ParkingProtocolVersion;

 

   /** The Performance Interrupt field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT32PerformanceInterruptGsiv;

+  UINT32 PerformanceInterruptGsiv;

 

   /** The CPU Parked address field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT64ParkedAddress;

+  UINT64 ParkedAddress;

 

   /** The base address for the GIC CPU Interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64PhysicalBaseAddress;

+  UINT64 PhysicalBaseAddress;

 

   /** The base address for GICV interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICV;

+  UINT64 GICV;

 

   /** The base address for GICH interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICH;

+  UINT64 GICH;

 

   /** The GICV maintenance interrupt

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT32VGICMaintenanceInterrupt;

+  UINT32 VGICMaintenanceInterrupt;

 

   /** The base address for GICR interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICRBaseAddress;

+  UINT64 GICRBaseAddress;

 

   /** The MPIDR for the CPU

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64MPIDR;

+  UINT64 MPIDR;

 

   /** The Processor Power Efficiency class

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT8 ProcessorPowerEfficiencyClass;

+  UINT8  ProcessorPowerEfficiencyClass;

 

   /** Statistical Profiling Extension buffer overflow GSIV. Zero if

   unsupported by this processor. This field was introduced in

   ACPI 6.3 (MADT revision 5) and is therefore ignored when

   generating MADT revision 4 or lower.

   */

-  UINT16SpeOverflowInterrupt;

+  UINT16 SpeOverflowInterrupt;

 

   /** The proximity domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ProximityDomain;

+  UINT32 ProximityDomain;

 

   /** The clock domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ClockDomain;

+  UINT32 ClockDomain;

 

   /** The GICC Affinity flags field as described by the GICC Affinity structure

   in the SRAT table.

   */

-  UINT32AffinityFlags;

+  UINT32 AffinityFlags;

+

+  /** Optional field: Reference Token for the Cpc info of this processor.

+  Token identifying a CM_ARM_OBJ_REF structure, itself referencing

+  CM_ARM_CPC_INFO objects.

+  */

+  CM_OBJECT_TOKENCpcToken;

 } CM_ARM_GICC_INFO;

 

 /** A structure that describes the

@@ -1070,6 +1077,113 @@ typedef

[edk2-devel] [PATCH v2 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-14 Thread Jeff Brasen via groups.io
_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 

---

 .../Include/Library/AmlLib/AmlLib.h   | 156 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 543 ++

 2 files changed, 699 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 39968660f2..3fafa6b0e8 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1336,6 +1336,162 @@ AmlAddNameIntegerPackage (

   IN AML_OBJECT_NODE_HANDLE  PackageNode

   );

 

+/** Create a _CPC node.

+

+  Creates and optionally adds the following node

+   Name(_CPC, Package()

+   {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer (Resource 
Descriptor)

+NominalPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestPerformance,   // Integer or Buffer (Resource 
Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource Descriptor)

+TimeWindowRegister,  // Buffer (Resource Descriptor)

+CounterWraparoundTime,   // Integer or Buffer (Resource 
Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource Descriptor)

+CPPCEnableRegister   // Buffer (Resource Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer (Resource 
Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)

+ReferencePerformance // Integer or Buffer (Resource 
Descriptor)

+LowestFrequency, // Integer or Buffer (Resource 
Descriptor)

+NominalFrequency // Integer or Buffer (Resource 
Descriptor)

+  })

+

+  If resource buffer is NULL then integer will be used.

+

+  Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)

+

+  @ingroup CodeGenApis

+

+  @param [in]  HighestPerformanceBuffer   If provided, buffer that 
indicates the highest level

+  of performance the 
processor.

+  @param [in]  HighestPerformanceInteger  Indicates the highest 
level of performance the processor,

+  used if buffer is NULL.

+  @param [in]  NominalPerformanceBuffer   If provided buffer that 
indicates the highest sustained

+  performance level of the 
processor.

+  @param [in]  NominalPerformanceInteger  Indicates the highest 
sustained performance level

+  of the processor, used 
if buffer is NULL.

+  @param [in]  LowestNonlinearPerformanceBuffer   If provided, buffer that 
indicates the lowest performance level

+  of the processor with 
non-linear power savings.

+  @param [in]  LowestNonlinearPerformanceInteger  Indicates the lowest 
performance level of the processor with

+  non-linear power 
savings, used if buffer is NULL.

+  @param [in]  LowestPerformanceBufferIf provided, buffer that 
indicates the

+  lowest performance level 
of the processor.

+  @param [in]  LowestPerformanceInteger   Indicates the lowest 
performance level of the processor,

+  used if buffer is NULL.

+  @param [in]  GuaranteedPerformanceRegister  If provided, Guaranteed 
Performance Register Buffer.

+  @param [in]  DesiredPerformanceRegister If provided, Desired 
Performance Register Buffer.

+  @param [in]  MinimumPerformanceRegister If provided, Minimum 
Performance Register Buffer.

+  @param [in]  MaximumPerformanceRegister 

[edk2-devel] [PATCH v2 1/3] DynamicTablesPkg: Add CM_ARM_CPC_INFO object

2022-09-14 Thread Jeff Brasen via groups.io
Introduce the CM_ARM_CPC_INFO CmObj in the ArmNameSpaceObjects.

This allows to describe CPC information, as described in ACPI 6.4,

s8.4.7.1 "_CPC (Continuous Performance Control)".



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h | 148 --

 .../ConfigurationManagerObjectParser.c|  79 ++

 2 files changed, 210 insertions(+), 17 deletions(-)



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 102e0f96be..d76cc08e14 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -63,6 +63,7 @@ typedef enum ArmObjectID {

   EArmObjPciInterruptMapInfo,  ///< 39 - Pci Interrupt Map Info

   EArmObjRmr,  ///< 40 - Reserved Memory Range Node

   EArmObjMemoryRangeDescriptor,///< 41 - Memory Range Descriptor

+  EArmObjCpcInfo,  ///< 42 - Continuous Performance 
Control Info

   EArmObjMax

 } EARM_OBJECT_ID;

 

@@ -97,99 +98,105 @@ typedef struct CmArmPowerManagementProfileInfo {

 */

 typedef struct CmArmGicCInfo {

   /// The GIC CPU Interface number.

-  UINT32CPUInterfaceNumber;

+  UINT32 CPUInterfaceNumber;

 

   /** The ACPI Processor UID. This must match the

   _UID of the CPU Device object information described

   in the DSDT/SSDT for the CPU.

   */

-  UINT32AcpiProcessorUid;

+  UINT32 AcpiProcessorUid;

 

   /** The flags field as described by the GICC structure

   in the ACPI Specification.

   */

-  UINT32Flags;

+  UINT32 Flags;

 

   /** The parking protocol version field as described by

 the GICC structure in the ACPI Specification.

   */

-  UINT32ParkingProtocolVersion;

+  UINT32 ParkingProtocolVersion;

 

   /** The Performance Interrupt field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT32PerformanceInterruptGsiv;

+  UINT32 PerformanceInterruptGsiv;

 

   /** The CPU Parked address field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT64ParkedAddress;

+  UINT64 ParkedAddress;

 

   /** The base address for the GIC CPU Interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64PhysicalBaseAddress;

+  UINT64 PhysicalBaseAddress;

 

   /** The base address for GICV interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICV;

+  UINT64 GICV;

 

   /** The base address for GICH interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICH;

+  UINT64 GICH;

 

   /** The GICV maintenance interrupt

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT32VGICMaintenanceInterrupt;

+  UINT32 VGICMaintenanceInterrupt;

 

   /** The base address for GICR interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICRBaseAddress;

+  UINT64 GICRBaseAddress;

 

   /** The MPIDR for the CPU

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64MPIDR;

+  UINT64 MPIDR;

 

   /** The Processor Power Efficiency class

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT8 ProcessorPowerEfficiencyClass;

+  UINT8  ProcessorPowerEfficiencyClass;

 

   /** Statistical Profiling Extension buffer overflow GSIV. Zero if

   unsupported by this processor. This field was introduced in

   ACPI 6.3 (MADT revision 5) and is therefore ignored when

   generating MADT revision 4 or lower.

   */

-  UINT16SpeOverflowInterrupt;

+  UINT16 SpeOverflowInterrupt;

 

   /** The proximity domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ProximityDomain;

+  UINT32 ProximityDomain;

 

   /** The clock domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ClockDomain;

+  UINT32 ClockDomain;

 

   /** The GICC Affinity flags field as described by the GICC Affinity structure

   in the SRAT table.

   */

-  UINT32AffinityFlags;

+  UINT32 AffinityFlags;

+

+  /** Optional field: Reference Token for the Cpc info of this processor.

+  Token identifying a CM_ARM_OBJ_REF structure, itself referencing

+  CM_ARM_CPC_INFO objects.

+  */

+  CM_OBJECT_TOKENCpcToken;

 } CM_ARM_GICC_INFO;

 

 /** A structure that describes the

@@ -1070,6 +1077,113 @@ typedef

[edk2-devel] [PATCH v2 3/3] DynamicTablesPkg: SSDT CPU _CPC generator

2022-09-14 Thread Jeff Brasen via groups.io
Add code to use a token attached to GICC to generate _CPC object on cpus.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 223 +-

 1 file changed, 217 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 8561f48e1f..56741e7b58 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -76,6 +76,16 @@ GET_OBJECT_LIST (

   CM_ARM_LPI_INFO

   );

 

+/**

+  This macro expands to a function that retrieves the CPC

+  information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceArm,

+  EArmObjCpcInfo,

+  CM_ARM_CPC_INFO

+  );

+

 /** Initialize the TokenTable.

 

   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO

@@ -229,6 +239,183 @@ WriteAslName (

   return EFI_SUCCESS;

 }

 

+/** Utility function to check if generic address points to NULL

+

+  @param [in]  Address  Pointer to the Generic address

+

+  @retval TRUE  Address is system memory with an Address of 0.

+  @retval FALSE Address does not point to NULL.

+**/

+STATIC

+BOOLEAN

+EFIAPI

+IsNullGenericAddress (

+  IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE  *Address

+  )

+{

+  if ((Address == NULL) ||

+  ((Address->AddressSpaceId == EFI_ACPI_6_4_SYSTEM_MEMORY) &&

+   (Address->Address == 0x0)))

+  {

+return TRUE;

+  }

+

+  return FALSE;

+}

+

+/** Create and add an _CPC Node to Cpu Node.

+

+  For instance, transform an AML node from:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  }

+

+  To:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  Name(_CPC, Package()

+  {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer 
(Resource Descriptor)

+NominalPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestPerformance,   // Integer or Buffer 
(Resource Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource 
Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource 
Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource 
Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource 
Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource 
Descriptor)

+TimeWindowRegister,  // Buffer (Resource 
Descriptor)

+CounterWraparoundTime,   // Integer or Buffer 
(Resource Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource 
Descriptor)

+CPPCEnableRegister   // Buffer (Resource 
Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer 
(Resource Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource 
Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource 
Descriptor)

+ReferencePerformance // Integer or Buffer 
(Resource Descriptor)

+LowestFrequency, // Integer or Buffer 
(Resource Descriptor)

+NominalFrequency // Integer or Buffer 
(Resource Descriptor)

+  })

+  }

+

+  @param [in]  Generator  The SSDT Cpu Topology generator.

+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

+  Protocol Interface.

+  @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

+  the Cpu.

+  @param [in]  Node   CPU Node to which the _CPC node is

+  attached.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+CreateAmlCpcNode (

+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  INCM_ARM_GICC_INFO  *GicCInfo,

+  IN  AML_OBJECT_NODE_HANDLE  

[edk2-devel] [PATCH v2 0/3] DynamicTablesPkg: _CPC support

2022-09-14 Thread Jeff Brasen via groups.io
Add generator for creating the _CPC object for CPU nodes.

If viewing this review by a pull request is helpful one exists here:
https://github.com/NVIDIA/edk2/pull/12

Change Log:
v1 - Initial Revision
v2 - Added revision to object, improved error handling, changed to ACPI 6.4 
structures.

Jeff Brasen (3):
  DynamicTablesPkg: Add CM_ARM_CPC_INFO object
  DynamicTablesPkg: AML Code generation to add _CPC entries
  DynamicTablesPkg: SSDT CPU _CPC generator

 .../Include/ArmNameSpaceObjects.h | 148 -
 .../Include/Library/AmlLib/AmlLib.h   | 156 +
 .../SsdtCpuTopologyGenerator.c| 223 ++-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 543 ++
 .../ConfigurationManagerObjectParser.c|  79 +++
 5 files changed, 1126 insertions(+), 23 deletions(-)

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93790): https://edk2.groups.io/g/devel/message/93790
Mute This Topic: https://groups.io/mt/93687863/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-09-08 Thread Jeff Brasen via groups.io


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Monday, August 15, 2022 8:42 AM
> To: devel@edk2.groups.io; Jeff Brasen 
> Cc: hao.a...@intel.com; ray...@intel.com; quic_llind...@quicinc.com;
> ardb+tianoc...@kernel.org
> Subject: Re: [edk2-devel] [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> 
> External email: Use caution opening links or attachments
> 
> 
> On Fri, 5 Aug 2022 at 18:56, Jeff Brasen via groups.io
>  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: Ard Biesheuvel 
> > > Sent: Tuesday, August 2, 2022 10:51 AM
> > > To: Jeff Brasen 
> > > Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> > > quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> > > Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > Allow partial FreeBuffer
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > On Tue, 2 Aug 2022 at 17:32, Jeff Brasen  wrote:
> > > >
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: Ard Biesheuvel 
> > > > > Sent: Friday, July 29, 2022 9:48 AM
> > > > > To: Jeff Brasen 
> > > > > Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> > > > > quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> > > > > Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > > > Allow partial FreeBuffer
> > > > >
> > > > > External email: Use caution opening links or attachments
> > > > >
> > > > >
> > > > > On Thu, 28 Jul 2022 at 13:25, Jeff Brasen  wrote:
> > > > > >
> > > > > >
> > > > > > Adding Leif/Ard to CC incase they have any comments on this patch.
> > > > > >
> > > > >
> > > > > This generally looks ok to me. I just wonder if it wouldn't be
> > > > > simpler to reuse the existing allocation descriptor if it is not
> > > > > being freed entirely. Given the [presumably] the most common
> > > > > case is to allocate and then free some pages at the end,
> > > > > lowering the page count on the existing descriptor would cover
> > > > > most cases, and we'd only need to allocate new ones if pages are
> > > > > being freed at the start or in
> > > the middle.
> > > >
> > > > There is often freeing at the beginning as well as this is being
> > > > used to create
> > > a 64K aligned section of memory in the case. So it over allocates
> > > and the free's some at the beginning and the end. I could probably
> > > make it detect and use that but figured this code would support all
> > > cases and required less case specific detection.
> > > >
> > >
> > > Ah interesting. Would it help if the allocate routine aligned
> > > allocations to their size?
> >
> > The PciIo->AllocateBuffer function doesn't support passing the request in so
> we would need to know that info beforehand. The current calling in the XHCI
> driver does a free at the beginning and then the end of the buffer so we could
> the existing allocation tracker but figured it would be better to correct the
> function just in case someone called it to free in the middle.
> >
> 
> What I was wondering is whether such allocations are themselves multiples of
> 64k. This is perhaps orthogonal to the issue this patch addresses, as we'' 
> still
> need to deal with partial free calls regardless. But I was curious whether 
> XHCI in
> particular, and perhaps more generally, we could streamline this by aligning 
> all
> allocations to a log2 upper bound of their sizes.

Xhci code 
(https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c#L604)
 in allocation requested is greater the EFI_PAGE_SIZE allocates number of 
requested pages plus pages for the alignment and then frees pages at the 
beginning and end of the allocation.  I am not sure we really could change this 
without adding an alignment field to the PciIo protocol.

Is there anything else you would like to change on this patch?

Thanks,
Jeff



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93527): https://edk2.groups.io/g/devel/message/93527
Mute This Topic: https://groups.io/mt/89143704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] EmbeddedPkg/PrePiMemoryAllocationLib: Check for space on offset allocation

2022-09-07 Thread Jeff Brasen via groups.io


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Wednesday, September 7, 2022 10:16 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; ardb+tianoc...@kernel.org;
> abner.ch...@amd.com; g...@danielschaefer.me; quic_llind...@quicinc.com
> Subject: Re: [PATCH v2] EmbeddedPkg/PrePiMemoryAllocationLib: Check for
> space on offset allocation
> 
> External email: Use caution opening links or attachments
> 
> 
> On Wed, 7 Sept 2022 at 17:46, Jeff Brasen  wrote:
> >
> > Update check for enough space to occur prior to alignment offset
> > modification. This prevents a case where EfiFreeMemoryTop could be
> > less than EfiFreeMemoryBottom
> >
> > Signed-off-by: Jeff Brasen 
> 
> Thanks for the respin. I have caught up in the mean time.
> 
> 
> > ---
> >  .../MemoryAllocationLib.c | 53 +++
> >  1 file changed, 30 insertions(+), 23 deletions(-)
> >
> > diff --git
> >
> a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> >
> b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> > index 2cc2a71121..9208826565 100644
> > ---
> >
> a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> > +++
> b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib
> > +++ .c
> > @@ -27,37 +27,44 @@ InternalAllocatePages (
> >
> >Hob.Raw = GetHobList ();
> >
> > -  // Check to see if on 4k boundary
> >Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;
> > +  //
> > +  // Verify that there is sufficient memory to satisfy the allocation
> > + and padding prior to updating anything  //  if
> > + ((Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages *
> EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) - Offset) <
> Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
> > +if (Offset != 0) {
> > +  DEBUG ((DEBUG_ERROR, "Offset applied without enough
> space\r\n"));
> > +} else {
> > +  DEBUG ((DEBUG_ERROR, "Out of memory\r\n"));
> > +}
> > +
> > +ASSERT (FALSE);
> > +return 0;
> > +  }
> > +
> > +  // Check to see if on 4k boundary
> >if (Offset != 0) {
> >  // If not aligned, make the allocation aligned.
> >  Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;
> >}
> >
> 
> I understand how you are trying to stick with the original code as much as
> possible, but this is all extremely clunky, and I'd prefer we just clean it 
> up, if
> you don't mind.
> 
> Would something like the below work for you as well?

Yup this looks good to me and cleaner as well.

> 
> 
> 
> diff --git
> a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> index 2cc2a7112197..547117dc13d6 100644
> ---
> a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> +++
> b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> @@ -23,41 +23,36 @@ InternalAllocatePages (
>)
>  {
>EFI_PEI_HOB_POINTERS  Hob;
> -  EFI_PHYSICAL_ADDRESS  Offset;
> +  EFI_PHYSICAL_ADDRESS  NewTop;
> 
>Hob.Raw = GetHobList ();
> 
> -  // Check to see if on 4k boundary
> -  Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;
> -  if (Offset != 0) {
> -// If not aligned, make the allocation aligned.
> -Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;
> -  }
> +  NewTop = Hob.HandoffInformationTable->EfiFreeMemoryTop &
> ~(EFI_PHYSICAL_ADDRESS)EFI_PAGE_MASK;
> +  NewTop -= Pages * EFI_PAGE_SIZE;
> 
>//
>// Verify that there is sufficient memory to satisfy the allocation
>//
> -  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages *
> EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) <
> Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
> -return 0;
> -  } else {
> -//
> -// Update the PHIT to reflect the memory usage
> -//
> -Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages *
> EFI_PAGE_SIZE;
> -
> -// This routine used to create a memory allocation HOB a la PEI,
> but that's not
> -// necessary for us.
> -
> -//
> -// Create a memory allocation HOB.
> -//
> -BuildMemoryAllocationHob (
> -  Hob.HandoffInformationTable->EfiFreeMemoryTop,
> -  Pages * EFI_PAGE_SIZE,
> -  MemoryType
> -  );
> -return (VOID *)(UINTN)Hob.HandoffInformationTable-
> >EfiFreeMemoryTop;
> +  if (NewTop < (Hob.HandoffInformationTable->EfiFreeMemoryBottom +
> sizeof (EFI_HOB_MEMORY_ALLOCATION)))
> +  {
> +return NULL;
>}
> +
> +  //
> +  // Update the PHIT to reflect the memory usage  //
> + Hob.HandoffInformationTable->EfiFreeMemoryTop = NewTop;
> +
> +  //
> +  // Create a memory allocation HOB.
> +  //
> +  BuildMemoryAllocationHob (
> +Hob.HandoffInformationTable->EfiFreeMemoryTop,
> +Pages * EFI_PAGE_SIZE,
> +MemoryType
> +);
> +
> +  return (VOID *)(UINTN)Hob.HandoffInformationTable-
> >EfiFreeMemoryTop;
>  }
> 
>  /**


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You r

[edk2-devel] [PATCH v2] EmbeddedPkg/PrePiMemoryAllocationLib: Check for space on offset allocation

2022-09-07 Thread Jeff Brasen via groups.io
Update check for enough space to occur prior to alignment offset

modification. This prevents a case where EfiFreeMemoryTop could be

less than EfiFreeMemoryBottom



Signed-off-by: Jeff Brasen 

---

 .../MemoryAllocationLib.c | 53 +++

 1 file changed, 30 insertions(+), 23 deletions(-)



diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 2cc2a71121..9208826565 100644

--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

@@ -27,37 +27,44 @@ InternalAllocatePages (

 

   Hob.Raw = GetHobList ();

 

-  // Check to see if on 4k boundary

   Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;

+  //

+  // Verify that there is sufficient memory to satisfy the allocation and 
padding prior to updating anything

+  //

+  if ((Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * 
EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) - Offset) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

+if (Offset != 0) {

+  DEBUG ((DEBUG_ERROR, "Offset applied without enough space\r\n"));

+} else {

+  DEBUG ((DEBUG_ERROR, "Out of memory\r\n"));

+}

+

+ASSERT (FALSE);

+return 0;

+  }

+

+  // Check to see if on 4k boundary

   if (Offset != 0) {

 // If not aligned, make the allocation aligned.

 Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;

   }

 

   //

-  // Verify that there is sufficient memory to satisfy the allocation

+  // Update the PHIT to reflect the memory usage

   //

-  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) 
+ sizeof (EFI_HOB_MEMORY_ALLOCATION)) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

-return 0;

-  } else {

-//

-// Update the PHIT to reflect the memory usage

-//

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

-

-// This routine used to create a memory allocation HOB a la PEI, but 
that's not

-// necessary for us.

-

-//

-// Create a memory allocation HOB.

-//

-BuildMemoryAllocationHob (

-  Hob.HandoffInformationTable->EfiFreeMemoryTop,

-  Pages * EFI_PAGE_SIZE,

-  MemoryType

-  );

-return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

-  }

+  Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

+

+  // This routine used to create a memory allocation HOB a la PEI, but that's 
not

+  // necessary for us.

+

+  //

+  // Create a memory allocation HOB.

+  //

+  BuildMemoryAllocationHob (

+Hob.HandoffInformationTable->EfiFreeMemoryTop,

+Pages * EFI_PAGE_SIZE,

+MemoryType

+);

+  return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

 }

 

 /**

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93448): https://edk2.groups.io/g/devel/message/93448
Mute This Topic: https://groups.io/mt/93527827/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 0/3] DynamicTablesPkg: _CPC support

2022-09-07 Thread Jeff Brasen via groups.io
Add generator for creating the _CPC object for CPU nodes.

If viewing this review by a pull request is helpful one exists here:
https://github.com/NVIDIA/edk2/pull/12

Jeff Brasen (3):
  DynamicTablesPkg: Add CM_ARM_CPC_INFO object
  DynamicTablesPkg: AML Code generation to add _CPC entries
  DynamicTablesPkg: SSDT CPU _CPC generator

 .../Include/ArmNameSpaceObjects.h | 146 -
 .../Include/Library/AmlLib/AmlLib.h   | 155 +
 .../SsdtCpuTopologyGenerator.c| 211 ++-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 549 ++
 .../ConfigurationManagerObjectParser.c|  79 +++
 5 files changed, 1118 insertions(+), 22 deletions(-)

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93438): https://edk2.groups.io/g/devel/message/93438
Mute This Topic: https://groups.io/mt/93527147/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 2/3] DynamicTablesPkg: AML Code generation to add _CPC entries

2022-09-07 Thread Jeff Brasen via groups.io
_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 

---

 .../Include/Library/AmlLib/AmlLib.h   | 155 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 549 ++

 2 files changed, 704 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 39968660f2..65f6cd7583 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1336,6 +1336,161 @@ AmlAddNameIntegerPackage (

   IN AML_OBJECT_NODE_HANDLE  PackageNode

   );

 

+/** Create a _CPC node.

+

+  Creates and optionally adds the following node

+   Name(_CPC, Package()

+   {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer (Resource 
Descriptor)

+NominalPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer (Resource 
Descriptor)

+LowestPerformance,   // Integer or Buffer (Resource 
Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource Descriptor)

+TimeWindowRegister,  // Buffer (Resource Descriptor)

+CounterWraparoundTime,   // Integer or Buffer (Resource 
Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource Descriptor)

+CPPCEnableRegister   // Buffer (Resource Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer (Resource 
Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor)

+ReferencePerformance // Integer or Buffer (Resource 
Descriptor)

+LowestFrequency, // Integer or Buffer (Resource 
Descriptor)

+NominalFrequency // Integer or Buffer (Resource 
Descriptor)

+  })

+

+  If resource buffer is NULL then integer will be used.

+

+  Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)

+

+  @ingroup CodeGenApis

+

+  @param [in]  HighestPerformanceBuffer   If provided, buffer that 
indicates the highest level

+  of performance the 
processor.

+  @param [in]  HighestPerformanceInteger  Indicates the highest 
level of performance the processor,

+  used if buffer is NULL.

+  @param [in]  NominalPerformanceBuffer   If provided buffer that 
indicates the highest sustained

+  performance level of the 
processor.

+  @param [in]  NominalPerformanceInteger  Indicates the highest 
sustained performance level

+  of the processor, used 
if buffer is NULL.

+  @param [in]  LowestNonlinearPerformanceBuffer   If provided, buffer that 
indicates the lowest performance level

+  of the processor with 
non-linear power savings.

+  @param [in]  LowestNonlinearPerformanceInteger  Indicates the lowest 
performance level of the processor with

+  non-linear power 
savings, used if buffer is NULL.

+  @param [in]  LowestPerformanceBufferIf provided, buffer that 
indicates the

+  lowest performance level 
of the processor.

+  @param [in]  LowestPerformanceInteger   Indicates the lowest 
performance level of the processor,

+  used if buffer is NULL.

+  @param [in]  GuaranteedPerformanceRegister  If provided, Guaranteed 
Performance Register Buffer.

+  @param [in]  DesiredPerformanceRegister If provided, Desired 
Performance Register Buffer.

+  @param [in]  MinimumPerformanceRegister If provided, Minimum 
Performance Register Buffer.

+  @param [in]  MaximumPerformanceRegister 

[edk2-devel] [PATCH 3/3] DynamicTablesPkg: SSDT CPU _CPC generator

2022-09-07 Thread Jeff Brasen via groups.io
Add code to use a token attached to GICC to generate _CPC object on cpus.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 211 +-

 1 file changed, 206 insertions(+), 5 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 8561f48e1f..ba1f1bd436 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -76,6 +76,16 @@ GET_OBJECT_LIST (

   CM_ARM_LPI_INFO

   );

 

+/**

+  This macro expands to a function that retrieves the CPC

+  information from the Configuration Manager.

+*/

+GET_OBJECT_LIST (

+  EObjNameSpaceArm,

+  EArmObjCpcInfo,

+  CM_ARM_CPC_INFO

+  );

+

 /** Initialize the TokenTable.

 

   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO

@@ -229,6 +239,182 @@ WriteAslName (

   return EFI_SUCCESS;

 }

 

+/** Utility function to check if generic address points to NULL

+

+  @param [in]  Address  Pointer to the Generic address

+

+  @retval TRUE  Address is system memory with an Address of 0.

+  @retval FALSE Address does not point to NULL.

+**/

+STATIC

+BOOLEAN

+EFIAPI

+IsNullGenericAddress (

+  IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE  *Address

+  )

+{

+  if ((Address == NULL) ||

+  ((Address->AddressSpaceId == EFI_ACPI_6_3_SYSTEM_MEMORY) &&

+   (Address->Address == 0x0)))

+  {

+return TRUE;

+  }

+

+  return FALSE;

+}

+

+/** Create and add an _CPC Node to Cpu Node.

+

+  For instance, transform an AML node from:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  }

+

+  To:

+  Device (C002)

+  {

+  Name (_UID, 2)

+  Name (_HID, "ACPI0007")

+  Name(_CPC, Package()

+  {

+NumEntries,  // Integer

+Revision,// Integer

+HighestPerformance,  // Integer or Buffer 
(Resource Descriptor)

+NominalPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestNonlinearPerformance,  // Integer or Buffer 
(Resource Descriptor)

+LowestPerformance,   // Integer or Buffer 
(Resource Descriptor)

+GuaranteedPerformanceRegister,   // Buffer (Resource 
Descriptor)

+DesiredPerformanceRegister , // Buffer (Resource 
Descriptor)

+MinimumPerformanceRegister , // Buffer (Resource 
Descriptor)

+MaximumPerformanceRegister , // Buffer (Resource 
Descriptor)

+PerformanceReductionToleranceRegister,   // Buffer (Resource 
Descriptor)

+TimeWindowRegister,  // Buffer (Resource 
Descriptor)

+CounterWraparoundTime,   // Integer or Buffer 
(Resource Descriptor)

+ReferencePerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+DeliveredPerformanceCounterRegister, // Buffer (Resource 
Descriptor)

+PerformanceLimitedRegister,  // Buffer (Resource 
Descriptor)

+CPPCEnableRegister   // Buffer (Resource 
Descriptor)

+AutonomousSelectionEnable,   // Integer or Buffer 
(Resource Descriptor)

+AutonomousActivityWindowRegister,// Buffer (Resource 
Descriptor)

+EnergyPerformancePreferenceRegister, // Buffer (Resource 
Descriptor)

+ReferencePerformance // Integer or Buffer 
(Resource Descriptor)

+LowestFrequency, // Integer or Buffer 
(Resource Descriptor)

+NominalFrequency // Integer or Buffer 
(Resource Descriptor)

+  })

+  }

+

+  @param [in]  Generator  The SSDT Cpu Topology generator.

+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

+  Protocol Interface.

+  @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO describing

+  the Cpu.

+  @param [in]  Node   CPU Node to which the _CPC node is

+  attached.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+STATIC

+EFI_STATUS

+EFIAPI

+CreateAmlCpcNode (

+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,

+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

+  INCM_ARM_GICC_INFO  *GicCInfo,

+  IN  AML_OBJECT_NODE_HANDLE  

[edk2-devel] [PATCH 1/3] DynamicTablesPkg: Add CM_ARM_CPC_INFO object

2022-09-07 Thread Jeff Brasen via groups.io
Introduce the CM_ARM_CPC_INFO CmObj in the ArmNameSpaceObjects.

This allows to describe CPC information, as described in ACPI 6.4,

s8.4.7.1 "_CPC (Continuous Performance Control)".



Signed-off-by: Jeff Brasen 

---

 .../Include/ArmNameSpaceObjects.h | 146 --

 .../ConfigurationManagerObjectParser.c|  79 ++

 2 files changed, 208 insertions(+), 17 deletions(-)



diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

index 102e0f96be..4d3f9ae534 100644

--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h

@@ -63,6 +63,7 @@ typedef enum ArmObjectID {

   EArmObjPciInterruptMapInfo,  ///< 39 - Pci Interrupt Map Info

   EArmObjRmr,  ///< 40 - Reserved Memory Range Node

   EArmObjMemoryRangeDescriptor,///< 41 - Memory Range Descriptor

+  EArmObjCpcInfo,  ///< 42 - Continuous Performance 
Control Info

   EArmObjMax

 } EARM_OBJECT_ID;

 

@@ -97,99 +98,105 @@ typedef struct CmArmPowerManagementProfileInfo {

 */

 typedef struct CmArmGicCInfo {

   /// The GIC CPU Interface number.

-  UINT32CPUInterfaceNumber;

+  UINT32 CPUInterfaceNumber;

 

   /** The ACPI Processor UID. This must match the

   _UID of the CPU Device object information described

   in the DSDT/SSDT for the CPU.

   */

-  UINT32AcpiProcessorUid;

+  UINT32 AcpiProcessorUid;

 

   /** The flags field as described by the GICC structure

   in the ACPI Specification.

   */

-  UINT32Flags;

+  UINT32 Flags;

 

   /** The parking protocol version field as described by

 the GICC structure in the ACPI Specification.

   */

-  UINT32ParkingProtocolVersion;

+  UINT32 ParkingProtocolVersion;

 

   /** The Performance Interrupt field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT32PerformanceInterruptGsiv;

+  UINT32 PerformanceInterruptGsiv;

 

   /** The CPU Parked address field as described by

   the GICC structure in the ACPI Specification.

   */

-  UINT64ParkedAddress;

+  UINT64 ParkedAddress;

 

   /** The base address for the GIC CPU Interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64PhysicalBaseAddress;

+  UINT64 PhysicalBaseAddress;

 

   /** The base address for GICV interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICV;

+  UINT64 GICV;

 

   /** The base address for GICH interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICH;

+  UINT64 GICH;

 

   /** The GICV maintenance interrupt

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT32VGICMaintenanceInterrupt;

+  UINT32 VGICMaintenanceInterrupt;

 

   /** The base address for GICR interface

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64GICRBaseAddress;

+  UINT64 GICRBaseAddress;

 

   /** The MPIDR for the CPU

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT64MPIDR;

+  UINT64 MPIDR;

 

   /** The Processor Power Efficiency class

   as described by the GICC structure in the

   ACPI Specification.

   */

-  UINT8 ProcessorPowerEfficiencyClass;

+  UINT8  ProcessorPowerEfficiencyClass;

 

   /** Statistical Profiling Extension buffer overflow GSIV. Zero if

   unsupported by this processor. This field was introduced in

   ACPI 6.3 (MADT revision 5) and is therefore ignored when

   generating MADT revision 4 or lower.

   */

-  UINT16SpeOverflowInterrupt;

+  UINT16 SpeOverflowInterrupt;

 

   /** The proximity domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ProximityDomain;

+  UINT32 ProximityDomain;

 

   /** The clock domain to which the logical processor belongs.

   This field is used to populate the GICC affinity structure

   in the SRAT table.

   */

-  UINT32ClockDomain;

+  UINT32 ClockDomain;

 

   /** The GICC Affinity flags field as described by the GICC Affinity structure

   in the SRAT table.

   */

-  UINT32AffinityFlags;

+  UINT32 AffinityFlags;

+

+  /** Optional field: Reference Token for the Cpc info of this processor.

+  Token identifying a CM_ARM_OBJ_REF structure, itself referencing

+  CM_ARM_CPC_INFO objects.

+  */

+  CM_OBJECT_TOKENCpcToken;

 } CM_ARM_GICC_INFO;

 

 /** A structure that describes the

@@ -1070,6 +1077,111 @@ typedef

Re: [edk2-devel] [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for space on offset allocation

2022-09-07 Thread Jeff Brasen via groups.io
I'll post another version to fix the formatting issue in a bit, but before the 
patch the issue was we applied the alignment offset before we did a space check.

-Jeff


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Wednesday, September 7, 2022 2:34 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; quic_llind...@quicinc.com;
> ardb+tianoc...@kernel.org; abner.ch...@hpe.com; daniel.schae...@hpe.com
> Subject: Re: [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for
> space on offset allocation
> 
> External email: Use caution opening links or attachments
> 
> 
> On Thu, 30 Jun 2022 at 21:06, Jeff Brasen  wrote:
> >
> > Update check for enough space to occur prior to alignment offset.
> > This prevents cases where EfiFreeMemoryTop < EfiFreeMemoryBottom.
> >
> 
> So prior to this patch, we would
> - check for enough space
> - apply the alignment
> - potentially exceed the available space due to alignment padding?
> 
> > Signed-off-by: Jeff Brasen 
> 
> This patch got mangled so I cannot apply it from the list.
> 
> > ---
> >  .../MemoryAllocationLib.c | 53 +++
> >  1 file changed, 30 insertions(+), 23 deletions(-)
> >
> > diff --git
> > a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> > b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> > index 78f8da5e95..1956d644c3 100644
> > ---
> > a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c
> > +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib
> > +++ .c
> > @@ -38,37 +38,44 @@ AllocatePages (
> >
> >Hob.Raw = GetHobList ();
> >
> > -  // Check to see if on 4k boundary
> >Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;
> > +  //
> > +  // Verify that there is sufficient memory to satisfy the allocation
> > + and padding prior to updating anything  //  if
> > + ((Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages *
> EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) - Offset) <
> Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
> > +if (Offset != 0) {
> > +  DEBUG ((DEBUG_ERROR, "Offset applied without enough space\r\n"));
> > +} else {
> > +  DEBUG ((DEBUG_ERROR, "Out of memory\r\n"));
> > +}
> > +
> > +ASSERT (FALSE);
> > +return 0;
> > +  }
> > +
> > +  // Check to see if on 4k boundary
> >if (Offset != 0) {
> >  // If not aligned, make the allocation aligned.
> >  Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;
> >}
> >
> >//
> > -  // Verify that there is sufficient memory to satisfy the allocation
> > +  // Update the PHIT to reflect the memory usage
> >//
> > -  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages *
> EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) <
> Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
> > -return 0;
> > -  } else {
> > -//
> > -// Update the PHIT to reflect the memory usage
> > -//
> > -Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages *
> EFI_PAGE_SIZE;
> > -
> > -// This routine used to create a memory allocation HOB a la PEI, but 
> > that's
> not
> > -// necessary for us.
> > -
> > -//
> > -// Create a memory allocation HOB.
> > -//
> > -BuildMemoryAllocationHob (
> > -  Hob.HandoffInformationTable->EfiFreeMemoryTop,
> > -  Pages * EFI_PAGE_SIZE,
> > -  EfiBootServicesData
> > -  );
> > -return (VOID *)(UINTN)Hob.HandoffInformationTable-
> >EfiFreeMemoryTop;
> > -  }
> > +  Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages *
> > + EFI_PAGE_SIZE;
> > +
> > +  // This routine used to create a memory allocation HOB a la PEI,
> > + but that's not  // necessary for us.
> > +
> > +  //
> > +  // Create a memory allocation HOB.
> > +  //
> > +  BuildMemoryAllocationHob (
> > +Hob.HandoffInformationTable->EfiFreeMemoryTop,
> > +Pages * EFI_PAGE_SIZE,
> > +EfiBootServicesData
> > +);
> > +  return (VOID
> > + *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;
> >  }
> >
> >  /**
> > --
> > 2.25.1
> >


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93431): https://edk2.groups.io/g/devel/message/93431
Mute This Topic: https://groups.io/mt/92093864/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as UID

2022-09-06 Thread Jeff Brasen via groups.io
Add support for selecting to use index or segment number as UID and name.

This allows the path of the nodes to be well known.

For example, if the PCIe node needs to be notified from by an interrupt

for a Generic Event Device



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/DynamicTablesPkg.dec |  3 +++

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 19 ++-

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  3 +++

 3 files changed, 24 insertions(+), 1 deletion(-)



diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec

index cc34c2bdd6..adc2e67cbf 100644

--- a/DynamicTablesPkg/DynamicTablesPkg.dec

+++ b/DynamicTablesPkg/DynamicTablesPkg.dec

@@ -60,5 +60,8 @@

   # Non BSA Compliant 16550 Serial HID

   
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHid|""|VOID*|0x4008

 

+  # Use PCI segment numbers as UID

+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|BOOLEAN|0x4009

+

 [Guids]

   gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index d82f071e85..85098752c6 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -981,6 +981,7 @@ BuildSsdtPciTableEx (

   UINTN Index;

   EFI_ACPI_DESCRIPTION_HEADER   **TableList;

   ACPI_PCI_GENERATOR*Generator;

+  UINT32Uid;

 

   ASSERT (This != NULL);

   ASSERT (AcpiTableInfo != NULL);

@@ -1036,13 +1037,29 @@ BuildSsdtPciTableEx (

   *Table = TableList;

 

   for (Index = 0; Index < PciCount; Index++) {

+if (PcdGetBool (PcdPciUseSegmentAsUid)) {

+  Uid = PciInfo[Index].PciSegmentGroupNumber;

+  if (Uid > MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {

+DEBUG ((

+  DEBUG_ERROR,

+  "ERROR: SSDT-PCI: Pci root complexes segment number: %d."

+  " Greater than maximum number of Pci root complexes supported = 
%d.\n",

+  Uid,

+  MAX_PCI_ROOT_COMPLEXES_SUPPORTED

+  ));

+return EFI_INVALID_PARAMETER;

+  }

+} else {

+  Uid = Index;

+}

+

 // Build a SSDT table describing the Pci devices.

 Status = BuildSsdtPciTable (

Generator,

CfgMgrProtocol,

AcpiTableInfo,

&PciInfo[Index],

-   Index,

+   Uid,

&TableList[Index]

);

 if (EFI_ERROR (Status)) {

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

index b38a4e9d34..c2a1acb570 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

@@ -30,3 +30,6 @@

   AmlLib

   BaseLib

   SsdtPcieSupportLib

+

+[Pcd]

+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#93302): https://edk2.groups.io/g/devel/message/93302
Mute This Topic: https://groups.io/mt/93510745/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2] DynamicTablesPkg: AcpiSsdtPcieLibArm : Add UID to slot creation

2022-08-23 Thread Jeff Brasen via groups.io
Expose the UID value to GeneratePciSlots().

This is needed for some cases for example:

https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#identifying-externally-exposed-pcie-root-ports



Name (_DSD, Package () {

  ToUUID("EFCC06CC-73AC-4BC3-BFF0-76143807C389"),

  Package () {

Package (2) {"ExternalFacingPort", 1},

Package (2) {"UID", 0},

  }

})



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h | 8 +---

 .../Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c   | 5 -

 .../Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c| 8 +---

 3 files changed, 14 insertions(+), 7 deletions(-)



diff --git a/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h 
b/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

index 85e283a994..4171dabc33 100644

--- a/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

+++ b/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

@@ -54,9 +54,10 @@ AddOscMethod (

   used. It should be possible to enumerate them, but this is additional

   information.

 

-  @param [in]   PciInfo Pci device information.

-  @param [in]  MappingTable The mapping table structure.

-  @param [in, out]  PciNode Pci node to amend.

+  @param [in]   PciInfo   Pci device information.

+  @param [in]   MappingTable  The mapping table structure.

+  @param [in]   Uid   Unique Id of the Pci device.

+  @param [in, out]  PciNode   Pci node to amend.

 

   @retval EFI_SUCCESSSuccess.

   @retval EFI_INVALID_PARAMETER  Invalid parameter.

@@ -67,6 +68,7 @@ EFIAPI

 GeneratePciSlots (

   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

   IN  CONST MAPPING_TABLE *MappingTable,

+  INUINT32Uid,

   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

   );

 

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index ceffe2838c..24e074ea90 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -295,6 +295,7 @@ GeneratePciDeviceInfo (

   @param [in]   CfgMgrProtocol  Pointer to the Configuration Manager

 Protocol interface.

   @param [in]   PciInfo Pci device information.

+  @param [in]   Uid Unique Id of the Pci device.

   @param [in, out]  PciNode Pci node to amend.

 

   @retval EFI_SUCCESS The function completed successfully.

@@ -308,6 +309,7 @@ GeneratePrt (

   INACPI_PCI_GENERATOR*Generator,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

+  INUINT32Uid,

   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

   )

 {

@@ -416,7 +418,7 @@ GeneratePrt (

   PrtNode = NULL;

 

   // Generate the Pci slots once all the device have been added.

-  Status = GeneratePciSlots (PciInfo, &Generator->DeviceTable, PciNode);

+  Status = GeneratePciSlots (PciInfo, &Generator->DeviceTable, Uid, PciNode);

   if (EFI_ERROR (Status)) {

 ASSERT (0);

 goto exit_handler;

@@ -687,6 +689,7 @@ GeneratePciDevice (

Generator,

CfgMgrProtocol,

PciInfo,

+   Uid,

PciNode

);

 if (EFI_ERROR (Status)) {

diff --git 
a/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c 
b/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

index e5ab3a3ca8..b35fb6a7dd 100644

--- a/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

+++ b/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

@@ -41,9 +41,10 @@

   used. It should be possible to enumerate them, but this is additional

   information.

 

-  @param [in]   PciInfo Pci device information.

-  @param [in]  MappingTable The mapping table structure.

-  @param [in, out]  PciNode Pci node to amend.

+  @param [in]   PciInfo   Pci device information.

+  @param [in]   MappingTable  The mapping table structure.

+  @param [in]   Uid   Unique Id of the Pci device.

+  @param [in, out]  PciNode   Pci node to amend.

 

   @retval EFI_SUCCESSSuccess.

   @retval EFI_INVALID_PARAMETER  Invalid parameter.

@@ -54,6 +55,7 @@ EFIAPI

 GeneratePciSlots (

   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

   IN  CONST MAPPING_TABLE *MappingTable,

+  INUINT32Uid,

   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

   )

 {

[edk2-devel] [PATCH] DynamicTablesPkg: AcpiSsdtPcieLibArm : Add UID to slot creation

2022-08-22 Thread Jeff Brasen via groups.io
Expose the UID value to GeneratePciSlots().

This is needed for some cases for example:

https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#identifying-externally-exposed-pcie-root-ports



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h | 8 +---

 .../Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c   | 5 -

 .../Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c| 8 +---

 3 files changed, 14 insertions(+), 7 deletions(-)



diff --git a/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h 
b/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

index 85e283a994..4171dabc33 100644

--- a/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

+++ b/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

@@ -54,9 +54,10 @@ AddOscMethod (

   used. It should be possible to enumerate them, but this is additional

   information.

 

-  @param [in]   PciInfo Pci device information.

-  @param [in]  MappingTable The mapping table structure.

-  @param [in, out]  PciNode Pci node to amend.

+  @param [in]   PciInfo   Pci device information.

+  @param [in]   MappingTable  The mapping table structure.

+  @param [in]   Uid   Unique Id of the Pci device.

+  @param [in, out]  PciNode   Pci node to amend.

 

   @retval EFI_SUCCESSSuccess.

   @retval EFI_INVALID_PARAMETER  Invalid parameter.

@@ -67,6 +68,7 @@ EFIAPI

 GeneratePciSlots (

   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

   IN  CONST MAPPING_TABLE *MappingTable,

+  INUINT32Uid,

   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

   );

 

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index ceffe2838c..24e074ea90 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -295,6 +295,7 @@ GeneratePciDeviceInfo (

   @param [in]   CfgMgrProtocol  Pointer to the Configuration Manager

 Protocol interface.

   @param [in]   PciInfo Pci device information.

+  @param [in]   Uid Unique Id of the Pci device.

   @param [in, out]  PciNode Pci node to amend.

 

   @retval EFI_SUCCESS The function completed successfully.

@@ -308,6 +309,7 @@ GeneratePrt (

   INACPI_PCI_GENERATOR*Generator,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

+  INUINT32Uid,

   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

   )

 {

@@ -416,7 +418,7 @@ GeneratePrt (

   PrtNode = NULL;

 

   // Generate the Pci slots once all the device have been added.

-  Status = GeneratePciSlots (PciInfo, &Generator->DeviceTable, PciNode);

+  Status = GeneratePciSlots (PciInfo, &Generator->DeviceTable, Uid, PciNode);

   if (EFI_ERROR (Status)) {

 ASSERT (0);

 goto exit_handler;

@@ -687,6 +689,7 @@ GeneratePciDevice (

Generator,

CfgMgrProtocol,

PciInfo,

+   Uid,

PciNode

);

 if (EFI_ERROR (Status)) {

diff --git 
a/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c 
b/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

index e5ab3a3ca8..b35fb6a7dd 100644

--- a/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

+++ b/DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

@@ -41,9 +41,10 @@

   used. It should be possible to enumerate them, but this is additional

   information.

 

-  @param [in]   PciInfo Pci device information.

-  @param [in]  MappingTable The mapping table structure.

-  @param [in, out]  PciNode Pci node to amend.

+  @param [in]   PciInfo   Pci device information.

+  @param [in]   MappingTable  The mapping table structure.

+  @param [in]   Uid   Unique Id of the Pci device.

+  @param [in, out]  PciNode   Pci node to amend.

 

   @retval EFI_SUCCESSSuccess.

   @retval EFI_INVALID_PARAMETER  Invalid parameter.

@@ -54,6 +55,7 @@ EFIAPI

 GeneratePciSlots (

   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

   IN  CONST MAPPING_TABLE *MappingTable,

+  INUINT32Uid,

   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

   )

 {

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92621): https://edk2.groups.io/g/devel/message/92621

[edk2-devel] [PATCH v2] DynamicTablesPkg: Fix nested processor containers

2022-08-18 Thread Jeff Brasen via groups.io
Current code will generate duplicate UID if there are nested processor

containers in the topology. For example if there is a

socket/cluster/core layout.



Change references to processor container from cluster to be more

accurate on what is being created.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 94 ++-

 1 file changed, 50 insertions(+), 44 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 3266d8dd98..8561f48e1f 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -587,10 +587,10 @@ CreateAmlCpuFromProcHierarchy (

   return Status;

 }

 

-/** Create a Cluster in the AML namespace.

+/** Create a Processor Container in the AML namespace.

 

   Any CM_ARM_PROC_HIERARCHY_INFO object with the following flags is

-  assumed to be a cluster:

+  assumed to be a processor container:

- EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL

- EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID

- EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF

@@ -605,13 +605,13 @@ CreateAmlCpuFromProcHierarchy (

   @param [in]  Generator  The SSDT Cpu Topology generator.

   @param [in]  CfgMgrProtocol Pointer to the Configuration Manager

   Protocol Interface.

-  @param [in]  ParentNode Parent node to attach the Cluster

-  node to.

+  @param [in]  ParentNode Parent node to attach the processor

+  container node to.

   @param [in]  ProcHierarchyNodeInfo  CM_ARM_PROC_HIERARCHY_INFO object used

   to create the node.

-  @param [in]  ClusterIndex   Index used to generate the node name.

-  @param [out] ClusterNodePtr If success, contains the created Cluster

-  node.

+  @param [in]  ProcContainerIndex Index used to generate the node name.

+  @param [out] ProcContainerNodePtr   If success, contains the created 
processor

+  container node.

 

   @retval EFI_SUCCESS Success.

   @retval EFI_INVALID_PARAMETER   Invalid parameter.

@@ -620,43 +620,43 @@ CreateAmlCpuFromProcHierarchy (

 STATIC

 EFI_STATUS

 EFIAPI

-CreateAmlCluster (

+CreateAmlProcessorContainer (

   INACPI_CPU_TOPOLOGY_GENERATOR   *Generator,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   INAML_NODE_HANDLE   ParentNode,

   INCM_ARM_PROC_HIERARCHY_INFO
*ProcHierarchyNodeInfo,

-  INUINT32ClusterIndex,

-  OUT   AML_OBJECT_NODE_HANDLE*ClusterNodePtr

+  INUINT32ProcContainerIndex,

+  OUT   AML_OBJECT_NODE_HANDLE*ProcContainerNodePtr

   )

 {

   EFI_STATUS  Status;

-  AML_OBJECT_NODE_HANDLE  ClusterNode;

-  CHAR8   AslNameCluster[AML_NAME_SEG_SIZE + 1];

+  AML_OBJECT_NODE_HANDLE  ProcContainerNode;

+  CHAR8   AslNameProcContainer[AML_NAME_SEG_SIZE + 1];

 

   ASSERT (Generator != NULL);

   ASSERT (CfgMgrProtocol != NULL);

   ASSERT (ParentNode != NULL);

   ASSERT (ProcHierarchyNodeInfo != NULL);

-  ASSERT (ClusterNodePtr != NULL);

+  ASSERT (ProcContainerNodePtr != NULL);

 

-  Status = WriteAslName ('C', ClusterIndex, AslNameCluster);

+  Status = WriteAslName ('C', ProcContainerIndex, AslNameProcContainer);

   if (EFI_ERROR (Status)) {

 ASSERT (0);

 return Status;

   }

 

-  Status = AmlCodeGenDevice (AslNameCluster, ParentNode, &ClusterNode);

+  Status = AmlCodeGenDevice (AslNameProcContainer, ParentNode, 
&ProcContainerNode);

   if (EFI_ERROR (Status)) {

 ASSERT (0);

 return Status;

   }

 

-  // Use the ClusterIndex for the _UID value as there is no AcpiProcessorUid

+  // Use the ProcContainerIndex for the _UID value as there is no 
AcpiProcessorUid

   // and EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID is set for non-Cpus.

   Status = AmlCodeGenNameInteger (

  "_UID",

- ClusterIndex,

- ClusterNode,

+ ProcContainerIndex,

+ ProcContainerNode,

  NULL

  );

   if (EFI_ERROR (Status)) {

@@ -667,7 +667,7 @@ CreateAmlCluster (

   Status = AmlCodeGenNameString (

  "_HID",

  ACPI_HID_PROCESSOR_CONTAINER_DEVICE,

- ClusterNode,

+ ProcContainerNode,

  NULL

  );

   if (EFI_ERROR (Status)) {

@@ -681,7 +681,7 @@ 

[edk2-devel] [PATCH v3] DynamicTablesPkg: Add support to build _DSD

2022-08-17 Thread Jeff Brasen via groups.io
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 

---

 .../Include/Library/AmlLib/AmlLib.h   |  60 +

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 254 ++

 2 files changed, 314 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 6f214c0dfa..18013f3c0c 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1280,6 +1280,66 @@ AmlAddLpiState (

   IN  AML_OBJECT_NODE_HANDLE  LpiNode

   );

 

+/** AML code generation for a _DSD device data object.

+

+  AmlAddDeviceDataDescriptorPackage (Uuid, DsdNode, PackageNode) is

+  equivalent of the following ASL code:

+ToUUID(Uuid),

+Package () {}

+

+  Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".

+

+  _DSD (Device Specific Data) Implementation Guide

+  https://github.com/UEFI/DSD-Guide

+  Per s3. "'Well-Known _DSD UUIDs and Data Structure Formats'"

+  If creating a Device Properties data then UUID 
daffd814-6eba-4d8c-8a91-bc9bbf4aa301 should be used.

+

+  @ingroup CodeGenApis

+

+  @param [in]  Uuid   The Uuid of the descriptor to be created

+  @param [in]  DsdNodeNode of the DSD Package.

+  @param [out] PackageNodeIf success, contains the created package node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddDeviceDataDescriptorPackage (

+  IN  CONST EFI_GUID*Uuid,

+  INAML_OBJECT_NODE_HANDLE  DsdNode,

+  OUT   AML_OBJECT_NODE_HANDLE  *PackageNode

+  );

+

+/** AML code generation to add a package with a name and value,

+to a parent package.

+This is useful for build the _DSD package but can be used in other cases.

+

+  AmlAddNameValuePackage ("Name", Value, PackageNode) is

+  equivalent of the following ASL code:

+Package (2) {"Name", Value}

+

+  Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".

+

+  @ingroup CodeGenApis

+

+  @param [in]  Name   String to place in first entry of package

+  @param [in]  Value  Integer to place in second entry of package

+  @param [in]  PackageNodePackage to add new sub package to.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameIntegerPackage (

+  IN CHAR8   *Name,

+  IN UINT64  Value,

+  IN AML_OBJECT_NODE_HANDLE  PackageNode

+  );

+

 // DEPRECATED APIS

 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES

 

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index e51d2dd7f0..cf92e7aee7 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -2600,3 +2600,257 @@ error_handler:

 

   return Status;

 }

+

+/** AML code generation for a _DSD device data object.

+

+  AmlAddDeviceDataDescriptorPackage (Uuid, DsdNode, PackageNode) is

+  equivalent of the following ASL code:

+ToUUID(Uuid),

+Package () {}

+

+  Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".

+

+  _DSD (Device Specific Data) Implementation Guide

+  https://github.com/UEFI/DSD-Guide

+  Per s3. "'Well-Known _DSD UUIDs and Data Structure Formats'"

+  If creating a Device Properties data then UUID 
daffd814-6eba-4d8c-8a91-bc9bbf4aa301 should be used.

+

+  @ingroup CodeGenApis

+

+  @param [in]  Uuid   The Uuid of the descriptor to be created

+  @param [in]  DsdNodeNode of the DSD Package.

+  @param [out] PackageNodeIf success, contains the created package node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddDeviceDataDescriptorPackage (

+  IN  CONST EFI_GUID*Uuid,

+  INAML_OBJECT_NODE_HANDLE  DsdNode,

+  OUT   AML_OBJECT_NODE_HANDLE  *PackageNode

+  )

+{

+  EFI_STATUS  Status;

+  AML_OBJECT_NODE *UuidNode;

+  AML_DATA_NODE   *UuidDataNode;

+  AML_OBJECT_NODE_HANDLE  DsdEntryList;

+

+  if ((Uuid == NULL) ||

+  (PackageNode == NULL) ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)DsdNode) != EAmlNodeObject) ||

+  (!AmlNodeHasOpCode (DsdNode, AML_NAME_OP, 0)) ||

+  !AmlNameOpCompareName (DsdNode, "_DSD"))

+  {

+ASSERT_EFI_ERROR (EFI_INVALID_PARAM

Re: [edk2-devel] [PATCH] DynamicTablesPkg: Correct cluster index

2022-08-17 Thread Jeff Brasen via groups.io


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Wednesday, August 17, 2022 1:01 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; quic_llind...@quicinc.com;
> ardb+tianoc...@kernel.org; sami.muja...@arm.com;
> alexei.fedo...@arm.com
> Subject: Re: [PATCH] DynamicTablesPkg: Correct cluster index
> 
> External email: Use caution opening links or attachments
> 
> 
> On Tue, 16 Aug 2022 at 22:46, Jeff Brasen  wrote:
> >
> > Current code will generate duplicate UID if there are nested clusters
> > in the topology.
> >
> 
> What is a nested cluster?
> 

Better terminology would be nested processor containers, in our case we have 
socket/cluster/cpu. I'll update the commit message. Should I also change 
CreateAmlCluster to CreateAmlProcessorContainer?

> > Signed-off-by: Jeff Brasen 
> > ---
> >  .../SsdtCpuTopologyGenerator.c| 22 ---
> >  1 file changed, 14 insertions(+), 8 deletions(-)
> >
> > diff --git
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> >
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> > index 3266d8dd98..9295117f1f 100644
> > ---
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCp
> uT
> > opologyGenerator.c
> > +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ssdt
> > +++ CpuTopologyGenerator.c
> > @@ -706,6 +706,8 @@ CreateAmlCluster (
> >   Cannot be CM_NULL_TOKEN.
> >@param [in] ParentNode Parent node to attach the created
> >   node to.
> > +  @param [in,out] ClusterIndex   Pointer to the current cluster index
> > + to be used as UID.
> >
> >@retval EFI_SUCCESS Success.
> >@retval EFI_INVALID_PARAMETER   Invalid parameter.
> > @@ -718,13 +720,13 @@ CreateAmlCpuTopologyTree (
> >INACPI_CPU_TOPOLOGY_GENERATOR   *Generator,
> >IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST
> CfgMgrProtocol,
> >INCM_OBJECT_TOKEN   NodeToken,
> > -  INAML_NODE_HANDLE   ParentNode
> > +  INAML_NODE_HANDLE   ParentNode,
> > +  IN OUTUINT32*ClusterIndex
> >)
> >  {
> >EFI_STATUS  Status;
> >UINT32  Index;
> >UINT32  CpuIndex;
> > -  UINT32  ClusterIndex;
> >AML_OBJECT_NODE_HANDLE  ClusterNode;
> >
> >ASSERT (Generator != NULL);
> > @@ -733,9 +735,9 @@ CreateAmlCpuTopologyTree (
> >ASSERT (CfgMgrProtocol != NULL);
> >ASSERT (NodeToken != CM_NULL_TOKEN);
> >ASSERT (ParentNode != NULL);
> > +  ASSERT (ClusterIndex != NULL);
> >
> > -  CpuIndex = 0;
> > -  ClusterIndex = 0;
> > +  CpuIndex = 0;
> >
> >for (Index = 0; Index < Generator->ProcNodeCount; Index++) {
> >  // Find the children of the CM_ARM_PROC_HIERARCHY_INFO @@ -
> 790,7
> > +792,7 @@ CreateAmlCpuTopologyTree (
> > CfgMgrProtocol,
> > ParentNode,
> > &Generator->ProcNodeList[Index],
> > -   ClusterIndex,
> > +   *ClusterIndex,
> > &ClusterNode
> > );
> >  if (EFI_ERROR (Status)) {
> > @@ -800,7 +802,7 @@ CreateAmlCpuTopologyTree (
> >
> >  // Nodes must have a unique name in the ASL namespace.
> >  // Reset the Cpu index whenever we create a new Cluster.
> > -ClusterIndex++;
> > +(*ClusterIndex)++;
> >  CpuIndex = 0;
> >
> >  // Recursively continue creating an AML tree.
> > @@ -808,7 +810,8 @@ CreateAmlCpuTopologyTree (
> > Generator,
> > CfgMgrProtocol,
> > Generator->ProcNodeList[Index].Token,
> > -   ClusterNode
> > +   ClusterNode,
> > +   ClusterIndex
> > );
> >  if (EFI_ERROR (Status)) {
> >ASSERT (0);
> > @@ -845,6 +848,7 @@ CreateTopologyFromProcHierarchy (
> >EFI_STATUS  Status;
> >UINT32  Index;
> >UINT32  TopLevelProcNodeIndex;
> > +  UINT32  ClusterIndex;
> >
> >ASSERT (Generator != NULL);
> >ASSERT (Generator->ProcNodeCount != 0); @@ -853,6 +857,7 @@
> > CreateTopologyFromProcHierarchy (
> >ASSERT (ScopeNode != NULL);
> >
> >TopLevelProcNodeIndex = MAX_UINT32;
> > +  ClusterIndex  = 0;
> >
> >Status = TokenTableInitialize (Generator, Generator->ProcNodeCount);
> >if (EFI_ERROR (Status)) {
> > @@ -887,7 +892,8 @@ CreateTopologyFromProcHierarchy (
> >   Generator,
> >   CfgMgrProtocol,
> >   Generator->ProcNodeList[TopLevelProcNodeIndex].Token,
> > - ScopeNode
> > + ScopeNode,
> > + 

[edk2-devel] [PATCH] DynamicTablesPkg: Correct cluster index

2022-08-16 Thread Jeff Brasen via groups.io
Current code will generate duplicate UID if there are nested clusters

in the topology.



Signed-off-by: Jeff Brasen 

---

 .../SsdtCpuTopologyGenerator.c| 22 ---

 1 file changed, 14 insertions(+), 8 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

index 3266d8dd98..9295117f1f 100644

--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c

@@ -706,6 +706,8 @@ CreateAmlCluster (

  Cannot be CM_NULL_TOKEN.

   @param [in] ParentNode Parent node to attach the created

  node to.

+  @param [in,out] ClusterIndex   Pointer to the current cluster index

+ to be used as UID.

 

   @retval EFI_SUCCESS Success.

   @retval EFI_INVALID_PARAMETER   Invalid parameter.

@@ -718,13 +720,13 @@ CreateAmlCpuTopologyTree (

   INACPI_CPU_TOPOLOGY_GENERATOR   *Generator,

   IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,

   INCM_OBJECT_TOKEN   NodeToken,

-  INAML_NODE_HANDLE   ParentNode

+  INAML_NODE_HANDLE   ParentNode,

+  IN OUTUINT32*ClusterIndex

   )

 {

   EFI_STATUS  Status;

   UINT32  Index;

   UINT32  CpuIndex;

-  UINT32  ClusterIndex;

   AML_OBJECT_NODE_HANDLE  ClusterNode;

 

   ASSERT (Generator != NULL);

@@ -733,9 +735,9 @@ CreateAmlCpuTopologyTree (

   ASSERT (CfgMgrProtocol != NULL);

   ASSERT (NodeToken != CM_NULL_TOKEN);

   ASSERT (ParentNode != NULL);

+  ASSERT (ClusterIndex != NULL);

 

-  CpuIndex = 0;

-  ClusterIndex = 0;

+  CpuIndex = 0;

 

   for (Index = 0; Index < Generator->ProcNodeCount; Index++) {

 // Find the children of the CM_ARM_PROC_HIERARCHY_INFO

@@ -790,7 +792,7 @@ CreateAmlCpuTopologyTree (

CfgMgrProtocol,

ParentNode,

&Generator->ProcNodeList[Index],

-   ClusterIndex,

+   *ClusterIndex,

&ClusterNode

);

 if (EFI_ERROR (Status)) {

@@ -800,7 +802,7 @@ CreateAmlCpuTopologyTree (

 

 // Nodes must have a unique name in the ASL namespace.

 // Reset the Cpu index whenever we create a new Cluster.

-ClusterIndex++;

+(*ClusterIndex)++;

 CpuIndex = 0;

 

 // Recursively continue creating an AML tree.

@@ -808,7 +810,8 @@ CreateAmlCpuTopologyTree (

Generator,

CfgMgrProtocol,

Generator->ProcNodeList[Index].Token,

-   ClusterNode

+   ClusterNode,

+   ClusterIndex

);

 if (EFI_ERROR (Status)) {

   ASSERT (0);

@@ -845,6 +848,7 @@ CreateTopologyFromProcHierarchy (

   EFI_STATUS  Status;

   UINT32  Index;

   UINT32  TopLevelProcNodeIndex;

+  UINT32  ClusterIndex;

 

   ASSERT (Generator != NULL);

   ASSERT (Generator->ProcNodeCount != 0);

@@ -853,6 +857,7 @@ CreateTopologyFromProcHierarchy (

   ASSERT (ScopeNode != NULL);

 

   TopLevelProcNodeIndex = MAX_UINT32;

+  ClusterIndex  = 0;

 

   Status = TokenTableInitialize (Generator, Generator->ProcNodeCount);

   if (EFI_ERROR (Status)) {

@@ -887,7 +892,8 @@ CreateTopologyFromProcHierarchy (

  Generator,

  CfgMgrProtocol,

  Generator->ProcNodeList[TopLevelProcNodeIndex].Token,

- ScopeNode

+ ScopeNode,

+ &ClusterIndex

  );

   if (EFI_ERROR (Status)) {

 ASSERT (0);

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92487): https://edk2.groups.io/g/devel/message/92487
Mute This Topic: https://groups.io/mt/93067950/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2] DynamicTablesPkg: Add support to build _DSD

2022-08-16 Thread Jeff Brasen via groups.io
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 

---

 .../Include/Library/AmlLib/AmlLib.h   |  55 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 249 ++

 2 files changed, 304 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 6f214c0dfa..86a0e802f4 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1280,6 +1280,61 @@ AmlAddLpiState (

   IN  AML_OBJECT_NODE_HANDLE  LpiNode

   );

 

+/** AML code generation for a _DSD device data object.

+

+  AmlAddDeviceDataDescriptorPackage (Uuid, DsdNode, PackageNode) is

+  equivalent of the following ASL code:

+ToUUID(Uuid),

+Package () {}

+

+  Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".

+

+  @ingroup CodeGenApis

+

+  @param [in]  Uuid   The Uuid of the descriptor to be created

+  @param [in]  DsdNodeNode of the DSD Package.

+  @param [out] PackageNodeIf success, contains the created package node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddDeviceDataDescriptorPackage (

+  IN  CONST EFI_GUID*Uuid,

+  INAML_OBJECT_NODE_HANDLE  DsdNode,

+  OUT   AML_OBJECT_NODE_HANDLE  *PackageNode

+  );

+

+/** AML code generation to add a package with a name and value,

+to a parent package.

+This is useful for build the _DSD package but can be used in other cases.

+

+  AmlAddNameValuePackage ("Name", Value, ParentNode) is

+  equivalent of the following ASL code:

+Package (2) {"Name", Value}

+

+  Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".

+

+  @ingroup CodeGenApis

+

+  @param [in]  Name   String to place in first entry of package

+  @param [in]  Value  Integer to place in second entry of package

+  @param [in]  PackageNodePackage to add new sub package to.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameIntegerPackage (

+  IN CHAR8   *Name,

+  IN UINT64  Value,

+  IN AML_OBJECT_NODE_HANDLE  PackageNode

+  );

+

 // DEPRECATED APIS

 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES

 

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index e51d2dd7f0..6f96e5952b 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -2600,3 +2600,252 @@ error_handler:

 

   return Status;

 }

+

+/** AML code generation for a _DSD device data object.

+

+  AmlAddDeviceDataDescriptorPackage (Uuid, DsdNode, PackageNode) is

+  equivalent of the following ASL code:

+ToUUID(Uuid),

+Package () {}

+

+  Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".

+

+  @ingroup CodeGenApis

+

+  @param [in]  Uuid   The Uuid of the descriptor to be created

+  @param [in]  DsdNodeNode of the DSD Package.

+  @param [out] PackageNodeIf success, contains the created package node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddDeviceDataDescriptorPackage (

+  IN  CONST EFI_GUID*Uuid,

+  INAML_OBJECT_NODE_HANDLE  DsdNode,

+  OUT   AML_OBJECT_NODE_HANDLE  *PackageNode

+  )

+{

+  EFI_STATUS  Status;

+  AML_OBJECT_NODE *UuidNode;

+  AML_DATA_NODE   *UuidDataNode;

+  AML_OBJECT_NODE_HANDLE  DsdEntryList;

+

+  if ((Uuid == NULL) ||

+  (PackageNode == NULL) ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)DsdNode) != EAmlNodeObject) ||

+  (!AmlNodeHasOpCode (DsdNode, AML_NAME_OP, 0)) ||

+  !AmlNameOpCompareName (DsdNode, "_DSD"))

+  {

+ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);

+return EFI_INVALID_PARAMETER;

+  }

+

+  // Get the Package object node of the _DSD node,

+  // which is the 2nd fixed argument (i.e. index 1).

+  DsdEntryList = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (

+   DsdNode,

+   EAmlParseIndexTerm1

+   );

+  if ((DsdEntryList == NULL)  ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)DsdEntryList) != 

Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-08-05 Thread Jeff Brasen via groups.io


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Tuesday, August 2, 2022 10:51 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> Allow partial FreeBuffer
> 
> External email: Use caution opening links or attachments
> 
> 
> On Tue, 2 Aug 2022 at 17:32, Jeff Brasen  wrote:
> >
> >
> >
> > > -Original Message-
> > > From: Ard Biesheuvel 
> > > Sent: Friday, July 29, 2022 9:48 AM
> > > To: Jeff Brasen 
> > > Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> > > quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> > > Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > Allow partial FreeBuffer
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > On Thu, 28 Jul 2022 at 13:25, Jeff Brasen  wrote:
> > > >
> > > >
> > > > Adding Leif/Ard to CC incase they have any comments on this patch.
> > > >
> > >
> > > This generally looks ok to me. I just wonder if it wouldn't be
> > > simpler to reuse the existing allocation descriptor if it is not
> > > being freed entirely. Given the [presumably] the most common case is
> > > to allocate and then free some pages at the end, lowering the page
> > > count on the existing descriptor would cover most cases, and we'd
> > > only need to allocate new ones if pages are being freed at the start or in
> the middle.
> >
> > There is often freeing at the beginning as well as this is being used to 
> > create
> a 64K aligned section of memory in the case. So it over allocates and the
> free's some at the beginning and the end. I could probably make it detect
> and use that but figured this code would support all cases and required less
> case specific detection.
> >
> 
> Ah interesting. Would it help if the allocate routine aligned allocations to 
> their
> size?

The PciIo->AllocateBuffer function doesn't support passing the request in so we 
would need to know that info beforehand. The current calling in the XHCI driver 
does a free at the beginning and then the end of the buffer so we could the 
existing allocation tracker but figured it would be better to correct the 
function just in case someone called it to free in the middle.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92171): https://edk2.groups.io/g/devel/message/92171
Mute This Topic: https://groups.io/mt/89143704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] DynamicTablesPkg: Add support to build _DSD

2022-08-05 Thread Jeff Brasen via groups.io
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 

---

 .../Include/Library/AmlLib/AmlLib.h   |  50 

 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 236 ++

 2 files changed, 286 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index 6f214c0dfa..30cab3f6bb 100644

--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

@@ -1280,6 +1280,56 @@ AmlAddLpiState (

   IN  AML_OBJECT_NODE_HANDLE  LpiNode

   );

 

+/** AML code generation for a _DSD device data object.

+

+  AmlAddDeviceDataDescriptorPackage (Uuid, ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ToUUID(Uuid),

+Package () {}

+

+  @ingroup CodeGenApis

+

+  @param [in]  Uuid   The Uuid of the descriptor to be created

+  @param [in]  DsdNodeNode of the DSD Package.

+  @param [out] PackageNodeIf success, contains the created package node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddDeviceDataDescriptorPackage (

+  IN  CONST EFI_GUID*Uuid,

+  INAML_OBJECT_NODE_HANDLE  DsdNode,

+  OUT   AML_OBJECT_NODE_HANDLE  *PackageNode

+  );

+

+/** AML code generation to add a package with a name and value,

+ *  to a parent package

+

+  AmlAddNameValuePackage ("Name", Value, ParentNode) is

+  equivalent of the following ASL code:

+Package (2) {"Name", Value}

+

+  @ingroup CodeGenApis

+

+  @param [in]  Name   String to place in first entry of package

+  @param [in]  Value  Integer to place in second entry of package

+  @param [in]  PackageNodePackage to add new sub package to.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddNameIntegerPackage (

+  IN CHAR8   *Name,

+  IN UINT64  Value,

+  IN AML_OBJECT_NODE_HANDLE  PackageNode

+  );

+

 // DEPRECATED APIS

 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES

 

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

index e51d2dd7f0..80e43d0e62 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -2600,3 +2600,239 @@ error_handler:

 

   return Status;

 }

+

+/** AML code generation for a _DSD device data object.

+

+  AmlAddDeviceDataDescriptorPackage (Uuid, ParentNode, NewObjectNode) is

+  equivalent of the following ASL code:

+ToUUID(Uuid),

+Package () {}

+

+  @ingroup CodeGenApis

+

+  @param [in]  Uuid   The Uuid of the descriptor to be created

+  @param [in]  DsdNodeNode of the DSD Package.

+  @param [out] PackageNodeIf success, contains the created package node.

+

+  @retval EFI_SUCCESS Success.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AmlAddDeviceDataDescriptorPackage (

+  IN  CONST EFI_GUID*Uuid,

+  INAML_OBJECT_NODE_HANDLE  DsdNode,

+  OUT   AML_OBJECT_NODE_HANDLE  *PackageNode

+  )

+{

+  EFI_STATUS  Status;

+  AML_OBJECT_NODE *UuidNode;

+  AML_DATA_NODE   *UuidDataNode;

+  AML_OBJECT_NODE_HANDLE  DsdEntryList;

+

+  if ((Uuid == NULL) ||

+  (PackageNode == NULL) ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)DsdNode) != EAmlNodeObject) ||

+  (!AmlNodeHasOpCode (DsdNode, AML_NAME_OP, 0)) ||

+  !AmlNameOpCompareName (DsdNode, "_DSD"))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  // Get the Package object node of the _DSD node,

+  // which is the 2nd fixed argument (i.e. index 1).

+  DsdEntryList = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (

+   DsdNode,

+   EAmlParseIndexTerm1

+   );

+  if ((DsdEntryList == NULL)  ||

+  (AmlGetNodeType ((AML_NODE_HANDLE)DsdEntryList) != EAmlNodeObject)  ||

+  (!AmlNodeHasOpCode (DsdEntryList, AML_PACKAGE_OP, 0)))

+  {

+ASSERT (0);

+return EFI_INVALID_PARAMETER;

+  }

+

+  *PackageNode = NULL;

+  UuidNode = NULL;

+

+  Status = AmlCodeGenBuffer (NULL, 0, &UuidNode);

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+goto e

Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-08-02 Thread Jeff Brasen via groups.io


> -Original Message-
> From: Ard Biesheuvel 
> Sent: Friday, July 29, 2022 9:48 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; hao.a...@intel.com; ray...@intel.com;
> quic_llind...@quicinc.com; ardb+tianoc...@kernel.org
> Subject: Re: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> Allow partial FreeBuffer
> 
> External email: Use caution opening links or attachments
> 
> 
> On Thu, 28 Jul 2022 at 13:25, Jeff Brasen  wrote:
> >
> >
> > Adding Leif/Ard to CC incase they have any comments on this patch.
> >
> 
> This generally looks ok to me. I just wonder if it wouldn't be simpler to 
> reuse
> the existing allocation descriptor if it is not being freed entirely. Given 
> the
> [presumably] the most common case is to allocate and then free some pages
> at the end, lowering the page count on the existing descriptor would cover
> most cases, and we'd only need to allocate new ones if pages are being freed
> at the start or in the middle.

There is often freeing at the beginning as well as this is being used to create 
a 64K aligned section of memory in the case. So it over allocates and the 
free's some at the beginning and the end. I could probably make it detect and 
use that but figured this code would support all cases and required less case 
specific detection.

-Jeff

> 
> 
> > > -Original Message-
> > > From: Jeff Brasen
> > > Sent: Friday, June 17, 2022 9:39 AM
> > > To: devel@edk2.groups.io
> > > Cc: hao.a...@intel.com; ray...@intel.com
> > > Subject: RE: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > Allow partial FreeBuffer
> > >
> > > Any thoughts on this patch?
> > >
> > > > -Original Message-
> > > > From: Jeff Brasen 
> > > > Sent: Monday, February 14, 2022 11:46 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: hao.a...@intel.com; ray...@intel.com; Jeff Brasen
> > > > 
> > > > Subject: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> > > > Allow partial FreeBuffer
> > > >
> > > > Add support for partial free of non cached buffers.
> > > > If a request for less than the full size is requested new
> > > > allocations for the remaining head and tail of the buffer are added to
> the list.
> > > > Added verification that Buffer is EFI_PAGE_SIZE aligned.
> > > > The XHCI driver does this if the page size for the controller is >4KB.
> > > >
> > > > Signed-off-by: Jeff Brasen 
> > > > ---
> > > >  .../NonDiscoverablePciDeviceIo.c  | 53 ++-
> > > >  1 file changed, 51 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git
> > > >
> > >
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > > > PciDeviceIo.c
> > > >
> > >
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > > > PciDeviceIo.c
> > > > index c1c5c6267c..77809cfedf 100644
> > > > ---
> > > >
> > >
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > > > PciDeviceIo.c
> > > > +++
> > > >
> > >
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > > > Pc
> > > > +++ iDeviceIo.c
> > > > @@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
> > > >LIST_ENTRY   *Entry;
> > > >EFI_STATUS   Status;
> > > >NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
> > > > +  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION
> *AllocHead;
> > > > + NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
> > > >BOOLEAN  Found;
> > > > +  UINTNStartPages;
> > > > +  UINTNEndPages;
> > > > +
> > > > +  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
> > > > +ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> > > > +return EFI_INVALID_PARAMETER;  }
> > > >
> > > >Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
> > > >
> > > >Found = FALSE;
> > > >Alloc = NULL;
> > > > +  AllocHead = NULL;
> > > > +  AllocTail = NULL;
> > > >
> > > >//
> > > >// Find the uncached allocation list entry associated @@ -976,9
> > > > +987,13 @@ NonCoherentPciIoFreeBuffer (
> > > > Entry = Entry->ForwardLink)
> > > >{
> > > >  Alloc = BASE_CR (Entry,
> > > > NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
> > > > -if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages ==
> > > Pages))
> > > > {
> > > > +StartPages = 0;
> > > > +if (Alloc->HostAddress < HostAddress) {
> > > > +  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
> > > > +}
> > > > +if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages
> > > > + >= (Pages + StartPages))) {
> > > >//
> > > > -  // We are freeing the exact allocation we were given
> > > > +  // We are freeing at least part of what we were given
> > > >// before by AllocateBuffer()
> > > >//
> > > >Found = TRUE;
> > > > @@ -991,7 +1006,41 @@ NonCoherentPciIoFreeB

Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-07-28 Thread Jeff Brasen via groups.io


Adding Leif/Ard to CC incase they have any comments on this patch.

Thanks
Jeff
> -Original Message-
> From: Jeff Brasen
> Sent: Friday, June 17, 2022 9:39 AM
> To: devel@edk2.groups.io
> Cc: hao.a...@intel.com; ray...@intel.com
> Subject: RE: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe:
> Allow partial FreeBuffer
> 
> Any thoughts on this patch?
> 
> > -Original Message-
> > From: Jeff Brasen 
> > Sent: Monday, February 14, 2022 11:46 AM
> > To: devel@edk2.groups.io
> > Cc: hao.a...@intel.com; ray...@intel.com; Jeff Brasen
> > 
> > Subject: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow
> > partial FreeBuffer
> >
> > Add support for partial free of non cached buffers.
> > If a request for less than the full size is requested new allocations
> > for the remaining head and tail of the buffer are added to the list.
> > Added verification that Buffer is EFI_PAGE_SIZE aligned.
> > The XHCI driver does this if the page size for the controller is >4KB.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >  .../NonDiscoverablePciDeviceIo.c  | 53 ++-
> >  1 file changed, 51 insertions(+), 2 deletions(-)
> >
> > diff --git
> >
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > PciDeviceIo.c
> >
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > PciDeviceIo.c
> > index c1c5c6267c..77809cfedf 100644
> > ---
> >
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > PciDeviceIo.c
> > +++
> >
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> > Pc
> > +++ iDeviceIo.c
> > @@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
> >LIST_ENTRY   *Entry;
> >EFI_STATUS   Status;
> >NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
> > +  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;
> > + NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
> >BOOLEAN  Found;
> > +  UINTNStartPages;
> > +  UINTNEndPages;
> > +
> > +  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
> > +ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> > +return EFI_INVALID_PARAMETER;
> > +  }
> >
> >Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
> >
> >Found = FALSE;
> >Alloc = NULL;
> > +  AllocHead = NULL;
> > +  AllocTail = NULL;
> >
> >//
> >// Find the uncached allocation list entry associated @@ -976,9
> > +987,13 @@ NonCoherentPciIoFreeBuffer (
> > Entry = Entry->ForwardLink)
> >{
> >  Alloc = BASE_CR (Entry,
> > NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
> > -if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages ==
> Pages))
> > {
> > +StartPages = 0;
> > +if (Alloc->HostAddress < HostAddress) {
> > +  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
> > +}
> > +if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >=
> > + (Pages + StartPages))) {
> >//
> > -  // We are freeing the exact allocation we were given
> > +  // We are freeing at least part of what we were given
> >// before by AllocateBuffer()
> >//
> >Found = TRUE;
> > @@ -991,7 +1006,41 @@ NonCoherentPciIoFreeBuffer (
> >  return EFI_NOT_FOUND;
> >}
> >
> > +  EndPages = Alloc->NumPages - (Pages + StartPages);
> > +
> > +  if (StartPages != 0) {
> > +AllocHead = AllocatePool (sizeof *AllocHead);
> > +if (AllocHead == NULL) {
> > +  return EFI_OUT_OF_RESOURCES;
> > +}
> > +
> > +AllocHead->HostAddress = Alloc->HostAddress;
> > +AllocHead->NumPages = StartPages;
> > +AllocHead->Attributes = Alloc->Attributes;  }
> > +
> > +  if (EndPages != 0) {
> > +AllocTail = AllocatePool (sizeof *AllocTail);
> > +if (AllocTail == NULL) {
> > +  return EFI_OUT_OF_RESOURCES;
> > +}
> > +
> > +AllocTail->HostAddress = Alloc->HostAddress + ((Pages +
> > + StartPages) *
> > EFI_PAGE_SIZE);
> > +AllocTail->NumPages = EndPages;
> > +AllocTail->Attributes = Alloc->Attributes;  }
> > +
> >RemoveEntryList (&Alloc->List);
> > +  //
> > +  // Record this new sub allocations in the linked list, so we  //
> > + can restore the memory space attributes later  //  if (AllocHead !=
> > + NULL) {
> > +InsertHeadList (&Dev->UncachedAllocationList, &AllocHead->List);
> > + } if (AllocTail != NULL) {
> > +InsertHeadList (&Dev->UncachedAllocationList, &AllocTail->List);
> > + }
> >
> >Status = gDS->SetMemorySpaceAttributes (
> >(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
> > --
> > 2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91951): https://edk2.groups.io/g/devel/message/91951
Mute This Topic: https://groups.io/mt/89143704/21656
Group Owner: devel+ow...

Re: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Add Disk Info support for Ufs

2022-07-19 Thread Jeff Brasen via groups.io
Yes, Universal Flash Storage is based on the SCSI architectural model and 
installs gEfiExtScsiPassThruProtocolGuid to function.

Thanks,
Jeff

> -Original Message-
> From: gaoliming 
> Sent: Monday, July 18, 2022 7:44 PM
> To: devel@edk2.groups.io; Jeff Brasen 
> Cc: jian.j.w...@intel.com; zhichao@intel.com; ray...@intel.com
> Subject: 回复: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib:
> Add Disk Info support for Ufs
> 
> External email: Use caution opening links or attachments
> 
> 
> Jeff:
>   I want to confirm why UFS apply the same rule to SCSI. Does UFS follows
> SCSI spec?
> 
> Thanks
> Liming
> > -----邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Jeff Brasen
> via
> > groups.io
> > 发送时间: 2022年6月15日 1:54
> > 收件人: devel@edk2.groups.io
> > 抄送: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> > zhichao@intel.com; ray...@intel.com; Jeff Brasen
> > 
> > 主题: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Add
> Disk
> > Info support for Ufs
> >
> > Add support for getting disk info from UFS devices.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c| 3
> > ++-
> >  MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf | 1
> +
> >  2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git
> > a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > index fac33b9ee9..87b82f299f 100644
> > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> > @@ -195,7 +195,8 @@ BmGetDescriptionFromDiskInfo (
> >
> >
> >BmEliminateExtraSpaces (Description);
> >
> >  }
> >
> > -  } else if (CompareGuid (&DiskInfo->Interface,
> > &gEfiDiskInfoScsiInterfaceGuid)) {
> >
> > +  } else if (CompareGuid (&DiskInfo->Interface,
> > &gEfiDiskInfoScsiInterfaceGuid) ||
> >
> > + CompareGuid (&DiskInfo->Interface,
> > &gEfiDiskInfoUfsInterfaceGuid)) {
> >
> >  BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
> >
> >  Status = DiskInfo->Inquiry (
> >
> >   DiskInfo,
> >
> > diff --git
> > a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > index fe05d5f1cc..2fc0a80a4e 100644
> > ---
> a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > +++
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> > @@ -85,6 +85,7 @@
> >gEfiDiskInfoIdeInterfaceGuid  ##
> > SOMETIMES_CONSUMES ## GUID
> >
> >gEfiDiskInfoScsiInterfaceGuid ##
> > SOMETIMES_CONSUMES ## GUID
> >
> >gEfiDiskInfoSdMmcInterfaceGuid##
> > SOMETIMES_CONSUMES ## GUID
> >
> > +  gEfiDiskInfoUfsInterfaceGuid  ##
> > SOMETIMES_CONSUMES ## GUID
> >
> >
> >
> >  [Protocols]
> >
> >gEfiPciRootBridgeIoProtocolGuid   ## CONSUMES
> >
> > --
> > 2.25.1
> >
> >
> >
> > 
> >
> >
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91535): https://edk2.groups.io/g/devel/message/91535
Mute This Topic: https://groups.io/mt/92484604/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override protocol

2022-07-11 Thread Jeff Brasen via groups.io
Yes we have systems where we will have more than 16 controllers/segments.

> -Original Message-
> From: Pierre Gondois 
> Sent: Monday, July 11, 2022 11:15 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> support for override protocol
> 
> External email: Use caution opening links or attachments
> 
> 
> On 7/11/22 17:32, Jeff Brasen wrote:
> > We also on some PCIe devices add a device entry under DOO_ w/ it's own
> _RST and _DSD. If you see the v3 version of the patch where I add a support
> library that we can override allows us to customize the device as we need.
> 
> Ok thanks! GeneratePciSlots() should allow you to add any platform specific
> device, and should ideally not modify the parent 'PCI0' object (even if it is
> possible in practice). So it should be ok.
> 
> A one last question:
> 
> [PATCH v3 2/3] DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF Is
> is still needed ?
> 
> Regards,
> Pierre
> 
> >
> > -Jeff
> >
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Monday, July 11, 2022 9:02 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> >> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> >> support for override protocol
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> Hello Jeff,
> >> To be sure I understand correctly, the SsdtPcieGenerator currently
> >> allows to generate something like this:
> >>
> >> Scope(_SB) {
> >> Device(PCI0) {
> >>   Device (D00_) { // Device 0
> >> Name(_ADR, 0x)
> >>   }
> >>   Method(_OSC,4) {
> >> [...] // Generic _OSC method
> >>   }
> >> }
> >> }
> >>
> >> What you want to do is:
> >> 1. Use another _OSC method
> >> 2. Add more information in the D00_ object, i.e.:
> >> - a _DSD object
> >> - a _RST method
> >> 3. As _RST is added in 2., also add a _RST method to PCI0
> >>
> >> Is it correct ? Or is there some other information you want to add ?
> >>
> >> Regards,
> >> Pierre
> >>
> >> On 7/8/22 17:36, Jeff Brasen wrote:
> >>> I think this would work. Instead of GeneratePciDeviceInfo the
> >>> function we would want to break out would be GeneratePciSlots. I'll
> >>> work on changing my patch series to this. Unless you have a better
> >>> name will call this library SsdtPciSupportLib and place in under
> >>> Library/Common
> >>>
> >>> Going to also pass PciInfo into AddOscMethod in this new approach in
> >>> case
> >> client needs to have different _OSC per controller (And to
> >> GeneratePciSlots as well).
> >>>
> >>> Thanks,
> >>> Jeff
> >>>
>  -Original Message-
>  From: Pierre Gondois 
>  Sent: Monday, July 4, 2022 2:48 AM
>  To: Jeff Brasen ; devel@edk2.groups.io
>  Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
>  Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
>  support for override protocol
> 
>  External email: Use caution opening links or attachments
> 
> 
>  Hello Jeff,
>  I think it would ideally be better to have the code
>  adding/replacing the methods/objects you noted inside the
>  edk2/edk2-platfoms repositories. The methods/objects that you want
>  to replace seem to only
> >> concern:
>  -the objects available in the 'Device (PCIx)' node -the _OSC method
> 
>  If a library with the following two methods (extracted from
>  SsdtPcieLibArm.inf) was created, would it be sufficient for all the
>  replacements you want to do ?
>  Like this we would have a generic implementation and specific ones.
> 
>  EFI_STATUS
>  EFIAPI
>  GeneratePciDeviceInfo (
>   IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,
>   INUINT32Uid,
>   IN  OUT   AML_OBJECT_NODE_HANDLEPciNode
>   )
> 
>  EFI_STATUS
>  EFIAPI
>  AddOscMethod (
>   IN  OUT   AML_OBJECT_NODE_HANDLE  PciNode
>   )
> 
>  Regards,
>  Pierre
> 
>  On 7/1/22 17:52, Jeff Brasen wrote:
> > Currently we do the following in this call.
> >
> > Remove and replace the _OSC method on certain targets. I
> > originally had this pass the template over but removed that when I
> > added this more generic override support Add a _RST method to the
> > root port device sub node Add a _DSD for device properties
> > Conditionally add an entry for the device attached to the PCIe bus
> > if we need to add properties or _RST methods. This will likely
> > eventually move to another driver (which is the purpose of patch
> > 2/4 in this series)
> >
> > I figured trying to get the generator to handle that would be more
> > difficult
>  as these would be hard to generalize.
> >
> >
> >

Re: [edk2-devel] [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override protocol

2022-07-11 Thread Jeff Brasen via groups.io
We also on some PCIe devices add a device entry under DOO_ w/ it's own _RST and 
_DSD. If you see the v3 version of the patch where I add a support library that 
we can override allows us to customize the device as we need. 

-Jeff


> -Original Message-
> From: Pierre Gondois 
> Sent: Monday, July 11, 2022 9:02 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> support for override protocol
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> To be sure I understand correctly, the SsdtPcieGenerator currently allows to
> generate something like this:
> 
> Scope(_SB) {
>Device(PCI0) {
>  Device (D00_) { // Device 0
>Name(_ADR, 0x)
>  }
>  Method(_OSC,4) {
>[...] // Generic _OSC method
>  }
>}
> }
> 
> What you want to do is:
> 1. Use another _OSC method
> 2. Add more information in the D00_ object, i.e.:
>- a _DSD object
>- a _RST method
> 3. As _RST is added in 2., also add a _RST method to PCI0
> 
> Is it correct ? Or is there some other information you want to add ?
> 
> Regards,
> Pierre
> 
> On 7/8/22 17:36, Jeff Brasen wrote:
> > I think this would work. Instead of GeneratePciDeviceInfo the function
> > we would want to break out would be GeneratePciSlots. I'll work on
> > changing my patch series to this. Unless you have a better name will
> > call this library SsdtPciSupportLib and place in under Library/Common
> >
> > Going to also pass PciInfo into AddOscMethod in this new approach in case
> client needs to have different _OSC per controller (And to GeneratePciSlots
> as well).
> >
> > Thanks,
> > Jeff
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Monday, July 4, 2022 2:48 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> >> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> >> support for override protocol
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> Hello Jeff,
> >> I think it would ideally be better to have the code adding/replacing
> >> the methods/objects you noted inside the edk2/edk2-platfoms
> >> repositories. The methods/objects that you want to replace seem to only
> concern:
> >> -the objects available in the 'Device (PCIx)' node -the _OSC method
> >>
> >> If a library with the following two methods (extracted from
> >> SsdtPcieLibArm.inf) was created, would it be sufficient for all the
> >> replacements you want to do ?
> >> Like this we would have a generic implementation and specific ones.
> >>
> >> EFI_STATUS
> >> EFIAPI
> >> GeneratePciDeviceInfo (
> >> IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,
> >> INUINT32Uid,
> >> IN  OUT   AML_OBJECT_NODE_HANDLEPciNode
> >> )
> >>
> >> EFI_STATUS
> >> EFIAPI
> >> AddOscMethod (
> >> IN  OUT   AML_OBJECT_NODE_HANDLE  PciNode
> >> )
> >>
> >> Regards,
> >> Pierre
> >>
> >> On 7/1/22 17:52, Jeff Brasen wrote:
> >>> Currently we do the following in this call.
> >>>
> >>> Remove and replace the _OSC method on certain targets. I originally
> >>> had this pass the template over but removed that when I added this
> >>> more generic override support Add a _RST method to the root port
> >>> device sub node Add a _DSD for device properties Conditionally add
> >>> an entry for the device attached to the PCIe bus if we need to add
> >>> properties or _RST methods. This will likely eventually move to
> >>> another driver (which is the purpose of patch 2/4 in this series)
> >>>
> >>> I figured trying to get the generator to handle that would be more
> >>> difficult
> >> as these would be hard to generalize.
> >>>
> >>>
> >>> Thanks,
> >>> Jeff
> >>>
>  -Original Message-
>  From: Pierre Gondois 
>  Sent: Friday, July 1, 2022 6:40 AM
>  To: Jeff Brasen ; devel@edk2.groups.io
>  Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
>  Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
>  support for override protocol
> 
>  External email: Use caution opening links or attachments
> 
> 
>  Hello Jeff,
>  Is it possible to know what the UpdateTable() function would do ?
>  Maybe it would be possible to integrate the alternative
>  implementation without adding a new protocol.
> 
>  Regards,
>  Pierre
> 
>  On 6/30/22 17:48, Jeff Brasen wrote:
> > Some platfoms may want to modify the ACPI table created.
> > Add support for protocol that can provide an alternative
> >> implementation.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> > DynamicTablesPkg/DynamicTablesPkg.dec |  3 +
> > .../Protocol/SsdtPcieOverrideProtocol.h   | 63
> >> +++
> > .../AcpiSsdtPcieLibArm/SsdtPcieGenerat

[edk2-devel] [PATCH v3 2/3] DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF

2022-07-08 Thread Jeff Brasen via groups.io
Add support for PCIe devices with UID > 0xF.
This is done by using the next value in the name so
PCI5, PC26, etc

Signed-off-by: Jeff Brasen 
---
 .../Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c  | 5 -
 .../Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h  | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
index d4c5f47b07..68ecae96be 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
@@ -824,7 +824,10 @@ GeneratePciDevice (
 
   // Write the name of the PCI device.
   CopyMem (AslName, "PCIx", AML_NAME_SEG_SIZE + 1);
-  AslName[AML_NAME_SEG_SIZE - 1] = AsciiFromHex (Uid);
+  AslName[AML_NAME_SEG_SIZE - 1] = AsciiFromHex (Uid & 0xF);
+  if (Uid > 0xF) {
+AslName[AML_NAME_SEG_SIZE - 2] = AsciiFromHex ((Uid >> 4) & 0xF);
+  }
 
   // ASL: Device (PCIx) {}
   Status = AmlCodeGenDevice (AslName, ScopeNode, &PciNode);
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h
index 59a0d601a3..515a3e1785 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h
@@ -31,7 +31,7 @@
 Corresponding changes would be needed to support the Name and
 UID fields describing the Pci root complexes.
 */
-#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED  16
+#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED  256
 
 // _SB scope of the AML namespace.
 #define SB_SCOPE  "\\_SB_"
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91194): https://edk2.groups.io/g/devel/message/91194
Mute This Topic: https://groups.io/mt/92260872/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 3/3] DynamicTablesPkg: AcpiSsdtPcieLibArm: Create support library

2022-07-08 Thread Jeff Brasen via groups.io
Add support library to allow for customization of _OSC and slot info.

The functions in the library are unchanged,

with the exception of adding PciInfo pointer to the APIs.



Signed-off-by: Jeff Brasen 

---

 .../Include/Library/SsdtPcieSupportLib.h  |  73 +++

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 168 +--

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h|  15 --

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |   2 +-

 .../SsdtPcieOscTemplate.asl   |   0

 .../SsdtPcieSupportLib/SsdtPcieSupportLib.c   | 200 ++

 .../SsdtPcieSupportLib/SsdtPcieSupportLib.inf |  30 +++

 .../SsdtPcieSupportLibPrivate.h   |  25 +++

 8 files changed, 332 insertions(+), 181 deletions(-)

 create mode 100644 DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

 rename DynamicTablesPkg/Library/{Acpi/Arm/AcpiSsdtPcieLibArm => 
Common/SsdtPcieSupportLib}/SsdtPcieOscTemplate.asl (100%)

 create mode 100644 
DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c

 create mode 100644 
DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.inf

 create mode 100644 
DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLibPrivate.h



diff --git a/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h 
b/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

new file mode 100644

index 00..f65431ef28

--- /dev/null

+++ b/DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h

@@ -0,0 +1,73 @@

+/** @file

+  Ssdt PCie Support Library

+

+  Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#ifndef SSDT_PCIE_SUPPORT_LIB_H_

+#define SSDT_PCIE_SUPPORT_LIB_H_

+

+#pragma pack(1)

+

+/** Structure used to map integer to an index.

+*/

+typedef struct MappingTable {

+  /// Mapping table.

+  /// Contains the Index <-> integer mapping

+  UINT32*Table;

+

+  /// Last used index of the Table.

+  /// Bound by MaxIndex.

+  UINT32LastIndex;

+

+  /// Number of entries in the Table.

+  UINT32MaxIndex;

+} MAPPING_TABLE;

+

+#pragma pack()

+

+/** Add an _OSC template method to the PciNode.

+

+  The _OSC method is provided as an AML blob. The blob is

+  parsed and attached at the end of the PciNode list of variable elements.

+

+  @param [in]   PciInfo Pci device information.

+  @param [in, out]  PciNode Pci node to amend.

+

+  @retval EFI_SUCCESS The function completed successfully.

+  @retval EFI_INVALID_PARAMETER   Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCESCould not allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+AddOscMethod (

+  IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

+  IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

+  );

+

+/** Generate Pci slots devices.

+

+  PCI Firmware Specification - Revision 3.3,

+  s4.8 "Generic ACPI PCI Slot Description" requests to describe the PCI slot

+  used. It should be possible to enumerate them, but this is additional

+  information.

+

+  @param [in]   PciInfo Pci device information.

+  @param [in]  MappingTable The mapping table structure.

+  @param [in, out]  PciNode Pci node to amend.

+

+  @retval EFI_SUCCESSSuccess.

+  @retval EFI_INVALID_PARAMETER  Invalid parameter.

+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory.

+**/

+EFI_STATUS

+EFIAPI

+GeneratePciSlots (

+  IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

+  IN  CONST MAPPING_TABLE *MappingTable,

+  IN  OUT   AML_OBJECT_NODE_HANDLEPciNode

+  );

+

+#endif // SSDT_PCIE_SUPPORT_LIB_H_

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index 68ecae96be..62cec3753c 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -29,6 +29,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 

 #include "SsdtPcieGenerator.h"

@@ -280,86 +281,6 @@ GeneratePciDeviceInfo (

   return Status;

 }

 

-/** Generate Pci slots devices.

-

-  PCI Firmware Specification - Revision 3.3,

-  s4.8 "Generic ACPI PCI Slot Description" requests to describe the PCI slot

-  used. It should be possible to enumerate them, but this is additional

-  information.

-

-  @param [in]  MappingTable  The mapping table structure.

-  @param [in, out]  PciNode Pci node to amend.

-

-  @retval EFI_SUCCESSSuccess.

-  @retval EFI_INVALID_PARAMETER  Invalid parameter.

-  @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory.

-**/

-STATIC

-EFI_STATUS

-EFIAPI

-GeneratePciSlots (

-  IN  CONST MAPPING_TABLE   *MappingTable,

-  IN  OUT   AML_OBJECT_NODE_HANDLE  PciNode

-  )

-{

-  EFI_STATUS  Status;

-  UINT32

[edk2-devel] [PATCH v3 1/3] DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value

2022-07-08 Thread Jeff Brasen via groups.io
The translation value in ACPI should be the difference between the CPU and PCIe 
address.



Signed-off-by: Jeff Brasen 

---

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 18 --

 1 file changed, 12 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index a34018151f..d4c5f47b07 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -540,6 +540,7 @@ GeneratePciCrs (

   UINT32   RefCount;

   CM_ARM_PCI_ADDRESS_MAP_INFO  *AddrMapInfo;

   AML_OBJECT_NODE_HANDLE   CrsNode;

+  BOOLEAN  IsPosDecode;

 

   ASSERT (Generator != NULL);

   ASSERT (CfgMgrProtocol != NULL);

@@ -609,6 +610,11 @@ GeneratePciCrs (

 }

 

 Translation = (AddrMapInfo->CpuAddress != AddrMapInfo->PciAddress);

+if (AddrMapInfo->CpuAddress >= AddrMapInfo->PciAddress) {

+  IsPosDecode = TRUE;

+} else {

+  IsPosDecode = FALSE;

+}

 

 switch (AddrMapInfo->SpaceCode) {

   case PCI_SS_IO:

@@ -616,12 +622,12 @@ GeneratePciCrs (

FALSE,

TRUE,

TRUE,

-   TRUE,

+   IsPosDecode,

3,

0,

AddrMapInfo->PciAddress,

AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,

-   Translation ? AddrMapInfo->CpuAddress : 0,

+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,

AddrMapInfo->AddressSize,

0,

NULL,

@@ -635,7 +641,7 @@ GeneratePciCrs (

   case PCI_SS_M32:

 Status = AmlCodeGenRdDWordMemory (

FALSE,

-   TRUE,

+   IsPosDecode,

TRUE,

TRUE,

TRUE,

@@ -643,7 +649,7 @@ GeneratePciCrs (

0,

AddrMapInfo->PciAddress,

AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,

-   Translation ? AddrMapInfo->CpuAddress : 0,

+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,

AddrMapInfo->AddressSize,

0,

NULL,

@@ -657,7 +663,7 @@ GeneratePciCrs (

   case PCI_SS_M64:

 Status = AmlCodeGenRdQWordMemory (

FALSE,

-   TRUE,

+   IsPosDecode,

TRUE,

TRUE,

TRUE,

@@ -665,7 +671,7 @@ GeneratePciCrs (

0,

AddrMapInfo->PciAddress,

AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,

-   Translation ? AddrMapInfo->CpuAddress : 0,

+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,

AddrMapInfo->AddressSize,

0,

NULL,

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91192): https://edk2.groups.io/g/devel/message/91192
Mute This Topic: https://groups.io/mt/92260870/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 0/3] DynamicTablesPkg: Pcie generation updates

2022-07-08 Thread Jeff Brasen via groups.io


Add fixes/features to dynamic PCIe support

 - Correct issue with translation in generated ACPI tables.
 - Allow for more than 16 controllers to be generated.
 - Add support library to allow for override of _OSC and slot info.

Updates:
 v3 - Remove segment as UID patch, convert override to library
 v2 - Add IsPosDecode logic to translation patch


Jeff Brasen (3):
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Create support library

 .../Include/Library/SsdtPcieSupportLib.h  |  73 +++
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 191 ++---
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h|  17 +-
 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |   2 +-
 .../SsdtPcieOscTemplate.asl   |   0
 .../SsdtPcieSupportLib/SsdtPcieSupportLib.c   | 200 ++
 .../SsdtPcieSupportLib/SsdtPcieSupportLib.inf |  30 +++
 .../SsdtPcieSupportLibPrivate.h   |  25 +++
 8 files changed, 349 insertions(+), 189 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Library/SsdtPcieSupportLib.h
 rename DynamicTablesPkg/Library/{Acpi/Arm/AcpiSsdtPcieLibArm => 
Common/SsdtPcieSupportLib}/SsdtPcieOscTemplate.asl (100%)
 create mode 100644 
DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.c
 create mode 100644 
DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.inf
 create mode 100644 
DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLibPrivate.h

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91191): https://edk2.groups.io/g/devel/message/91191
Mute This Topic: https://groups.io/mt/92260869/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override protocol

2022-07-08 Thread Jeff Brasen via groups.io
I think this would work. Instead of GeneratePciDeviceInfo the function we would 
want to break out would be GeneratePciSlots. I'll work on changing my patch 
series to this. Unless you have a better name will call this library 
SsdtPciSupportLib and place in under Library/Common

Going to also pass PciInfo into AddOscMethod in this new approach in case 
client needs to have different _OSC per controller (And to GeneratePciSlots as 
well).

Thanks,
Jeff

> -Original Message-
> From: Pierre Gondois 
> Sent: Monday, July 4, 2022 2:48 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> support for override protocol
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> I think it would ideally be better to have the code adding/replacing the
> methods/objects you noted inside the edk2/edk2-platfoms repositories. The
> methods/objects that you want to replace seem to only concern:
> -the objects available in the 'Device (PCIx)' node -the _OSC method
> 
> If a library with the following two methods (extracted from
> SsdtPcieLibArm.inf) was created, would it be sufficient for all the
> replacements you want to do ?
> Like this we would have a generic implementation and specific ones.
> 
> EFI_STATUS
> EFIAPI
> GeneratePciDeviceInfo (
>IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,
>INUINT32Uid,
>IN  OUT   AML_OBJECT_NODE_HANDLEPciNode
>)
> 
> EFI_STATUS
> EFIAPI
> AddOscMethod (
>IN  OUT   AML_OBJECT_NODE_HANDLE  PciNode
>)
> 
> Regards,
> Pierre
> 
> On 7/1/22 17:52, Jeff Brasen wrote:
> > Currently we do the following in this call.
> >
> > Remove and replace the _OSC method on certain targets. I originally
> > had this pass the template over but removed that when I added this
> > more generic override support Add a _RST method to the root port
> > device sub node Add a _DSD for device properties Conditionally add an
> > entry for the device attached to the PCIe bus if we need to add
> > properties or _RST methods. This will likely eventually move to
> > another driver (which is the purpose of patch 2/4 in this series)
> >
> > I figured trying to get the generator to handle that would be more difficult
> as these would be hard to generalize.
> >
> >
> > Thanks,
> > Jeff
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Friday, July 1, 2022 6:40 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> >> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> >> support for override protocol
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> Hello Jeff,
> >> Is it possible to know what the UpdateTable() function would do ?
> >> Maybe it would be possible to integrate the alternative
> >> implementation without adding a new protocol.
> >>
> >> Regards,
> >> Pierre
> >>
> >> On 6/30/22 17:48, Jeff Brasen wrote:
> >>> Some platfoms may want to modify the ACPI table created.
> >>> Add support for protocol that can provide an alternative
> implementation.
> >>>
> >>> Signed-off-by: Jeff Brasen 
> >>> ---
> >>>DynamicTablesPkg/DynamicTablesPkg.dec |  3 +
> >>>.../Protocol/SsdtPcieOverrideProtocol.h   | 63
> +++
> >>>.../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 31 -
> >>>.../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  4 ++
> >>>4 files changed, 98 insertions(+), 3 deletions(-)
> >>>create mode 100644
> >>> DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> >>>
> >>> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> b/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> index a890a048be..bb66bdaf14 100644
> >>> --- a/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> +++ b/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> @@ -43,6 +43,9 @@
> >>>  # Dynamic Table Factory Protocol GUID
> >>>  gEdkiiDynamicTableFactoryProtocolGuid = { 0x91d1e327, 0xfe5a,
> >>> 0x49b8, { 0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec } }
> >>>
> >>> +  # Protocol to override PCI SSDT table generation
> >>> + gEdkiiDynamicTableSsdtPcieOverrideProtocolGuid = { 0x962e8b44,
> >>> + 0x23b3, 0x41da, { 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 }
> >>> + }
> >>> +
> >>>[PcdsFixedAtBuild]
> >>>
> >>>  # Maximum number of Custom ACPI Generators diff --git
> >>> a/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> >>> b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> >>> new file mode 100644
> >>> index 00..29568a0159
> >>> --- /dev/null
> >>> +++ b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> >>> @@ -0,0 +1,63 @@
> >>> +/** @file
> >>> +
> >>> +  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
> >>> +
> >>> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> >>> +
> >>> +*

Re: [edk2-devel] [PATCH 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as UID

2022-07-08 Thread Jeff Brasen via groups.io
So to detail the use case we have an embedded device on a known controller (we 
know the segment number) by forcing the autogeneration to the segment number we 
could in another SSDT create the subdevice node right. With just \SB\PCI9\D0x 
as the scope right? If we had a callback I suppose we don't need that. I think 
we could handle that with the proposed change you had in [4/4] if we just chain 
the implementation of GeneratePciDeviceInfo to our second place we would 
implement this. I think we can drop this patch and do it that way. Will move 
additional thoughts to the other patch.

Thanks,
Jeff


> -Original Message-
> From: Pierre Gondois 
> Sent: Monday, July 4, 2022 2:38 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use
> of segment number as UID
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> I understand that since the _UID value is generated, it is not possible for an
> external module to guess its value.
> However, the pcd (and the case you detailed) seem to be really specific.
> If you need an interface in the AmlLib to locate an AML node based on
> custom callback, we can help.
> Would this fit your need ?
> Also I don't understand how having a known _UID would ease locating the
> PCI device node.
> 
> Regards,
> Pierre
> 
> On 7/1/22 17:54, Jeff Brasen wrote:
> > I don't think there are any requirements that this should be mapped this
> way which is why I added this under a PCD to enable it. We have a use case
> where it would be helpful to know the ACPI path of the PCIe controllers
> externally and using the segment number for that would allow us to do this
> without having to have matching logic that calculates the PCIe UID from the
> CM object list again.
> >
> > Thanks,
> > Jeff
> >
> >
> >> -Original Message-
> >> From: Pierre Gondois 
> >> Sent: Friday, July 1, 2022 6:42 AM
> >> To: Jeff Brasen ; devel@edk2.groups.io
> >> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> >> Subject: Re: [PATCH 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow
> >> use of segment number as UID
> >>
> >> External email: Use caution opening links or attachments
> >>
> >>
> >> Hello Jeff,
> >>
> >>   From "PCI Firmware Specification Revision 3.3", s4.1.2.
> >> "MCFG Table Description", the "PCI Segment Group Number" field of the
> >> MCFG table must match the value returned by the _SEG object in the
> >> corresponding object.
> >>
> >> I didn't find any constraint about the _UID value. Would it be
> >> possible to know why this is required ?
> >>
> >> Regards,
> >> Pierre
> >>
> >> On 6/30/22 17:48, Jeff Brasen wrote:
> >>> Add support for selecting to use index or segment number as UID and
> >> name.
> >>> This allows the path of the nodes to be well known.
> >>>
> >>> Signed-off-by: Jeff Brasen 
> >>> ---
> >>>DynamicTablesPkg/DynamicTablesPkg.dec |  3 +++
> >>>.../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 19
> >> ++-
> >>>.../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  3 +++
> >>>3 files changed, 24 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> b/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> index 9b74c5a671..a890a048be 100644
> >>> --- a/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> +++ b/DynamicTablesPkg/DynamicTablesPkg.dec
> >>> @@ -57,5 +57,8 @@
> >>>  # Non BSA Compliant 16550 Serial HID
> >>>
> >>>
> >>
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHi
> >> d|
> >>> ""|VOID*|0x4008
> >>>
> >>> +  # Use PCI segment numbers as UID
> >>> +
> >>> +
> >>
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|B
> >> OO
> >>> + LEAN|0x4009
> >>> +
> >>>[Guids]
> >>>  gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8,
> >>> 0x4613, { 0x87, 0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } } diff
> >>> --git
> >>>
> >>
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> >> t
> >>> or.c
> >>>
> >>
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> >> t
> >>> or.c
> >>> index f0d15f69a4..85782af380 100644
> >>> ---
> >>>
> >>
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> >> t
> >>> or.c
> >>> +++
> >> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGen
> >>> +++ erator.c
> >>> @@ -996,6 +996,7 @@ BuildSsdtPciTableEx (
> >>>  UINTN Index;
> >>>  EFI_ACPI_DESCRIPTION_HEADER   **TableList;
> >>>  ACPI_PCI_GENERATOR*Generator;
> >>> +  UINT32Uid;
> >>>
> >>>  ASSERT (This != NULL);
> >>>  ASSERT (AcpiTableInfo != NULL); @@ -1051,13 +1052,29 @@
> >>> BuildSsdtPciTableEx (
> >>>  *Table = TableList;
> >>>
> >>>  for (Index = 0; Index < PciCount; Index++) {
> >>> +if (PcdGetBool (PcdPciUseSegmentAsUid)) {
> >>> +  Uid = 

Re: [edk2-devel] [PATCH v2 0/4] DynamicTablesPkg: Pcie generation updates

2022-07-08 Thread Jeff Brasen via groups.io
Ok, I never got those responses, will have to check what happened with my 
email. Will respond to those.

> -Original Message-
> From: Pierre Gondois 
> Sent: Friday, July 8, 2022 1:31 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH v2 0/4] DynamicTablesPkg: Pcie generation updates
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> I had some questions about the V1 at:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2.groups.io%2Fg%2Fdevel%2Ftopic%2F92089320%2390932&data=05%7
> C01%7Cjbrasen%40nvidia.com%7C8a911ded72fd403690f208da60b3e0a9%7C
> 43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637928622942274065%7C
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB
> TiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=p3jCMX%
> 2Fi0wf60FA2DgsGV7b3Vq6qw8jP6Kjp82YOoKg%3D&reserved=0
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2.groups.io%2Fg%2Fdevel%2Ftopic%2F92089321%2390933&data=05%7
> C01%7Cjbrasen%40nvidia.com%7C8a911ded72fd403690f208da60b3e0a9%7C
> 43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637928622942274065%7C
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB
> TiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=IBjcEWb5
> VY7iXXkwOuP5LZN8c3aFdB25ophGXAVfHjQ%3D&reserved=0
> 
> Regards,
> Pierre
> 
> On 7/7/22 18:59, Jeff Brasen wrote:
> > Pierre,
> >
> >   Any thoughts on this v2 version?
> >
> > -Jeff
> >
> >
> >> -Original Message-
> >> From: Jeff Brasen 
> >> Sent: Friday, July 1, 2022 10:33 AM
> >> To: devel@edk2.groups.io
> >> Cc: pierre.gond...@arm.com; sami.muja...@arm.com;
> >> alexei.fedo...@arm.com; Jeff Brasen 
> >> Subject: [PATCH v2 0/4] DynamicTablesPkg: Pcie generation updates
> >>
> >> Add fixes/features to dynamic PCIe support
> >>
> >> - Correct issue with translation in generated ACPI tables.
> >> - Allow for more than 16 controllers to be generated.
> >> - Allow optional use of segment number as UID for cases where ACPI
> >> path is needed in other places.
> >> - Add support for override protocol that allows platform specific
> >> modification of node prior to creation.
> >>
> >> Update:
> >> v2 - Add IsPosDecode logic to translation patch
> >>
> >> Jeff Brasen (4):
> >>DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value
> >>DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number
> as
> >>  UID
> >>DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF
> >>DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override
> >>  protocol
> >>
> >>   DynamicTablesPkg/DynamicTablesPkg.dec |  6 ++
> >>   .../Protocol/SsdtPcieOverrideProtocol.h   | 63 
> >>   .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 73 -
> --
> >>   .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h|  2 +-
> >>   .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  7 ++
> >>   5 files changed, 139 insertions(+), 12 deletions(-)  create mode
> >> 100644 DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> >>
> >> --
> >> 2.25.1
> >


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91183): https://edk2.groups.io/g/devel/message/91183
Mute This Topic: https://groups.io/mt/92113674/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Add Disk Info support for Ufs

2022-07-07 Thread Jeff Brasen via groups.io
Just following up on my outstanding edk2 patches to check on status/review 
feedback.

Thanks,
Jeff

> -Original Message-
> From: Jeff Brasen 
> Sent: Tuesday, June 14, 2022 11:54 AM
> To: devel@edk2.groups.io
> Cc: jian.j.w...@intel.com; gaolim...@byosoft.com.cn;
> zhichao@intel.com; ray...@intel.com; Jeff Brasen
> 
> Subject: [PATCH] MdeModulePkg/UefiBootManagerLib: Add Disk Info
> support for Ufs
> 
> Add support for getting disk info from UFS devices.
> 
> Signed-off-by: Jeff Brasen 
> ---
>  MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c| 3 ++-
>  MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> index fac33b9ee9..87b82f299f 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
> @@ -195,7 +195,8 @@ BmGetDescriptionFromDiskInfo (
> 
> 
>BmEliminateExtraSpaces (Description);
> 
>  }
> 
> -  } else if (CompareGuid (&DiskInfo->Interface,
> &gEfiDiskInfoScsiInterfaceGuid)) {
> 
> +  } else if (CompareGuid (&DiskInfo->Interface,
> &gEfiDiskInfoScsiInterfaceGuid) ||
> 
> + CompareGuid (&DiskInfo->Interface,
> &gEfiDiskInfoUfsInterfaceGuid)) {
> 
>  BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
> 
>  Status = DiskInfo->Inquiry (
> 
>   DiskInfo,
> 
> diff --git
> a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> index fe05d5f1cc..2fc0a80a4e 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> +++
> b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
> @@ -85,6 +85,7 @@
>gEfiDiskInfoIdeInterfaceGuid  ## SOMETIMES_CONSUMES ## GUID
> 
>gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID
> 
>gEfiDiskInfoSdMmcInterfaceGuid## SOMETIMES_CONSUMES ##
> GUID
> 
> +  gEfiDiskInfoUfsInterfaceGuid  ## SOMETIMES_CONSUMES ##
> GUID
> 
> 
> 
>  [Protocols]
> 
>gEfiPciRootBridgeIoProtocolGuid   ## CONSUMES
> 
> --
> 2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91160): https://edk2.groups.io/g/devel/message/91160
Mute This Topic: https://groups.io/mt/91755004/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs

2022-07-07 Thread Jeff Brasen via groups.io
Just following up on my outstanding edk2 patches to check on status/review 
feedback.

Thanks,
Jeff

> -Original Message-
> From: Jeff Brasen
> Sent: Friday, June 17, 2022 9:38 AM
> To: gaoliming ; devel@edk2.groups.io;
> bob.c.f...@intel.com
> Cc: 'Chen, Christine' 
> Subject: RE: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> 
> Anything else needed prior to getting this merged to edk2?
> 
> > -Original Message-
> > From: gaoliming 
> > Sent: Thursday, May 19, 2022 7:19 PM
> > To: devel@edk2.groups.io; bob.c.f...@intel.com; Jeff Brasen
> > 
> > Cc: 'Chen, Christine' 
> > Subject: 回复: [edk2-devel] [PATCH] .gitignore: Ignore build tools build
> > logs
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Reviewed-by: Liming Gao 
> >
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Bob Feng
> > > 发送时间: 2022年5月18日 15:15
> > > 收件人: devel@edk2.groups.io; Gao, Liming
> > ;
> > > jbra...@nvidia.com
> > > 抄送: Chen, Christine 
> > > 主题: Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build
> > > logs
> > >
> > > They are the BaseTools build log files that are generated by
> > > BaseTools/Edk2ToolsBuild.py.
> > >
> > > Thanks,
> > > Bob
> > >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of
> > > gaoliming
> > > Sent: Wednesday, May 18, 2022 2:40 PM
> > > To: devel@edk2.groups.io; jbra...@nvidia.com
> > > Cc: Feng, Bob C ; Chen, Christine
> > > 
> > > Subject: 回复: [edk2-devel] [PATCH] .gitignore: Ignore build tools
> > > build logs
> > >
> > > Bob:
> > >   Do you know what files will be generated in
> > > BaseTools/BaseToolsBuild directory?
> > >
> > > Thanks
> > > Liming
> > > > -邮件原件-
> > > > 发件人: devel@edk2.groups.io  代表 Jeff
> > Brasen
> > > via
> > > > groups.io
> > > > 发送时间: 2022年4月22日 1:01
> > > > 收件人: devel@edk2.groups.io
> > > > 抄送: bob.c.f...@intel.com; gaolim...@byosoft.com.cn;
> > > > yuwei.c...@intel.com; Jeff Brasen 
> > > > 主题: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> > > >
> > > > The python BaseTools/Edk2ToolsBuild.py creates files in
> > > > BaseTools/BaseToolsBuild and should be ignored.
> > > >
> > > > Signed-off-by: Jeff Brasen 
> > > > ---
> > > >  BaseTools/.gitignore | 3 ++-
> > > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/BaseTools/.gitignore b/BaseTools/.gitignore index
> > > > a45689bc89..ddf93b7116 100644
> > > > --- a/BaseTools/.gitignore
> > > > +++ b/BaseTools/.gitignore
> > > > @@ -17,4 +17,5 @@ Source/C/VfrCompile/VfrTokens.h  Source/C/bin/
> > > > Source/C/libs/
> > > >  Bin/Win32
> > > > -Lib
> > > > \ No newline at end of file
> > > > +Lib
> > > > +BaseToolsBuild/
> > > > \ No newline at end of file
> > > > --
> > > > 2.25.1
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > 
> > >
> >
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91159): https://edk2.groups.io/g/devel/message/91159
Mute This Topic: https://groups.io/mt/91823747/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 0/4] DynamicTablesPkg: Pcie generation updates

2022-07-07 Thread Jeff Brasen via groups.io
Pierre,

 Any thoughts on this v2 version?

-Jeff


> -Original Message-
> From: Jeff Brasen 
> Sent: Friday, July 1, 2022 10:33 AM
> To: devel@edk2.groups.io
> Cc: pierre.gond...@arm.com; sami.muja...@arm.com;
> alexei.fedo...@arm.com; Jeff Brasen 
> Subject: [PATCH v2 0/4] DynamicTablesPkg: Pcie generation updates
> 
> Add fixes/features to dynamic PCIe support
> 
> - Correct issue with translation in generated ACPI tables.
> - Allow for more than 16 controllers to be generated.
> - Allow optional use of segment number as UID for cases where ACPI path is
> needed in other places.
> - Add support for override protocol that allows platform specific modification
> of node prior to creation.
> 
> Update:
> v2 - Add IsPosDecode logic to translation patch
> 
> Jeff Brasen (4):
>   DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value
>   DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as
> UID
>   DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF
>   DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override
> protocol
> 
>  DynamicTablesPkg/DynamicTablesPkg.dec |  6 ++
>  .../Protocol/SsdtPcieOverrideProtocol.h   | 63 
>  .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 73 ---
>  .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h|  2 +-
>  .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  7 ++
>  5 files changed, 139 insertions(+), 12 deletions(-)  create mode 100644
> DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> 
> --
> 2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91146): https://edk2.groups.io/g/devel/message/91146
Mute This Topic: https://groups.io/mt/92113674/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override protocol

2022-07-01 Thread Jeff Brasen via groups.io
Some platfoms may want to modify the ACPI table created.

Add support for protocol that can provide an alternative implementation.



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/DynamicTablesPkg.dec |  3 +

 .../Protocol/SsdtPcieOverrideProtocol.h   | 63 +++

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 31 -

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  4 ++

 4 files changed, 98 insertions(+), 3 deletions(-)

 create mode 100644 DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h



diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec

index a890a048be..bb66bdaf14 100644

--- a/DynamicTablesPkg/DynamicTablesPkg.dec

+++ b/DynamicTablesPkg/DynamicTablesPkg.dec

@@ -43,6 +43,9 @@

   # Dynamic Table Factory Protocol GUID

   gEdkiiDynamicTableFactoryProtocolGuid = { 0x91d1e327, 0xfe5a, 0x49b8, { 
0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec } }

 

+  # Protocol to override PCI SSDT table generation

+  gEdkiiDynamicTableSsdtPcieOverrideProtocolGuid = { 0x962e8b44, 0x23b3, 
0x41da, { 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 } }

+

 [PcdsFixedAtBuild]

 

   # Maximum number of Custom ACPI Generators

diff --git a/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h 
b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h

new file mode 100644

index 00..29568a0159

--- /dev/null

+++ b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h

@@ -0,0 +1,63 @@

+/** @file

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#ifndef SSDT_PCIE_OVERRIDE_PROTOCOL_H_

+#define SSDT_PCIE_OVERRIDE_PROTOCOL_H_

+

+#include 

+#include 

+

+/** This macro defines the SSDT PCI Override Protocol GUID.

+

+  GUID: {D85A4835-5A82-4894-AC02-706F43D5978E}

+*/

+#define EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_GUID   \

+  { 0x962e8b44, 0x23b3, 0x41da, \

+{ 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 }  \

+  };

+

+/**

+  Forward declarations:

+*/

+typedef struct SsdtOverridePciProtocol EDKII_SSDT_PCI_OVERRIDE_PROTOCOL;

+

+/** The UpdateTable function allows the override protocol to update the

+ *   PCIe SSDT table prior to being created.

+

+  @param [in]  ThisPointer to the SSDT PCI Override Protocol.

+  @param [in]  PciInfo The PCIe configuration info for this node.

+  @param [in]  Uid UID that was selected for this PCIe node.

+  @param [in, out] PciNode Pointer to the PCI node of this ACPI table.

+

+  @retval EFI_SUCCESS   Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_DEVICE_ERROR  Failed to update the table.

+**/

+typedef

+EFI_STATUS

+(EFIAPI *EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_UPDATE_TABLE)(

+  IN  CONST EDKII_SSDT_PCI_OVERRIDE_PROTOCOL  *CONST  This,

+  IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

+  INUINT32Uid,

+  IN  OUT   AML_ROOT_NODE_HANDLE  *PciNode

+  );

+

+/** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure describes the

+Configuration Manager Protocol interface.

+*/

+typedef struct SsdtOverridePciProtocol {

+  /** The interface used to update the ACPI table for PCI.

+  */

+  EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_UPDATE_TABLEUpdateTable;

+} EDKII_SSDT_PCI_OVERRIDE_PROTOCOL;

+

+/** The SSDT PCI Override Protocol GUID.

+*/

+extern EFI_GUID  gEdkiiDynamicTableSsdtPcieOverrideProtocolGuid;

+

+#endif // SSDT_PCIE_OVERRIDE_PROTOCOL_H_

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index 9f785ca5ac..46e0a98b98 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -20,6 +20,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 

 // Module specific include files.

@@ -30,6 +31,7 @@

 #include 

 #include 

 #include 

+#include 

 

 #include "SsdtPcieGenerator.h"

 

@@ -804,9 +806,10 @@ GeneratePciDevice (

 {

   EFI_STATUS  Status;

 

-  CHAR8   AslName[AML_NAME_SEG_SIZE + 1];

-  AML_OBJECT_NODE_HANDLE  ScopeNode;

-  AML_OBJECT_NODE_HANDLE  PciNode;

+  CHAR8 AslName[AML_NAME_SEG_SIZE + 1];

+  AML_OBJECT_NODE_HANDLEScopeNode;

+  AML_OBJECT_NODE_HANDLEPciNode;

+  EDKII_SSDT_PCI_OVERRIDE_PROTOCOL  *OverrideProtocol;

 

   ASSERT (Generator != NULL);

   ASSERT (CfgMgrProtocol != NULL);

@@ -866,6 +869,28 @@ GeneratePciDevice (

 

   // Add the template _OSC method.

   Status = AddOscMethod (PciNode);

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = gBS->LocateProtocol (

+  &gEdkiiDynam

[edk2-devel] [PATCH v2 1/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value

2022-07-01 Thread Jeff Brasen via groups.io
The translation value in ACPI should be the difference between the CPU and PCIe 
address.



Signed-off-by: Jeff Brasen 

---

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 18 --

 1 file changed, 12 insertions(+), 6 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index a34018151f..d4c5f47b07 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -540,6 +540,7 @@ GeneratePciCrs (

   UINT32   RefCount;

   CM_ARM_PCI_ADDRESS_MAP_INFO  *AddrMapInfo;

   AML_OBJECT_NODE_HANDLE   CrsNode;

+  BOOLEAN  IsPosDecode;

 

   ASSERT (Generator != NULL);

   ASSERT (CfgMgrProtocol != NULL);

@@ -609,6 +610,11 @@ GeneratePciCrs (

 }

 

 Translation = (AddrMapInfo->CpuAddress != AddrMapInfo->PciAddress);

+if (AddrMapInfo->CpuAddress >= AddrMapInfo->PciAddress) {

+  IsPosDecode = TRUE;

+} else {

+  IsPosDecode = FALSE;

+}

 

 switch (AddrMapInfo->SpaceCode) {

   case PCI_SS_IO:

@@ -616,12 +622,12 @@ GeneratePciCrs (

FALSE,

TRUE,

TRUE,

-   TRUE,

+   IsPosDecode,

3,

0,

AddrMapInfo->PciAddress,

AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,

-   Translation ? AddrMapInfo->CpuAddress : 0,

+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,

AddrMapInfo->AddressSize,

0,

NULL,

@@ -635,7 +641,7 @@ GeneratePciCrs (

   case PCI_SS_M32:

 Status = AmlCodeGenRdDWordMemory (

FALSE,

-   TRUE,

+   IsPosDecode,

TRUE,

TRUE,

TRUE,

@@ -643,7 +649,7 @@ GeneratePciCrs (

0,

AddrMapInfo->PciAddress,

AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,

-   Translation ? AddrMapInfo->CpuAddress : 0,

+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,

AddrMapInfo->AddressSize,

0,

NULL,

@@ -657,7 +663,7 @@ GeneratePciCrs (

   case PCI_SS_M64:

 Status = AmlCodeGenRdQWordMemory (

FALSE,

-   TRUE,

+   IsPosDecode,

TRUE,

TRUE,

TRUE,

@@ -665,7 +671,7 @@ GeneratePciCrs (

0,

AddrMapInfo->PciAddress,

AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,

-   Translation ? AddrMapInfo->CpuAddress : 0,

+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,

AddrMapInfo->AddressSize,

0,

NULL,

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90998): https://edk2.groups.io/g/devel/message/90998
Mute This Topic: https://groups.io/mt/92113675/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as UID

2022-07-01 Thread Jeff Brasen via groups.io
Add support for selecting to use index or segment number as UID and name.

This allows the path of the nodes to be well known.



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/DynamicTablesPkg.dec |  3 +++

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 19 ++-

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  3 +++

 3 files changed, 24 insertions(+), 1 deletion(-)



diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec

index 9b74c5a671..a890a048be 100644

--- a/DynamicTablesPkg/DynamicTablesPkg.dec

+++ b/DynamicTablesPkg/DynamicTablesPkg.dec

@@ -57,5 +57,8 @@

   # Non BSA Compliant 16550 Serial HID

   
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHid|""|VOID*|0x4008

 

+  # Use PCI segment numbers as UID

+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|BOOLEAN|0x4009

+

 [Guids]

   gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index d4c5f47b07..80776ceb79 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -1002,6 +1002,7 @@ BuildSsdtPciTableEx (

   UINTN Index;

   EFI_ACPI_DESCRIPTION_HEADER   **TableList;

   ACPI_PCI_GENERATOR*Generator;

+  UINT32Uid;

 

   ASSERT (This != NULL);

   ASSERT (AcpiTableInfo != NULL);

@@ -1057,13 +1058,29 @@ BuildSsdtPciTableEx (

   *Table = TableList;

 

   for (Index = 0; Index < PciCount; Index++) {

+if (PcdGetBool (PcdPciUseSegmentAsUid)) {

+  Uid = PciInfo[Index].PciSegmentGroupNumber;

+  if (Uid > MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {

+DEBUG ((

+  DEBUG_ERROR,

+  "ERROR: SSDT-PCI: Pci root complexes segment number: %d."

+  " Greater than maximum number of Pci root complexes supported = 
%d.\n",

+  Uid,

+  MAX_PCI_ROOT_COMPLEXES_SUPPORTED

+  ));

+return EFI_INVALID_PARAMETER;

+  }

+} else {

+  Uid = Index;

+}

+

 // Build a SSDT table describing the Pci devices.

 Status = BuildSsdtPciTable (

Generator,

CfgMgrProtocol,

AcpiTableInfo,

&PciInfo[Index],

-   Index,

+   Uid,

&TableList[Index]

);

 if (EFI_ERROR (Status)) {

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

index 283b564801..431e32a777 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

@@ -30,3 +30,6 @@

   AcpiHelperLib

   AmlLib

   BaseLib

+

+[Pcd]

+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91000): https://edk2.groups.io/g/devel/message/91000
Mute This Topic: https://groups.io/mt/92113679/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 3/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF

2022-07-01 Thread Jeff Brasen via groups.io
Add support for PCIe devices with UID > 0xF.
This is done by using the next value in the name so
PCI5, PC26, etc

Signed-off-by: Jeff Brasen 
---
 .../Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c   | 11 +++
 .../Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h   |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
index 80776ceb79..9f785ca5ac 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
@@ -824,7 +824,10 @@ GeneratePciDevice (
 
   // Write the name of the PCI device.
   CopyMem (AslName, "PCIx", AML_NAME_SEG_SIZE + 1);
-  AslName[AML_NAME_SEG_SIZE - 1] = AsciiFromHex (Uid);
+  AslName[AML_NAME_SEG_SIZE - 1] = AsciiFromHex (Uid & 0xF);
+  if (Uid > 0xF) {
+AslName[AML_NAME_SEG_SIZE - 2] = AsciiFromHex ((Uid >> 4) & 0xF);
+  }
 
   // ASL: Device (PCIx) {}
   Status = AmlCodeGenDevice (AslName, ScopeNode, &PciNode);
@@ -1060,13 +1063,13 @@ BuildSsdtPciTableEx (
   for (Index = 0; Index < PciCount; Index++) {
 if (PcdGetBool (PcdPciUseSegmentAsUid)) {
   Uid = PciInfo[Index].PciSegmentGroupNumber;
-  if (Uid > MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {
+  if (Uid >= MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {
 DEBUG ((
   DEBUG_ERROR,
   "ERROR: SSDT-PCI: Pci root complexes segment number: %d."
-  " Greater than maximum number of Pci root complexes supported = 
%d.\n",
+  " Greater than maximum supported value = %d.\n",
   Uid,
-  MAX_PCI_ROOT_COMPLEXES_SUPPORTED
+  MAX_PCI_ROOT_COMPLEXES_SUPPORTED - 1
   ));
 return EFI_INVALID_PARAMETER;
   }
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h
index 59a0d601a3..515a3e1785 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h
@@ -31,7 +31,7 @@
 Corresponding changes would be needed to support the Name and
 UID fields describing the Pci root complexes.
 */
-#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED  16
+#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED  256
 
 // _SB scope of the AML namespace.
 #define SB_SCOPE  "\\_SB_"
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90999): https://edk2.groups.io/g/devel/message/90999
Mute This Topic: https://groups.io/mt/92113677/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 0/4] DynamicTablesPkg: Pcie generation updates

2022-07-01 Thread Jeff Brasen via groups.io
Add fixes/features to dynamic PCIe support

- Correct issue with translation in generated ACPI tables.
- Allow for more than 16 controllers to be generated.
- Allow optional use of segment number as UID for cases where ACPI path is 
needed in other places.
- Add support for override protocol that allows platform specific modification 
of node prior to creation.

Update:
v2 - Add IsPosDecode logic to translation patch

Jeff Brasen (4):
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as
UID
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override
protocol

 DynamicTablesPkg/DynamicTablesPkg.dec |  6 ++
 .../Protocol/SsdtPcieOverrideProtocol.h   | 63 
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 73 ---
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h|  2 +-
 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  7 ++
 5 files changed, 139 insertions(+), 12 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90997): https://edk2.groups.io/g/devel/message/90997
Mute This Topic: https://groups.io/mt/92113674/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as UID

2022-07-01 Thread Jeff Brasen via groups.io
I don't think there are any requirements that this should be mapped this way 
which is why I added this under a PCD to enable it. We have a use case where it 
would be helpful to know the ACPI path of the PCIe controllers externally and 
using the segment number for that would allow us to do this without having to 
have matching logic that calculates the PCIe UID from the CM object list again.

Thanks,
Jeff


> -Original Message-
> From: Pierre Gondois 
> Sent: Friday, July 1, 2022 6:42 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use
> of segment number as UID
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> 
>  From "PCI Firmware Specification Revision 3.3", s4.1.2.
> "MCFG Table Description", the "PCI Segment Group Number" field of the
> MCFG table must match the value returned by the _SEG object in the
> corresponding object.
> 
> I didn't find any constraint about the _UID value. Would it be possible to
> know why this is required ?
> 
> Regards,
> Pierre
> 
> On 6/30/22 17:48, Jeff Brasen wrote:
> > Add support for selecting to use index or segment number as UID and
> name.
> > This allows the path of the nodes to be well known.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >   DynamicTablesPkg/DynamicTablesPkg.dec |  3 +++
> >   .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 19
> ++-
> >   .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  3 +++
> >   3 files changed, 24 insertions(+), 1 deletion(-)
> >
> > diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec
> > b/DynamicTablesPkg/DynamicTablesPkg.dec
> > index 9b74c5a671..a890a048be 100644
> > --- a/DynamicTablesPkg/DynamicTablesPkg.dec
> > +++ b/DynamicTablesPkg/DynamicTablesPkg.dec
> > @@ -57,5 +57,8 @@
> > # Non BSA Compliant 16550 Serial HID
> >
> >
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHi
> d|
> > ""|VOID*|0x4008
> >
> > +  # Use PCI segment numbers as UID
> > +
> > +
> gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|B
> OO
> > + LEAN|0x4009
> > +
> >   [Guids]
> > gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8,
> > 0x4613, { 0x87, 0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } } diff
> > --git
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> t
> > or.c
> >
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> t
> > or.c
> > index f0d15f69a4..85782af380 100644
> > ---
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> t
> > or.c
> > +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGen
> > +++ erator.c
> > @@ -996,6 +996,7 @@ BuildSsdtPciTableEx (
> > UINTN Index;
> > EFI_ACPI_DESCRIPTION_HEADER   **TableList;
> > ACPI_PCI_GENERATOR*Generator;
> > +  UINT32Uid;
> >
> > ASSERT (This != NULL);
> > ASSERT (AcpiTableInfo != NULL);
> > @@ -1051,13 +1052,29 @@ BuildSsdtPciTableEx (
> > *Table = TableList;
> >
> > for (Index = 0; Index < PciCount; Index++) {
> > +if (PcdGetBool (PcdPciUseSegmentAsUid)) {
> > +  Uid = PciInfo[Index].PciSegmentGroupNumber;
> > +  if (Uid > MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {
> > +DEBUG ((
> > +  DEBUG_ERROR,
> > +  "ERROR: SSDT-PCI: Pci root complexes segment number: %d."
> > +  " Greater than maximum number of Pci root complexes supported =
> %d.\n",
> > +  Uid,
> > +  MAX_PCI_ROOT_COMPLEXES_SUPPORTED
> > +  ));
> > +return EFI_INVALID_PARAMETER;
> > +  }
> > +} else {
> > +  Uid = Index;
> > +}
> > +
> >   // Build a SSDT table describing the Pci devices.
> >   Status = BuildSsdtPciTable (
> >  Generator,
> >  CfgMgrProtocol,
> >  AcpiTableInfo,
> >  &PciInfo[Index],
> > -   Index,
> > +   Uid,
> >  &TableList[Index]
> >  );
> >   if (EFI_ERROR (Status)) {
> > diff --git
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.
> > inf
> >
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.
> > inf
> > index 283b564801..431e32a777 100644
> > ---
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.
> > inf
> > +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLib
> > +++ Arm.inf
> > @@ -30,3 +30,6 @@
> > AcpiHelperLib
> > AmlLib
> > BaseLib
> > +
> > +[Pcd]
> > +  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90995): https://edk2.groups.io/g/devel/message/90995
Mute This Topic: https://groups.io/mt/92089320/21656
Group Owner: devel+ow...@edk2.groups.io
U

Re: [edk2-devel] [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override protocol

2022-07-01 Thread Jeff Brasen via groups.io
Currently we do the following in this call.

Remove and replace the _OSC method on certain targets. I originally had this 
pass the template over but removed that when I added this more generic override 
support
Add a _RST method to the root port device sub node
Add a _DSD for device properties
Conditionally add an entry for the device attached to the PCIe bus if we need 
to add properties or _RST methods. This will likely eventually move to another 
driver (which is the purpose of patch 2/4 in this series)

I figured trying to get the generator to handle that would be more difficult as 
these would be hard to generalize.


Thanks,
Jeff

> -Original Message-
> From: Pierre Gondois 
> Sent: Friday, July 1, 2022 6:40 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add
> support for override protocol
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> Is it possible to know what the UpdateTable() function would do ?
> Maybe it would be possible to integrate the alternative implementation
> without adding a new protocol.
> 
> Regards,
> Pierre
> 
> On 6/30/22 17:48, Jeff Brasen wrote:
> > Some platfoms may want to modify the ACPI table created.
> > Add support for protocol that can provide an alternative implementation.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >   DynamicTablesPkg/DynamicTablesPkg.dec |  3 +
> >   .../Protocol/SsdtPcieOverrideProtocol.h   | 63 +++
> >   .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 31 -
> >   .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  4 ++
> >   4 files changed, 98 insertions(+), 3 deletions(-)
> >   create mode 100644
> > DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> >
> > diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec
> > b/DynamicTablesPkg/DynamicTablesPkg.dec
> > index a890a048be..bb66bdaf14 100644
> > --- a/DynamicTablesPkg/DynamicTablesPkg.dec
> > +++ b/DynamicTablesPkg/DynamicTablesPkg.dec
> > @@ -43,6 +43,9 @@
> > # Dynamic Table Factory Protocol GUID
> > gEdkiiDynamicTableFactoryProtocolGuid = { 0x91d1e327, 0xfe5a,
> > 0x49b8, { 0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec } }
> >
> > +  # Protocol to override PCI SSDT table generation
> > + gEdkiiDynamicTableSsdtPcieOverrideProtocolGuid = { 0x962e8b44,
> > + 0x23b3, 0x41da, { 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 } }
> > +
> >   [PcdsFixedAtBuild]
> >
> > # Maximum number of Custom ACPI Generators diff --git
> > a/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> > b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> > new file mode 100644
> > index 00..29568a0159
> > --- /dev/null
> > +++ b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h
> > @@ -0,0 +1,63 @@
> > +/** @file
> > +
> > +  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
> > +
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#ifndef SSDT_PCIE_OVERRIDE_PROTOCOL_H_ #define
> > +SSDT_PCIE_OVERRIDE_PROTOCOL_H_
> > +
> > +#include 
> > +#include 
> > +
> > +/** This macro defines the SSDT PCI Override Protocol GUID.
> > +
> > +  GUID: {D85A4835-5A82-4894-AC02-706F43D5978E}
> > +*/
> > +#define EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_GUID   \
> > +  { 0x962e8b44, 0x23b3, 0x41da, \
> > +{ 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 }  \
> > +  };
> > +
> > +/**
> > +  Forward declarations:
> > +*/
> > +typedef struct SsdtOverridePciProtocol
> > +EDKII_SSDT_PCI_OVERRIDE_PROTOCOL;
> > +
> > +/** The UpdateTable function allows the override protocol to update the
> > + *   PCIe SSDT table prior to being created.
> > +
> > +  @param [in]  ThisPointer to the SSDT PCI Override Protocol.
> > +  @param [in]  PciInfo The PCIe configuration info for this node.
> > +  @param [in]  Uid UID that was selected for this PCIe node.
> > +  @param [in, out] PciNode Pointer to the PCI node of this ACPI table.
> > +
> > +  @retval EFI_SUCCESS   Success.
> > +  @retval EFI_INVALID_PARAMETER A parameter is invalid.
> > +  @retval EFI_DEVICE_ERROR  Failed to update the table.
> > +**/
> > +typedef
> > +EFI_STATUS
> > +(EFIAPI *EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_UPDATE_TABLE)(
> > +  IN  CONST EDKII_SSDT_PCI_OVERRIDE_PROTOCOL  *CONST  This,
> > +  IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,
> > +  INUINT32Uid,
> > +  IN  OUT   AML_ROOT_NODE_HANDLE  *PciNode
> > +  );
> > +
> > +/** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure
> describes the
> > +Configuration Manager Protocol interface.
> > +*/
> > +typedef struct SsdtOverridePciProtocol {
> > +  /** The interface used to update the ACPI table for PCI.
> > +  */
> > +  EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_UPDATE_TABLEUpdateTable;
> > +} EDKII

Re: [edk2-devel] [PATCH 1/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value

2022-07-01 Thread Jeff Brasen via groups.io
Yes, I'll try to add a v2 patch for this shortly.

Thanks,
Jeff

> -Original Message-
> From: Pierre Gondois 
> Sent: Friday, July 1, 2022 6:40 AM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: sami.muja...@arm.com; alexei.fedo...@arm.com
> Subject: Re: [PATCH 1/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct
> translation value
> 
> External email: Use caution opening links or attachments
> 
> 
> Hello Jeff,
> The patch is correct, but there will be an issue if
> AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress < 0
> 
> AmlCodeGenRdDWordIo() takes an 'IsPosDecode' argment, would it be
> possible to set IsPosDecode to FALSE in such case ?
> 
> Regards,
> Pierre
> 
> On 6/30/22 17:48, Jeff Brasen wrote:
> > The translation value in ACPI should be the difference between the CPU
> and PCIe address.
> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >   .../Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> t
> > or.c
> >
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> t
> > or.c
> > index a34018151f..f0d15f69a4 100644
> > ---
> >
> a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenera
> t
> > or.c
> > +++
> b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGen
> > +++ erator.c
> > @@ -621,7 +621,7 @@ GeneratePciCrs (
> >  0,
> >  AddrMapInfo->PciAddress,
> >  AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
> > -   Translation ? AddrMapInfo->CpuAddress : 0,
> > +   Translation ? AddrMapInfo->CpuAddress -
> > + AddrMapInfo->PciAddress : 0,
> >  AddrMapInfo->AddressSize,
> >  0,
> >  NULL,
> > @@ -643,7 +643,7 @@ GeneratePciCrs (
> >  0,
> >  AddrMapInfo->PciAddress,
> >  AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
> > -   Translation ? AddrMapInfo->CpuAddress : 0,
> > +   Translation ? AddrMapInfo->CpuAddress -
> > + AddrMapInfo->PciAddress : 0,
> >  AddrMapInfo->AddressSize,
> >  0,
> >  NULL,
> > @@ -665,7 +665,7 @@ GeneratePciCrs (
> >  0,
> >  AddrMapInfo->PciAddress,
> >  AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
> > -   Translation ? AddrMapInfo->CpuAddress : 0,
> > +   Translation ? AddrMapInfo->CpuAddress -
> > + AddrMapInfo->PciAddress : 0,
> >  AddrMapInfo->AddressSize,
> >  0,
> >  NULL,


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90993): https://edk2.groups.io/g/devel/message/90993
Mute This Topic: https://groups.io/mt/92089318/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] EmbeddedPkg/PrePiMemoryAllocationLib: Add check for space on offset allocation

2022-06-30 Thread Jeff Brasen via groups.io
Update check for enough space to occur prior to alignment offset.

This prevents cases where EfiFreeMemoryTop < EfiFreeMemoryBottom.



Signed-off-by: Jeff Brasen 

---

 .../MemoryAllocationLib.c | 53 +++

 1 file changed, 30 insertions(+), 23 deletions(-)



diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c 
b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

index 78f8da5e95..1956d644c3 100644

--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.c

@@ -38,37 +38,44 @@ AllocatePages (

 

   Hob.Raw = GetHobList ();

 

-  // Check to see if on 4k boundary

   Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;

+  //

+  // Verify that there is sufficient memory to satisfy the allocation and 
padding prior to updating anything

+  //

+  if ((Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * 
EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) - Offset) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

+if (Offset != 0) {

+  DEBUG ((DEBUG_ERROR, "Offset applied without enough space\r\n"));

+} else {

+  DEBUG ((DEBUG_ERROR, "Out of memory\r\n"));

+}

+

+ASSERT (FALSE);

+return 0;

+  }

+

+  // Check to see if on 4k boundary

   if (Offset != 0) {

 // If not aligned, make the allocation aligned.

 Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;

   }

 

   //

-  // Verify that there is sufficient memory to satisfy the allocation

+  // Update the PHIT to reflect the memory usage

   //

-  if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) 
+ sizeof (EFI_HOB_MEMORY_ALLOCATION)) < 
Hob.HandoffInformationTable->EfiFreeMemoryBottom) {

-return 0;

-  } else {

-//

-// Update the PHIT to reflect the memory usage

-//

-Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

-

-// This routine used to create a memory allocation HOB a la PEI, but 
that's not

-// necessary for us.

-

-//

-// Create a memory allocation HOB.

-//

-BuildMemoryAllocationHob (

-  Hob.HandoffInformationTable->EfiFreeMemoryTop,

-  Pages * EFI_PAGE_SIZE,

-  EfiBootServicesData

-  );

-return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

-  }

+  Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;

+

+  // This routine used to create a memory allocation HOB a la PEI, but that's 
not

+  // necessary for us.

+

+  //

+  // Create a memory allocation HOB.

+  //

+  BuildMemoryAllocationHob (

+Hob.HandoffInformationTable->EfiFreeMemoryTop,

+Pages * EFI_PAGE_SIZE,

+EfiBootServicesData

+);

+  return (VOID *)(UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop;

 }

 

 /**

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90936): https://edk2.groups.io/g/devel/message/90936
Mute This Topic: https://groups.io/mt/92093864/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 3/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF

2022-06-30 Thread Jeff Brasen via groups.io
Add support for PCIe devices with UID > 0xF.

This is done by using the next value in the name so

PCI5, PC26, etc



Signed-off-by: Jeff Brasen 

---

 .../Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c   | 11 +++

 .../Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h   |  2 +-

 2 files changed, 8 insertions(+), 5 deletions(-)



diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index 85782af380..c5b23d91d0 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -818,7 +818,10 @@ GeneratePciDevice (

 

   // Write the name of the PCI device.

   CopyMem (AslName, "PCIx", AML_NAME_SEG_SIZE + 1);

-  AslName[AML_NAME_SEG_SIZE - 1] = AsciiFromHex (Uid);

+  AslName[AML_NAME_SEG_SIZE - 1] = AsciiFromHex (Uid & 0xF);

+  if (Uid > 0xF) {

+AslName[AML_NAME_SEG_SIZE - 2] = AsciiFromHex ((Uid >> 4) & 0xF);

+  }

 

   // ASL: Device (PCIx) {}

   Status = AmlCodeGenDevice (AslName, ScopeNode, &PciNode);

@@ -1054,13 +1057,13 @@ BuildSsdtPciTableEx (

   for (Index = 0; Index < PciCount; Index++) {

 if (PcdGetBool (PcdPciUseSegmentAsUid)) {

   Uid = PciInfo[Index].PciSegmentGroupNumber;

-  if (Uid > MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {

+  if (Uid >= MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {

 DEBUG ((

   DEBUG_ERROR,

   "ERROR: SSDT-PCI: Pci root complexes segment number: %d."

-  " Greater than maximum number of Pci root complexes supported = 
%d.\n",

+  " Greater than maximum supported value = %d.\n",

   Uid,

-  MAX_PCI_ROOT_COMPLEXES_SUPPORTED

+  MAX_PCI_ROOT_COMPLEXES_SUPPORTED - 1

   ));

 return EFI_INVALID_PARAMETER;

   }

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h

index 59a0d601a3..515a3e1785 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.h

@@ -31,7 +31,7 @@

 Corresponding changes would be needed to support the Name and

 UID fields describing the Pci root complexes.

 */

-#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED  16

+#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED  256

 

 // _SB scope of the AML namespace.

 #define SB_SCOPE  "\\_SB_"

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90934): https://edk2.groups.io/g/devel/message/90934
Mute This Topic: https://groups.io/mt/92089322/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 4/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override protocol

2022-06-30 Thread Jeff Brasen via groups.io
Some platfoms may want to modify the ACPI table created.

Add support for protocol that can provide an alternative implementation.



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/DynamicTablesPkg.dec |  3 +

 .../Protocol/SsdtPcieOverrideProtocol.h   | 63 +++

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 31 -

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  4 ++

 4 files changed, 98 insertions(+), 3 deletions(-)

 create mode 100644 DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h



diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec

index a890a048be..bb66bdaf14 100644

--- a/DynamicTablesPkg/DynamicTablesPkg.dec

+++ b/DynamicTablesPkg/DynamicTablesPkg.dec

@@ -43,6 +43,9 @@

   # Dynamic Table Factory Protocol GUID

   gEdkiiDynamicTableFactoryProtocolGuid = { 0x91d1e327, 0xfe5a, 0x49b8, { 
0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec } }

 

+  # Protocol to override PCI SSDT table generation

+  gEdkiiDynamicTableSsdtPcieOverrideProtocolGuid = { 0x962e8b44, 0x23b3, 
0x41da, { 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 } }

+

 [PcdsFixedAtBuild]

 

   # Maximum number of Custom ACPI Generators

diff --git a/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h 
b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h

new file mode 100644

index 00..29568a0159

--- /dev/null

+++ b/DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h

@@ -0,0 +1,63 @@

+/** @file

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+**/

+

+#ifndef SSDT_PCIE_OVERRIDE_PROTOCOL_H_

+#define SSDT_PCIE_OVERRIDE_PROTOCOL_H_

+

+#include 

+#include 

+

+/** This macro defines the SSDT PCI Override Protocol GUID.

+

+  GUID: {D85A4835-5A82-4894-AC02-706F43D5978E}

+*/

+#define EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_GUID   \

+  { 0x962e8b44, 0x23b3, 0x41da, \

+{ 0x9f, 0x36, 0xca, 0xde, 0x68, 0x49, 0xfb, 0xf6 }  \

+  };

+

+/**

+  Forward declarations:

+*/

+typedef struct SsdtOverridePciProtocol EDKII_SSDT_PCI_OVERRIDE_PROTOCOL;

+

+/** The UpdateTable function allows the override protocol to update the

+ *   PCIe SSDT table prior to being created.

+

+  @param [in]  ThisPointer to the SSDT PCI Override Protocol.

+  @param [in]  PciInfo The PCIe configuration info for this node.

+  @param [in]  Uid UID that was selected for this PCIe node.

+  @param [in, out] PciNode Pointer to the PCI node of this ACPI table.

+

+  @retval EFI_SUCCESS   Success.

+  @retval EFI_INVALID_PARAMETER A parameter is invalid.

+  @retval EFI_DEVICE_ERROR  Failed to update the table.

+**/

+typedef

+EFI_STATUS

+(EFIAPI *EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_UPDATE_TABLE)(

+  IN  CONST EDKII_SSDT_PCI_OVERRIDE_PROTOCOL  *CONST  This,

+  IN  CONST CM_ARM_PCI_CONFIG_SPACE_INFO  *PciInfo,

+  INUINT32Uid,

+  IN  OUT   AML_ROOT_NODE_HANDLE  *PciNode

+  );

+

+/** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure describes the

+Configuration Manager Protocol interface.

+*/

+typedef struct SsdtOverridePciProtocol {

+  /** The interface used to update the ACPI table for PCI.

+  */

+  EDKII_SSDT_PCI_OVERRIDE_PROTOCOL_UPDATE_TABLEUpdateTable;

+} EDKII_SSDT_PCI_OVERRIDE_PROTOCOL;

+

+/** The SSDT PCI Override Protocol GUID.

+*/

+extern EFI_GUID  gEdkiiDynamicTableSsdtPcieOverrideProtocolGuid;

+

+#endif // SSDT_PCIE_OVERRIDE_PROTOCOL_H_

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index c5b23d91d0..d5982c24ff 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -20,6 +20,7 @@

 #include 

 #include 

 #include 

+#include 

 #include 

 

 // Module specific include files.

@@ -30,6 +31,7 @@

 #include 

 #include 

 #include 

+#include 

 

 #include "SsdtPcieGenerator.h"

 

@@ -798,9 +800,10 @@ GeneratePciDevice (

 {

   EFI_STATUS  Status;

 

-  CHAR8   AslName[AML_NAME_SEG_SIZE + 1];

-  AML_OBJECT_NODE_HANDLE  ScopeNode;

-  AML_OBJECT_NODE_HANDLE  PciNode;

+  CHAR8 AslName[AML_NAME_SEG_SIZE + 1];

+  AML_OBJECT_NODE_HANDLEScopeNode;

+  AML_OBJECT_NODE_HANDLEPciNode;

+  EDKII_SSDT_PCI_OVERRIDE_PROTOCOL  *OverrideProtocol;

 

   ASSERT (Generator != NULL);

   ASSERT (CfgMgrProtocol != NULL);

@@ -860,6 +863,28 @@ GeneratePciDevice (

 

   // Add the template _OSC method.

   Status = AddOscMethod (PciNode);

+  if (EFI_ERROR (Status)) {

+ASSERT (0);

+return Status;

+  }

+

+  Status = gBS->LocateProtocol (

+  &gEdkiiDynam

[edk2-devel] [PATCH 2/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as UID

2022-06-30 Thread Jeff Brasen via groups.io
Add support for selecting to use index or segment number as UID and name.

This allows the path of the nodes to be well known.



Signed-off-by: Jeff Brasen 

---

 DynamicTablesPkg/DynamicTablesPkg.dec |  3 +++

 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 19 ++-

 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  3 +++

 3 files changed, 24 insertions(+), 1 deletion(-)



diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec

index 9b74c5a671..a890a048be 100644

--- a/DynamicTablesPkg/DynamicTablesPkg.dec

+++ b/DynamicTablesPkg/DynamicTablesPkg.dec

@@ -57,5 +57,8 @@

   # Non BSA Compliant 16550 Serial HID

   
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdNonBsaCompliant16550SerialHid|""|VOID*|0x4008

 

+  # Use PCI segment numbers as UID

+  
gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid|FALSE|BOOLEAN|0x4009

+

 [Guids]

   gEdkiiDynamicTablesPkgTokenSpaceGuid = { 0xab226e66, 0x31d8, 0x4613, { 0x87, 
0x9d, 0xd2, 0xfa, 0xb6, 0x10, 0x26, 0x3c } }

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

index f0d15f69a4..85782af380 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c

@@ -996,6 +996,7 @@ BuildSsdtPciTableEx (

   UINTN Index;

   EFI_ACPI_DESCRIPTION_HEADER   **TableList;

   ACPI_PCI_GENERATOR*Generator;

+  UINT32Uid;

 

   ASSERT (This != NULL);

   ASSERT (AcpiTableInfo != NULL);

@@ -1051,13 +1052,29 @@ BuildSsdtPciTableEx (

   *Table = TableList;

 

   for (Index = 0; Index < PciCount; Index++) {

+if (PcdGetBool (PcdPciUseSegmentAsUid)) {

+  Uid = PciInfo[Index].PciSegmentGroupNumber;

+  if (Uid > MAX_PCI_ROOT_COMPLEXES_SUPPORTED) {

+DEBUG ((

+  DEBUG_ERROR,

+  "ERROR: SSDT-PCI: Pci root complexes segment number: %d."

+  " Greater than maximum number of Pci root complexes supported = 
%d.\n",

+  Uid,

+  MAX_PCI_ROOT_COMPLEXES_SUPPORTED

+  ));

+return EFI_INVALID_PARAMETER;

+  }

+} else {

+  Uid = Index;

+}

+

 // Build a SSDT table describing the Pci devices.

 Status = BuildSsdtPciTable (

Generator,

CfgMgrProtocol,

AcpiTableInfo,

&PciInfo[Index],

-   Index,

+   Uid,

&TableList[Index]

);

 if (EFI_ERROR (Status)) {

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

index 283b564801..431e32a777 100644

--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf

@@ -30,3 +30,6 @@

   AcpiHelperLib

   AmlLib

   BaseLib

+

+[Pcd]

+  gEdkiiDynamicTablesPkgTokenSpaceGuid.PcdPciUseSegmentAsUid

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90932): https://edk2.groups.io/g/devel/message/90932
Mute This Topic: https://groups.io/mt/92089320/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 1/4] DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value

2022-06-30 Thread Jeff Brasen via groups.io
The translation value in ACPI should be the difference between the CPU and PCIe 
address.

Signed-off-by: Jeff Brasen 
---
 .../Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
index a34018151f..f0d15f69a4 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtPcieLibArm/SsdtPcieGenerator.c
@@ -621,7 +621,7 @@ GeneratePciCrs (
0,
AddrMapInfo->PciAddress,
AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
-   Translation ? AddrMapInfo->CpuAddress : 0,
+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,
AddrMapInfo->AddressSize,
0,
NULL,
@@ -643,7 +643,7 @@ GeneratePciCrs (
0,
AddrMapInfo->PciAddress,
AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
-   Translation ? AddrMapInfo->CpuAddress : 0,
+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,
AddrMapInfo->AddressSize,
0,
NULL,
@@ -665,7 +665,7 @@ GeneratePciCrs (
0,
AddrMapInfo->PciAddress,
AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
-   Translation ? AddrMapInfo->CpuAddress : 0,
+   Translation ? AddrMapInfo->CpuAddress - 
AddrMapInfo->PciAddress : 0,
AddrMapInfo->AddressSize,
0,
NULL,
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90930): https://edk2.groups.io/g/devel/message/90930
Mute This Topic: https://groups.io/mt/92089318/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 0/4] DynamicTablesPkg: Pcie generation updates

2022-06-30 Thread Jeff Brasen via groups.io
Add fixes/features to dynamic PCIe support

- Correct issue with translation in generated ACPI tables.
- Allow for more than 16 controllers to be generated.
- Allow optional use of segment number as UID for cases where ACPI path is 
needed in other places.
- Add support for override protocol that allows platform specific modification 
of node prior to creation.

Jeff Brasen (4):
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Correct translation value
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Allow use of segment number as
UID
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Support UID > 0xF
  DynamicTablesPkg: AcpiSsdtPcieLibArm: Add support for override
protocol

 DynamicTablesPkg/DynamicTablesPkg.dec |  6 ++
 .../Protocol/SsdtPcieOverrideProtocol.h   | 63 +++
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.c| 61 +++---
 .../AcpiSsdtPcieLibArm/SsdtPcieGenerator.h|  2 +-
 .../Arm/AcpiSsdtPcieLibArm/SsdtPcieLibArm.inf |  7 +++
 5 files changed, 130 insertions(+), 9 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/Protocol/SsdtPcieOverrideProtocol.h

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90931): https://edk2.groups.io/g/devel/message/90931
Mute This Topic: https://groups.io/mt/92089319/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-06-17 Thread Jeff Brasen via groups.io
Any thoughts on this patch?

> -Original Message-
> From: Jeff Brasen 
> Sent: Monday, February 14, 2022 11:46 AM
> To: devel@edk2.groups.io
> Cc: hao.a...@intel.com; ray...@intel.com; Jeff Brasen
> 
> Subject: [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow
> partial FreeBuffer
> 
> Add support for partial free of non cached buffers.
> If a request for less than the full size is requested new allocations for the
> remaining head and tail of the buffer are added to the list.
> Added verification that Buffer is EFI_PAGE_SIZE aligned.
> The XHCI driver does this if the page size for the controller is >4KB.
> 
> Signed-off-by: Jeff Brasen 
> ---
>  .../NonDiscoverablePciDeviceIo.c  | 53 ++-
>  1 file changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> index c1c5c6267c..77809cfedf 100644
> ---
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> +++
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> Pc
> +++ iDeviceIo.c
> @@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
>LIST_ENTRY   *Entry;
>EFI_STATUS   Status;
>NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
> +  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;
> + NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
>BOOLEAN  Found;
> +  UINTNStartPages;
> +  UINTNEndPages;
> +
> +  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
> +ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +return EFI_INVALID_PARAMETER;
> +  }
> 
>Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
> 
>Found = FALSE;
>Alloc = NULL;
> +  AllocHead = NULL;
> +  AllocTail = NULL;
> 
>//
>// Find the uncached allocation list entry associated @@ -976,9 +987,13 @@
> NonCoherentPciIoFreeBuffer (
> Entry = Entry->ForwardLink)
>{
>  Alloc = BASE_CR (Entry,
> NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
> -if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages))
> {
> +StartPages = 0;
> +if (Alloc->HostAddress < HostAddress) {
> +  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
> +}
> +if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >=
> + (Pages + StartPages))) {
>//
> -  // We are freeing the exact allocation we were given
> +  // We are freeing at least part of what we were given
>// before by AllocateBuffer()
>//
>Found = TRUE;
> @@ -991,7 +1006,41 @@ NonCoherentPciIoFreeBuffer (
>  return EFI_NOT_FOUND;
>}
> 
> +  EndPages = Alloc->NumPages - (Pages + StartPages);
> +
> +  if (StartPages != 0) {
> +AllocHead = AllocatePool (sizeof *AllocHead);
> +if (AllocHead == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
> +
> +AllocHead->HostAddress = Alloc->HostAddress;
> +AllocHead->NumPages = StartPages;
> +AllocHead->Attributes = Alloc->Attributes;  }
> +
> +  if (EndPages != 0) {
> +AllocTail = AllocatePool (sizeof *AllocTail);
> +if (AllocTail == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
> +
> +AllocTail->HostAddress = Alloc->HostAddress + ((Pages + StartPages) *
> EFI_PAGE_SIZE);
> +AllocTail->NumPages = EndPages;
> +AllocTail->Attributes = Alloc->Attributes;  }
> +
>RemoveEntryList (&Alloc->List);
> +  //
> +  // Record this new sub allocations in the linked list, so we  // can
> + restore the memory space attributes later  //  if (AllocHead != NULL)
> + {
> +InsertHeadList (&Dev->UncachedAllocationList, &AllocHead->List);  }
> + if (AllocTail != NULL) {
> +InsertHeadList (&Dev->UncachedAllocationList, &AllocTail->List);  }
> 
>Status = gDS->SetMemorySpaceAttributes (
>(EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
> --
> 2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90580): https://edk2.groups.io/g/devel/message/90580
Mute This Topic: https://groups.io/mt/89143704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs

2022-06-17 Thread Jeff Brasen via groups.io
Anything else needed prior to getting this merged to edk2?

> -Original Message-
> From: gaoliming 
> Sent: Thursday, May 19, 2022 7:19 PM
> To: devel@edk2.groups.io; bob.c.f...@intel.com; Jeff Brasen
> 
> Cc: 'Chen, Christine' 
> Subject: 回复: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> 
> External email: Use caution opening links or attachments
> 
> 
> Reviewed-by: Liming Gao 
> 
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Bob Feng
> > 发送时间: 2022年5月18日 15:15
> > 收件人: devel@edk2.groups.io; Gao, Liming
> ;
> > jbra...@nvidia.com
> > 抄送: Chen, Christine 
> > 主题: Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> >
> > They are the BaseTools build log files that are generated by
> > BaseTools/Edk2ToolsBuild.py.
> >
> > Thanks,
> > Bob
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of
> > gaoliming
> > Sent: Wednesday, May 18, 2022 2:40 PM
> > To: devel@edk2.groups.io; jbra...@nvidia.com
> > Cc: Feng, Bob C ; Chen, Christine
> > 
> > Subject: 回复: [edk2-devel] [PATCH] .gitignore: Ignore build tools build
> > logs
> >
> > Bob:
> >   Do you know what files will be generated in BaseTools/BaseToolsBuild
> > directory?
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Jeff
> Brasen
> > via
> > > groups.io
> > > 发送时间: 2022年4月22日 1:01
> > > 收件人: devel@edk2.groups.io
> > > 抄送: bob.c.f...@intel.com; gaolim...@byosoft.com.cn;
> > > yuwei.c...@intel.com; Jeff Brasen 
> > > 主题: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs
> > >
> > > The python BaseTools/Edk2ToolsBuild.py creates files in
> > > BaseTools/BaseToolsBuild and should be ignored.
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  BaseTools/.gitignore | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/BaseTools/.gitignore b/BaseTools/.gitignore index
> > > a45689bc89..ddf93b7116 100644
> > > --- a/BaseTools/.gitignore
> > > +++ b/BaseTools/.gitignore
> > > @@ -17,4 +17,5 @@ Source/C/VfrCompile/VfrTokens.h  Source/C/bin/
> > > Source/C/libs/
> > >  Bin/Win32
> > > -Lib
> > > \ No newline at end of file
> > > +Lib
> > > +BaseToolsBuild/
> > > \ No newline at end of file
> > > --
> > > 2.25.1
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > 
> >
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90579): https://edk2.groups.io/g/devel/message/90579
Mute This Topic: https://groups.io/mt/91823747/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY

2022-06-17 Thread Jeff Brasen via groups.io
Resending this as I replying via edk2.groups.io doesn't seem to copy 
maintainers.

Resuming this patch to see if there are any additional thoughts on this.

In response to the query about DXE/BDS services we have some internal 
connection logic that runs in DXE to connect the devices that are needed for 
arch services that have to be connected prior the end of dxe.

Thanks,
Jeff

> -Original Message-
> From: Jeff Brasen
> Sent: Tuesday, December 14, 2021 9:48 PM
> To: Wu, Hao A ; devel@edk2.groups.io
> Cc: Ni, Ray 
> Subject: RE: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> 
> 
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Tuesday, December 14, 2021 8:00 PM
> > To: Jeff Brasen ; devel@edk2.groups.io
> > Cc: Ni, Ray 
> > Subject: RE: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> >
> > External email: Use caution opening links or attachments
> >
> >
> > > -Original Message-
> > > From: Jeff Brasen 
> > > Sent: Wednesday, December 15, 2021 1:59 AM
> > > To: devel@edk2.groups.io
> > > Cc: Wu, Hao A ; Ni, Ray ; Jeff
> > > Brasen 
> > > Subject: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> > >
> > > Increase TPL to TPL_NOTIFY to allow for use if caller is > TPL_CALLBACK.
> > > This allows services like variable services that run at TPL_NOTIFY
> > > to be hosted on ScsiDisks (i.e. UFS)
> > >
> > > Aligns with the eMMC driver that also uses a higher TPL.
> > > This change was made in 3b1d8241d0dac25c5e678c364fa2754ac1731060
> >
> >
> > Sorry, my take is that this change is not equivalent to the one made
> > in the SD/MMC stack.
> >
> > For the SD/MMC change you mentioned (commit
> > 3b1d8241d0dac25c5e678c364fa2754ac1731060), the TPL is raised to
> > TPL_NOTIFY only when:
> >   a) Operation to the linked lists that manage the asynchronous IO tasks
> >   b) Callback functions that process the asynchronous IO tasks The TPL
> > remains TPL_CALLBACK during the BlockIO services and the majority of
> > the
> > BlockIO2 services (operations to asynchronous tasks linked list are
> > the exceptions).
> >
> > But the proposed change in ScsiDisk modifies the TPL level of the
> > entire
> > BlockIO/BlockIO2 (and other protocols) services to TPL_NOTIFY.
> > For me, this is not aligned with the "TPL Restrictions" documented in
> > the UEFI specification.
> >
> > Best Regards,
> > Hao Wu
> >
> >
> 
> I had sent out a query on this before and didn't see any response. The core
> of the issue I am trying to solve it support variable services on a UFS 
> device.
> When the UFS blockIO is invoked from variable services it is not allowed
> (which does align from the UEFI spec perspective but does not allow me to
> implement variables services on UFS)
> 
>  The other way that worked was lowering the lock TPL level in the PCD driver
> and Variable down to callback. The PCD one seems like it should be done as
> variable services is supposed to only be called from <= TPL_CALLBACK.
> However, I was worried about that having a larger system impact on that
> change.
> 
> > >
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 22
> > > ++--
> > >  1 file changed, 11 insertions(+), 11 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > index 98e84b4ea8..b6e5848e77 100644
> > > --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > > @@ -514,7 +514,7 @@ ScsiDiskReset (
> > >SCSI_DISK_DEV  *ScsiDiskDevice;
> > >EFI_STATUS Status;
> > >
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> > >
> > > @@ -581,7 +581,7 @@ ScsiDiskReadBlocks (
> > >EFI_TPL OldTpl;
> > >
> > >MediaChange= FALSE;
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> > >Media  = ScsiDiskDevice->BlkIo.Media;
> > >
> > > @@ -733,7 +733,7 @@ ScsiDiskWriteBlocks (
> > >EFI_TPL OldTpl;
> > >
> > >MediaChange= FALSE;
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> > >Media  = ScsiDiskDevice->BlkIo.Media;
> > >
> > > @@ -898,7 +898,7 @@ ScsiDiskResetEx (
> > >SCSI_DISK_DEV  *ScsiDiskDevice;
> > >EFI_STATUS Status;
> > >
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> > >
> > >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
> > >
> > > @@ -975,7 +975,7 @@ ScsiDiskReadBlocksEx (
> > >EFI_TPL OldTpl;
> > >
> > >MediaChange= FALSE;
> > > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > > +  OldTpl  

[edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Add Disk Info support for Ufs

2022-06-14 Thread Jeff Brasen via groups.io
Add support for getting disk info from UFS devices.

Signed-off-by: Jeff Brasen 
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c| 3 ++-
 MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
index fac33b9ee9..87b82f299f 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
@@ -195,7 +195,8 @@ BmGetDescriptionFromDiskInfo (
 

   BmEliminateExtraSpaces (Description);

 }

-  } else if (CompareGuid (&DiskInfo->Interface, 
&gEfiDiskInfoScsiInterfaceGuid)) {

+  } else if (CompareGuid (&DiskInfo->Interface, 
&gEfiDiskInfoScsiInterfaceGuid) ||

+ CompareGuid (&DiskInfo->Interface, 
&gEfiDiskInfoUfsInterfaceGuid)) {

 BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);

 Status = DiskInfo->Inquiry (

  DiskInfo,

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf 
b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
index fe05d5f1cc..2fc0a80a4e 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+++ b/MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
@@ -85,6 +85,7 @@
   gEfiDiskInfoIdeInterfaceGuid  ## SOMETIMES_CONSUMES ## GUID

   gEfiDiskInfoScsiInterfaceGuid ## SOMETIMES_CONSUMES ## GUID

   gEfiDiskInfoSdMmcInterfaceGuid## SOMETIMES_CONSUMES ## GUID

+  gEfiDiskInfoUfsInterfaceGuid  ## SOMETIMES_CONSUMES ## GUID

 

 [Protocols]

   gEfiPciRootBridgeIoProtocolGuid   ## CONSUMES

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#90519): https://edk2.groups.io/g/devel/message/90519
Mute This Topic: https://groups.io/mt/91755004/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-05-17 Thread Jeff Brasen via groups.io
Any comments on this patch?

Thanks,

Jeff


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89876): https://edk2.groups.io/g/devel/message/89876
Mute This Topic: https://groups.io/mt/89143704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] .gitignore: Ignore build tools build logs

2022-05-17 Thread Jeff Brasen via groups.io
Any comments on this patch?

Thanks,

Jeff


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89875): https://edk2.groups.io/g/devel/message/89875
Mute This Topic: https://groups.io/mt/90610467/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] .gitignore: Ignore build tools build logs

2022-04-21 Thread Jeff Brasen via groups.io
The python BaseTools/Edk2ToolsBuild.py creates files in
BaseTools/BaseToolsBuild and should be ignored.

Signed-off-by: Jeff Brasen 
---
 BaseTools/.gitignore | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BaseTools/.gitignore b/BaseTools/.gitignore
index a45689bc89..ddf93b7116 100644
--- a/BaseTools/.gitignore
+++ b/BaseTools/.gitignore
@@ -17,4 +17,5 @@ Source/C/VfrCompile/VfrTokens.h
 Source/C/bin/
 Source/C/libs/
 Bin/Win32
-Lib
\ No newline at end of file
+Lib
+BaseToolsBuild/
\ No newline at end of file
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89196): https://edk2.groups.io/g/devel/message/89196
Mute This Topic: https://groups.io/mt/90610467/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY

2022-03-10 Thread Jeff Brasen via groups.io
Resuming this PATCH to see if there are any additional thoughts on this.

In response to the query about DXE/BDS services we have some internal 
connection logic that runs in DXE to connect the devices that are needed for 
arch services that have to be connected prior the end of dxe.

Thanks,
Jeff


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87420): https://edk2.groups.io/g/devel/message/87420
Mute This Topic: https://groups.io/mt/87726872/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-03-02 Thread Jeff Brasen via groups.io
Any thoughts on this patch, now that the stable tag is out?

> -Original Message-
> From: Ni, Ray 
> Sent: Tuesday, February 15, 2022 11:52 PM
> To: Sindhu, Deepthi 
> Cc: Wu, Hao A ; Jeff Brasen ;
> devel@edk2.groups.io
> Subject: RE: [edk2-devel] [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> 
> External email: Use caution opening links or attachments
> 
> 
> Deepthi,
> Can you please help to review the changes and provide comments?
> 
> Thanks,
> Ray
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Jeff
> Brasen via groups.io
> Sent: Tuesday, February 15, 2022 2:46 AM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A ; Ni, Ray ; Jeff
> Brasen 
> Subject: [edk2-devel] [PATCH v2]
> MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer
> 
> Add support for partial free of non cached buffers.
> If a request for less than the full size is requested new allocations for the
> remaining head and tail of the buffer are added to the list.
> Added verification that Buffer is EFI_PAGE_SIZE aligned.
> The XHCI driver does this if the page size for the controller is >4KB.
> 
> Signed-off-by: Jeff Brasen 
> ---
>  .../NonDiscoverablePciDeviceIo.c  | 53 ++-
>  1 file changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> index c1c5c6267c..77809cfedf 100644
> ---
> a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> PciDeviceIo.c
> +++
> b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverable
> Pc
> +++ iDeviceIo.c
> @@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
>LIST_ENTRY   *Entry;
>EFI_STATUS   Status;
>NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
> +  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;
> + NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
>BOOLEAN  Found;
> +  UINTNStartPages;
> +  UINTNEndPages;
> +
> +  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
> +ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +return EFI_INVALID_PARAMETER;
> +  }
> 
>Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
> 
>Found = FALSE;
>Alloc = NULL;
> +  AllocHead = NULL;
> +  AllocTail = NULL;
> 
>//
>// Find the uncached allocation list entry associated @@ -976,9 +987,13 @@
> NonCoherentPciIoFreeBuffer (
> Entry = Entry->ForwardLink)
>{
>  Alloc = BASE_CR (Entry,
> NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
> -if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages))
> {
> +StartPages = 0;
> +if (Alloc->HostAddress < HostAddress) {
> +  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
> +}
> +if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >=
> + (Pages + StartPages))) {
>//
> -  // We are freeing the exact allocation we were given
> +  // We are freeing at least part of what we were given
>// before by AllocateBuffer()
>//
>Found = TRUE;
> @@ -991,7 +1006,41 @@ NonCoherentPciIoFreeBuffer (
>  return EFI_NOT_FOUND;
>}
> 
> +  EndPages = Alloc->NumPages - (Pages + StartPages);
> +
> +  if (StartPages != 0) {
> +AllocHead = AllocatePool (sizeof *AllocHead);
> +if (AllocHead == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
> +
> +AllocHead->HostAddress = Alloc->HostAddress;
> +AllocHead->NumPages = StartPages;
> +AllocHead->Attributes = Alloc->Attributes;  }
> +
> +  if (EndPages != 0) {
> +AllocTail = AllocatePool (sizeof *AllocTail);
> +if (AllocTail == NULL) {
> +  return EFI_OUT_OF_RESOURCES;
> +}
> +
> +AllocTail->HostAddress = Alloc->HostAddress + ((Pages + StartPages) *
> EFI_PAGE_SIZE);
> +AllocTail->NumPages = EndPages;
> +AllocTail->Attributes = Alloc->Attributes;  }
> +
>RemoveEntryList (&Alloc->List);
> +  //
> +  // Record this new sub allocations in the linked list, so we  // can
> + restore the memory space attributes later  //  if (AllocHead != NULL)
> + {
> +InsertHeadList (&Dev->UncachedAllocationList, &AllocHead->List);  }
> + if (AllocTail != NULL) {
> +

[edk2-devel] [PATCH v2] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial FreeBuffer

2022-02-14 Thread Jeff Brasen via groups.io
Add support for partial free of non cached buffers.
If a request for less than the full size is requested new allocations
for the remaining head and tail of the buffer are added to the list.
Added verification that Buffer is EFI_PAGE_SIZE aligned.
The XHCI driver does this if the page size for the controller is >4KB.

Signed-off-by: Jeff Brasen 
---
 .../NonDiscoverablePciDeviceIo.c  | 53 ++-
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index c1c5c6267c..77809cfedf 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
@@ -960,12 +960,23 @@ NonCoherentPciIoFreeBuffer (
   LIST_ENTRY   *Entry;
   EFI_STATUS   Status;
   NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
+  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;
+  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
   BOOLEAN  Found;
+  UINTNStartPages;
+  UINTNEndPages;
+
+  if (HostAddress != ALIGN_POINTER (HostAddress, EFI_PAGE_SIZE)) {
+ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+return EFI_INVALID_PARAMETER;
+  }
 
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
 
   Found = FALSE;
   Alloc = NULL;
+  AllocHead = NULL;
+  AllocTail = NULL;
 
   //
   // Find the uncached allocation list entry associated
@@ -976,9 +987,13 @@ NonCoherentPciIoFreeBuffer (
Entry = Entry->ForwardLink)
   {
 Alloc = BASE_CR (Entry, NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
-if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages)) {
+StartPages = 0;
+if (Alloc->HostAddress < HostAddress) {
+  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
+}
+if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >= (Pages + 
StartPages))) {
   //
-  // We are freeing the exact allocation we were given
+  // We are freeing at least part of what we were given
   // before by AllocateBuffer()
   //
   Found = TRUE;
@@ -991,7 +1006,41 @@ NonCoherentPciIoFreeBuffer (
 return EFI_NOT_FOUND;
   }
 
+  EndPages = Alloc->NumPages - (Pages + StartPages);
+
+  if (StartPages != 0) {
+AllocHead = AllocatePool (sizeof *AllocHead);
+if (AllocHead == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+AllocHead->HostAddress = Alloc->HostAddress;
+AllocHead->NumPages = StartPages;
+AllocHead->Attributes = Alloc->Attributes;
+  }
+
+  if (EndPages != 0) {
+AllocTail = AllocatePool (sizeof *AllocTail);
+if (AllocTail == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+AllocTail->HostAddress = Alloc->HostAddress + ((Pages + StartPages) * 
EFI_PAGE_SIZE);
+AllocTail->NumPages = EndPages;
+AllocTail->Attributes = Alloc->Attributes;
+  }
+
   RemoveEntryList (&Alloc->List);
+  //
+  // Record this new sub allocations in the linked list, so we
+  // can restore the memory space attributes later
+  //
+  if (AllocHead != NULL) {
+InsertHeadList (&Dev->UncachedAllocationList, &AllocHead->List);
+  }
+  if (AllocTail != NULL) {
+InsertHeadList (&Dev->UncachedAllocationList, &AllocTail->List);
+  }
 
   Status = gDS->SetMemorySpaceAttributes (
   (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86661): https://edk2.groups.io/g/devel/message/86661
Mute This Topic: https://groups.io/mt/89143704/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH] MdeModulePkg/NonDiscoverablePciDeviceDxe: Allow partial free

2022-02-11 Thread Jeff Brasen via groups.io
Add support for partial free of non cached buffers.
If a request for less than the full size is requested new allocations
for the remaining head and tail of the buffer are added to the list.
The XHCI driver does this if the page size for the controller is >4KB.

Signed-off-by: Jeff Brasen 
---
 .../NonDiscoverablePciDeviceIo.c  | 48 ++-
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
index c1c5c6267c..858d953acf 100644
--- 
a/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
+++ 
b/MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c
@@ -960,12 +960,18 @@ NonCoherentPciIoFreeBuffer (
   LIST_ENTRY   *Entry;
   EFI_STATUS   Status;
   NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *Alloc;
+  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocHead;
+  NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION  *AllocTail;
   BOOLEAN  Found;
+  UINTNStartPages;
+  UINTNEndPages;
 
   Dev = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
 
   Found = FALSE;
   Alloc = NULL;
+  AllocHead = NULL;
+  AllocTail = NULL;
 
   //
   // Find the uncached allocation list entry associated
@@ -976,9 +982,13 @@ NonCoherentPciIoFreeBuffer (
Entry = Entry->ForwardLink)
   {
 Alloc = BASE_CR (Entry, NON_DISCOVERABLE_DEVICE_UNCACHED_ALLOCATION, List);
-if ((Alloc->HostAddress == HostAddress) && (Alloc->NumPages == Pages)) {
+StartPages = 0;
+if (Alloc->HostAddress < HostAddress) {
+  StartPages = (HostAddress - Alloc->HostAddress) / EFI_PAGE_SIZE;
+}
+if ((Alloc->HostAddress <= HostAddress) && (Alloc->NumPages >= (Pages + 
StartPages))) {
   //
-  // We are freeing the exact allocation we were given
+  // We are freeing at least part of what we were given
   // before by AllocateBuffer()
   //
   Found = TRUE;
@@ -991,7 +1001,41 @@ NonCoherentPciIoFreeBuffer (
 return EFI_NOT_FOUND;
   }
 
+  EndPages = Alloc->NumPages - (Pages + StartPages);
+
+  if (StartPages != 0) {
+AllocHead = AllocatePool (sizeof *AllocHead);
+if (AllocHead == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+AllocHead->HostAddress = Alloc->HostAddress;
+AllocHead->NumPages = StartPages;
+AllocHead->Attributes = Alloc->Attributes;
+  }
+
+  if (EndPages != 0) {
+AllocTail = AllocatePool (sizeof *AllocTail);
+if (AllocTail == NULL) {
+  return EFI_OUT_OF_RESOURCES;
+}
+
+AllocTail->HostAddress = Alloc->HostAddress + ((Pages + StartPages) * 
EFI_PAGE_SIZE);
+AllocTail->NumPages = EndPages;
+AllocTail->Attributes = Alloc->Attributes;
+  }
+
   RemoveEntryList (&Alloc->List);
+  //
+  // Record this new sub allocations in the linked list, so we
+  // can restore the memory space attributes later
+  //
+  if (AllocHead != NULL) {
+InsertHeadList (&Dev->UncachedAllocationList, &AllocHead->List);
+  }
+  if (AllocTail != NULL) {
+InsertHeadList (&Dev->UncachedAllocationList, &AllocTail->List);
+  }
 
   Status = gDS->SetMemorySpaceAttributes (
   (EFI_PHYSICAL_ADDRESS)(UINTN)HostAddress,
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#86624): https://edk2.groups.io/g/devel/message/86624
Mute This Topic: https://groups.io/mt/89079887/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY

2021-12-14 Thread Jeff Brasen via groups.io



> -Original Message-
> From: Wu, Hao A 
> Sent: Tuesday, December 14, 2021 8:00 PM
> To: Jeff Brasen ; devel@edk2.groups.io
> Cc: Ni, Ray 
> Subject: RE: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> 
> External email: Use caution opening links or attachments
> 
> 
> > -Original Message-
> > From: Jeff Brasen 
> > Sent: Wednesday, December 15, 2021 1:59 AM
> > To: devel@edk2.groups.io
> > Cc: Wu, Hao A ; Ni, Ray ; Jeff
> > Brasen 
> > Subject: [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY
> >
> > Increase TPL to TPL_NOTIFY to allow for use if caller is > TPL_CALLBACK.
> > This allows services like variable services that run at TPL_NOTIFY to
> > be hosted on ScsiDisks (i.e. UFS)
> >
> > Aligns with the eMMC driver that also uses a higher TPL.
> > This change was made in 3b1d8241d0dac25c5e678c364fa2754ac1731060
> 
> 
> Sorry, my take is that this change is not equivalent to the one made in the
> SD/MMC stack.
> 
> For the SD/MMC change you mentioned (commit
> 3b1d8241d0dac25c5e678c364fa2754ac1731060), the TPL is raised to
> TPL_NOTIFY only when:
>   a) Operation to the linked lists that manage the asynchronous IO tasks
>   b) Callback functions that process the asynchronous IO tasks The TPL
> remains TPL_CALLBACK during the BlockIO services and the majority of the
> BlockIO2 services (operations to asynchronous tasks linked list are the
> exceptions).
> 
> But the proposed change in ScsiDisk modifies the TPL level of the entire
> BlockIO/BlockIO2 (and other protocols) services to TPL_NOTIFY.
> For me, this is not aligned with the "TPL Restrictions" documented in the UEFI
> specification.
> 
> Best Regards,
> Hao Wu
> 
> 

I had sent out a query on this before and didn't see any response. The core of 
the issue I am trying to solve it support variable services on a UFS device. 
When the UFS blockIO is invoked from variable services it is not allowed (which 
does align from the UEFI spec perspective but does not allow me to implement 
variables services on UFS)

 The other way that worked was lowering the lock TPL level in the PCD driver 
and Variable down to callback. The PCD one seems like it should be done as 
variable services is supposed to only be called from <= TPL_CALLBACK. However, 
I was worried about that having a larger system impact on that change.

> >
> > Signed-off-by: Jeff Brasen 
> > ---
> >  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 22
> > ++--
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > index 98e84b4ea8..b6e5848e77 100644
> > --- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > +++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
> > @@ -514,7 +514,7 @@ ScsiDiskReset (
> >SCSI_DISK_DEV  *ScsiDiskDevice;
> >EFI_STATUS Status;
> >
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> >
> > @@ -581,7 +581,7 @@ ScsiDiskReadBlocks (
> >EFI_TPL OldTpl;
> >
> >MediaChange= FALSE;
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> >Media  = ScsiDiskDevice->BlkIo.Media;
> >
> > @@ -733,7 +733,7 @@ ScsiDiskWriteBlocks (
> >EFI_TPL OldTpl;
> >
> >MediaChange= FALSE;
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
> >Media  = ScsiDiskDevice->BlkIo.Media;
> >
> > @@ -898,7 +898,7 @@ ScsiDiskResetEx (
> >SCSI_DISK_DEV  *ScsiDiskDevice;
> >EFI_STATUS Status;
> >
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
> >
> > @@ -975,7 +975,7 @@ ScsiDiskReadBlocksEx (
> >EFI_TPL OldTpl;
> >
> >MediaChange= FALSE;
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
> >Media  = ScsiDiskDevice->BlkIo.Media;
> >
> > @@ -1154,7 +1154,7 @@ ScsiDiskWriteBlocksEx (
> >EFI_TPL OldTpl;
> >
> >MediaChange= FALSE;
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
> >Media  = ScsiDiskDevice->BlkIo.Media;
> >
> > @@ -1323,7 +1323,7 @@ ScsiDiskFlushBlocksEx (
> >EFI_TPL OldTpl;
> >
> >MediaChange= FALSE;
> > -  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
> > +  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> >ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
> >Media  = ScsiDiskDevice->BlkIo.Me

[edk2-devel] [PATCH] MdeModulePkg/ScsiDisk: Change TPL to NOTIFY

2021-12-14 Thread Jeff Brasen via groups.io
Increase TPL to TPL_NOTIFY to allow for use if caller is > TPL_CALLBACK.
This allows services like variable services that run at TPL_NOTIFY to
be hosted on ScsiDisks (i.e. UFS)

Aligns with the eMMC driver that also uses a higher TPL.
This change was made in 3b1d8241d0dac25c5e678c364fa2754ac1731060

Signed-off-by: Jeff Brasen 
---
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 22 ++--
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c 
b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index 98e84b4ea8..b6e5848e77 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -514,7 +514,7 @@ ScsiDiskReset (
   SCSI_DISK_DEV  *ScsiDiskDevice;
   EFI_STATUS Status;
 
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
 
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
 
@@ -581,7 +581,7 @@ ScsiDiskReadBlocks (
   EFI_TPL OldTpl;
 
   MediaChange= FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -733,7 +733,7 @@ ScsiDiskWriteBlocks (
   EFI_TPL OldTpl;
 
   MediaChange= FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -898,7 +898,7 @@ ScsiDiskResetEx (
   SCSI_DISK_DEV  *ScsiDiskDevice;
   EFI_STATUS Status;
 
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
 
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
 
@@ -975,7 +975,7 @@ ScsiDiskReadBlocksEx (
   EFI_TPL OldTpl;
 
   MediaChange= FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -1154,7 +1154,7 @@ ScsiDiskWriteBlocksEx (
   EFI_TPL OldTpl;
 
   MediaChange= FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -1323,7 +1323,7 @@ ScsiDiskFlushBlocksEx (
   EFI_TPL OldTpl;
 
   MediaChange= FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -1717,7 +1717,7 @@ ScsiDiskEraseBlocks (
   EFI_TPL OldTpl;
 
   MediaChange= FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_ERASEBLK (This);
 
   if (!IS_DEVICE_FIXED (ScsiDiskDevice)) {
@@ -1907,7 +1907,7 @@ ScsiDiskReceiveData (
   AlignedBuffer  = NULL;
   MediaChange= FALSE;
   AlignedBufferAllocated = FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -2122,7 +2122,7 @@ ScsiDiskSendData (
   AlignedBuffer  = NULL;
   MediaChange= FALSE;
   AlignedBufferAllocated = FALSE;
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   ScsiDiskDevice = SCSI_DISK_DEV_FROM_STORSEC (This);
   Media  = ScsiDiskDevice->BlkIo.Media;
 
@@ -2294,7 +2294,7 @@ ScsiDiskDetectMedia (
 
   Status = gBS->CreateEvent (
   EVT_TIMER,
-  TPL_CALLBACK,
+  TPL_NOTIFY,
   NULL,
   NULL,
   &TimeoutEvt
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84826): https://edk2.groups.io/g/devel/message/84826
Mute This Topic: https://groups.io/mt/87726872/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] Question on TPL in PCD/Variable code

2021-12-02 Thread Jeff Brasen via groups.io
I am trying to get variable services hosted on a UFS device and running into 
TPL related issues. The variable and PCD code have locks that raise the TPL to 
NOTIFY prior to calling into the FVB instance and the UFS driver has a few 
raise tpl calls that increase the TPL to TPL_CALLBACK. This is causing a 
failure as you can't do a RaiseTPL to CALLBACK when current TPL is NOTIFY.

The UEFI specification states that both BlockIO and Variable services should 
only be called at <= TPL_CALLBACK.

I see a couple options.


  1.  Change the locks to TPL_CALLBACK which seems to keep things in line with 
the UEFI spec but may introduce race conditions if that higher lock was 
blocking things
  2.  Change the raise tpl in the UFS driver to TPL_NOTIFY. This is how the 
eMMC driver is written.

I am leaning towards option 2 but wanted to get some feedback prior to pushing 
a patch.

Thanks,
Jeff



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84249): https://edk2.groups.io/g/devel/message/84249
Mute This Topic: https://groups.io/mt/87453882/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 0/4] AndroidBootImgLib improvements

2021-09-23 Thread Jeff Brasen via groups.io
That looks like something I missed and looks good, do you need me to make a v4 
or will you just add that in. When I built I just used our application that has 
the guid in our inf so missed this.

>From my looking at it AndroidFastBootApp doesn't seem to use this lib.

> -Original Message-
> From: Leif Lindholm 
> Sent: Thursday, September 23, 2021 5:06 AM
> To: Jeff Brasen 
> Cc: devel@edk2.groups.io; daniel.schae...@hpe.com;
> abner.ch...@hpe.com; ardb+tianoc...@kernel.org; Jun Nie
> 
> Subject: Re: [PATCH v3 0/4] AndroidBootImgLib improvements
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Jeff,
> 
> I was about to say "no more issues", and then I went to build EmbeddedPkg,
> and it turns out this fails in Applications/AndroidBootApp due to the missing
> dependency on gEfiLoadFile2ProtocolGuid in AndroidBootImgLib.inf.
> 
> (Why this doesn't break AndroidFastbootApp build as well is not immediately
> obvious to me.)
> 
> Would you like to figure out why, or would you prefer me to just fold in
> 
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> index affde50f617a..8eefeef4f915 100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> @@ -39,6 +39,7 @@ [Packages]
>  [Protocols]
>gAndroidBootImgProtocolGuid
>gEfiLoadedImageProtocolGuid
> +  gEfiLoadFile2ProtocolGuid
> 
>  [Guids]
>gEfiAcpiTableGuid
> 
> ?
> 
> /
> Leif
> 
> On Tue, Sep 21, 2021 at 16:32:58 +, Jeff Brasen wrote:
> > Jun/Others,
> >
> >   Any additional comments on this patch series?
> >
> >
> > Thanks,
> >
> > Jeff
> >
> > 
> > From: Jeff Brasen 
> > Sent: Tuesday, September 14, 2021 10:57 AM
> > To: Leif Lindholm 
> > Cc: devel@edk2.groups.io ;
> > daniel.schae...@hpe.com ;
> abner.ch...@hpe.com
> > ; ardb+tianoc...@kernel.org
> > ; Jun Nie 
> > Subject: Re: [PATCH v3 0/4] AndroidBootImgLib improvements
> >
> > So for patch 3: This is only a change if mAndroidBootImg->UpdateDtb ==
> NULL.
> >
> > This seemed like a bug as we would not add the initrd values nor would we
> use the fdt from the BootImg if that is where the device tree was sourced
> from.
> >
> > It seems like either we should require UpdateDtb to be implemented
> (which seems to cause greater compatibility issues) or we install the device
> tree we have if that function isn't implemented.
> >
> > As far as merging goes I am fine either way. Our particular flow won't hit
> this path as we don't have a device tree in the bootimg (use the system
> config table) and we will have the new pcd set, but this seemed like a bug
> while I looking at this code.
> >
> >
> > Thanks,
> >
> > Jeff
> >
> > 
> > From: Leif Lindholm 
> > Sent: Tuesday, September 14, 2021 9:00 AM
> > To: Jeff Brasen 
> > Cc: devel@edk2.groups.io ;
> > daniel.schae...@hpe.com ;
> abner.ch...@hpe.com
> > ; ardb+tianoc...@kernel.org
> > ; Jun Nie 
> > Subject: Re: [PATCH v3 0/4] AndroidBootImgLib improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Hi Jeff,
> >
> > Thanks for this.
> > This set looks good to me, with a slight question mark wrt behaviour
> > compatibility with previous versions for 3/4.
> > (I think it's fine, but I'm a bear of very little brain, and it's been
> > several years since I reviewed this code, and even longer since I
> > really interacted with Android.
> > ^
> > | shameless plug for more EmbeddedPkg reviewer volunteers.)
> >
> > I've added Jun Nie, who wrote the original version of this code, to
> > see if he has any comments.
> >
> > 1-2/4 are obviously unproblematic, and I could merge those ahead of
> > time if preferred. You can add
> > Reviewed-by: Leif Lindholm  for those if there are
> > any further revisions of the set.
> >
> > Best Regards,
> >
> > Leif
> >
> > On Mon, Sep 13, 2021 at 23:18:47 +, Jeff Brasen wrote:
> > > Added support for using loadfile2 approach for passing ramdisk to linux.
> > > Created patch series for general error handling improvments based on
> > > review feedback.
> > > If ACPI tables are in system table or PCD is defined the LoadFile2
> > > method of passing initrd will be used.
> > >
> > > [v3]
> > > -Code review cleanup
> > > -Removed duplicate header file
> > > -Added change to allow FDT to install if UpdateDtb function is not
> > > defined -Added specific ACPI check -Moved install functions to
> > > subfunctions
> > >
> > > [v2]
> > > -Added review feedback
> > > -General improvements to error handling
> > >
> > > [v1]
> > > - Intial revision
> > >
> > >
> > > Jeff Brasen (4):
> > >   EmbeddedPkg: Remove duplicate libfdt.h include
> > >   EmbeddedPkg: AndroidBootImgBoot error handling updates
> > >   EmbeddedPkg: Install FDT if UpdateDtb is not present
> > >   EmbeddedPkg: Add LoadFile2 for linux initrd
> > >
> > >  E

Re: [edk2-devel] [PATCH v3 0/4] AndroidBootImgLib improvements

2021-09-21 Thread Jeff Brasen via groups.io
Jun/Others,

  Any additional comments on this patch series?


Thanks,

Jeff


From: Jeff Brasen 
Sent: Tuesday, September 14, 2021 10:57 AM
To: Leif Lindholm 
Cc: devel@edk2.groups.io ; daniel.schae...@hpe.com 
; abner.ch...@hpe.com ; 
ardb+tianoc...@kernel.org ; Jun Nie 

Subject: Re: [PATCH v3 0/4] AndroidBootImgLib improvements

So for patch 3: This is only a change if mAndroidBootImg->UpdateDtb == NULL.

This seemed like a bug as we would not add the initrd values nor would we use 
the fdt from the BootImg if that is where the device tree was sourced from.

It seems like either we should require UpdateDtb to be implemented (which seems 
to cause greater compatibility issues) or we install the device tree we have if 
that function isn't implemented.

As far as merging goes I am fine either way. Our particular flow won't hit this 
path as we don't have a device tree in the bootimg (use the system config 
table) and we will have the new pcd set, but this seemed like a bug while I 
looking at this code.


Thanks,

Jeff


From: Leif Lindholm 
Sent: Tuesday, September 14, 2021 9:00 AM
To: Jeff Brasen 
Cc: devel@edk2.groups.io ; daniel.schae...@hpe.com 
; abner.ch...@hpe.com ; 
ardb+tianoc...@kernel.org ; Jun Nie 

Subject: Re: [PATCH v3 0/4] AndroidBootImgLib improvements

External email: Use caution opening links or attachments


Hi Jeff,

Thanks for this.
This set looks good to me, with a slight question mark wrt behaviour
compatibility with previous versions for 3/4.
(I think it's fine, but I'm a bear of very little brain, and it's been
several years since I reviewed this code, and even longer since I
really interacted with Android.
^
| shameless plug for more EmbeddedPkg reviewer volunteers.)

I've added Jun Nie, who wrote the original version of this code, to
see if he has any comments.

1-2/4 are obviously unproblematic, and I could merge those ahead of
time if preferred. You can add
Reviewed-by: Leif Lindholm 
for those if there are any further revisions of the set.

Best Regards,

Leif

On Mon, Sep 13, 2021 at 23:18:47 +, Jeff Brasen wrote:
> Added support for using loadfile2 approach for passing ramdisk to linux.
> Created patch series for general error handling improvments based on
> review feedback.
> If ACPI tables are in system table or PCD is defined the LoadFile2 method
> of passing initrd will be used.
>
> [v3]
> -Code review cleanup
> -Removed duplicate header file
> -Added change to allow FDT to install if UpdateDtb function is not defined
> -Added specific ACPI check
> -Moved install functions to subfunctions
>
> [v2]
> -Added review feedback
> -General improvements to error handling
>
> [v1]
> - Intial revision
>
>
> Jeff Brasen (4):
>   EmbeddedPkg: Remove duplicate libfdt.h include
>   EmbeddedPkg: AndroidBootImgBoot error handling updates
>   EmbeddedPkg: Install FDT if UpdateDtb is not present
>   EmbeddedPkg: Add LoadFile2 for linux initrd
>
>  EmbeddedPkg/EmbeddedPkg.dec   |   1 +
>  .../AndroidBootImgLib/AndroidBootImgLib.inf   |   4 +
>  .../AndroidBootImgLib/AndroidBootImgLib.c | 275 +++---
>  3 files changed, 233 insertions(+), 47 deletions(-)
>
> --
> 2.17.1
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80935): https://edk2.groups.io/g/devel/message/80935
Mute This Topic: https://groups.io/mt/85589861/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 0/4] AndroidBootImgLib improvements

2021-09-14 Thread Jeff Brasen via groups.io
So for patch 3: This is only a change if mAndroidBootImg->UpdateDtb == NULL.

This seemed like a bug as we would not add the initrd values nor would we use 
the fdt from the BootImg if that is where the device tree was sourced from.

It seems like either we should require UpdateDtb to be implemented (which seems 
to cause greater compatibility issues) or we install the device tree we have if 
that function isn't implemented.

As far as merging goes I am fine either way. Our particular flow won't hit this 
path as we don't have a device tree in the bootimg (use the system config 
table) and we will have the new pcd set, but this seemed like a bug while I 
looking at this code.


Thanks,

Jeff


From: Leif Lindholm 
Sent: Tuesday, September 14, 2021 9:00 AM
To: Jeff Brasen 
Cc: devel@edk2.groups.io ; daniel.schae...@hpe.com 
; abner.ch...@hpe.com ; 
ardb+tianoc...@kernel.org ; Jun Nie 

Subject: Re: [PATCH v3 0/4] AndroidBootImgLib improvements

External email: Use caution opening links or attachments


Hi Jeff,

Thanks for this.
This set looks good to me, with a slight question mark wrt behaviour
compatibility with previous versions for 3/4.
(I think it's fine, but I'm a bear of very little brain, and it's been
several years since I reviewed this code, and even longer since I
really interacted with Android.
^
| shameless plug for more EmbeddedPkg reviewer volunteers.)

I've added Jun Nie, who wrote the original version of this code, to
see if he has any comments.

1-2/4 are obviously unproblematic, and I could merge those ahead of
time if preferred. You can add
Reviewed-by: Leif Lindholm 
for those if there are any further revisions of the set.

Best Regards,

Leif

On Mon, Sep 13, 2021 at 23:18:47 +, Jeff Brasen wrote:
> Added support for using loadfile2 approach for passing ramdisk to linux.
> Created patch series for general error handling improvments based on
> review feedback.
> If ACPI tables are in system table or PCD is defined the LoadFile2 method
> of passing initrd will be used.
>
> [v3]
> -Code review cleanup
> -Removed duplicate header file
> -Added change to allow FDT to install if UpdateDtb function is not defined
> -Added specific ACPI check
> -Moved install functions to subfunctions
>
> [v2]
> -Added review feedback
> -General improvements to error handling
>
> [v1]
> - Intial revision
>
>
> Jeff Brasen (4):
>   EmbeddedPkg: Remove duplicate libfdt.h include
>   EmbeddedPkg: AndroidBootImgBoot error handling updates
>   EmbeddedPkg: Install FDT if UpdateDtb is not present
>   EmbeddedPkg: Add LoadFile2 for linux initrd
>
>  EmbeddedPkg/EmbeddedPkg.dec   |   1 +
>  .../AndroidBootImgLib/AndroidBootImgLib.inf   |   4 +
>  .../AndroidBootImgLib/AndroidBootImgLib.c | 275 +++---
>  3 files changed, 233 insertions(+), 47 deletions(-)
>
> --
> 2.17.1
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80666): https://edk2.groups.io/g/devel/message/80666
Mute This Topic: https://groups.io/mt/85589861/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 0/4] AndroidBootImgLib improvements

2021-09-13 Thread Jeff Brasen via groups.io
Added support for using loadfile2 approach for passing ramdisk to linux.
Created patch series for general error handling improvments based on
review feedback.
If ACPI tables are in system table or PCD is defined the LoadFile2 method
of passing initrd will be used.

[v3]
-Code review cleanup
-Removed duplicate header file
-Added change to allow FDT to install if UpdateDtb function is not defined
-Added specific ACPI check
-Moved install functions to subfunctions

[v2]
-Added review feedback
-General improvements to error handling

[v1]
- Intial revision


Jeff Brasen (4):
  EmbeddedPkg: Remove duplicate libfdt.h include
  EmbeddedPkg: AndroidBootImgBoot error handling updates
  EmbeddedPkg: Install FDT if UpdateDtb is not present
  EmbeddedPkg: Add LoadFile2 for linux initrd

 EmbeddedPkg/EmbeddedPkg.dec   |   1 +
 .../AndroidBootImgLib/AndroidBootImgLib.inf   |   4 +
 .../AndroidBootImgLib/AndroidBootImgLib.c | 275 +++---
 3 files changed, 233 insertions(+), 47 deletions(-)

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80622): https://edk2.groups.io/g/devel/message/80622
Mute This Topic: https://groups.io/mt/85589861/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 4/4] EmbeddedPkg: Add LoadFile2 for linux initrd

2021-09-13 Thread Jeff Brasen via groups.io
Add support under a pcd feature for using the new interface to pass
initrd to the linux kernel instead of via device tree.
This feature is also enabled if ACPI tables are present, and will skip
locating and installation of device tree.

Signed-off-by: Jeff Brasen 
---
 EmbeddedPkg/EmbeddedPkg.dec   |   1 +
 .../AndroidBootImgLib/AndroidBootImgLib.inf   |   4 +
 .../AndroidBootImgLib/AndroidBootImgLib.c | 218 --
 3 files changed, 201 insertions(+), 22 deletions(-)

diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index c2068ce5a8ce..7638deb8 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -86,6 +86,7 @@ [Ppis]
 [PcdsFeatureFlag.common]
   
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE|BOOLEAN|0x001b
   gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x0053
+  gEmbeddedTokenSpaceGuid.PcdAndroidBootLoadFile2|FALSE|BOOLEAN|0x005b
 
 [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0|UINT32|0x000b
diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
index bfed4ba9dcd4..affde50f617a 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
@@ -41,4 +41,8 @@ [Protocols]
   gEfiLoadedImageProtocolGuid
 
 [Guids]
+  gEfiAcpiTableGuid
   gFdtTableGuid
+
+[FeaturePcd]
+  gEmbeddedTokenSpaceGuid.PcdAndroidBootLoadFile2
diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index 4f8ff5b261ca..cc39fef4895c 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -10,12 +10,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
+#include 
 #include 
 
+#include 
+
 #define FDT_ADDITIONAL_ENTRIES_SIZE 0x400
 
 typedef struct {
@@ -23,7 +27,15 @@ typedef struct {
   EFI_DEVICE_PATH_PROTOCOLEnd;
 } MEMORY_DEVICE_PATH;
 
+typedef struct {
+  VENDOR_DEVICE_PATH  VendorMediaNode;
+  EFI_DEVICE_PATH_PROTOCOLEndNode;
+} RAMDISK_DEVICE_PATH;
+
 STATIC ANDROID_BOOTIMG_PROTOCOL *mAndroidBootImg;
+STATIC VOID *mRamdiskData = NULL;
+STATIC UINTNmRamdiskSize = 0;
+STATIC EFI_HANDLE   mRamDiskLoadFileHandle = NULL;
 
 STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
 {
@@ -46,6 +58,99 @@ STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
   } // End
 };
 
+STATIC CONST RAMDISK_DEVICE_PATH mRamdiskDevicePath =
+{
+  {
+{
+  MEDIA_DEVICE_PATH,
+  MEDIA_VENDOR_DP,
+  { sizeof (VENDOR_DEVICE_PATH), 0 }
+},
+LINUX_EFI_INITRD_MEDIA_GUID
+  },
+  {
+END_DEVICE_PATH_TYPE,
+END_ENTIRE_DEVICE_PATH_SUBTYPE,
+{ sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+  }
+};
+
+/**
+  Causes the driver to load a specified file.
+
+  @param  This   Protocol instance pointer.
+  @param  FilePath   The device specific path of the file to load.
+  @param  BootPolicy Should always be FALSE.
+  @param  BufferSize On input the size of Buffer in bytes. On output with a 
return
+ code of EFI_SUCCESS, the amount of data transferred to
+ Buffer. On output with a return code of 
EFI_BUFFER_TOO_SMALL,
+ the size of Buffer required to retrieve the requested 
file.
+  @param  Buffer The memory buffer to transfer the file to. IF Buffer is 
NULL,
+ then no the size of the requested file is returned in
+ BufferSize.
+
+  @retval EFI_SUCCESS   The file was loaded.
+  @retval EFI_UNSUPPORTED   BootPolicy is TRUE.
+  @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
+BufferSize is NULL.
+  @retval EFI_NO_MEDIA  No medium was present to load the file.
+  @retval EFI_DEVICE_ERROR  The file was not loaded due to a device error.
+  @retval EFI_NO_RESPONSE   The remote system did not respond.
+  @retval EFI_NOT_FOUND The file was not found
+  @retval EFI_ABORTED   The file load process was manually canceled.
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize is too small to read the current
+directory entry. BufferSize has been updated 
with
+the size needed to complete the request.
+
+
+**/
+EFI_STATUS
+EFIAPI
+AndroidBootImgLoadFile2 (
+  IN EFI_LOAD_FILE2_PROTOCOL*This,
+  IN EFI_DEVICE_PATH_PROTOCOL   *FilePath,
+  IN BOOLEANBootPolicy,
+  IN OUT UINTN  *BufferSize,
+  IN VOID   *Buffer OPTIONAL
+  )
+
+{
+  // Verify if the valid parameters
+  if

[edk2-devel] [PATCH v3 2/4] EmbeddedPkg: AndroidBootImgBoot error handling updates

2021-09-13 Thread Jeff Brasen via groups.io
Update AndroidBootImgBoot to use a single return point
Make sure Kernel args are freed and Image is unloaded.

Signed-off-by: Jeff Brasen 
---
 .../AndroidBootImgLib/AndroidBootImgLib.c | 50 +++
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index 33425060b15d..324933013d91 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -382,10 +382,13 @@ AndroidBootImgBoot (
   UINTN   RamdiskSize;
   IN  VOID   *FdtBase;
 
+  NewKernelArg = NULL;
+  ImageHandle = NULL;
+
   Status = gBS->LocateProtocol (&gAndroidBootImgProtocolGuid, NULL,
 (VOID **) &mAndroidBootImg);
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgGetKernelInfo (
@@ -394,19 +397,19 @@ AndroidBootImgBoot (
 &KernelSize
 );
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
 
   NewKernelArg = AllocateZeroPool (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
   if (NewKernelArg == NULL) {
 DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
-return EFI_OUT_OF_RESOURCES;
+Status = EFI_OUT_OF_RESOURCES;
+goto Exit;
   }
 
   Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg);
   if (EFI_ERROR (Status)) {
-FreePool (NewKernelArg);
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgGetRamdiskInfo (
@@ -415,19 +418,17 @@ AndroidBootImgBoot (
 &RamdiskSize
 );
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgLocateFdt (Buffer, &FdtBase);
   if (EFI_ERROR (Status)) {
-FreePool (NewKernelArg);
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgUpdateFdt (Buffer, FdtBase, RamdiskData, RamdiskSize);
   if (EFI_ERROR (Status)) {
-FreePool (NewKernelArg);
-return Status;
+goto Exit;
   }
 
   KernelDevicePath = mMemoryDevicePathTemplate;
@@ -440,21 +441,15 @@ AndroidBootImgBoot (
(EFI_DEVICE_PATH *)&KernelDevicePath,
(VOID*)(UINTN)Kernel, KernelSize, &ImageHandle);
   if (EFI_ERROR (Status)) {
-//
-// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an 
ImageHandle was created
-// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be 
started right now.
-// If the caller doesn't have the option to defer the execution of an 
image, we should
-// unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
-//
-if (Status == EFI_SECURITY_VIOLATION) {
-  gBS->UnloadImage (ImageHandle);
-}
-return Status;
+goto Exit;
   }
 
   // Set kernel arguments
   Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
 (VOID **) &ImageInfo);
+  if (EFI_ERROR (Status)) {
+goto Exit;
+  }
   ImageInfo->LoadOptions = NewKernelArg;
   ImageInfo->LoadOptionsSize = StrLen (NewKernelArg) * sizeof (CHAR16);
 
@@ -464,5 +459,18 @@ AndroidBootImgBoot (
   Status = gBS->StartImage (ImageHandle, NULL, NULL);
   // Clear the Watchdog Timer if the image returns
   gBS->SetWatchdogTimer (0, 0x1, 0, NULL);
-  return EFI_SUCCESS;
+
+Exit:
+  //Unload image as it will not be used anymore
+  if (ImageHandle != NULL) {
+gBS->UnloadImage (ImageHandle);
+ImageHandle = NULL;
+  }
+  if (EFI_ERROR (Status)) {
+if (NewKernelArg != NULL) {
+  FreePool (NewKernelArg);
+  NewKernelArg = NULL;
+}
+  }
+  return Status;
 }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80620): https://edk2.groups.io/g/devel/message/80620
Mute This Topic: https://groups.io/mt/85589858/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 1/4] EmbeddedPkg: Remove duplicate libfdt.h include

2021-09-13 Thread Jeff Brasen via groups.io
Remove duplicate libfdt.h include statement in AndroidBootImgLib

Signed-off-by: Jeff Brasen 
---
 EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index bbc240c3632a..33425060b15d 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -16,8 +16,6 @@
 #include 
 #include 
 
-#include 
-
 #define FDT_ADDITIONAL_ENTRIES_SIZE 0x400
 
 typedef struct {
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80619): https://edk2.groups.io/g/devel/message/80619
Mute This Topic: https://groups.io/mt/85589857/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 3/4] EmbeddedPkg: Install FDT if UpdateDtb is not present

2021-09-13 Thread Jeff Brasen via groups.io
Currently if mAndroidBootImg->UpdateDtb is not supported on the platform
the device tree updates of the initrd are not made.

Signed-off-by: Jeff Brasen 
---
 .../Library/AndroidBootImgLib/AndroidBootImgLib.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index 324933013d91..4f8ff5b261ca 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -349,12 +349,13 @@ AndroidBootImgUpdateFdt (
 if (EFI_ERROR (Status)) {
   goto Fdt_Exit;
 }
-
-Status = gBS->InstallConfigurationTable (
-&gFdtTableGuid,
-(VOID *)(UINTN)NewFdtBase
-);
+  } else {
+NewFdtBase = UpdatedFdtBase;
   }
+  Status = gBS->InstallConfigurationTable (
+  &gFdtTableGuid,
+  (VOID *)(UINTN)NewFdtBase
+  );
 
   if (!EFI_ERROR (Status)) {
 return EFI_SUCCESS;
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80618): https://edk2.groups.io/g/devel/message/80618
Mute This Topic: https://groups.io/mt/85589856/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 2/2] Ext4Pkg: Support uncleanly unmounted filesystems

2021-09-10 Thread Jeff Brasen via groups.io
Support for uncleanly mounted filesystems, if there is a recovery
journal mark filesystem as read-only.

Signed-off-by: Jeff Brasen 
---
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c 
b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index 0c965415c5..9c3f7a9e7b 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -18,7 +18,7 @@ STATIC CONST UINT32  gSupportedIncompatFeat =
   EXT4_FEATURE_INCOMPAT_64BIT | EXT4_FEATURE_INCOMPAT_DIRDATA |
   EXT4_FEATURE_INCOMPAT_FLEX_BG | EXT4_FEATURE_INCOMPAT_FILETYPE |
   EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_LARGEDIR |
-  EXT4_FEATURE_INCOMPAT_MMP;
+  EXT4_FEATURE_INCOMPAT_MMP | EXT4_FEATURE_INCOMPAT_RECOVER;
 
 // Future features that may be nice additions in the future:
 // 1) Btree support: Required for write support and would speed up lookups in 
large directories.
@@ -89,10 +89,8 @@ Ext4SuperblockValidate (
 return FALSE;
   }
 
-  // Is this correct behaviour? Imagine the power cuts out, should the system 
fail to boot because
-  // we're scared of touching something corrupt?
   if ((Sb->s_state & EXT4_FS_STATE_UNMOUNTED) == 0) {
-return FALSE;
+DEBUG ((DEBUG_WARN, "[ext4] Filesystem was not unmounted cleanly\n"));
   }
 
   return TRUE;
@@ -215,6 +213,11 @@ Ext4OpenSuperblock (
 return EFI_UNSUPPORTED;
   }
 
+  if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_RECOVER)) {
+DEBUG ((DEBUG_WARN, "[ext4] Needs journal recovery, mounting 
read-only\n"));
+Partition->ReadOnly = TRUE;
+  }
+
   // At the time of writing, it's the only supported checksum.
   if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM &&
   Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C) {
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80512): https://edk2.groups.io/g/devel/message/80512
Mute This Topic: https://groups.io/mt/85521569/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v3 1/2] Ext4Pkg: Improve Ext4IsBindingSupported() behavior

2021-09-10 Thread Jeff Brasen via groups.io
A couple of improvements to improve performance.
Add check to return ACCESS_DENIED if already connected
Add check to verify superblock magic during supported to reduce start calls

Signed-off-by: Jeff Brasen 
---
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 54 +--
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 35 +
 3 files changed, 92 insertions(+), 11 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h 
b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
index 64eab455db..a9b932ed52 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -1117,4 +1117,18 @@ Ext4GetVolumeName (
   OUT UINTN  *VolNameLen
   );
 
+/**
+   Checks the superblock's magic value.
+
+   @param[in] DiskIo  Pointer to the DiskIo.
+   @param[in] BlockIo Pointer to the BlockIo.
+
+   @returns Whether the partition has a valid EXT4 superblock magic value.
+**/
+BOOLEAN
+Ext4SuperblockCheckMagic (
+  IN EFI_DISK_IO_PROTOCOL   *DiskIo,
+  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo
+  );
+
 #endif
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c 
b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
index ea2e048d77..d9fbe9ea78 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
@@ -631,7 +631,6 @@ Ext4Unload (
   @retval EFI_ACCESS_DENIEDThe device specified by ControllerHandle and
RemainingDevicePath is already being 
managed by a different
driver or an application that requires 
exclusive access.
-   Currently not implemented.
   @retval EFI_UNSUPPORTED  The device specified by ControllerHandle and
RemainingDevicePath is not supported by the 
driver specified by This.
 **/
@@ -643,32 +642,65 @@ Ext4IsBindingSupported (
   IN EFI_DEVICE_PATH *RemainingDevicePath  OPTIONAL
   )
 {
-  // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the
-  // protocol and ignore the output argument entirely
+  EFI_STATUSStatus;
+  EFI_DISK_IO_PROTOCOL  *DiskIo;
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;
 
-  EFI_STATUS  Status;
+  DiskIo = NULL;
+  BlockIo = NULL;
 
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiDiskIoProtocolGuid,
-  NULL,
-  BindingProtocol->ImageHandle,
+  (VOID **) &DiskIo,
+  BindingProtocol->DriverBindingHandle,
   ControllerHandle,
-  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+  EFI_OPEN_PROTOCOL_BY_DRIVER
   );
 
   if (EFI_ERROR (Status)) {
 return Status;
   }
-
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiBlockIoProtocolGuid,
-  NULL,
-  BindingProtocol->ImageHandle,
+  (VOID **) &BlockIo,
+  BindingProtocol->DriverBindingHandle,
   ControllerHandle,
-  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+  EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
+
+  if (!EFI_ERROR (Status)) {
+if (!Ext4SuperblockCheckMagic (DiskIo, BlockIo)) {
+  Status = EFI_UNSUPPORTED;
+}
+  }
+
+  //
+  // Close the I/O Abstraction(s) used to perform the supported test
+  //
+  if (DiskIo != NULL) {
+gBS->CloseProtocol (
+  ControllerHandle,
+  &gEfiDiskIoProtocolGuid,
+  BindingProtocol->DriverBindingHandle,
+  ControllerHandle
+  );
+  }
+  if (BlockIo != NULL) {
+gBS->CloseProtocol (
+  ControllerHandle,
+  &gEfiBlockIoProtocolGuid,
+  BindingProtocol->DriverBindingHandle,
+  ControllerHandle
+  );
+  }
   return Status;
 }
 
diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c 
b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index c321d8c3d8..0c965415c5 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -34,6 +34,41 @@ STATIC CONST UINT32  gSupportedIncompatFeat =
 // this is desired, it's fairly trivial to look for EFI_VOLUME_CORRUPTED
 // references and add some Ext4SignalCorruption function + function call.
 
+/**
+   Checks the superblock's magic value.
+
+   @param[in] DiskIo  Pointer to the DiskIo.
+   @param[in] BlockIo Pointer to the BlockIo.
+
+   @returns Whether the partition has a valid EXT4 superblock magic value.
+**/
+BOOLEAN
+Ext4SuperblockCheckMagic (
+  IN EFI_DISK_IO_PROTOCOL   *DiskIo,
+  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo
+  )
+{
+  UINT16  Magic;
+  EFI_STATUS  Status;
+
+  Status = DiskIo->ReadDisk (
+ DiskIo,
+ BlockIo->Media->MediaId,
+ 

[edk2-devel] [PATCH v3 0/2] ExtPkg Updates

2021-09-10 Thread Jeff Brasen via groups.io
I have been using the new Ext4Pkg and been pretty successful and it is solving 
a use case we had.

Had a couple updates to propose

1. Changed the implementation of the binding protocol to both check if the 
driver is already bound
to the partition as well as added a really quick check to validate the magic 
value in supported.
This improves performance when you have a large number of non-ext4 partitions 
on the system.

2. As we are planning on using this for boot support we want to support unclean 
filesystem states in
case the user doesn't reset cleanly. I added a check if the recovery journal is 
present and if so treat
the filesystem as read-only (I know the driver is only RO at this point, but 
figured if you added write
support prior to recovery journal support we would want that). With this 
everything seems to work great.
I can add this under a FeaturePcd if desired as well.

Change log

v3 - Removed goto flow on binding supported failures
 Minor code review comments
v2 - Minor code review comments
v1 - Initial revision

Jeff Brasen (2):
  Ext4Pkg: Improve Ext4IsBindingSupported() behavior
  Ext4Pkg: Support uncleanly unmounted filesystems

 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 54 +--
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 46 +--
 3 files changed, 99 insertions(+), 15 deletions(-)

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80510): https://edk2.groups.io/g/devel/message/80510
Mute This Topic: https://groups.io/mt/85521567/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 1/2] Ext4Pkg: Improve Ext4IsBindingSupported() behavior

2021-09-10 Thread Jeff Brasen via groups.io
We actually can't open the BlockIo protocol as BY_DRIVER as it is already owned 
by the DiskIoDxe driver. Will upload a v3 with the other feedback though.


Thanks,

Jeff


From: Marvin Häuser 
Sent: Friday, September 10, 2021 12:09 PM
To: Pedro Falcato 
Cc: edk2-devel-groups-io ; Jeff Brasen 

Subject: Re: [edk2-devel] [PATCH v2 1/2] Ext4Pkg: Improve 
Ext4IsBindingSupported() behavior

External email: Use caution opening links or attachments


On 10/09/2021 19:08, Pedro Falcato wrote:
> Ah yes, thanks! Although I didn't find the part where they say that
> you need to use the same attributes,
> after re-reading the spec it seems they recommend using BY_DRIVER.

UEFI 2.9, 11.1, "Device Driver", 2.: "It must use the same Attribute
value that was used in Supported()."

> So, change it to BY_DRIVER. The performance should be the same and
> it's more consistent.

Should be better because all handles opened by BY_DRIVER already will
immediately fail.

Best regards,
Marvin

>
> On Fri, Sep 10, 2021 at 5:56 PM Marvin Häuser  wrote:
>> On 10/09/2021 18:52, Pedro Falcato wrote:
>>> Like Marvin raised in v1, it's a good idea to change the first
>>> OpenProtocol's EFI_OPEN_PROTOCOL_BY_DRIVER
>>> into EFI_OPEN_PROTOCOL_GET_PROTOCOL, for consistency's sake.
>>> Since we're not keeping these protocols open, using BY_DRIVER makes no
>>> difference.
>> No, the UEFI spec demands Supported() to use the same Attributes as
>> Start() (likely for these very performance reasons), actually I thought
>> both need BY_DRIVER.
>>
>> Best regards,
>> Marvin
>>
>>> You didn't update Ext4SuperblockCheckMagic's comment in Superblock.c
>>> when you changed it in the header.
>>> Just a nitpick, but if you could quickly align the
>>> Ext4SuperblockCheckMagic's parameters' descriptions like
>>>
>>>  @param[in] DiskIo  Pointer to the DiskIo.
>>>  @param[in] BlockIo Pointer to the BlockIo.
>>>
>>> it would be excellent.
>>>
>>> Apart from that, looks great to me and the patch series will get my RB
>>> after that quick change.
>>>
>>> Best regards,
>>>
>>> Pedro
>>>
>>> On Fri, Sep 10, 2021 at 4:58 PM Jeff Brasen  wrote:
 A couple of improvements to improve performance.
 Add check to return ACCESS_DENIED if already connected
 Add check to verify superblock magic during supported to reduce start calls

 Signed-off-by: Jeff Brasen 
 ---
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 58 +--
Features/Ext4Pkg/Ext4Dxe/Superblock.c | 35 
3 files changed, 95 insertions(+), 12 deletions(-)

 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h 
 b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
 index 64eab455db..5c60860894 100644
 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
 +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
 @@ -1117,4 +1117,18 @@ Ext4GetVolumeName (
  OUT UINTN  *VolNameLen
  );

 +/**
 +   Checks the superblock's magic value.
 +
 +   @param[in] DiskIo Pointer to the DiskIo.
 +   @param[in] BlockIo Pointer to the BlockIo.
 +
 +   @return TRUE if a valid ext4 superblock, else FALSE.
 +**/
 +BOOLEAN
 +Ext4SuperblockCheckMagic (
 +  IN EFI_DISK_IO_PROTOCOL   *DiskIo,
 +  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo
 +  );
 +
#endif
 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c 
 b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
 index ea2e048d77..5ae93d0484 100644
 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
 +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
 @@ -631,7 +631,6 @@ Ext4Unload (
  @retval EFI_ACCESS_DENIEDThe device specified by 
 ControllerHandle and
   RemainingDevicePath is already being 
 managed by a different
   driver or an application that 
 requires exclusive access.
 -   Currently not implemented.
  @retval EFI_UNSUPPORTED  The device specified by 
 ControllerHandle and
   RemainingDevicePath is not supported 
 by the driver specified by This.
**/
 @@ -643,32 +642,67 @@ Ext4IsBindingSupported (
  IN EFI_DEVICE_PATH *RemainingDevicePath  OPTIONAL
  )
{
 -  // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the
 -  // protocol and ignore the output argument entirely
 +  EFI_STATUSStatus;
 +  EFI_DISK_IO_PROTOCOL  *DiskIo;
 +  EFI_BLOCK_IO_PROTOCOL *BlockIo;

 -  EFI_STATUS  Status;
 +  DiskIo = NULL;
 +  BlockIo = NULL;

 +  //
 +  // Open the IO Abstraction(s) needed to perform the supported test
 +  //
  Status = gBS->OpenProtocol (
  ControllerHandle,
  &gEfiDiskIoProt

Re: [edk2-devel] [PATCH v2 1/2] Ext4Pkg: Improve Ext4IsBindingSupported() behavior

2021-09-10 Thread Jeff Brasen via groups.io
Yeah we need by_driver on at least one protocol to prevent re-binding to the 
controller. It will return ALREADY_STARTED if this driver already has it open 
(from in Start) or ACCESS_DENIED if another driver is holding this.

I can covert both to by_driver if that is desired.

Will make the other little changes as well once I get a desired direction on 
how to open BlockIo.


Thanks,

Jeff


From: Marvin Häuser 
Sent: Friday, September 10, 2021 10:56 AM
To: devel@edk2.groups.io ; pedro.falc...@gmail.com 
; Jeff Brasen 
Subject: Re: [edk2-devel] [PATCH v2 1/2] Ext4Pkg: Improve 
Ext4IsBindingSupported() behavior

External email: Use caution opening links or attachments


On 10/09/2021 18:52, Pedro Falcato wrote:
> Like Marvin raised in v1, it's a good idea to change the first
> OpenProtocol's EFI_OPEN_PROTOCOL_BY_DRIVER
> into EFI_OPEN_PROTOCOL_GET_PROTOCOL, for consistency's sake.
> Since we're not keeping these protocols open, using BY_DRIVER makes no
> difference.

No, the UEFI spec demands Supported() to use the same Attributes as
Start() (likely for these very performance reasons), actually I thought
both need BY_DRIVER.

Best regards,
Marvin

> You didn't update Ext4SuperblockCheckMagic's comment in Superblock.c
> when you changed it in the header.
> Just a nitpick, but if you could quickly align the
> Ext4SuperblockCheckMagic's parameters' descriptions like
>
> @param[in] DiskIo  Pointer to the DiskIo.
> @param[in] BlockIo Pointer to the BlockIo.
>
> it would be excellent.
>
> Apart from that, looks great to me and the patch series will get my RB
> after that quick change.
>
> Best regards,
>
> Pedro
>
> On Fri, Sep 10, 2021 at 4:58 PM Jeff Brasen  wrote:
>> A couple of improvements to improve performance.
>> Add check to return ACCESS_DENIED if already connected
>> Add check to verify superblock magic during supported to reduce start calls
>>
>> Signed-off-by: Jeff Brasen 
>> ---
>>   Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
>>   Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 58 +--
>>   Features/Ext4Pkg/Ext4Dxe/Superblock.c | 35 
>>   3 files changed, 95 insertions(+), 12 deletions(-)
>>
>> diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h 
>> b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
>> index 64eab455db..5c60860894 100644
>> --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
>> +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
>> @@ -1117,4 +1117,18 @@ Ext4GetVolumeName (
>> OUT UINTN  *VolNameLen
>> );
>>
>> +/**
>> +   Checks the superblock's magic value.
>> +
>> +   @param[in] DiskIo Pointer to the DiskIo.
>> +   @param[in] BlockIo Pointer to the BlockIo.
>> +
>> +   @return TRUE if a valid ext4 superblock, else FALSE.
>> +**/
>> +BOOLEAN
>> +Ext4SuperblockCheckMagic (
>> +  IN EFI_DISK_IO_PROTOCOL   *DiskIo,
>> +  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo
>> +  );
>> +
>>   #endif
>> diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c 
>> b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
>> index ea2e048d77..5ae93d0484 100644
>> --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
>> +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
>> @@ -631,7 +631,6 @@ Ext4Unload (
>> @retval EFI_ACCESS_DENIEDThe device specified by 
>> ControllerHandle and
>>  RemainingDevicePath is already being 
>> managed by a different
>>  driver or an application that requires 
>> exclusive access.
>> -   Currently not implemented.
>> @retval EFI_UNSUPPORTED  The device specified by 
>> ControllerHandle and
>>  RemainingDevicePath is not supported by 
>> the driver specified by This.
>>   **/
>> @@ -643,32 +642,67 @@ Ext4IsBindingSupported (
>> IN EFI_DEVICE_PATH *RemainingDevicePath  OPTIONAL
>> )
>>   {
>> -  // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the
>> -  // protocol and ignore the output argument entirely
>> +  EFI_STATUSStatus;
>> +  EFI_DISK_IO_PROTOCOL  *DiskIo;
>> +  EFI_BLOCK_IO_PROTOCOL *BlockIo;
>>
>> -  EFI_STATUS  Status;
>> +  DiskIo = NULL;
>> +  BlockIo = NULL;
>>
>> +  //
>> +  // Open the IO Abstraction(s) needed to perform the supported test
>> +  //
>> Status = gBS->OpenProtocol (
>> ControllerHandle,
>> &gEfiDiskIoProtocolGuid,
>> -  NULL,
>> -  BindingProtocol->ImageHandle,
>> +  (VOID **) &DiskIo,
>> +  BindingProtocol->DriverBindingHandle,
>> ControllerHandle,
>> -  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
>> +  EFI_OPEN_PROTOCOL_BY_DRIVER
>> );
>>
>> if (EFI_ERROR (Status)) {
>> -return Status;
>> +goto Exit;
>> }
>> -
>> +  //
>> +  // Open the IO Abstraction(s) needed to perform the supported test
>> +  //
>> Status = gBS->OpenProtocol (
>> 

[edk2-devel] [PATCH v2 2/2] Ext4Pkg: Support uncleanly unmounted filesystems

2021-09-10 Thread Jeff Brasen via groups.io
Support for uncleanly mounted filesystems, if there is a recovery
journal mark filesystem as read-only.

Signed-off-by: Jeff Brasen 
---
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c 
b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index 1ceb0d5cbb..251babb320 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -18,7 +18,7 @@ STATIC CONST UINT32  gSupportedIncompatFeat =
   EXT4_FEATURE_INCOMPAT_64BIT | EXT4_FEATURE_INCOMPAT_DIRDATA |
   EXT4_FEATURE_INCOMPAT_FLEX_BG | EXT4_FEATURE_INCOMPAT_FILETYPE |
   EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_LARGEDIR |
-  EXT4_FEATURE_INCOMPAT_MMP;
+  EXT4_FEATURE_INCOMPAT_MMP | EXT4_FEATURE_INCOMPAT_RECOVER;
 
 // Future features that may be nice additions in the future:
 // 1) Btree support: Required for write support and would speed up lookups in 
large directories.
@@ -89,10 +89,8 @@ Ext4SuperblockValidate (
 return FALSE;
   }
 
-  // Is this correct behaviour? Imagine the power cuts out, should the system 
fail to boot because
-  // we're scared of touching something corrupt?
   if ((Sb->s_state & EXT4_FS_STATE_UNMOUNTED) == 0) {
-return FALSE;
+DEBUG ((DEBUG_WARN, "[ext4] Filesystem was not unmounted cleanly\n"));
   }
 
   return TRUE;
@@ -215,6 +213,11 @@ Ext4OpenSuperblock (
 return EFI_UNSUPPORTED;
   }
 
+  if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_RECOVER)) {
+DEBUG ((DEBUG_WARN, "[ext4] Needs journal recovery, mounting 
read-only\n"));
+Partition->ReadOnly = TRUE;
+  }
+
   // At the time of writing, it's the only supported checksum.
   if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM &&
   Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C) {
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80495): https://edk2.groups.io/g/devel/message/80495
Mute This Topic: https://groups.io/mt/85513029/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 1/2] Ext4Pkg: Improve Ext4IsBindingSupported() behavior

2021-09-10 Thread Jeff Brasen via groups.io
A couple of improvements to improve performance.
Add check to return ACCESS_DENIED if already connected
Add check to verify superblock magic during supported to reduce start calls

Signed-off-by: Jeff Brasen 
---
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 58 +--
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 35 
 3 files changed, 95 insertions(+), 12 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h 
b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
index 64eab455db..5c60860894 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -1117,4 +1117,18 @@ Ext4GetVolumeName (
   OUT UINTN  *VolNameLen
   );
 
+/**
+   Checks the superblock's magic value.
+
+   @param[in] DiskIo Pointer to the DiskIo.
+   @param[in] BlockIo Pointer to the BlockIo.
+
+   @return TRUE if a valid ext4 superblock, else FALSE.
+**/
+BOOLEAN
+Ext4SuperblockCheckMagic (
+  IN EFI_DISK_IO_PROTOCOL   *DiskIo,
+  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo
+  );
+
 #endif
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c 
b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
index ea2e048d77..5ae93d0484 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
@@ -631,7 +631,6 @@ Ext4Unload (
   @retval EFI_ACCESS_DENIEDThe device specified by ControllerHandle and
RemainingDevicePath is already being 
managed by a different
driver or an application that requires 
exclusive access.
-   Currently not implemented.
   @retval EFI_UNSUPPORTED  The device specified by ControllerHandle and
RemainingDevicePath is not supported by the 
driver specified by This.
 **/
@@ -643,32 +642,67 @@ Ext4IsBindingSupported (
   IN EFI_DEVICE_PATH *RemainingDevicePath  OPTIONAL
   )
 {
-  // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the
-  // protocol and ignore the output argument entirely
+  EFI_STATUSStatus;
+  EFI_DISK_IO_PROTOCOL  *DiskIo;
+  EFI_BLOCK_IO_PROTOCOL *BlockIo;
 
-  EFI_STATUS  Status;
+  DiskIo = NULL;
+  BlockIo = NULL;
 
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiDiskIoProtocolGuid,
-  NULL,
-  BindingProtocol->ImageHandle,
+  (VOID **) &DiskIo,
+  BindingProtocol->DriverBindingHandle,
   ControllerHandle,
-  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+  EFI_OPEN_PROTOCOL_BY_DRIVER
   );
 
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
-
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiBlockIoProtocolGuid,
-  NULL,
-  BindingProtocol->ImageHandle,
+  (VOID **) &BlockIo,
+  BindingProtocol->DriverBindingHandle,
   ControllerHandle,
-  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+  EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
+  if (EFI_ERROR (Status)) {
+goto Exit;
+  }
+
+  if (!Ext4SuperblockCheckMagic (DiskIo, BlockIo)) {
+Status = EFI_UNSUPPORTED;
+  }
+
+Exit:
+  //
+  // Close the I/O Abstraction(s) used to perform the supported test
+  //
+  if (DiskIo != NULL) {
+gBS->CloseProtocol (
+  ControllerHandle,
+  &gEfiDiskIoProtocolGuid,
+  BindingProtocol->DriverBindingHandle,
+  ControllerHandle
+  );
+  }
+  if (BlockIo != NULL) {
+gBS->CloseProtocol (
+  ControllerHandle,
+  &gEfiBlockIoProtocolGuid,
+  BindingProtocol->DriverBindingHandle,
+  ControllerHandle
+  );
+  }
   return Status;
 }
 
diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c 
b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index c321d8c3d8..1ceb0d5cbb 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -34,6 +34,41 @@ STATIC CONST UINT32  gSupportedIncompatFeat =
 // this is desired, it's fairly trivial to look for EFI_VOLUME_CORRUPTED
 // references and add some Ext4SignalCorruption function + function call.
 
+/**
+   Checks only superblock magic value.
+
+   @param[in] DiskIo Pointer to the DiskIo.
+   @param[in] BlockIo Pointer to the BlockIo.
+
+   @return TRUE if a valid ext4 superblock, else FALSE.
+**/
+BOOLEAN
+Ext4SuperblockCheckMagic (
+  IN EFI_DISK_IO_PROTOCOL   *DiskIo,
+  IN EFI_BLOCK_IO_PROTOCOL  *BlockIo
+  )
+{
+  UINT16  Magic;
+  EFI_STATUS  Status;
+
+  Status = DiskIo->ReadDisk (
+ DiskIo,
+ BlockIo->Media->MediaId,
+ EXT4_S

[edk2-devel] [PATCH v2 0/2] ExtPkg Updates

2021-09-10 Thread Jeff Brasen via groups.io
I have been using the new Ext4Pkg and been pretty successful and it is solving 
a use case we had.

Had a couple updates to propose

1. Changed the implementation of the binding protocol to both check if the 
driver is already bound
to the partition as well as added a really quick check to validate the magic 
value in supported.
This improves performance when you have a large number of non-ext4 partitions 
on the system.

2. As we are planning on using this for boot support we want to support unclean 
filesystem states in
case the user doesn't reset cleanly. I added a check if the recovery journal is 
present and if so treat
the filesystem as read-only (I know the driver is only RO at this point, but 
figured if you added write
support prior to recovery journal support we would want that). With this 
everything seems to work great.
I can add this under a FeaturePcd if desired as well.

Change log

v2 - Minor code review comments
v1 - Initial revision

Jeff Brasen (2):
  Ext4Pkg: Improve Ext4IsBindingSupported() behavior
  Ext4Pkg: Support uncleanly unmounted filesystems

 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 58 +--
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 46 +++--
 3 files changed, 102 insertions(+), 16 deletions(-)

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80493): https://edk2.groups.io/g/devel/message/80493
Mute This Topic: https://groups.io/mt/85513025/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 1/2] Ext4Pkg: Improve Binding support behavior

2021-09-09 Thread Jeff Brasen via groups.io
Sounds good will update that in a v2 patch tomorrow

Get Outlook for Android

From: Pedro Falcato 
Sent: Thursday, September 9, 2021 10:22:51 PM
To: Jeff Brasen 
Cc: edk2-devel-groups-io 
Subject: Re: [PATCH 1/2] Ext4Pkg: Improve Binding support behavior

External email: Use caution opening links or attachments


Hi Jeff,

Comments below.

The patch itself looks good.

Nitpick on the commit message: I'd reword the commit message to
something like "Improve Ext4IsBindingSupported() behavior"
or "Improve IsBindingSupported behavior", since this patch doesn't
change Ext4Bind(), which does the actual bind.

On Thu, Sep 9, 2021 at 9:41 PM Jeff Brasen  wrote:
>
> A couple improvements to improve performance.
> Add check to return ACCESS_DENIED if already connected
> Add check to verify superblock magic during supported to deduce start calls
>
> Signed-off-by: Jeff Brasen 
> ---
>  Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
>  Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 57 +--
>  Features/Ext4Pkg/Ext4Dxe/Superblock.c | 34 
>  3 files changed, 92 insertions(+), 13 deletions(-)
>
> diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h 
> b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
> index 64eab455db..9a3938e671 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
> +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
> @@ -1117,4 +1117,18 @@ Ext4GetVolumeName (
>OUT UINTN  *VolNameLen
>);
>
> +/**
> +   Checks only superblock magic value.
> +
> +   @param[in] DiskIo Pointer to the DiskIo.
> +   @param[in] BlockIo Pointer to the BlockIo.
> +
> +   @return TRUE if a valid ext4 superblock, else FALSE.
> +**/
> +BOOLEAN
> +Ext4SuperblockCheckMagic (
> +  IN EFI_DISK_IO_PROTOCOL  *DiskIo,
> +  IN EFI_BLOCK_IO_PROTOCOL *BlockIo
> +  );

I'd reword the first part of the comment into something like "Checks
the superblock's magic value.".
Aligning the two "Pointer to the ...Io" would be neat :)
Types and parameter names need to be separated by at least two
columns. So, something like:

 IN EFI_DISK_IO_PROTOCOL   *DiskIo,
 IN EFI_BLOCK_IO_PROTOCOL  *BlockIo

The feedback above also applies to the function's definition below, in
Superblock.c.

> +
>  #endif
> diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c 
> b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
> index ea2e048d77..cb1e6d532a 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
> @@ -631,7 +631,6 @@ Ext4Unload (
>@retval EFI_ACCESS_DENIEDThe device specified by ControllerHandle 
> and
> RemainingDevicePath is already being 
> managed by a different
> driver or an application that requires 
> exclusive access.
> -   Currently not implemented.
>@retval EFI_UNSUPPORTED  The device specified by ControllerHandle 
> and
> RemainingDevicePath is not supported by 
> the driver specified by This.
>  **/
> @@ -643,32 +642,64 @@ Ext4IsBindingSupported (
>IN EFI_DEVICE_PATH *RemainingDevicePath  OPTIONAL
>)
>  {
> -  // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the
> -  // protocol and ignore the output argument entirely
> -
> -  EFI_STATUS  Status;
> +  EFI_STATUSStatus;
> +  EFI_DISK_IO_PROTOCOL  *DiskIo = NULL;
> +  EFI_BLOCK_IO_PROTOCOL *BlockIo = NULL;
>
Initialization of variables are always separate from the declaration. Example:
EFI_DISK_IO_PROTOCOL  *DiskIo;
...

DiskIo = NULL;

> +  //
> +  // Open the IO Abstraction(s) needed to perform the supported test
> +  //
>Status = gBS->OpenProtocol (
>ControllerHandle,
>&gEfiDiskIoProtocolGuid,
> -  NULL,
> -  BindingProtocol->ImageHandle,
> +  (VOID **) &DiskIo,
> +  BindingProtocol->DriverBindingHandle,
>ControllerHandle,
> -  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> +  EFI_OPEN_PROTOCOL_BY_DRIVER
>);
>
>if (EFI_ERROR (Status)) {
> -return Status;
> +goto Exit;
>}
> -
> +  //
> +  // Open the IO Abstraction(s) needed to perform the supported test
> +  //
>Status = gBS->OpenProtocol (
>ControllerHandle,
>&gEfiBlockIoProtocolGuid,
> -  NULL,
> -  BindingProtocol->ImageHandle,
> +  (VOID **) &BlockIo,
> +  BindingProtocol->DriverBindingHandle,
>ControllerHandle,
> -  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> +  EFI_OPEN_PROTOCOL_GET_PROTOCOL
>);
> +  if (EFI_ERROR (Status)) {
> +goto Exit;
> +  }
> +
> +  if (!Ext4SuperblockCheckMagic (DiskIo, BlockIo)) {
> +Status = EFI_UNSUPPORTED;
> +  }
> +
> +Exit:
> +  //
> +  // Close the I/O Abstrac

Re: [edk2-devel] [PATCH v2 2/2] EmbeddedPkg: Add LoadFile2 for linux initrd

2021-09-09 Thread Jeff Brasen via groups.io
Question below


Thanks,

Jeff


From: Leif Lindholm 
Sent: Tuesday, September 7, 2021 11:51 AM
To: Jeff Brasen 
Cc: devel@edk2.groups.io ; ardb+tianoc...@kernel.org 
; abner.ch...@hpe.com ; 
daniel.schae...@hpe.com 
Subject: Re: [PATCH v2 2/2] EmbeddedPkg: Add LoadFile2 for linux initrd

External email: Use caution opening links or attachments


Minor style comments below.

On Wed, Sep 01, 2021 at 20:28:27 +, Jeff Brasen wrote:
> Add support under a pcd feature for using the new interface to pass
> initrd to the linux kernel.
>
> Signed-off-by: Jeff Brasen 
> ---
>  EmbeddedPkg/EmbeddedPkg.dec   |   1 +
>  .../AndroidBootImgLib/AndroidBootImgLib.inf   |   3 +
>  .../AndroidBootImgLib/AndroidBootImgLib.c | 147 +-
>  3 files changed, 144 insertions(+), 7 deletions(-)
>
> diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
> index c2068ce5a8ce..7638deb8 100644
> --- a/EmbeddedPkg/EmbeddedPkg.dec
> +++ b/EmbeddedPkg/EmbeddedPkg.dec
> @@ -86,6 +86,7 @@ [Ppis]
>  [PcdsFeatureFlag.common]
>
> gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE|BOOLEAN|0x001b
>gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x0053
> +  gEmbeddedTokenSpaceGuid.PcdAndroidBootLoadFile2|FALSE|BOOLEAN|0x005b
>
>  [PcdsFixedAtBuild.common]
>gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0|UINT32|0x000b
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf 
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> index bfed4ba9dcd4..39d8abe72cd1 100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
> @@ -42,3 +42,6 @@ [Protocols]
>
>  [Guids]
>gFdtTableGuid
> +
> +[FeaturePcd]
> +  gEmbeddedTokenSpaceGuid.PcdAndroidBootLoadFile2
> diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
> b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> index 3c617649f735..635965690dc0 100644
> --- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> +++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
> @@ -10,11 +10,15 @@
>  #include 
>  #include 
>  #include 
> +#include 

Move that inserted line up one to maintain alphabetical sorting.

>  #include 
>  #include 
>
>  #include 
>  #include 
> +#include 
> +
> +#include 
>
>  #include 

Glad to see we're *really* including libfdt.h (also included above and
completely unrelated to this patch).

> @@ -25,7 +29,14 @@ typedef struct {
>EFI_DEVICE_PATH_PROTOCOLEnd;
>  } MEMORY_DEVICE_PATH;
>
> +typedef struct {
> +  VENDOR_DEVICE_PATH  VenMediaNode;

VendorMediaNode

> +  EFI_DEVICE_PATH_PROTOCOLEndNode;
> +} RAMDISK_DEVICE_PATH;
> +
>  STATIC ANDROID_BOOTIMG_PROTOCOL *mAndroidBootImg;
> +STATIC VOID *mRamdiskData = NULL;
> +STATIC UINTNmRamdiskSize = 0;
>
>  STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
>  {
> @@ -48,6 +59,99 @@ STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
>} // End
>  };
>
> +STATIC CONST RAMDISK_DEVICE_PATH mRamdiskDevicePath =
> +{
> +  {
> +{
> +  MEDIA_DEVICE_PATH,
> +  MEDIA_VENDOR_DP,
> +  { sizeof (VENDOR_DEVICE_PATH), 0 }
> +},
> +LINUX_EFI_INITRD_MEDIA_GUID
> +  },
> +  {
> +END_DEVICE_PATH_TYPE,
> +END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +{ sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
> +  }
> +};
> +
> +/**
> +  Causes the driver to load a specified file.
> +
> +  @param  This   Protocol instance pointer.
> +  @param  FilePath   The device specific path of the file to load.
> +  @param  BootPolicy Should always be FALSE.
> +  @param  BufferSize On input the size of Buffer in bytes. On output with a 
> return
> + code of EFI_SUCCESS, the amount of data transferred to
> + Buffer. On output with a return code of 
> EFI_BUFFER_TOO_SMALL,
> + the size of Buffer required to retrieve the requested 
> file.
> +  @param  Buffer The memory buffer to transfer the file to. IF Buffer is 
> NULL,
> + then no the size of the requested file is returned in
> + BufferSize.
> +
> +  @retval EFI_SUCCESS   The file was loaded.
> +  @retval EFI_UNSUPPORTED   BootPolicy is TRUE.
> +  @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
> +BufferSize is NULL.
> +  @retval EFI_NO_MEDIA  No medium was present to load the file.
> +  @retval EFI_DEVICE_ERROR  The file was not loaded due to a device 
> error.
> +  @retval EFI_NO_RESPONSE   The remote system did not respond.
> +  @retval EFI_NOT_FOUND The file was not found
> +  @retval EFI_ABORTED   The file load process was manually canceled.
> +  @retval 

[edk2-devel] [PATCH 0/2] ExtPkg Updates

2021-09-09 Thread Jeff Brasen via groups.io
I have been using the new Ext4Pkg and been pretty successful and it is solving 
a use case we had.

Had a couple updates to propose

1. Changed the implementation of the binding protocol to both check if the 
driver is already bound
to the partition as well as added a really quick check to validate the magic 
value in supported.
This improves performance when you have a large number of non-ext4 partitions 
on the system.

2. As we are planning on using this for boot support we want to support unclean 
filesystem states in
case the user doesn't reset cleanly. I added a check if the recovery journal is 
present and if so treat
the filesystem as read-only (I know the driver is only RO at this point, but 
figured if you added write
support prior to recovery journal support we would want that). With this 
everything seems to work great.
I can add this under a FeaturePcd if desired as well.

Change log

v1 - Initial revision

Jeff Brasen (2):
  Ext4Pkg: Improve Binding support behavior
  Ext4Pkg: Support non-cleanlty unmounted filesystems

 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 57 +--
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 45 +++--
 3 files changed, 99 insertions(+), 17 deletions(-)

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80448): https://edk2.groups.io/g/devel/message/80448
Mute This Topic: https://groups.io/mt/85494671/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 2/2] Ext4Pkg: Support non-cleanlty unmounted filesystems

2021-09-09 Thread Jeff Brasen via groups.io
Support for uncleanly mounted filesystems, if there is a recovery
journal mark filesystem as read-only.

Signed-off-by: Jeff Brasen 
---
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c 
b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index 1f8cdd3705..444dd3ca97 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -18,7 +18,7 @@ STATIC CONST UINT32  gSupportedIncompatFeat =
   EXT4_FEATURE_INCOMPAT_64BIT | EXT4_FEATURE_INCOMPAT_DIRDATA |
   EXT4_FEATURE_INCOMPAT_FLEX_BG | EXT4_FEATURE_INCOMPAT_FILETYPE |
   EXT4_FEATURE_INCOMPAT_EXTENTS | EXT4_FEATURE_INCOMPAT_LARGEDIR |
-  EXT4_FEATURE_INCOMPAT_MMP;
+  EXT4_FEATURE_INCOMPAT_MMP | EXT4_FEATURE_INCOMPAT_RECOVER;
 
 // Future features that may be nice additions in the future:
 // 1) Btree support: Required for write support and would speed up lookups in 
large directories.
@@ -88,10 +88,8 @@ Ext4SuperblockValidate (
 return FALSE;
   }
 
-  // Is this correct behaviour? Imagine the power cuts out, should the system 
fail to boot because
-  // we're scared of touching something corrupt?
   if ((Sb->s_state & EXT4_FS_STATE_UNMOUNTED) == 0) {
-return FALSE;
+DEBUG ((DEBUG_WARN, "[ext4] filesystem was not unmounted cleanly\n"));
   }
 
   return TRUE;
@@ -214,6 +212,11 @@ Ext4OpenSuperblock (
 return EFI_UNSUPPORTED;
   }
 
+  if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_RECOVER) == 
EXT4_FEATURE_INCOMPAT_RECOVER) {
+DEBUG ((DEBUG_WARN, "[ext4] Needs journal recovery mount read-only\n"));
+Partition->ReadOnly = TRUE;
+  }
+
   // At the time of writing, it's the only supported checksum.
   if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM &&
   Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C) {
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80450): https://edk2.groups.io/g/devel/message/80450
Mute This Topic: https://groups.io/mt/85494673/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH 1/2] Ext4Pkg: Improve Binding support behavior

2021-09-09 Thread Jeff Brasen via groups.io
A couple improvements to improve performance.
Add check to return ACCESS_DENIED if already connected
Add check to verify superblock magic during supported to deduce start calls

Signed-off-by: Jeff Brasen 
---
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h| 14 +++
 Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c| 57 +--
 Features/Ext4Pkg/Ext4Dxe/Superblock.c | 34 
 3 files changed, 92 insertions(+), 13 deletions(-)

diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h 
b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
index 64eab455db..9a3938e671 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h
@@ -1117,4 +1117,18 @@ Ext4GetVolumeName (
   OUT UINTN  *VolNameLen
   );
 
+/**
+   Checks only superblock magic value.
+
+   @param[in] DiskIo Pointer to the DiskIo.
+   @param[in] BlockIo Pointer to the BlockIo.
+
+   @return TRUE if a valid ext4 superblock, else FALSE.
+**/
+BOOLEAN
+Ext4SuperblockCheckMagic (
+  IN EFI_DISK_IO_PROTOCOL  *DiskIo,
+  IN EFI_BLOCK_IO_PROTOCOL *BlockIo
+  );
+
 #endif
diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c 
b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
index ea2e048d77..cb1e6d532a 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c
@@ -631,7 +631,6 @@ Ext4Unload (
   @retval EFI_ACCESS_DENIEDThe device specified by ControllerHandle and
RemainingDevicePath is already being 
managed by a different
driver or an application that requires 
exclusive access.
-   Currently not implemented.
   @retval EFI_UNSUPPORTED  The device specified by ControllerHandle and
RemainingDevicePath is not supported by the 
driver specified by This.
 **/
@@ -643,32 +642,64 @@ Ext4IsBindingSupported (
   IN EFI_DEVICE_PATH *RemainingDevicePath  OPTIONAL
   )
 {
-  // Note to self: EFI_OPEN_PROTOCOL_TEST_PROTOCOL lets us not close the
-  // protocol and ignore the output argument entirely
-
-  EFI_STATUS  Status;
+  EFI_STATUSStatus;
+  EFI_DISK_IO_PROTOCOL  *DiskIo = NULL;
+  EFI_BLOCK_IO_PROTOCOL *BlockIo = NULL;
 
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiDiskIoProtocolGuid,
-  NULL,
-  BindingProtocol->ImageHandle,
+  (VOID **) &DiskIo,
+  BindingProtocol->DriverBindingHandle,
   ControllerHandle,
-  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+  EFI_OPEN_PROTOCOL_BY_DRIVER
   );
 
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
-
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
   Status = gBS->OpenProtocol (
   ControllerHandle,
   &gEfiBlockIoProtocolGuid,
-  NULL,
-  BindingProtocol->ImageHandle,
+  (VOID **) &BlockIo,
+  BindingProtocol->DriverBindingHandle,
   ControllerHandle,
-  EFI_OPEN_PROTOCOL_TEST_PROTOCOL
+  EFI_OPEN_PROTOCOL_GET_PROTOCOL
   );
+  if (EFI_ERROR (Status)) {
+goto Exit;
+  }
+
+  if (!Ext4SuperblockCheckMagic (DiskIo, BlockIo)) {
+Status = EFI_UNSUPPORTED;
+  }
+
+Exit:
+  //
+  // Close the I/O Abstraction(s) used to perform the supported test
+  //
+  if (DiskIo != NULL) {
+gBS->CloseProtocol (
+  ControllerHandle,
+  &gEfiDiskIoProtocolGuid,
+  BindingProtocol->DriverBindingHandle,
+  ControllerHandle
+  );
+  }
+  if (BlockIo != NULL) {
+gBS->CloseProtocol (
+  ControllerHandle,
+  &gEfiBlockIoProtocolGuid,
+  BindingProtocol->DriverBindingHandle,
+  ControllerHandle
+  );
+  }
   return Status;
 }
 
diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c 
b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
index c321d8c3d8..1f8cdd3705 100644
--- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c
+++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c
@@ -34,6 +34,40 @@ STATIC CONST UINT32  gSupportedIncompatFeat =
 // this is desired, it's fairly trivial to look for EFI_VOLUME_CORRUPTED
 // references and add some Ext4SignalCorruption function + function call.
 
+/**
+   Checks only superblock magic value.
+
+   @param[in] DiskIo Pointer to the DiskIo.
+   @param[in] BlockIo Pointer to the BlockIo.
+
+   @return TRUE if a valid ext4 superblock, else FALSE.
+**/
+BOOLEAN
+Ext4SuperblockCheckMagic (
+  IN EFI_DISK_IO_PROTOCOL  *DiskIo,
+  IN EFI_BLOCK_IO_PROTOCOL *BlockIo
+  )
+{
+  UINT16  Magic;
+  EFI_STATUS Status;
+
+  Status = DiskIo->ReadDisk (DiskIo,
+ BlockIo->Media->MediaId,
+ EXT4_SUPERBLOCK_OFFSET + OFFSET_OF 
(EXT4_SUP

Re: [edk2-devel] [PATCH v2 0/2] AndroidBootImgLib improvements

2021-09-07 Thread Jeff Brasen via groups.io
Any additional feedback on this patchset?


Thanks,

Jeff


From: Jeff Brasen 
Sent: Wednesday, September 1, 2021 2:28 PM
To: devel@edk2.groups.io 
Cc: l...@nuviainc.com ; ardb+tianoc...@kernel.org 
; abner.ch...@hpe.com ; 
daniel.schae...@hpe.com ; Jeff Brasen 

Subject: [PATCH v2 0/2] AndroidBootImgLib improvements

Added support for using loadfile2 approach for passing ramdisk to linux.
Created patch series for general error handling improvments based on
review feedback.

[v2]
-Added review feedback
-General improvements to error handling

[v1]
- Intial revision

Jeff Brasen (2):
  EmbeddedPkg: AndroidBootImgBoot error handling updates
  EmbeddedPkg: Add LoadFile2 for linux initrd

 EmbeddedPkg/EmbeddedPkg.dec   |   1 +
 .../AndroidBootImgLib/AndroidBootImgLib.inf   |   3 +
 .../AndroidBootImgLib/AndroidBootImgLib.c | 193 +++---
 3 files changed, 171 insertions(+), 26 deletions(-)

--
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80309): https://edk2.groups.io/g/devel/message/80309
Mute This Topic: https://groups.io/mt/85313031/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 1/2] EmbeddedPkg: AndroidBootImgBoot error handling updates

2021-09-01 Thread Jeff Brasen via groups.io
Update AndroidBootImgBoot to use a single return point
Make sure Kernel args are freed and Image is unloaded.

Signed-off-by: Jeff Brasen 
---
 .../AndroidBootImgLib/AndroidBootImgLib.c | 50 +++
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index bbc240c3632a..3c617649f735 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -384,10 +384,13 @@ AndroidBootImgBoot (
   UINTN   RamdiskSize;
   IN  VOID   *FdtBase;
 
+  NewKernelArg = NULL;
+  ImageHandle = NULL;
+
   Status = gBS->LocateProtocol (&gAndroidBootImgProtocolGuid, NULL,
 (VOID **) &mAndroidBootImg);
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgGetKernelInfo (
@@ -396,19 +399,19 @@ AndroidBootImgBoot (
 &KernelSize
 );
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
 
   NewKernelArg = AllocateZeroPool (ANDROID_BOOTIMG_KERNEL_ARGS_SIZE);
   if (NewKernelArg == NULL) {
 DEBUG ((DEBUG_ERROR, "Fail to allocate memory\n"));
-return EFI_OUT_OF_RESOURCES;
+Status = EFI_OUT_OF_RESOURCES;
+goto Exit;
   }
 
   Status = AndroidBootImgUpdateArgs (Buffer, NewKernelArg);
   if (EFI_ERROR (Status)) {
-FreePool (NewKernelArg);
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgGetRamdiskInfo (
@@ -417,19 +420,17 @@ AndroidBootImgBoot (
 &RamdiskSize
 );
   if (EFI_ERROR (Status)) {
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgLocateFdt (Buffer, &FdtBase);
   if (EFI_ERROR (Status)) {
-FreePool (NewKernelArg);
-return Status;
+goto Exit;
   }
 
   Status = AndroidBootImgUpdateFdt (Buffer, FdtBase, RamdiskData, RamdiskSize);
   if (EFI_ERROR (Status)) {
-FreePool (NewKernelArg);
-return Status;
+goto Exit;
   }
 
   KernelDevicePath = mMemoryDevicePathTemplate;
@@ -442,21 +443,15 @@ AndroidBootImgBoot (
(EFI_DEVICE_PATH *)&KernelDevicePath,
(VOID*)(UINTN)Kernel, KernelSize, &ImageHandle);
   if (EFI_ERROR (Status)) {
-//
-// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an 
ImageHandle was created
-// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be 
started right now.
-// If the caller doesn't have the option to defer the execution of an 
image, we should
-// unload image for the EFI_SECURITY_VIOLATION to avoid resource leak.
-//
-if (Status == EFI_SECURITY_VIOLATION) {
-  gBS->UnloadImage (ImageHandle);
-}
-return Status;
+goto Exit;
   }
 
   // Set kernel arguments
   Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid,
 (VOID **) &ImageInfo);
+  if (EFI_ERROR (Status)) {
+goto Exit;
+  }
   ImageInfo->LoadOptions = NewKernelArg;
   ImageInfo->LoadOptionsSize = StrLen (NewKernelArg) * sizeof (CHAR16);
 
@@ -466,5 +461,18 @@ AndroidBootImgBoot (
   Status = gBS->StartImage (ImageHandle, NULL, NULL);
   // Clear the Watchdog Timer if the image returns
   gBS->SetWatchdogTimer (0, 0x1, 0, NULL);
-  return EFI_SUCCESS;
+
+Exit:
+  //Unload image as it will not be used anymore
+  if (ImageHandle != NULL) {
+gBS->UnloadImage (ImageHandle);
+ImageHandle = NULL;
+  }
+  if (EFI_ERROR (Status)) {
+if (NewKernelArg != NULL) {
+  FreePool (NewKernelArg);
+  NewKernelArg = NULL;
+}
+  }
+  return Status;
 }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80113): https://edk2.groups.io/g/devel/message/80113
Mute This Topic: https://groups.io/mt/85313032/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 2/2] EmbeddedPkg: Add LoadFile2 for linux initrd

2021-09-01 Thread Jeff Brasen via groups.io
Add support under a pcd feature for using the new interface to pass
initrd to the linux kernel.

Signed-off-by: Jeff Brasen 
---
 EmbeddedPkg/EmbeddedPkg.dec   |   1 +
 .../AndroidBootImgLib/AndroidBootImgLib.inf   |   3 +
 .../AndroidBootImgLib/AndroidBootImgLib.c | 147 +-
 3 files changed, 144 insertions(+), 7 deletions(-)

diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index c2068ce5a8ce..7638deb8 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -86,6 +86,7 @@ [Ppis]
 [PcdsFeatureFlag.common]
   
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|FALSE|BOOLEAN|0x001b
   gEmbeddedTokenSpaceGuid.PcdGdbSerial|FALSE|BOOLEAN|0x0053
+  gEmbeddedTokenSpaceGuid.PcdAndroidBootLoadFile2|FALSE|BOOLEAN|0x005b
 
 [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdPrePiStackBase|0|UINT32|0x000b
diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
index bfed4ba9dcd4..39d8abe72cd1 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.inf
@@ -42,3 +42,6 @@ [Protocols]
 
 [Guids]
   gFdtTableGuid
+
+[FeaturePcd]
+  gEmbeddedTokenSpaceGuid.PcdAndroidBootLoadFile2
diff --git a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c 
b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
index 3c617649f735..635965690dc0 100644
--- a/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
+++ b/EmbeddedPkg/Library/AndroidBootImgLib/AndroidBootImgLib.c
@@ -10,11 +10,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include 
 #include 
+#include 
+
+#include 
 
 #include 
 
@@ -25,7 +29,14 @@ typedef struct {
   EFI_DEVICE_PATH_PROTOCOLEnd;
 } MEMORY_DEVICE_PATH;
 
+typedef struct {
+  VENDOR_DEVICE_PATH  VenMediaNode;
+  EFI_DEVICE_PATH_PROTOCOLEndNode;
+} RAMDISK_DEVICE_PATH;
+
 STATIC ANDROID_BOOTIMG_PROTOCOL *mAndroidBootImg;
+STATIC VOID *mRamdiskData = NULL;
+STATIC UINTNmRamdiskSize = 0;
 
 STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
 {
@@ -48,6 +59,99 @@ STATIC CONST MEMORY_DEVICE_PATH mMemoryDevicePathTemplate =
   } // End
 };
 
+STATIC CONST RAMDISK_DEVICE_PATH mRamdiskDevicePath =
+{
+  {
+{
+  MEDIA_DEVICE_PATH,
+  MEDIA_VENDOR_DP,
+  { sizeof (VENDOR_DEVICE_PATH), 0 }
+},
+LINUX_EFI_INITRD_MEDIA_GUID
+  },
+  {
+END_DEVICE_PATH_TYPE,
+END_ENTIRE_DEVICE_PATH_SUBTYPE,
+{ sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+  }
+};
+
+/**
+  Causes the driver to load a specified file.
+
+  @param  This   Protocol instance pointer.
+  @param  FilePath   The device specific path of the file to load.
+  @param  BootPolicy Should always be FALSE.
+  @param  BufferSize On input the size of Buffer in bytes. On output with a 
return
+ code of EFI_SUCCESS, the amount of data transferred to
+ Buffer. On output with a return code of 
EFI_BUFFER_TOO_SMALL,
+ the size of Buffer required to retrieve the requested 
file.
+  @param  Buffer The memory buffer to transfer the file to. IF Buffer is 
NULL,
+ then no the size of the requested file is returned in
+ BufferSize.
+
+  @retval EFI_SUCCESS   The file was loaded.
+  @retval EFI_UNSUPPORTED   BootPolicy is TRUE.
+  @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
+BufferSize is NULL.
+  @retval EFI_NO_MEDIA  No medium was present to load the file.
+  @retval EFI_DEVICE_ERROR  The file was not loaded due to a device error.
+  @retval EFI_NO_RESPONSE   The remote system did not respond.
+  @retval EFI_NOT_FOUND The file was not found
+  @retval EFI_ABORTED   The file load process was manually canceled.
+  @retval EFI_BUFFER_TOO_SMALL  The BufferSize is too small to read the current
+directory entry. BufferSize has been updated 
with
+the size needed to complete the request.
+
+
+**/
+EFI_STATUS
+EFIAPI
+AndroidBootImgLoadFile2 (
+  IN EFI_LOAD_FILE2_PROTOCOL*This,
+  IN EFI_DEVICE_PATH_PROTOCOL   *FilePath,
+  IN BOOLEANBootPolicy,
+  IN OUT UINTN  *BufferSize,
+  IN VOID   *Buffer OPTIONAL
+  )
+
+{
+  // Verify if the valid parameters
+  if (This == NULL ||
+  BufferSize == NULL ||
+  FilePath == NULL ||
+  !IsDevicePathValid (FilePath, 0)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  if (BootPolicy) {
+return EFI_UNSUPPORTED;
+  }
+
+  // Check if the given buffer size is big enough
+  // EFI_BUFFER_TOO_SMALL to allow caller to allocate a bi

[edk2-devel] [PATCH v2 0/2] AndroidBootImgLib improvements

2021-09-01 Thread Jeff Brasen via groups.io
Added support for using loadfile2 approach for passing ramdisk to linux.
Created patch series for general error handling improvments based on
review feedback.

[v2]
-Added review feedback
-General improvements to error handling

[v1]
- Intial revision

Jeff Brasen (2):
  EmbeddedPkg: AndroidBootImgBoot error handling updates
  EmbeddedPkg: Add LoadFile2 for linux initrd

 EmbeddedPkg/EmbeddedPkg.dec   |   1 +
 .../AndroidBootImgLib/AndroidBootImgLib.inf   |   3 +
 .../AndroidBootImgLib/AndroidBootImgLib.c | 193 +++---
 3 files changed, 171 insertions(+), 26 deletions(-)

-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80112): https://edk2.groups.io/g/devel/message/80112
Mute This Topic: https://groups.io/mt/85313031/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




<    1   2   3   >