[edk2] Question about UfsPassThruDxe driver

2018-12-21 Thread Mike M
Dear MdeModulePkg maintainers, I'm a bit baffled about a way
physical addresses passed to UFS HCI at UfsPassThruDxe driver.
For example, UFS HCI V.2.1 declares Data Base Address in PRDT structure as
two 32 bit words,
where bits 0 and 1 of a physical address are reserved.
As well UTP Command Descriptor Base Address (UCDBA) shall be aligned to
128-byte address,
i.e. bits [06:00] are reserved.
In common such reserved bits are being cleared by AND operation
with appropriate mask, while in UfsPassThruDxe right shift operator is used
as below:
Prdt[PrdtIndex].DbAddr  = (UINT32)RShiftU64 ((UINT64)(UINTN)Remaining,
2);
Prdt[PrdtIndex].DbAddrU = (UINT32)RShiftU64 ((UINT64)(UINTN)Remaining,
32);
and
  Trd->UcdBa  = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 7);
  Trd->UcdBaU = (UINT32)RShiftU64 ((UINT64)CmdDescPhyAddr, 32);

How does UFS HCI deal with such values?  This doesn't look correct.
Would you like I prepare a patch replacing RShiftU64 operator with bitwise
AND operator
for lower 32-bit of a physical address value?
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ArmPkg/ArmLib ARM: set .fpu to let Clang 7 assemble ArmV7Support.S

2018-12-21 Thread Leif Lindholm
On Fri, Dec 21, 2018 at 07:00:04PM +0100, Ard Biesheuvel wrote:
> On Fri, 21 Dec 2018 at 18:58, Leif Lindholm  wrote:
> >
> > On Thu, Dec 20, 2018 at 08:16:53PM +0100, Ard Biesheuvel wrote:
> > > Clang 7 complains about the vmsr instruction in ArmV7Support.S,
> > > which is only available on cores that implement some flavour of
> > > VFP. So set the .fpu to NEON like we do in some other places.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel 
> > > ---
> > >  ArmPkg/Library/ArmLib/Arm/ArmV7Support.S | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S 
> > > b/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> > > index 281499b46cbc..1808962ee3e2 100644
> > > --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> > > +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> > > @@ -268,6 +268,7 @@ ASM_FUNC(ArmEnableVFP)
> > >  #ifndef __clang__
> > >mcr p10,#0x7,r0,c8,c0,#0
> > >  #else
> > > +  .fpuneon
> > >vmsrfpexc, r0
> > >  #endif
> >
> > No objection from me. But I would point out that the special clang
> > filtering here could possibly be dropped.
> >
> > I mean, theoretically someone could have an even older binutils, but
> > Linaro GCC 4.8-2013.05 will happily assemble the clang side of this
> > conditional.
> 
> Yeah, but that would be a separate patch, no?

Oh, sure. Just, it would be nice if that could precede this change.

That said, the other two .fpu neon instances in edk2 are both hidden
behind #if !defined(__APPLE__). Should we check with Andrew
(post-wilderbeest) if this is something we need to keep (and if so add
it here) or whether we can delete it across the board?

/
Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 35/41] Silicon/NXP: Implement PciHostBridgeLib support

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:49PM +0530, Meenakshi Aggarwal wrote:
> From: Vabhav 
> 
> Implement the library that exposes the PCIe root complexes to the
> generic PCI host bridge driver,Putting SoC Specific low level init
> code for the RCs.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> ---
>  .../Library/PciHostBridgeLib/PciHostBridgeLib.c| 639 
> +
>  .../Library/PciHostBridgeLib/PciHostBridgeLib.inf  |  51 ++
>  2 files changed, 690 insertions(+)
>  create mode 100644 Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
>  create mode 100644 Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
> 
> diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c 
> b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> new file mode 100644
> index 000..a543d7d
> --- /dev/null
> +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> @@ -0,0 +1,639 @@
> +/** @file
> +  PCI Host Bridge Library instance for NXP SoCs
> +
> +  Copyright 2018 NXP
> +
> +  This program and the accompanying materials are licensed and made available
> +  under the terms and conditions of the BSD License which accompanies this
> +  distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
> WITHOUT
> +  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#pragma pack(1)
> +typedef struct {
> +  ACPI_HID_DEVICE_PATH AcpiDevicePath;
> +  EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
> +} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
> +#pragma pack ()
> +
> +STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[] = 
> {
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG0_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  },
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG1_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  },
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG2_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  },
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG3_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  }
> +};
> +
> +STATIC
> +GLOBAL_REMOVE_IF_UNREFERENCED
> +CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
> +  L"Mem", L"I/O", L"Bus"
> +};
> +
> +#define PCI_ALLOCATION_ATTRIBUTES   EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM 
> | \
> +EFI_PCI_HOST_BRIDGE_MEM64_DECODE
> +
> +#define PCI_SUPPORT_ATTRIBUTES  EFI_PCI_ATTRIBUTE_ISA_IO_16 | \
> +EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 
> | \
> +EFI_PCI_ATTRIBUTE_VGA_MEMORY | \
> +EFI_PCI_ATTRIBUTE_VGA_IO_16  | \
> +EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16
> +
> +PCI_ROOT_BRIDGE mPciRootBridges[NUM_PCIE_CONTROLLER];
> +
> +/**
> +  Function to set-up iATU outbound window for PCIe controller
> +
> +  @param Dbi Address of PCIe host controller.
> +  @param Idx Index of iATU outbound window.
> +  @param TypeType(Cfg0/Cfg1/Mem/IO) of iATU outbound window.
> +  @param PhysPCIe controller phy address for outbound window.
> +  @param BusAdr  PCIe controller bus address for outbound 

Re: [edk2] [PATCH edk2-platforms 38/41] DWC3 : Add DWC3 USB controller initialization driver.

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:52PM +0530, Meenakshi Aggarwal wrote:
> Add support of DWC3 controller driver which
> Performs DWC3 controller initialization and
> Register itself as NonDiscoverableMmioDevice

So this is just a platform hook to load a memory mapped USB
controller that turns Xhci compliant once properly enabled?

I'm not going to insist on it, but this looks like half of it should
go into Silicon/Synopsys, and the other half be part of the platform
initialisation library.

/
Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c   | 218 
> +++
>  Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h   | 144 ++
>  Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf |  48 ++
>  Silicon/NXP/NxpQoriqLs.dec   |   5 +
>  4 files changed, 415 insertions(+)
>  create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
>  create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.h
>  create mode 100644 Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> 
> diff --git a/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c 
> b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> new file mode 100644
> index 000..0a9c821
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.c
> @@ -0,0 +1,218 @@
> +/** @file
> +
> +  Copyright 2017 NXP
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD 
> License
> +  which accompanies this distribution.  The full text of the license may be 
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "UsbHcd.h"
> +
> +STATIC
> +VOID
> +XhciSetBeatBurstLength (
> +  IN  UINTN  UsbReg
> +  )
> +{
> +  DWC3   *Dwc3Reg;
> +
> +  Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
> +
> +  MmioAndThenOr32 ((UINTN)>GSBusCfg0, ~USB3_ENABLE_BEAT_BURST_MASK,
> +  USB3_ENABLE_BEAT_BURST);
> +  MmioOr32 ((UINTN)>GSBusCfg1, USB3_SET_BEAT_BURST_LIMIT);
> +
> +  return;
> +}
> +
> +STATIC
> +VOID
> +Dwc3SetFladj (
> +  IN  DWC3   *Dwc3Reg,
> +  IN  UINT32 Val
> +  )
> +{
> +  MmioOr32 ((UINTN)>GFLAdj, GFLADJ_30MHZ_REG_SEL |
> +GFLADJ_30MHZ(Val));
> +}
> +
> +VOID
> +Dwc3SetMode (
> +  IN  DWC3   *Dwc3Reg,
> +  IN  UINT32 Mode
> +  )
> +{
> +  MmioAndThenOr32 ((UINTN)>GCtl,
> +   ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)),
> +   DWC3_GCTL_PRTCAPDIR(Mode));
> +}
> +
> +STATIC
> +VOID
> +Dwc3CoreSoftReset (
> +  IN  DWC3   *Dwc3Reg
> +  )
> +{
> +  MmioOr32 ((UINTN)>GCtl, DWC3_GCTL_CORESOFTRESET);
> +  MmioOr32 ((UINTN)>GUsb3PipeCtl[0], DWC3_GUSB3PIPECTL_PHYSOFTRST);
> +  MmioOr32 ((UINTN)>GUsb2PhyCfg, DWC3_GUSB2PHYCFG_PHYSOFTRST);
> +  MmioAnd32 ((UINTN)>GUsb3PipeCtl[0], 
> ~DWC3_GUSB3PIPECTL_PHYSOFTRST);
> +  MmioAnd32 ((UINTN)>GUsb2PhyCfg, ~DWC3_GUSB2PHYCFG_PHYSOFTRST);
> +  MmioAnd32 ((UINTN)>GCtl, ~DWC3_GCTL_CORESOFTRESET);
> +
> +  return;
> +}
> +
> +STATIC
> +EFI_STATUS
> +Dwc3CoreInit (
> +  IN  DWC3   *Dwc3Reg
> +  )
> +{
> +  UINT32 Revision;
> +  UINT32 Reg;
> +  UINTN  Dwc3Hwparams1;
> +
> +  Revision = MmioRead32 ((UINTN)>GSnpsId);
> +  //
> +  // This should read as 0x5533, ascii of U3(DWC_usb3) followed by revision 
> number
> +  //
> +  if ((Revision & DWC3_GSNPSID_MASK) != DWC3_SYNOPSYS_ID) {
> +DEBUG ((DEBUG_ERROR,"This is not a DesignWare USB3 DRD Core.\n"));
> +return EFI_NOT_FOUND;
> +  }
> +
> +  Dwc3CoreSoftReset (Dwc3Reg);
> +
> +  Reg = MmioRead32 ((UINTN)>GCtl);
> +  Reg &= ~DWC3_GCTL_SCALEDOWN_MASK;
> +  Reg &= ~DWC3_GCTL_DISSCRAMBLE;
> +
> +  Dwc3Hwparams1 = MmioRead32 ((UINTN)>GHwParams1);
> +
> +  if (DWC3_GHWPARAMS1_EN_PWROPT(Dwc3Hwparams1) == 
> DWC3_GHWPARAMS1_EN_PWROPT_CLK) {
> +Reg &= ~DWC3_GCTL_DSBLCLKGTNG;
> +  } else {
> +DEBUG ((DEBUG_ERROR,"No power optimization available.\n"));
> +  }
> +
> +  if ((Revision & DWC3_RELEASE_MASK) < DWC3_RELEASE_190a) {
> +Reg |= DWC3_GCTL_U2RSTECN;
> +  }
> +
> +  MmioWrite32 ((UINTN)>GCtl, Reg);
> +
> +  return EFI_SUCCESS;
> +}
> +
> +STATIC
> +EFI_STATUS
> +XhciCoreInit (
> +  IN  UINTN  UsbReg
> +  )
> +{
> +  EFI_STATUS Status;
> +  DWC3   *Dwc3Reg;
> +
> +  Dwc3Reg = (VOID *)(UsbReg + DWC3_REG_OFFSET);
> +
> +  Status = Dwc3CoreInit (Dwc3Reg);
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "Dwc3CoreInit Failed for controller 0x%x (0x%x) \n",
> +  UsbReg, Status));
> +return Status;
> +  }
> +
> +  Dwc3SetMode (Dwc3Reg, DWC3_GCTL_PRTCAP_HOST);
> +
> +  Dwc3SetFladj (Dwc3Reg, GFLADJ_30MHZ_DEFAULT);
> +
> +  return Status;
> +}
> +
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +InitializeUsbController (
> +  IN  

Re: [edk2] [PATCH edk2-platforms 37/41] Compilation: Update the fdf, dsc and dec files.

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:51PM +0530, Meenakshi Aggarwal wrote:
> LS1043A PCIe compilation and update firmware device,
> description and declaration files.Defining Embedded Package
> PCD which should be at least 20 for 64K PCIe IO size required
> for CPU hob during PEI phase to Add IO space post PEI phase.

One change per patch please.
This one needs to be at least two.

/
Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc | 16 
> 
>  Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.fdf |  7 +++
>  .../LS1043aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf |  2 ++
>  .../LS1043aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c|  6 ++
>  Platform/NXP/NxpQoriqLs.dsc.inc  |  2 ++
>  Silicon/NXP/LS1043A/LS1043A.dsc.inc  |  4 
>  Silicon/NXP/NxpQoriqLs.dec   | 10 ++
>  7 files changed, 47 insertions(+)
> 
> diff --git a/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc 
> b/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc
> index b69ffa2..b43c81a 100644
> --- a/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc
> +++ b/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc
> @@ -42,6 +42,8 @@
>BoardLib|Platform/NXP/LS1043aRdbPkg/Library/BoardLib/BoardLib.inf
>FpgaLib|Silicon/NXP/Library/FpgaLib/FpgaLib.inf
>NorFlashLib|Silicon/NXP/Library/NorFlashLib/NorFlashLib.inf
> +  PciSegmentLib|Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
> +  PciHostBridgeLib|Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>  
>  [PcdsFixedAtBuild.common]
>  
> @@ -74,6 +76,13 @@
>gNxpQoriqLsTokenSpaceGuid.PcdFlashDeviceBase64|0x06000
>gNxpQoriqLsTokenSpaceGuid.PcdFlashReservedRegionBase64|0x6030
>  
> +  #
> +  # PCI PCDs.
> +  #
> +  gNxpQoriqLsTokenSpaceGuid.PcdPciDebug|FALSE
> +  gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x1
> +  gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x7FC
> +
>  
> 
>  #
>  # Components Section - list of all EDK II Modules needed by this Platform
> @@ -94,4 +103,11 @@
>Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
>Silicon/NXP/Drivers/NorFlashDxe/NorFlashDxe.inf
>  
> +  Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
> +  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
> +
> +  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8010004F
> +  }
> +  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +
>   ##
> diff --git a/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.fdf 
> b/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.fdf
> index 6b27aed..d02b3cc 100644
> --- a/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.fdf
> +++ b/Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.fdf
> @@ -131,6 +131,13 @@ READ_LOCK_STATUS   = TRUE
>INF Silicon/NXP/Drivers/NorFlashDxe/NorFlashDxe.inf
>  
>#
> +  # PCI
> +  #
> +  INF Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
> +  INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
> +  INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +
> +  #
># Network modules
>#
>INF  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
> diff --git 
> a/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf 
> b/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> index 7feac56..f2c8b66 100644
> --- a/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> +++ b/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> @@ -65,3 +65,5 @@
>gNxpQoriqLsTokenSpaceGuid.PcdDram3Size
>gNxpQoriqLsTokenSpaceGuid.PcdQspiRegionBaseAddr
>gNxpQoriqLsTokenSpaceGuid.PcdQspiRegionSize
> +  gNxpQoriqLsTokenSpaceGuid.PcdRomBaseAddr
> +  gNxpQoriqLsTokenSpaceGuid.PcdRomSize
> diff --git a/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c 
> b/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> index 64c5612..1ef3292 100644
> --- a/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> +++ b/Platform/NXP/LS1043aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> @@ -67,6 +67,12 @@ ArmPlatformGetVirtualMemoryMap (
>VirtualMemoryTable[Index].Length   = FixedPcdGet64 (PcdCcsrSize);
>VirtualMemoryTable[Index].Attributes   = 
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>  
> +  // ROM Space
> +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdRomBaseAddr);
> +  VirtualMemoryTable[Index].VirtualBase  = FixedPcdGet64 (PcdRomBaseAddr);
> +  VirtualMemoryTable[Index].Length   = FixedPcdGet64 (PcdRomSize);
> +  VirtualMemoryTable[Index].Attributes   = 
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
>// IFC region 1
>//
>// A-009241   : Unaligned write transactions to IFC may result in 
> corruption of data
> diff --git a/Platform/NXP/NxpQoriqLs.dsc.inc b/Platform/NXP/NxpQoriqLs.dsc.inc
> index 5529a04..063d0b8 

Re: [edk2] EmbeddedPkg : Corrected flow for setting Buswidth for eMMC

2018-12-21 Thread Leif Lindholm
What is the incorrectness that is being resolved, and how is it being
resolved?

(Add a commit message, please.)

On Tue, Dec 04, 2018 at 03:58:50PM +0530, Meenakshi Aggarwal wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c 
> b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
> index f661a0c..9118eb2 100755
> --- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
> @@ -309,11 +309,14 @@ InitializeEmmcDevice (
>}
>Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_BUS_WIDTH, BusMode);
>if (EFI_ERROR (Status)) {
> -DEBUG ((DEBUG_ERROR, "InitializeEmmcDevice(): Failed to set EXTCSD 
> bus width, Status:%r\n", Status));
> +continue;
> +  } else {
> +DEBUG ((DEBUG_INFO, "InitializeEmmcDevice(): Set EXTCSD bus width %d 
> successfully\n", BusMode));
> +break;
>}
> -  return Status;
>  }
>}
> +
>return Status;
>  }
>  
> -- 
> 1.9.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 40/41] Platform/NXP:PCIe enablement for LS1046A RDB

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:54PM +0530, Meenakshi Aggarwal wrote:
> From: Vabhav 
> 
> Compilation: Update the fdf, dsc and dec files.

The diffstat below tells me that. The commit message is supposed to
tell me what is changed, and why.

/
Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.dsc  | 15 
> +++
>  Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.fdf  |  7 +++
>  .../LS1046aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf  |  2 ++
>  .../NXP/LS1046aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c |  6 ++
>  Silicon/NXP/LS1046A/LS1046A.dsc.inc   |  3 +++
>  5 files changed, 33 insertions(+)
> 
> diff --git a/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.dsc 
> b/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.dsc
> index 7eb08a9..57f2043 100644
> --- a/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.dsc
> +++ b/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.dsc
> @@ -41,6 +41,8 @@
>IfcLib|Silicon/NXP/Library/IfcLib/IfcLib.inf
>BoardLib|Platform/NXP/LS1046aRdbPkg/Library/BoardLib/BoardLib.inf
>FpgaLib|Silicon/NXP/Library/FpgaLib/FpgaLib.inf
> +  PciSegmentLib|Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
> +  PciHostBridgeLib|Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>  
>  [PcdsFixedAtBuild.common]
>  
> @@ -65,6 +67,7 @@
>gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian|TRUE
>gNxpQoriqLsTokenSpaceGuid.PcdWdogBigEndian|TRUE
>gNxpQoriqLsTokenSpaceGuid.PcdIfcBigEndian|TRUE
> +  gNxpQoriqLsTokenSpaceGuid.PcdPciLutBigEndian|TRUE
>  
>#
># RTC Pcds
> @@ -72,6 +75,12 @@
>gPcf2129RtcLibTokenSpaceGuid.PcdI2cSlaveAddress|0x51
>gPcf2129RtcLibTokenSpaceGuid.PcdI2cBusFrequency|10
>  
> +  #
> +  # PCI PCDs.
> +  #
> +  gNxpQoriqLsTokenSpaceGuid.PcdPciDebug|FALSE
> +  gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x8
> +  gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x407FC
>  
> 
>  #
>  # Components Section - list of all EDK II Modules needed by this Platform
> @@ -85,6 +94,12 @@
>  
>Silicon/NXP/Drivers/WatchDog/WatchDogDxe.inf
>Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf
> +  Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
> +  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
> +
> +  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8010004F
> +  }
> +  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
>  
>Platform/NXP/LS1046aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
>   ##
> diff --git a/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.fdf 
> b/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.fdf
> index 443b561..887f386 100644
> --- a/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.fdf
> +++ b/Platform/NXP/LS1046aRdbPkg/LS1046aRdbPkg.fdf
> @@ -124,6 +124,13 @@ READ_LOCK_STATUS   = TRUE
>INF EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
>  
>#
> +  # PCI
> +  #
> +  INF Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
> +  INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
> +  INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +
> +  #
># Network modules
>#
>INF  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
> diff --git 
> a/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf 
> b/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> index 49b57fc..5e09757 100644
> --- a/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> +++ b/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> @@ -42,6 +42,8 @@
>gArmTokenSpaceGuid.PcdArmPrimaryCore
>gNxpQoriqLsTokenSpaceGuid.PcdCcsrBaseAddr
>gNxpQoriqLsTokenSpaceGuid.PcdCcsrSize
> +  gNxpQoriqLsTokenSpaceGuid.PcdRomBaseAddr
> +  gNxpQoriqLsTokenSpaceGuid.PcdRomSize
>gNxpQoriqLsTokenSpaceGuid.PcdIfcRegion1BaseAddr
>gNxpQoriqLsTokenSpaceGuid.PcdIfcRegion1Size
>gNxpQoriqLsTokenSpaceGuid.PcdIfcRegion2BaseAddr
> diff --git a/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c 
> b/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> index 64c5612..1ef3292 100644
> --- a/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> +++ b/Platform/NXP/LS1046aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> @@ -67,6 +67,12 @@ ArmPlatformGetVirtualMemoryMap (
>VirtualMemoryTable[Index].Length   = FixedPcdGet64 (PcdCcsrSize);
>VirtualMemoryTable[Index].Attributes   = 
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>  
> +  // ROM Space
> +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdRomBaseAddr);
> +  VirtualMemoryTable[Index].VirtualBase  = FixedPcdGet64 (PcdRomBaseAddr);
> +  VirtualMemoryTable[Index].Length   = FixedPcdGet64 (PcdRomSize);
> +  VirtualMemoryTable[Index].Attributes   = 
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
>// IFC region 1
>//
>// A-009241   : Unaligned write transactions to IFC may 

Re: [edk2] [PATCH edk2-platforms 01/41] Silicon/NXP: Add Library to return Mmio APIs pointer

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:15PM +0530, Meenakshi Aggarwal wrote:
> This library add supports to return pointer to
> MMIO APIs on basis of Swap flag.
> If Flag is True then MMION APIs returened in which data
> swapped after reading from MMIO and before write using MMIO.

I conspicuously left this one for last.

First thing I would like to see is splitting the setting up of
function pointers bit from the actual I/O accesses (separate patches).

The I/O functions belong in edk2 MdeModulePkg (or possibly
EmbeddedPkg, of for some reason they don't want it in MdePkg). 
But regardless, please send that as a separate patch, preceding the
edk2-platforms set.

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Silicon/NXP/Include/Library/IoAccessLib.h   | 332 +++
>  Silicon/NXP/Library/IoAccessLib/IoAccessLib.c   | 410 
> 
>  Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf |  32 ++
>  3 files changed, 774 insertions(+)
>  create mode 100644 Silicon/NXP/Include/Library/IoAccessLib.h
>  create mode 100644 Silicon/NXP/Library/IoAccessLib/IoAccessLib.c
>  create mode 100644 Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
> 
> diff --git a/Silicon/NXP/Include/Library/IoAccessLib.h 
> b/Silicon/NXP/Include/Library/IoAccessLib.h
> new file mode 100644
> index 000..f7372a5
> --- /dev/null
> +++ b/Silicon/NXP/Include/Library/IoAccessLib.h
> @@ -0,0 +1,332 @@
> +/** @file
> + *
> + *  Copyright 2017 NXP
> + *
> + *  This program and the accompanying materials
> + *  are licensed and made available under the terms and conditions of the 
> BSD License
> + *  which accompanies this distribution.  The full text of the license may 
> be found at
> + *  http://opensource.org/licenses/bsd-license.php
> + *
> + *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> + *
> + **/
> +
> +#ifndef __IO_ACCESS_LIB_H__
> +#define __IO_ACCESS_LIB_H__
> +
> +#include 
> +
> +///
> +///  Structure to have pointer to R/W
> +///  Mmio operations for 16 bits.
> +///
> +typedef struct _MMIO_OPERATIONS_16 {
> +  UINT16 (*Read) (UINTN Address);
> +  UINT16 (*Write) (UINTN Address, UINT16 Value);
> +  UINT16 (*Or) (UINTN Address, UINT16 Or);
> +  UINT16 (*And) (UINTN Address, UINT16 AND);
> +  UINT16 (*AndThenOr) (UINTN Address, UINT16 And, UINT16 Or);
> +} MMIO_OPERATIONS_16;

I have sort of hinted at this in earlier comments on this set:

Why separate structs for different access sizes?
I don't expect there will be a noticeable image size or performance
difference if they are all put into one structure. And if there is. we
can conditionalise the inclusion of different widths with FixedPcds.

So I would like for just a single GetMmioOperations() function that
returns a single struct. And I would like for the member functions to
have the access size as the suffix to their names, just like the
regular IoLib functions.

> +
> +///
> +///  Structure to have pointer to R/W
> +///  Mmio operations for 32 bits.
> +///
> +typedef struct _MMIO_OPERATIONS_32 {
> +  UINT32 (*Read) (UINTN Address);
> +  UINT32 (*Write) (UINTN Address, UINT32 Value);
> +  UINT32 (*Or) (UINTN Address, UINT32 Or);
> +  UINT32 (*And) (UINTN Address, UINT32 AND);
> +  UINT32 (*AndThenOr) (UINTN Address, UINT32 And, UINT32 Or);
> +} MMIO_OPERATIONS_32;
> +
> +///
> +///  Structure to have pointer to R/W
> +///  Mmio operations for 64 bits.
> +///
> +typedef struct _MMIO_OPERATIONS_64 {
> +  UINT64 (*Read) (UINTN Address);
> +  UINT64 (*Write) (UINTN Address, UINT64 Value);
> +  UINT64 (*Or) (UINTN Address, UINT64 Or);
> +  UINT64 (*And) (UINTN Address, UINT64 AND);
> +  UINT64 (*AndThenOr) (UINTN Address, UINT64 And, UINT64 Or);
> +} MMIO_OPERATIONS_64;
> +
> +/**
> +  Function to return pointer to 16 bit Mmio operations.
> +
> +  @param  Swap  Flag to tell if Swap is needed or not
> +on Mmio Operations.
> +
> +  @return   Pointer to Mmio Operations.
> +
> +**/
> +MMIO_OPERATIONS_16 *
> +GetMmioOperations16  (
> +  IN  BOOLEAN  Swap
> +  );
> +
> +/**
> +  Function to return pointer to 32 bit Mmio operations.
> +
> +  @param  Swap  Flag to tell if Swap is needed or not
> +on Mmio Operations.
> +
> +  @return   Pointer to Mmio Operations.
> +
> +**/
> +MMIO_OPERATIONS_32 *
> +GetMmioOperations32  (
> +  IN  BOOLEAN  Swap
> +  );
> +
> +/**
> +  Function to return pointer to 64 bit Mmio operations.
> +
> +  @param  Swap  Flag to tell if Swap is needed or not
> +on Mmio Operations.
> +
> +  @return   Pointer to Mmio Operations.
> +
> +**/
> +MMIO_OPERATIONS_64 *
> +GetMmioOperations64  (
> +  IN  BOOLEAN  Swap
> +  );
> +
> +/**
> +  MmioRead16 for Big-Endian modules.

There is nothing inherently Big-Endian about this.
It is byte-swapping.

This concludes my review of this set, and I will now disappear on
holiday until 

Re: [edk2] [PATCH edk2-platforms 41/41] Platform/NXP:PCIe enablement for LS2088A RDB

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:55PM +0530, Meenakshi Aggarwal wrote:
> From: Vabhav 
> 
> Compilation: Update the fdf, dsc and dec files.

Please add a commit message. This isn't one.

/
Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc| 17 
> +
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf|  7 +++
>  .../Library/PlatformLib/ArmPlatformLib.inf  |  2 ++
>  .../LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c   |  6 ++
>  Silicon/NXP/LS2088A/LS2088A.dsc.inc |  3 +++
>  5 files changed, 35 insertions(+)
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> index e074991..aefc214 100755
> --- a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> @@ -43,6 +43,8 @@
>BoardLib|Platform/NXP/LS2088aRdbPkg/Library/BoardLib/BoardLib.inf
>FpgaLib|Platform/NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.inf
>NorFlashLib|Silicon/NXP/Library/NorFlashLib/NorFlashLib.inf
> +  PciSegmentLib|Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
> +  PciHostBridgeLib|Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>  
>  [PcdsFixedAtBuild.common]
>  
> @@ -92,6 +94,13 @@
>gNxpQoriqLsTokenSpaceGuid.PcdFlashDeviceBase64|0x58000
>gNxpQoriqLsTokenSpaceGuid.PcdFlashReservedRegionBase64|0x58030
>  
> +  #
> +  # PCI PCDs.
> +  #
> +  gNxpQoriqLsTokenSpaceGuid.PcdPciDebug|FALSE
> +  gNxpQoriqLsTokenSpaceGuid.PcdPcieLutBase|0x8
> +  gNxpQoriqLsTokenSpaceGuid.PcdPcieLutDbg|0x407FC
> +
>  
> 
>  #
>  # Components Section - list of all EDK II Modules needed by this Platform
> @@ -111,3 +120,11 @@
>Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
>Silicon/NXP/Drivers/NorFlashDxe/NorFlashDxe.inf
>Silicon/NXP/Drivers/UsbHcdInitDxe/UsbHcd.inf
> +  Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
> +  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
> +
> +  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8010004F
> +  }
> +  MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +
> + ##
> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
> index 62f084d..d32c5a0 100644
> --- a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
> @@ -129,6 +129,13 @@ READ_LOCK_STATUS   = TRUE
>INF Silicon/NXP/Drivers/NorFlashDxe/NorFlashDxe.inf
>  
>#
> +  # PCI
> +  #
> +  INF Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
> +  INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
> +  INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
> +
> +  #
># Network modules
>#
>INF  MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
> diff --git 
> a/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf 
> b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> index f5e5abd..0b836a8 100644
> --- a/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> +++ b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> @@ -44,6 +44,8 @@
>gArmTokenSpaceGuid.PcdArmPrimaryCore
>gNxpQoriqLsTokenSpaceGuid.PcdCcsrBaseAddr
>gNxpQoriqLsTokenSpaceGuid.PcdCcsrSize
> +  gNxpQoriqLsTokenSpaceGuid.PcdRomBaseAddr
> +  gNxpQoriqLsTokenSpaceGuid.PcdRomSize
>gNxpQoriqLsTokenSpaceGuid.PcdIfcRegion1BaseAddr
>gNxpQoriqLsTokenSpaceGuid.PcdIfcRegion1Size
>gNxpQoriqLsTokenSpaceGuid.PcdIfcRegion2BaseAddr
> diff --git a/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c 
> b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> index ccb49f6..8b2145b 100644
> --- a/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> +++ b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> @@ -80,6 +80,12 @@ ArmPlatformGetVirtualMemoryMap (
>VirtualMemoryTable[Index].Length   = FixedPcdGet64 (PcdCcsrSize);
>VirtualMemoryTable[Index].Attributes   = 
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
>  
> +  // ROM Space
> +  VirtualMemoryTable[++Index].PhysicalBase = FixedPcdGet64 (PcdRomBaseAddr);
> +  VirtualMemoryTable[Index].VirtualBase  = FixedPcdGet64 (PcdRomBaseAddr);
> +  VirtualMemoryTable[Index].Length   = FixedPcdGet64 (PcdRomSize);
> +  VirtualMemoryTable[Index].Attributes   = 
> ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
> +
>// IFC region 1
>//
>// A-009241   : Unaligned write transactions to IFC may result in 
> corruption of data
> diff --git a/Silicon/NXP/LS2088A/LS2088A.dsc.inc 
> b/Silicon/NXP/LS2088A/LS2088A.dsc.inc
> index 0d8fd82..831edea 100644
> --- a/Silicon/NXP/LS2088A/LS2088A.dsc.inc
> +++ b/Silicon/NXP/LS2088A/LS2088A.dsc.inc
> @@ -69,5 +69,8 @@
>

Re: [edk2] [PATCH edk2-platforms v1 5/6] Platform/ARM: Add OEM CPU generator for FVP

2018-12-21 Thread Sami Mujawar
Hi Ard,

Please see my response inline.

Regards,

Sami Mujawar

-Original Message-
From: Ard Biesheuvel  
Sent: 21 December 2018 05:08 PM
To: Sami Mujawar 
Cc: edk2-devel@lists.01.org; Arvind Chauhan ; Daniil 
Egranov ; Thomas Abraham ; Leif 
Lindholm ; Kinney, Michael D 
; Alexei Fedorov ; Matteo 
Carlini ; Stephanie Hughes-Fitt 
; nd 
Subject: Re: [PATCH edk2-platforms v1 5/6] Platform/ARM: Add OEM CPU generator 
for FVP

Hi Sami,

On Fri, 21 Dec 2018 at 18:01, Sami Mujawar  wrote:
>
> Add support for dynamic generation of ACPI CPU device information.
> This generator uses the compiled data from a template asl file and 
> patches it at runtime to generate the CPU information based on the 
> number of CPUs and their ACPI UID. This patched data is then installed 
> as a SSDT table.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sami Mujawar 
> ---
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
>|  27 ++
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
>  |  42 ++
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
>   | 403 
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.h
>   |  23 ++
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/SsdtCpuTemplate.asl
> |  25 ++
>  5 files changed, 520 insertions(+)
>
...
> diff --git 
> a/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib
> /OemCpuGenerator.c 
> b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib
> /OemCpuGenerator.c
> new file mode 100644
> index 
> ..d544244bfbd566c128b57d80b0c8
> c2bdc0cca374
> --- /dev/null
> +++ b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGenerato
> +++ rLib/OemCpuGenerator.c
> @@ -0,0 +1,403 @@
> +/** @file
> +  OEM CPU Table Generator
> +
> +  Copyright (c) 2018, ARM Limited. All rights reserved.
> +  This program and the accompanying materials  are licensed and made 
> + available under the terms and conditions of the BSD License  which 
> + accompanies this distribution.  The full text of the license may be 
> + found at  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" 
> +BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include  #include 
> +
> +#include 
> +
> +// Module specific include files.
> +#include 
> +#include  #include 
> + #include  
> +#include 
> +#include 
> +
> +#include 
> +
> +// AML Code Include files generated by iASL Compiler #include 
> +
> +
> +// AML Code offsets file generated by iASL Compiler #include 
> +
> +

Apologies if I should have spotted this before, but this is a no-go.
We are relying on intermediate output of some version of the IASL compiler 
here, which [AFAIK] is not formally specified or documented.
We cannot base an elaborate framework like DynamicTables on this.

I guess this only affects DSDT/SSDT generation, right?
[SAMI] Yes. The last 2 patches in this series add this feature. We probably 
need more discussion on this topic.
Until then can we proceed with review of the remaining patches, or should I 
submit a new patch series that drops the last 2 patches?

> +STATIC EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * mTableFactoryProtocol 
> += NULL;
> +
> +/** OEM CPU Generator
> +
> +Requirements:
> +  The following Configuration Manager Object(s) are required by
> +  this Generator:
> +  - EArmObjGicCInfo
> +*/
> +
> +/** This macro expands to a function that retrieves the GIC
> +CPU interface Information from the Configuration Manager.
> +*/
> +GET_OBJECT_LIST (
> +  EObjNameSpaceArm,
> +  EArmObjGicCInfo,
> +  CM_ARM_GICC_INFO
> +  );
> +
> +STATIC
> +CHAR8
> +AsciiFromHex (
> +  UINTN x
> +  )
> +{
> +  if (x < 10) {
> +return x + '0';
> +  }
> +
> +  if (x < 16) {
> +return x - 10 + 'A';
> +  }
> +
> +  ASSERT (FALSE);
> +  return -1;
> +}
> +
> +/** Free any resources allocated for constructing the tables.
> +
> +  @param [in]  This   Pointer to the ACPI table generator.
> +  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info.
> +  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
> +  Protocol Interface.
> +  @param [in, out] Table  Pointer to the list of ACPI Table(s).
> +  @param [in]  TableCount Number of ACPI table(s).
> +
> +  @retval EFI_SUCCESS   The resources were freed successfully.
> +  @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid.
> +**/
> +STATIC
> +EFI_STATUS
> +FreeOemCpuTableResourcesEx (
> +  IN  CONST ACPI_TABLE_GENERATOR   * CONST This,
> +  IN  

Re: [edk2] [PATCH edk2-platforms 36/41] Silicon/NXP: Implement EFI_CPU_IO2_PROTOCOL

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:50PM +0530, Meenakshi Aggarwal wrote:
> From: Vabhav 
> 
> NXP SOC has mutiple PCIe RCs,Adding respective implementation of
> EFI_CPU_IO2_PROTOCOL to provide Memory Space Read/Write functions
> used by generic Host Bridge Driver including correct value for
> the translation offset during MMIO accesses

Could you let me know (not necessarily in the commit message) which
implementation this is based on, so that I can have a look
specifically at the diff?

Really not a fan of this code, but most of the bits I dislike are
copied from elsewhere. I will try to remember to go back and make the
original(s) more C-like after the holidays.

/
Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v1 1/6] Platform/ARM: Configuration Manager for Juno

2018-12-21 Thread Sami Mujawar
The dynamic tables framework utilizes the configuration manager
protocol to get the platform specific information required for
building the firmware tables.

The configuration manager is a platform specific component that
collates the platform hardware information and builds an abstract
platform configuration repository. The configuration manager also
implements the configuration manager protocol which returns the
hardware information requested by the table generators.

This patch implements the configuration manager support for the
Juno platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  29 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 593 
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 156 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  86 +++
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h   
   |  65 +++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   | 276 +
 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  45 ++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtJunoUsb.asl 
   | 122 
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtPci.asl 
   | 218 +++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtUart.asl
   |  48 ++
 10 files changed, 1638 insertions(+)

diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
new file mode 100644
index 
..a5fe869483f4a005942006c8ba43d3a5aabad5bb
--- /dev/null
+++ b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
@@ -0,0 +1,29 @@
+## @file
+#  dsc include file for Configuration Manager
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+
+[BuildOptions]
+
+[LibraryClasses.common]
+
+[Components.common]
+  # Configuration Manager
+  
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 {
+
+# Platform ASL Tables
+
PlatformAslTablesLib|Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
+  
+   *_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib/OUTPUT
+  }
diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
new file mode 100644
index 
..4dc87352888274273a3334f113c5d34beaf3abb2
--- /dev/null
+++ 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -0,0 +1,593 @@
+/** @file
+  Configuration Manager Dxe
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ConfigurationManager.h"
+#include "Platform.h"
+
+// AML Code Include files generated by iASL Compiler
+#include 
+#include 
+#include 
+#include 
+
+/** The platform configuration repository information.
+*/
+STATIC
+EDKII_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo = {
+  /// Configuration Manager information
+  { CONFIGURATION_MANAGER_REVISION, CFG_MGR_OEM_ID },
+
+  // ACPI Table List
+  {
+// FADT Table
+{
+  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+  CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_FADT),
+  NULL
+},
+// GTDT 

Re: [edk2] [PATCH] ArmPkg/ArmLib ARM: set .fpu to let Clang 7 assemble ArmV7Support.S

2018-12-21 Thread Ard Biesheuvel
On Fri, 21 Dec 2018 at 18:58, Leif Lindholm  wrote:
>
> On Thu, Dec 20, 2018 at 08:16:53PM +0100, Ard Biesheuvel wrote:
> > Clang 7 complains about the vmsr instruction in ArmV7Support.S,
> > which is only available on cores that implement some flavour of
> > VFP. So set the .fpu to NEON like we do in some other places.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >  ArmPkg/Library/ArmLib/Arm/ArmV7Support.S | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S 
> > b/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> > index 281499b46cbc..1808962ee3e2 100644
> > --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> > +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> > @@ -268,6 +268,7 @@ ASM_FUNC(ArmEnableVFP)
> >  #ifndef __clang__
> >mcr p10,#0x7,r0,c8,c0,#0
> >  #else
> > +  .fpuneon
> >vmsrfpexc, r0
> >  #endif
>
> No objection from me. But I would point out that the special clang
> filtering here could possibly be dropped.
>
> I mean, theoretically someone could have an even older binutils, but
> Linaro GCC 4.8-2013.05 will happily assemble the clang side of this
> conditional.
>

Yeah, but that would be a separate patch, no?
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] ArmPkg/ArmLib ARM: set .fpu to let Clang 7 assemble ArmV7Support.S

2018-12-21 Thread Leif Lindholm
On Thu, Dec 20, 2018 at 08:16:53PM +0100, Ard Biesheuvel wrote:
> Clang 7 complains about the vmsr instruction in ArmV7Support.S,
> which is only available on cores that implement some flavour of
> VFP. So set the .fpu to NEON like we do in some other places.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
>  ArmPkg/Library/ArmLib/Arm/ArmV7Support.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S 
> b/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> index 281499b46cbc..1808962ee3e2 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Support.S
> @@ -268,6 +268,7 @@ ASM_FUNC(ArmEnableVFP)
>  #ifndef __clang__
>mcr p10,#0x7,r0,c8,c0,#0
>  #else
> +  .fpuneon
>vmsrfpexc, r0
>  #endif

No objection from me. But I would point out that the special clang
filtering here could possibly be dropped.

I mean, theoretically someone could have an even older binutils, but
Linaro GCC 4.8-2013.05 will happily assemble the clang side of this
conditional.

/
Leif
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v1 3/6] Platform/ARM: Configuration Manager for FVP

2018-12-21 Thread Sami Mujawar
The dynamic tables framework utilizes the configuration manager
protocol to get the platform specific information required for
building the firmware tables.

The configuration manager is a platform specific component that
collates the platform hardware information and builds an abstract
platform configuration repository. The configuration manager also
implements the configuration manager protocol which returns the
hardware information requested by the table generators.

This patch implements the configuration manager support for the
FVP platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  31 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 610 
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 172 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  79 +++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h
  |  91 +++
 Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   |  73 +++
 
Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  35 ++
 7 files changed, 1091 insertions(+)

diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
new file mode 100644
index 
..788b145b273fd49da7fb5d238491aef956977e61
--- /dev/null
+++ b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
@@ -0,0 +1,31 @@
+## @file
+#  dsc include file for Configuration Manager
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+
+[BuildOptions]
+# Required for pre-processing ASL files that include ArmPlatform.h
+  *_*_*_ASLPP_FLAGS= $(PLATFORM_FLAGS)
+
+[LibraryClasses.common]
+
+[Components.common]
+  # Configuration Manager
+  
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 {
+
+# Platform ASL Tables
+
PlatformAslTablesLib|Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
+  
+   *_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib/OUTPUT
+  }
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
new file mode 100644
index 
..4f79f91ef32cad4a1967d969cb39f801c3593089
--- /dev/null
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -0,0 +1,610 @@
+/** @file
+  Configuration Manager Dxe
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ConfigurationManager.h"
+#include "Platform.h"
+
+// AML Code Include files generated by iASL Compiler
+#include 
+
+/** The platform configuration repository information.
+*/
+STATIC
+EDKII_PLATFORM_REPOSITORY_INFO VExpressPlatRepositoryInfo = {
+  /// Configuration Manager information
+  { CONFIGURATION_MANAGER_REVISION, CFG_MGR_OEM_ID },
+
+  // ACPI Table List
+  {
+// FADT Table
+{
+  EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+  CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_FADT),
+  NULL
+},
+// GTDT Table
+{
+  EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
+  CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_GTDT),
+  NULL
+},
+// MADT Table
+{
+  

[edk2] [PATCH edk2-platforms v1 5/6] Platform/ARM: Add OEM CPU generator for FVP

2018-12-21 Thread Sami Mujawar
Add support for dynamic generation of ACPI CPU device information.
This generator uses the compiled data from a template asl file and
patches it at runtime to generate the CPU information based on the
number of CPUs and their ACPI UID. This patched data is then
installed as a SSDT table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
   |  27 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
 |  42 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
  | 403 
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.h
  |  23 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/SsdtCpuTemplate.asl
|  25 ++
 5 files changed, 520 insertions(+)

diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
new file mode 100644
index 
..faa7183b89660435ac50d91df00ea56a28a7a11f
--- /dev/null
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
@@ -0,0 +1,27 @@
+## @file
+#  OEM Cpu Table Generator
+#
+#  Copyright (c) 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = AcpiOemCpuASLLibArm
+  FILE_GUID  = 5392CA66-82AE-40E3-B130-3DD118421E87
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = AcpiOemCpuASLLibArm|DXE_DRIVER
+
+[Sources]
+  SsdtCpuTemplate.asl
+
+[Packages]
+  MdePkg/MdePkg.dec
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
new file mode 100644
index 
..2c73a53cbf813fd0a4072b6473c9bddd56a88aaa
--- /dev/null
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
@@ -0,0 +1,42 @@
+## @file
+#  OEM Cpu Table Generator
+#
+#  Copyright (c) 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = AcpiOemCpuGeneratorLibArm
+  FILE_GUID  = 5062BCB8-80C9-4971-9AD4-2A159554C318
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiOemCpuGeneratorLibConstructor
+  DESTRUCTOR = AcpiOemCpuGeneratorLibDestructor
+
+[Sources]
+  OemCpuGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+  gEdkiiDynamicTableFactoryProtocolGuid
+
+[Guids]
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
new file mode 100644
index 
..d544244bfbd566c128b57d80b0c8c2bdc0cca374
--- /dev/null
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
@@ -0,0 +1,403 @@
+/** @file
+  OEM CPU Table Generator
+
+  Copyright (c) 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 

[edk2] [PATCH edk2-platforms v1 2/6] Platform/ARM: Dynamic Tables support for Juno

2018-12-21 Thread Sami Mujawar
The dynamic tables framework uses the platform hardware
information described by the configuration manager to
generate ACPI tables. This support is configurable and
can be enabled using the DYNAMIC_TABLES_FRAMEWORK build
option.

When DYNAMIC_TABLES_FRAMEWORK is defined, ACPI tables are
generated and installed by the dynamic table framework.
Therefore, installation of ACPI tables from the Firmware
Volume (FV) is disabled by this option.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/JunoPkg/ArmJuno.dsc | 12 +++-
 Platform/ARM/JunoPkg/ArmJuno.fdf | 12 
 Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c |  9 +++--
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc b/Platform/ARM/JunoPkg/ArmJuno.dsc
index 
3edde5b65be47fe14988940ce2ef31a60f38dd31..a355c1e1d983339b3b461eddbf60e4a31888a361
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.dsc
+++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
@@ -33,6 +33,11 @@ [Defines]
 # On RTSM, most peripherals are VExpress Motherboard peripherals
 !include Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
 
+!ifdef DYNAMIC_TABLES_FRAMEWORK
+!include DynamicTablesPkg/DynamicTables.dsc.inc
+!include Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
+!endif
+
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
   ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -79,6 +84,10 @@ [LibraryClasses.common.UEFI_DRIVER, 
LibraryClasses.common.UEFI_APPLICATION, Libr
 [BuildOptions]
   GCC:*_*_ARM_PLATFORM_FLAGS = -march=armv8-a
 
+!ifdef DYNAMIC_TABLES_FRAMEWORK
+  *_*_*_PLATFORM_FLAGS = -DDYNAMIC_TABLES_FRAMEWORK
+!endif
+
 

 #
 # Pcd Section - list of all EDK II PCD Entries defined by this Platform
@@ -266,8 +275,9 @@ [Components.common]
   # ACPI Support
   #
   MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+!ifndef DYNAMIC_TABLES_FRAMEWORK
   Platform/ARM/JunoPkg/AcpiTables/AcpiTables.inf
-
+!endif
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
diff --git a/Platform/ARM/JunoPkg/ArmJuno.fdf b/Platform/ARM/JunoPkg/ArmJuno.fdf
index 
0a8b636d0ebd10a7bceb3cbe6ca1bed8688da1a6..b1295a579b094db1433898589a282702ec854bfb
 100644
--- a/Platform/ARM/JunoPkg/ArmJuno.fdf
+++ b/Platform/ARM/JunoPkg/ArmJuno.fdf
@@ -114,7 +114,17 @@ [FV.FvMain]
   # ACPI Support
   #
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+!ifndef DYNAMIC_TABLES_FRAMEWORK
   INF RuleOverride=ACPITABLE Platform/ARM/JunoPkg/AcpiTables/AcpiTables.inf
+!else
+  # Configuration Manager
+  INF 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
+
+  #
+  # Dynamic Table fdf
+  #
+  !include DynamicTablesPkg/DynamicTables.fdf.inc
+!endif
 
   INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
 
@@ -378,8 +388,10 @@ [Rule.Common.UEFI_APPLICATION.BINARY]
 VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
 
+!ifndef DYNAMIC_TABLES_FRAMEWORK
 [Rule.Common.USER_DEFINED.ACPITABLE]
   FILE FREEFORM = $(NAMED_GUID) {
 RAW ACPI   |.acpi
 RAW ASL|.aml
   }
+!endif
diff --git a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c 
b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
index 
18491c7378523f365644658c270de95e711c5ac1..0a42d21d4e9b60824f1d313a4d5ad9e4bc6db3aa
 100644
--- a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
+++ b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2013-2015, ARM Limited. All rights reserved.
+*  Copyright (c) 2013-2017, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD 
License
@@ -33,9 +33,10 @@
 #include 
 #include 
 
-
+#ifndef DYNAMIC_TABLES_FRAMEWORK
 // This GUID must match the FILE_GUID in 
ArmPlatformPkg/ArmJunoPkg/AcpiTables/AcpiTables.inf
 STATIC CONST EFI_GUID mJunoAcpiTableFile = { 0xa1dd808e, 0x1e95, 0x4399, { 
0xab, 0xc0, 0x65, 0x3c, 0x82, 0xe8, 0x53, 0x0c } };
+#endif
 
 typedef struct {
   ACPI_HID_DEVICE_PATH  AcpiDevicePath;
@@ -487,11 +488,13 @@ ArmJunoEntryPoint (
 
   GetJunoRevision(JunoRevision);
 
+#ifndef DYNAMIC_TABLES_FRAMEWORK
   //
   // Try to install the ACPI Tables
   //
   Status = LocateAndInstallAcpiFromFv ();
   ASSERT_EFI_ERROR (Status);
+#endif
 
   //
   // Setup R1/R2 options if not already done.
@@ -516,6 +519,7 @@ ArmJunoEntryPoint (
 
 );
 
+#ifndef DYNAMIC_TABLES_FRAMEWORK
 // Declare the related ACPI Tables
 EfiCreateProtocolNotifyEvent (
 ,
@@ -524,6 +528,7 @@ ArmJunoEntryPoint (
 NULL,
 
 );
+#endif
   }
 
   //
-- 

[edk2] [PATCH edk2-platforms v1 4/6] Platform/ARM: Dynamic Tables support for FVP

2018-12-21 Thread Sami Mujawar
The dynamic tables framework uses the platform hardware
information described by the configuration manager to
generate ACPI tables. This support is configurable and
can be enabled using the DYNAMIC_TABLES_FRAMEWORK build
option.

When DYNAMIC_TABLES_FRAMEWORK is defined, ACPI tables are
generated and installed by the dynamic table framework.
Therefore, installation of ACPI tables from the Firmware
Volume (FV) is disabled by this option.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc | 15 +++
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf | 16 ++--
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 
0941edeaf53c236cd69fbb54e47df9bd407a56d8..1cf2ebb58f99899864e3bc90b7a22a75ea9fc29b
 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -38,6 +38,10 @@ [Defines]
   DT_SUPPORT = FALSE
 
 !include Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
+!ifdef DYNAMIC_TABLES_FRAMEWORK
+  !include DynamicTablesPkg/DynamicTables.dsc.inc
+  !include 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
+!endif
 
 [LibraryClasses.common]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
@@ -128,6 +132,15 @@ [PcdsFixedAtBuild.common]
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x1c0a
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
+  gArmPlatformTokenSpaceGuid.PL011UartInterrupt|0x25
+
+  ## PL011 Serial Debug UART (DBG2)
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase|0x1c0b
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgUartBaudRate|115200
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgUartClkInHz|2400
+
+  # SBSA Generic Watchdog
+  gArmTokenSpaceGuid.PcdGenericWatchdogEl2IntrNum|59
 
   ## PL031 RealTimeClock
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase|0x1C17
@@ -257,8 +270,10 @@ [Components.common]
 !endif
   }
 
+!ifndef DYNAMIC_TABLES_FRAMEWORK
   MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   Platform/ARM/VExpressPkg/AcpiTables/AcpiTables.inf
+!endif
 
   ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
   ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf
diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf
index 
c3e573e1bb4fcf7889fefec4d6c919b118b76653..fc998ec746913a98ac6f62c1109b809bb530fb16
 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf
@@ -1,5 +1,5 @@
 #
-#  Copyright (c) 2011 - 2015, ARM Limited. All rights reserved.
+#  Copyright (c) 2011 - 2018, ARM Limited. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -97,9 +97,19 @@ [FV.FvMain]
 
   # ACPI Support
   #
-  INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
+!ifndef DYNAMIC_TABLES_FRAMEWORK
+  INF MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatformDxe.inf
   INF RuleOverride=ACPITABLE Platform/ARM/VExpressPkg/AcpiTables/AcpiTables.inf
+!else
+  # Configuration Manager
+  INF 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
+
+  #
+  # Dynamic Table fdf
+  #
+  !include DynamicTablesPkg/DynamicTables.fdf.inc
+!endif
 
   #
   # Multiple Console IO support
@@ -319,8 +329,10 @@ [Rule.Common.UEFI_APPLICATION.BINARY]
 VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
   }
 
+!ifndef DYNAMIC_TABLES_FRAMEWORK
 [Rule.Common.USER_DEFINED.ACPITABLE]
   FILE FREEFORM = $(NAMED_GUID) {
 RAW ACPI   |.acpi
 RAW ASL|.aml
   }
+!endif
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v1 13/22] DynamicTablesPkg: Dynamic Table Factory Dxe

2018-12-21 Thread Sami Mujawar
The dynamic table factory dxe implements the dynamic table
factory protocol. It also implements the ACPI, SMBIOS and
DT table factories. The table generators register themselves
with the respective table factories and the factories are
responsible for instantiating instances of the generators
to build the firmware tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
 | 226 
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DeviceTreeTableFactory/DeviceTreeTableFactory.c
 | 225 +++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h  
 | 125 +++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c   
 |  90 
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf 
 |  60 ++
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
 | 226 
 DynamicTablesPkg/DynamicTables.dsc.inc 
 |   6 +
 DynamicTablesPkg/{DynamicTables.dsc.inc => DynamicTables.fdf.inc}  
 |  10 +-
 DynamicTablesPkg/DynamicTablesPkg.dec  
 |  11 +
 9 files changed, 974 insertions(+), 5 deletions(-)

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
 
b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
new file mode 100644
index 
..f60d9f495150e1a2876eb1fa519ac6b6d16a421b
--- /dev/null
+++ 
b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
@@ -0,0 +1,226 @@
+/** @file
+  ACPI Table Factory
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Std - Standard
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+
+#include "DynamicTableFactory.h"
+
+extern EDKII_DYNAMIC_TABLE_FACTORY_INFO TableFactoryInfo;
+
+/** Return a pointer to the ACPI table generator.
+
+  @param [in]  This Pointer to the Dynamic Table Factory Protocol.
+  @param [in]  GeneratorId  The ACPI table generator ID for the
+requested generator.
+  @param [out] GeneratorPointer to the requested ACPI table
+generator.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The requested generator is not found
+in the list of registered generators.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTableGenerator (
+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * CONST This,
+  IN  CONST ACPI_TABLE_GENERATOR_ID   GeneratorId,
+  OUT CONST ACPI_TABLE_GENERATOR ** CONST Generator
+  )
+{
+  UINT16   TableId;
+  EDKII_DYNAMIC_TABLE_FACTORY_INFO * FactoryInfo;
+
+  ASSERT (This != NULL);
+
+  FactoryInfo = This->TableFactoryInfo;
+
+  if (Generator == NULL) {
+DEBUG ((DEBUG_ERROR, "ERROR: Invalid Generator pointer\n"));
+return EFI_INVALID_PARAMETER;
+  }
+
+  if (!IS_GENERATOR_TYPE_ACPI (GeneratorId)) {
+DEBUG ((DEBUG_ERROR, "ERROR: Generator Type is not ACPI\n"));
+return EFI_INVALID_PARAMETER;
+  }
+
+  *Generator = NULL;
+  TableId = GET_TABLE_ID (GeneratorId);
+  if (IS_GENERATOR_NAMESPACE_STD (GeneratorId)) {
+if (TableId >= (ESTD_ACPI_TABLE_ID_MAX)) {
+  ASSERT (TableId < (ESTD_ACPI_TABLE_ID_MAX));
+  return EFI_INVALID_PARAMETER;
+}
+if (FactoryInfo->StdAcpiTableGeneratorList[TableId] != NULL) {
+  *Generator = FactoryInfo->StdAcpiTableGeneratorList[TableId];
+} else {
+  return EFI_NOT_FOUND;
+}
+  } else {
+if (TableId > FixedPcdGet16 (PcdMaxCustomACPIGenerators)) {
+  ASSERT (TableId <= FixedPcdGet16 (PcdMaxCustomACPIGenerators));
+  return EFI_INVALID_PARAMETER;
+}
+if (FactoryInfo->CustomAcpiTableGeneratorList[TableId] != NULL) {
+  *Generator = FactoryInfo->CustomAcpiTableGeneratorList[TableId];
+} else {
+  return EFI_NOT_FOUND;
+}
+  }
+  return EFI_SUCCESS;
+}
+
+/** Register ACPI table factory generator.
+
+  The ACPI table factory maintains a list of the 

[edk2] [PATCH v1 11/22] DynamicTablesPkg: Table Helper Library

2018-12-21 Thread Sami Mujawar
A helper library that implements common functionality
for use by table generators.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc|  20 +++
 DynamicTablesPkg/Include/Library/TableHelperLib.h |  66 

 DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c  | 164 

 DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf |  36 +
 4 files changed, 286 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
new file mode 100644
index 
..1cac3e649afebb06190fb5bf6387857437706404
--- /dev/null
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -0,0 +1,20 @@
+## @file
+#  Dsc include file for Dynamic Tables Framework.
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+##
+
+[Defines]
+
+[LibraryClasses.common]
+  
TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
+
diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h 
b/DynamicTablesPkg/Include/Library/TableHelperLib.h
new file mode 100644
index 
..f17a0b23ddfc0aea39b08acd2c874dbfe8a0749d
--- /dev/null
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -0,0 +1,66 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef TABLE_HELPER_LIB_H_
+#define TABLE_HELPER_LIB_H_
+
+/** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
+object from the Configuration Manager.
+
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager protocol
+  interface.
+  @param [out] CfgMfrInfo Pointer to the Configuration Manager Info
+  object structure.
+
+  @retval EFI_SUCCESS   The object is returned.
+  @retval EFI_INVALID_PARAMETER The Object ID is invalid.
+  @retval EFI_NOT_FOUND The requested Object is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size.
+**/
+EFI_STATUS
+EFIAPI
+GetCgfMgrInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST  CfgMgrProtocol,
+  OUT   CM_STD_OBJ_CONFIGURATION_MANAGER_INFO**CfgMfrInfo
+  );
+
+/** The AddAcpiHeader function updates the ACPI header structure. It uses the
+ACPI table Generator and the Configuration Manager protocol to obtain the
+information required for constructing the header.
+
+  @param [in] CfgMgrProtocol Pointer to the Configuration Manager
+ protocol interface.
+  @param [in] Generator  Pointer to the ACPI table Generator.
+  @param [in,out] AcpiHeader Pointer to the ACPI table header to be
+ updated.
+  @param [in] Length Length of the ACPI table.
+
+  @retval EFI_SUCCESS   The ACPI table is updated successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+EFI_STATUS
+EFIAPI
+AddAcpiHeader (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  IN  CONST ACPI_TABLE_GENERATOR  * CONST Generator,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER * CONST AcpiHeader,
+  IN  CONST UINT32Length
+  );
+
+#endif // TABLE_HELPER_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c 
b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
new file mode 100644
index 
..5a7a44f20690d93891384024b3ac197e37a470cc
--- /dev/null
+++ 

[edk2] [PATCH v1 12/22] DynamicTablesPkg: Dynamic Table Factory Protocol

2018-12-21 Thread Sami Mujawar
This patch introduces the dynamic table factory protocol
that provides an interface to register and retrieve
registered generators.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTablesPkg.dec   |   3 +
 DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h | 269 

 2 files changed, 272 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
e5e731085a721f5f2a0129b4678dedbb0c7b985a..3137c14247920974082bd74173cab4e7ac02b3f7
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -27,3 +27,6 @@ [Protocols]
   # Configuration Manager Protocol GUID
   gEdkiiConfigurationManagerProtocolGuid = { 0xd85a4835, 0x5a82, 0x4894, { 
0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } }
 
+  # Dynamic Table Factory Protocol GUID
+  gEdkiiDynamicTableFactoryProtocolGuid = { 0x91d1e327, 0xfe5a, 0x49b8, { 
0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec } }
+
diff --git a/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h 
b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
new file mode 100644
index 
..55d62c9e7244c1cca35aaa6c7e3b1dbf9125c3b5
--- /dev/null
+++ b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
@@ -0,0 +1,269 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- ACPI   - Advanced Configuration and Power Interface
+- SMBIOS - System Management BIOS
+- DT - Device Tree
+**/
+
+#ifndef DYNAMIC_TABLE_FACTORY_PROTOCOL_H_
+#define DYNAMIC_TABLE_FACTORY_PROTOCOL_H_
+
+#include 
+#include 
+#include 
+
+/** This macro defines the Dynamic Table Factory Protocol GUID.
+
+  GUID: {91D1E327-FE5A-49B8-AB65-0ECE2DDB45EC}
+*/
+#define EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL_GUID   \
+  { 0x91d1e327, 0xfe5a, 0x49b8, \
+{ 0xab, 0x65, 0xe, 0xce, 0x2d, 0xdb, 0x45, 0xec }   \
+  };
+
+/** This macro defines the Configuration Manager Protocol Revision.
+*/
+#define EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL_REVISION  CREATE_REVISION (1, 0)
+
+#pragma pack(1)
+
+/**
+  Forward declarations:
+*/
+typedef struct DynamicTableFactoryProtocol 
EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL;
+typedef struct DynamicTableFactoryInfo EDKII_DYNAMIC_TABLE_FACTORY_INFO;
+
+/** Return a pointer to the ACPI table generator.
+
+  @param [in]  This   Pointer to the Dynamic Table Factory Protocol.
+  @param [in]  TableIdThe ACPI table generator ID for the
+  requested generator.
+  @param [out] Generator  Pointer to the requested ACPI table
+  generator.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The requested generator is not found
+in the list of registered generators.
+**/
+typedef
+EFI_STATUS
+EFIAPI
+(EFIAPI * EDKII_DYNAMIC_TABLE_FACTORY_GET_ACPI_TABLE_GENERATOR) (
+  IN  CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * CONST This,
+  IN  CONST ACPI_TABLE_GENERATOR_ID   GeneratorId,
+  OUT CONST ACPI_TABLE_GENERATOR ** CONST Generator
+  );
+
+/** Registers an ACPI table generator.
+
+  @param [in]  GeneratorPointer to the ACPI table generator.
+
+  @retval EFI_SUCCESS   The Generator was registered
+successfully.
+  @retval EFI_INVALID_PARAMETER The Generator ID is invalid or
+the Generator pointer is NULL.
+  @retval EFI_ALREADY_STARTED   The Generator for the Table ID is
+already registered.
+**/
+typedef
+EFI_STATUS
+EFIAPI
+(EFIAPI * EDKII_DYNAMIC_TABLE_FACTORY_REGISTER_ACPI_TABLE_GENERATOR) (
+  IN  CONST ACPI_TABLE_GENERATOR* CONST Generator
+  );
+
+/** Deregister an ACPI table generator.
+
+  @param [in]  Generator   Pointer to the ACPI table generator.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER The generator is invalid.
+  @retval EFI_NOT_FOUND The requested generator is not found
+in the list of registered generators.
+**/
+typedef
+EFI_STATUS
+EFIAPI
+(EFIAPI * EDKII_DYNAMIC_TABLE_FACTORY_DEREGISTER_ACPI_TABLE_GENERATOR) (
+  IN  CONST ACPI_TABLE_GENERATOR* CONST Generator
+  );
+
+/** Return a pointer to the 

[edk2] [PATCH v1 10/22] DynamicTablesPkg: Configuration Manager Helper

2018-12-21 Thread Sami Mujawar
This patch defines a helper macro 'GET_OBJECT_LIST()' that
expands to a function that uses the configuration manager
protocol to retrieve configuration manager object(s).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/ConfigurationManagerHelper.h | 119 

 1 file changed, 119 insertions(+)

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h 
b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
new file mode 100644
index 
..0630afc5ad755a613c273bfd02cf53fefcedccc5
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerHelper.h
@@ -0,0 +1,119 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_HELPER_H_
+#define CONFIGURATION_MANAGER_HELPER_H_
+
+/** The GET_OBJECT_LIST macro expands to a function that is used to retrieve
+an object or an object list from the Configuration Manager using the
+Configuration Manager Protocol interface.
+
+  The macro expands to a function which has the following prototype:
+
+  STATIC
+  EFI_STATUS
+  EFIAPI
+  Get (
+IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,
+IN  CONST CM_OBJECT_TOKEN  Token OPTIONAL,
+OUT   Type**   List,
+OUT   UINT32   *   Count OPTIONAL
+);
+
+  Generated function parameters:
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager protocol
+  interface.
+  @param [in]  Token  Reference token for the Object.
+  @param [out] List   Pointer to the Object list.
+  @param [out] Count  Count of the objects returned in the list.
+
+  Macro Parameters:
+  @param [in] CmObjectNameSpace The Object Namespace
+  @param [in] CmObjectIdObject Id.
+  @param [in] Type  Structure used to describe the Object.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
+Manager is less than the Object size for the
+requested object.
+**/
+#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)  \
+STATIC\
+EFI_STATUS\
+EFIAPI\
+Get##CmObjectId ( \
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol, \
+  IN  CONST CM_OBJECT_TOKEN   Token OPTIONAL, \
+  OUT   Type **   List,   \
+  OUT   UINT32* CONST Count OPTIONAL  \
+  )   \
+{ \
+  EFI_STATUS Status;  \
+  CM_OBJ_DESCRIPTOR  CmObjectDesc;\
+  UINT32 ObjCount = 0;\
+  if (List == NULL) { \
+Status = EFI_INVALID_PARAMETER;   \
+DEBUG ((  \
+  DEBUG_ERROR,\
+  "ERROR: Get" #CmObjectId ": Invalid out parameter for"  \
+  " object list. Status = %r\n",  \
+  Status  \
+  )); \
+goto error_handler;   \
+  }   \
+  Status = CfgMgrProtocol->GetObject (\
+ 

[edk2] [PATCH v1 09/22] DynamicTablesPkg: Configuration Manager Protocol

2018-12-21 Thread Sami Mujawar
Introduce configuration manager protocol interface
that is used by the dynamic tables framework core
to communicate with configuration manager.

Configuration manager is a platform specific module
that implements the configuration manager protocol.

Table generators use this interface to retrieve the
hardware information from the configuration manager.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTablesPkg.dec|   5 +
 DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h | 128 

 2 files changed, 133 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index 
b1a6c64948d01426fc95b8599fc17adaa8c35f3d..e5e731085a721f5f2a0129b4678dedbb0c7b985a
 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -22,3 +22,8 @@ [Defines]
 [Includes]
   Include
 
+[Protocols]
+
+  # Configuration Manager Protocol GUID
+  gEdkiiConfigurationManagerProtocolGuid = { 0xd85a4835, 0x5a82, 0x4894, { 
0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } }
+
diff --git a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h 
b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
new file mode 100644
index 
..02c3d22ca7e961058c2c157e7f5a981e1418535e
--- /dev/null
+++ b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
@@ -0,0 +1,128 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_PROTOCOL_H_
+#define CONFIGURATION_MANAGER_PROTOCOL_H_
+
+#include 
+
+/** This macro defines the Configuration Manager Protocol GUID.
+
+  GUID: {D85A4835-5A82-4894-AC02-706F43D5978E}
+*/
+#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_GUID   \
+  { 0xd85a4835, 0x5a82, 0x4894, \
+{ 0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e }   \
+  };
+
+/** This macro defines the Configuration Manager Protocol Revision.
+*/
+#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION  CREATE_REVISION (1, 0)
+
+#pragma pack(1)
+
+/**
+  Forward declarations:
+*/
+typedef struct ConfigurationManagerProtocol 
EDKII_CONFIGURATION_MANAGER_PROTOCOL;
+typedef struct PlatformRepositoryInfo   EDKII_PLATFORM_REPOSITORY_INFO;
+
+/** The GetObject function defines the interface implemented by the
+Configuration Manager Protocol for returning the Configuration
+Manager Objects.
+
+  @param [in]  ThisPointer to the Configuration Manager Protocol.
+  @param [in]  CmObjectId  The Configuration Manager Object ID.
+  @param [in]  Token   An optional token identifying the object. If
+   unused this must be CM_NULL_TOKEN.
+  @param [out] CmObjectPointer to the Configuration Manager Object
+   descriptor describing the requested Object.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is not found.
+  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration Manager
+is less than the Object size for the requested
+object.
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EDKII_CONFIGURATION_MANAGER_GET_OBJECT) (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  IN  CONST CM_OBJECT_ID  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN   Token OPTIONAL,
+  IN  OUT   CM_OBJ_DESCRIPTOR * CONST CmObject
+  );
+
+/** The SetObject function defines the interface implemented by the
+Configuration Manager Protocol for updating the Configuration
+Manager Objects.
+
+  @param [in]  ThisPointer to the Configuration Manager Protocol.
+  @param [in]  CmObjectId  The Configuration Manager Object ID.
+  @param [in]  Token   An optional token identifying the object. If
+   unused this must be CM_NULL_TOKEN.
+  @param [out] CmObjectPointer to the Configuration Manager Object
+   descriptor describing the Object.
+
+  @retval EFI_SUCCESS   The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND The required object information is 

Re: [edk2] [PATCH v3] ArmPkg/ArmScmiDxe: Add clock enable function

2018-12-21 Thread Ard Biesheuvel
On Fri, 21 Dec 2018 at 17:48, Girish Pathak  wrote:
>
> Apart from some minor indentation errors in function parameter declarations 
> in ArmScmiClock2Protocol.h , this looks fine.
>

Thanks

Reviewed-by: Ard Biesheuvel 

I've cleaned it up a bit and pushed it as 9bba10eb4336..559a07d84e5a


>
> -Original Message-
> From: Ard Biesheuvel 
> Sent: 21 December 2018 14:55
> To: Jeff Brasen ; Girish Pathak 
> Cc: edk2-devel@lists.01.org; Leif Lindholm 
> Subject: Re: [PATCH v3] ArmPkg/ArmScmiDxe: Add clock enable function
>
> On Fri, 14 Dec 2018 at 00:48, Jeff Brasen  wrote:
> >
> > Add function to allow enabling and disabling of the clock using the
> > SCMI interface. Add gArmScmiClock2ProtocolGuid to distinguish
> > platforms that support new API from those that just have the older protocol.
> >
> > SCMI_CLOCK2_PROTOCOL also adds a version parameter to allow for future
> > changes. It is placed after the functions that are present in the
> > existing protocol to allow SCMI_CLOCK2_PROTOCOL to be cast to
> > SCMI_CLOCK_PROTOCOL so that only a single implementation of those
> > function are needed.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Jeff Brasen 
> > Cc: Ard Biesheuvel 
> > Cc: Leif Lindholm 
> > Cc: Grish Pathak 
>
> I'd like to hear from Girish as well, since he contributed this code 
> originally.
>
> > ---
> >  ArmPkg/ArmPkg.dec  |   1 +
> >  .../ArmScmiDxe/ArmScmiClockProtocolPrivate.h   |   7 +
> >  ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf   |   1 +
> >  ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c  |  62 +++
> >  ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h| 198 
> > +
> >  5 files changed, 269 insertions(+)
> >  create mode 100644 ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h
> >
> > diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index
> > d99eb67..2f5e5b3 100644
> > --- a/ArmPkg/ArmPkg.dec
> > +++ b/ArmPkg/ArmPkg.dec
> > @@ -59,6 +59,7 @@
> >## Arm System Control and Management Interface(SCMI) Clock management 
> > protocol
> >## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
> >gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9,
> > 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
> > +  gArmScmiClock2ProtocolGuid = { 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8,
> > + 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } }
> >
> >## Arm System Control and Management Interface(SCMI) Clock management 
> > protocol
> >## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > index 0d1ec6f..c135bac 100644
> > --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> > @@ -59,6 +59,13 @@ typedef struct {
> >CLOCK_RATE_DWORD Rate;
> >  } CLOCK_RATE_SET_ATTRIBUTES;
> >
> > +
> > +// Message parameters for CLOCK_CONFIG_SET command.
> > +typedef struct {
> > +  UINT32 ClockId;
> > +  UINT32 Attributes;
> > +} CLOCK_CONFIG_SET_ATTRIBUTES;
> > +
> >  //  if ClockAttr Bit[0] is set then clock device is enabled.
> >  #define CLOCK_ENABLE_MASK 0x1
> >  #define CLOCK_ENABLED(ClockAttr)  ((ClockAttr & CLOCK_ENABLE_MASK) ==
> > 1) diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > index 05ce9c0..9b29b9f 100644
> > --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> > @@ -46,6 +46,7 @@
> >  [Protocols]
> >gArmScmiBaseProtocolGuid
> >gArmScmiClockProtocolGuid
> > +  gArmScmiClock2ProtocolGuid
> >gArmScmiPerformanceProtocolGuid
> >
> >  [Depex]
> > diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> > b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> > index 64d2afa..c7f27a3 100644
> > --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> > +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> > @@ -19,6 +19,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >
> >  #include "ArmScmiClockProtocolPrivate.h"
> >  #include "ScmiPrivate.h"
> > @@ -388,6 +389,53 @@ ClockRateSet (
> >return Status;
> >  }
> >
> > +/** Enable/Disable specified clock.
> > +
> > +  @param[in]  ThisA Pointer to SCMI_CLOCK_PROTOCOL Instance.
> > +  @param[in]  ClockId Identifier for the clock device.
> > +  @param[in]  Enable  TRUE to enable, FALSE to disable.
> > +
> > +  @retval EFI_SUCCESS  Clock enable/disable successful.
> > +  @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> > +  @retval !(EFI_SUCCESS)   Other errors.
> > +**/
> > +STATIC
> > +EFI_STATUS
> > +ClockEnable (
> > +  IN SCMI_CLOCK2_PROTOCOL *This,
> > +  IN UINT32   ClockId,
> > +  IN BOOLEAN  Enable
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  CLOCK_CONFIG_SET_ATTRIBUTES 

Re: [edk2] [PATCH v1] Maintainers.txt: Change DynamicTablesPkg maintainer

2018-12-21 Thread Leif Lindholm
Hi Sami,

No, I was just waiting to see if we'd get an R-b from Andrew and then
it slipped my mind :)

Pushed as: 9bba10eb43

On Fri, Dec 21, 2018 at 09:57:07AM +, Sami Mujawar wrote:
> Hi All,
> 
> This patch has been acked by:
>   Reviewed by: Alexei Fedorov 
>   Reviewed-by: Laszlo Ersek 
>   Reviewed-by: Leif Lindholm 
>   Reviewed-by: Michael D Kinney 
> 
> The Github account details for Alexei are as below:
>   GitHub ID: AlexeiFedorov
>   Email: Alexei Fedorov 
> 
> I can confirm that Evan is no longer evan.ll...@arm.com, so that account 
> can't give an r-b on the change.
> 
> Is there anything else that is needed before this patch is accepted?
> 
> Regards,
> 
> Sami Mujawar
> 
> -Original Message-
> From: Kinney, Michael D  
> Sent: 13 November 2018 10:13 PM
> To: Leif Lindholm ; Sami Mujawar 
> ; Kinney, Michael D 
> Cc: edk2-devel@lists.01.org; ard.biesheu...@linaro.org; Matteo Carlini 
> ; Stephanie Hughes-Fitt 
> ; Alexei Fedorov ; 
> Andrew Fish ; Laszlo Ersek 
> Subject: RE: [PATCH v1] Maintainers.txt: Change DynamicTablesPkg maintainer
> 
> Reviewed-by: Michael D Kinney 
> 
> > -Original Message-
> > From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
> > Sent: Tuesday, November 13, 2018 2:08 PM
> > To: Sami Mujawar 
> > Cc: edk2-devel@lists.01.org; ard.biesheu...@linaro.org; 
> > matteo.carl...@arm.com; stephanie.hughes-f...@arm.com; 
> > alexei.fedo...@arm.com; Andrew Fish ; Laszlo Ersek 
> > ; Kinney, Michael D 
> > Subject: Re: [PATCH v1] Maintainers.txt: Change DynamicTablesPkg 
> > maintainer
> > 
> > +Andrew, Laszlo and Mike.
> > 
> > Hi Sami,
> > 
> > For my part, I can confirm that Evan is no longer evan.ll...@arm.com, 
> > so that account can't give an r-b on the change.
> > 
> > Reviewed-by: Leif Lindholm 
> > 
> > On Mon, Nov 12, 2018 at 04:27:46PM +, Sami Mujawar
> > wrote:
> > > Removing Evan and adding Alexei as the co-maintainer.
> > >
> > > Contributed-under: TianoCore Contribution Agreement
> > 1.1
> > > Signed-off-by: Sami Mujawar 
> > > ---
> > >  Maintainers.txt | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/Maintainers.txt b/Maintainers.txt index
> > cd2a310cbd8c17a8d893c5c747025d1cef1ac433..7b3cb9a0255bf
> > 7c249c8202666332e3c4fd83e6c 100644
> > > --- a/Maintainers.txt
> > > +++ b/Maintainers.txt
> > > @@ -106,8 +106,8 @@ M: Hao Wu 
> > >
> > >  DynamicTablesPkg
> > >  W:
> > https://github.com/tianocore/tianocore.github.io/wiki/D
> > ynamicTablesPkg
> > > -M: Evan Lloyd 
> > >  M: Sami Mujawar 
> > > +M: Alexei Fedorov 
> > >
> > >  EdkCompatibilityPkg
> > >  W:
> > https://github.com/tianocore/tianocore.github.io/wiki/E
> > dkCompatibilityPkg
> > > --
> > > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> > >
> > >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v1 6/6] Platform/ARM: Dynamic CPU Device info for FVP

2018-12-21 Thread Sami Mujawar
Integrate the OEM CPU Generator support for FVP to
dynamically generate the ACPI CPU device information.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc   
  |  3 +-
 Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
  |  3 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 |  7 
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
 |  2 +-
 Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
  | 39 ++--
 5 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
index 
1cf2ebb58f99899864e3bc90b7a22a75ea9fc29b..295fea1f45401fdb80a8327955b73388655434fb
 100644
--- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
+++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
@@ -74,7 +74,8 @@ [LibraryClasses.common.UEFI_DRIVER, 
LibraryClasses.common.UEFI_APPLICATION, Libr
 
 [BuildOptions]
   GCC:*_*_AARCH64_PLATFORM_FLAGS == 
-I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include/Platform/RTSM
-
+  *_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib/OUTPUT
+  *_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib/OUTPUT
 
 

 #
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
index 
788b145b273fd49da7fb5d238491aef956977e61..4264eadde01b66a5c2c4a9267debcbed5ed3800b
 100644
--- a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
+++ b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc
@@ -26,6 +26,9 @@ [Components.common]
 
 # Platform ASL Tables
 
PlatformAslTablesLib|Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
+
NULL|Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
+
NULL|Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
   
*_*_*_PLATFORM_FLAGS = 
-I$(BIN_DIR)/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib/OUTPUT
+   *_*_*_PLATFORM_FLAGS = 
-I$(WORKSPACE)/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib
   }
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
index 
4f79f91ef32cad4a1967d969cb39f801c3593089..7a7a2199477bbd4edaeacb8622b54e4a62466bc2
 100644
--- 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "ConfigurationManager.h"
@@ -78,6 +79,12 @@ EDKII_PLATFORM_REPOSITORY_INFO VExpressPlatRepositoryInfo = {
   EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE,
   CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_DBG2),
   NULL
+},
+// OEM CPU Table
+{
+  0, // Unused
+  CREATE_OEM_ACPI_TABLE_GEN_ID (OEM_ACPI_TABLE_ID_CPU),
+  NULL
 }
   },
 
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
index 
bb457077d2329041aa5e5eaa6feec6f486a0114e..d1ced89ddc6902695b0d345086046d819604076d
 100644
--- 
a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
@@ -105,7 +105,7 @@
 
 /** The number of ACPI tables to install
 */
-#define PLAT_ACPI_TABLE_COUNT   6
+#define PLAT_ACPI_TABLE_COUNT   7
 
 /** The number of platform generic timer blocks
 */
diff --git 
a/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl 
b/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
index 
625930db4d88d9e966eea990ea2b293842f011ea..2d6767b35c87f91fd56febabb3644c91617f53ed
 100644
--- 
a/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
+++ 
b/Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
@@ -1,7 +1,7 @@
 /** @file
   Differentiated System Description Table Fields (DSDT)
 
-  Copyright (c) 2014-2017, ARM Ltd. All 

Re: [edk2] [PATCH edk2-platforms v1 5/6] Platform/ARM: Add OEM CPU generator for FVP

2018-12-21 Thread Ard Biesheuvel
Hi Sami,

On Fri, 21 Dec 2018 at 18:01, Sami Mujawar  wrote:
>
> Add support for dynamic generation of ACPI CPU device information.
> This generator uses the compiled data from a template asl file and
> patches it at runtime to generate the CPU information based on the
> number of CPUs and their ACPI UID. This patched data is then
> installed as a SSDT table.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sami Mujawar 
> ---
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
>|  27 ++
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
>  |  42 ++
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
>   | 403 
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.h
>   |  23 ++
>  
> Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/SsdtCpuTemplate.asl
> |  25 ++
>  5 files changed, 520 insertions(+)
>
...
> diff --git 
> a/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
>  
> b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
> new file mode 100644
> index 
> ..d544244bfbd566c128b57d80b0c8c2bdc0cca374
> --- /dev/null
> +++ 
> b/Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
> @@ -0,0 +1,403 @@
> +/** @file
> +  OEM CPU Table Generator
> +
> +  Copyright (c) 2018, ARM Limited. All rights reserved.
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD 
> License
> +  which accompanies this distribution.  The full text of the license may be 
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +// Module specific include files.
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +// AML Code Include files generated by iASL Compiler
> +#include 
> +
> +// AML Code offsets file generated by iASL Compiler
> +#include 
> +

Apologies if I should have spotted this before, but this is a no-go.
We are relying on intermediate output of some version of the IASL
compiler here, which [AFAIK] is not formally specified or documented.
We cannot base an elaborate framework like DynamicTables on this.

I guess this only affects DSDT/SSDT generation, right?


> +STATIC EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * mTableFactoryProtocol = NULL;
> +
> +/** OEM CPU Generator
> +
> +Requirements:
> +  The following Configuration Manager Object(s) are required by
> +  this Generator:
> +  - EArmObjGicCInfo
> +*/
> +
> +/** This macro expands to a function that retrieves the GIC
> +CPU interface Information from the Configuration Manager.
> +*/
> +GET_OBJECT_LIST (
> +  EObjNameSpaceArm,
> +  EArmObjGicCInfo,
> +  CM_ARM_GICC_INFO
> +  );
> +
> +STATIC
> +CHAR8
> +AsciiFromHex (
> +  UINTN x
> +  )
> +{
> +  if (x < 10) {
> +return x + '0';
> +  }
> +
> +  if (x < 16) {
> +return x - 10 + 'A';
> +  }
> +
> +  ASSERT (FALSE);
> +  return -1;
> +}
> +
> +/** Free any resources allocated for constructing the tables.
> +
> +  @param [in]  This   Pointer to the ACPI table generator.
> +  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info.
> +  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
> +  Protocol Interface.
> +  @param [in, out] Table  Pointer to the list of ACPI Table(s).
> +  @param [in]  TableCount Number of ACPI table(s).
> +
> +  @retval EFI_SUCCESS   The resources were freed successfully.
> +  @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid.
> +**/
> +STATIC
> +EFI_STATUS
> +FreeOemCpuTableResourcesEx (
> +  IN  CONST ACPI_TABLE_GENERATOR   * CONST This,
> +  IN  CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,
> +  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL   * CONST 
> CfgMgrProtocol,
> +  IN OUTEFI_ACPI_DESCRIPTION_HEADER  *** CONST Table,
> +  IN  CONST UINTN  TableCount
> +  )
> +{
> +  EFI_ACPI_DESCRIPTION_HEADER** TableList = NULL;
> +  UINTN Index;
> +
> +  ASSERT (This != NULL);
> +  ASSERT (AcpiTableInfo != NULL);
> +  ASSERT (CfgMgrProtocol != NULL);
> +  ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
> +  ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
> +
> +  if ((Table == NULL) || 

[edk2] [PATCH v1 22/22] DynamicTablesPkg: Arm IORT Table Generator

2018-12-21 Thread Sami Mujawar
The IORT generator uses the configuration manager protocol
to obtain information about the PCI Root Complex, SMMU,
GIC ITS, Performance Monitoring counters etc. and generates
the IORT table.

The mappings between the components are represented using
tokens. The generator invokes the configuration manager
protocol interfaces and requests for objects referenced by
tokens to establish the link.

This table data is then used by the Table Manager to install
the IORT table.

The Table Manager then invokes the generator interface to free
any resources allocated by the IORT table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c| 2055 

 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h|   50 +
 4 files changed, 2148 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
98a37efa5d567942a18163c44961bd4c86552bb6..a6bb9d3c71a548161af48b45812a233afd2bd0ef
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -30,6 +30,7 @@ [Components.common]
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
new file mode 100644
index 
..ce828eb09147d8cc149902c852cc8eaac9b12dc4
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  IORT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiIortLibArm
+  FILE_GUID  = 25682BA8-B41D-4403-B034-253769E0DAD5
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiIortLibConstructor
+  DESTRUCTOR = AcpiIortLibDestructor
+
+[Sources]
+  IortGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
new file mode 100644
index 
..979024493dfd47b45eb621b44616076e4b883231
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c
@@ -0,0 +1,2055 @@
+/** @file
+  IORT Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - IO Remapping Table, Platform Design Document,
+Document number: ARM DEN 0049D, Issue D, March 2018
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "IortGenerator.h"
+
+/** ARM standard IORT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjItsGroup
+  - EArmObjNamedComponent
+  - EArmObjRootComplex
+  - EArmObjSmmuV1SmmuV2
+  - EArmObjSmmuV3
+  - EArmObjPmcg
+  - EArmObjGicItsIdentifierArray
+  - EArmObjIdMapping
+  - EArmObjGicItsIdentifierArray
+*/
+
+/** This macro expands 

[edk2] [PATCH edk2-platforms v1 0/6] Platform/ARM: Platform support for Dynamic Tables Framework

2018-12-21 Thread Sami Mujawar
Dynamic Tables Framework aims to reduce the amount of effort
required for porting firmware to new platforms by simplifying
the generation of firmware tables based on hardware description
provided by a platform specific component.
 
The Dynamic Tables Framework core queries the platform specific
component to retrieve the required hardware information for
generating standardised firmware tables at run-time.
 
The platform specific component responsible for collating the
hardware information is called the Configuration Manager. 
 
This patch series introduce the Configuration Manager that
provides the hardware description to Dynamic Tables Framework.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 

The changes can be seen at:
https://github.com/samimujawar/edk2-platforms/tree/365_dynamic_tables_framework_v1

Sami Mujawar (6):
  Platform/ARM: Configuration Manager for Juno
  Platform/ARM: Dynamic Tables support for Juno
  Platform/ARM: Configuration Manager for FVP
  Platform/ARM: Dynamic Tables support for FVP
  Platform/ARM: Add OEM CPU generator for FVP
  Platform/ARM: Dynamic CPU Device info for FVP

 Platform/ARM/JunoPkg/ArmJuno.dsc   
   |  12 +-
 Platform/ARM/JunoPkg/ArmJuno.fdf   
   |  12 +
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  29 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 593 +++
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 156 +
 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  86 +++
 Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h   
   |  65 +++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   | 276 +
 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  45 ++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtJunoUsb.asl 
   | 122 
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtPci.asl 
   | 218 +++
 Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/SsdtUart.asl
   |  48 ++
 Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c   
   |   9 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc   
   |  18 +-
 Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.fdf   
   |  16 +-
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuASLLib.inf
 |  27 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/AcpiOemCpuGeneratorLib.inf
   |  42 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.c
| 403 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/OemCpuGenerator.h
|  23 +
 
Platform/ARM/VExpressPkg/ConfigurationManager/AcpiOemCpuGeneratorLib/SsdtCpuTemplate.asl
  |  25 +
 Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManager.dsc.inc 
   |  34 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
  | 617 
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
  | 172 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 |  79 +++
 
Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h
  |  91 +++
 Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
   |  40 ++
 
Platform/ARM/VExpressPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
   |  35 ++
 27 files changed, 3287 insertions(+), 6 deletions(-)
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManager.dsc.inc
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.h
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/Platform.h
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/Dsdt.asl
 create mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/PlatformASLTablesLib/PlatformASLTablesLib.inf
 create mode 100644 

[edk2] [PATCH v1 21/22] DynamicTablesPkg: Arm PCI MCFG Table Generator

2018-12-21 Thread Sami Mujawar
The MCFG generator uses the configuration manager protocol
to obtain the PCI Configuration space information from the
platform configuration manager and builds the MCFG table.

This table data is then used by the Table Manager to install
the MCFG table.

The Table Manager then invokes the generator interface to free
any resources allocated by the MCFG table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf |  42 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c| 344 

 3 files changed, 387 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
5ff981619fcd3a579afc50faff41e474a5d604ad..98a37efa5d567942a18163c44961bd4c86552bb6
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -31,6 +31,7 @@ [Components.common]
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
   }
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
new file mode 100644
index 
..e491ad6b24faae24e473f0fd501e06a6f3b456b5
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/AcpiMcfgLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  MCFG Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiMcfgLibArm
+  FILE_GUID  = 8C9BDCB2-72D4-4F30-A12D-1145C3807FF7
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiMcfgLibConstructor
+  DESTRUCTOR = AcpiMcfgLibDestructor
+
+[Sources]
+  McfgGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
new file mode 100644
index 
..1be27160c12b51b36b90cd5f5c9e01efecd8cc03
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c
@@ -0,0 +1,344 @@
+/** @file
+  MCFG Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - PCI Firmware Specification - Revision 3.2, January 26, 2015.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard MCFG Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjPciConfigSpaceInfo
+*/
+
+#pragma pack(1)
+
+/** This typedef is used to shorten the name of the MCFG Table
+header structure.
+*/
+typedef
+  EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER
+  MCFG_TABLE;
+
+/** This typedef is used to shorten the name of the Enhanced
+Configuration Space address structure.
+*/
+typedef
+  
EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE
+  MCFG_CFG_SPACE_ADDR;
+
+#pragma pack()
+
+/** Retrieve the PCI Configuration Space Information.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjPciConfigSpaceInfo,
+  CM_ARM_PCI_CONFIG_SPACE_INFO
+  );
+
+/** Add the PCI Enhanced Configuration Space 

[edk2] [PATCH v1 20/22] DynamicTablesPkg: Arm DBG2 Table Generator

2018-12-21 Thread Sami Mujawar
The DBG2 generator uses the configuration manager protocol
to obtain the debug serial port information from the platform
configuration manager. It then updates a template DBG2 table
structure. This table data is used by the Table Manager to
install the DBG2 table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf |  48 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c| 442 

 3 files changed, 491 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
cfefd57d451155880e6b0e62f1f0605160e6a9aa..5ff981619fcd3a579afc50faff41e474a5d604ad
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -27,6 +27,7 @@ [Components.common]
   #
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
new file mode 100644
index 
..4075862204c9a12cfd26002e359e054c36914ef0
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
@@ -0,0 +1,48 @@
+## @file
+# DBG2 Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiDbg2LibArm
+  FILE_GUID  = A17BA4F0-3DEB-4FE5-BD27-EC008E541B22
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiDbg2LibConstructor
+  DESTRUCTOR = AcpiDbg2LibDestructor
+
+[Sources]
+  Dbg2Generator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  SerialPortLib
+
+[FixedPcd]
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
new file mode 100644
index 
..2c41afd8a50ca6fbea6950fa59af74b528111840
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c
@@ -0,0 +1,442 @@
+/** @file
+  DBG2 Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard DBG2 Table Generator
+
+  Constructs the DBG2 table for PL011 or SBSA UART peripherals.
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjSerialDebugPortInfo
+*/
+
+#pragma pack(1)
+
+/** The number of debug ports represented by the Table.
+*/
+#define DBG2_NUM_DEBUG_PORTS   1
+
+/** The number of Generic Address Registers
+presented in the debug device information.
+*/
+#define DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS   1
+
+/** The index for the debug port 1 in the Debug port information list.
+*/
+#define DBG_PORT_INDEX_PORT1   0
+
+/** A string representing the name of the debug port 1.
+*/
+#define 

[edk2] [PATCH v1 19/22] DynamicTablesPkg: Arm SPCR Table Generator

2018-12-21 Thread Sami Mujawar via edk2-devel
The SPCR generator uses the configuration manager protocol to
obtain the serial port information from the platform configuration
manager. It then updates a template SPCR table structure. This
table data is used by the Table Manager to install the SPCR table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf |  42 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c| 326 

 3 files changed, 369 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
056a1293c93268a6203fc3711079880d11cbc1bc..cfefd57d451155880e6b0e62f1f0605160e6a9aa
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -31,6 +31,7 @@ [Components.common]
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
   }
 
   #
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
new file mode 100644
index 
..8dd94e550b8181dea13d5be81688cc35b8b80eac
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/AcpiSpcrLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  SPCR Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiSpcrLibArm
+  FILE_GUID  = 55088136-7B78-4974-B1EE-F630150D0DE7
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiSpcrLibConstructor
+  DESTRUCTOR = AcpiSpcrLibDestructor
+
+[Sources]
+  SpcrGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
new file mode 100644
index 
..52c7e475baf511c0abf1442113e88248c5d035b3
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c
@@ -0,0 +1,326 @@
+/** @file
+  SPCR Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - Microsoft Serial Port Console Redirection Table
+Specification - Version 1.03 - August 10, 2015.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard SPCR Table Generator
+
+  Constructs the SPCR table for PL011 or SBSA UART peripherals.
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjSerialConsolePortInfo
+
+NOTE: This implementation ignores the possibility that the Serial settings may
+  be modified from the UEFI Shell.  A more complex handler would be needed
+  to (e.g.) recover serial port settings from the UART, or non-volatile
+  storage.
+*/
+
+#pragma pack(1)
+
+/** This macro defines the no flow control option.
+*/
+#define SPCR_FLOW_CONTROL_NONE   0
+
+/**A template for generating the SPCR Table.
+
+  Note: fields marked "{Template}" will be updated dynamically.
+*/
+STATIC
+EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE AcpiSpcr = {
+  ACPI_HEADER (
+EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE,
+EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE,
+EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION
+),
+  0, // {Template}: Serial Port Subtype
+  {
+

[edk2] [PATCH v1 08/22] DynamicTablesPkg: Configuration Manager Objects

2018-12-21 Thread Sami Mujawar
The dynamic tables frameworks core communicates with the
platform specific implementation using the configuration
manager protocol interface. The dynamic tables framework
core uses this interface to retrieve information required
for generating the firmware tables. This information is
represented in the form of objects, which are classified
as standard namespace objects, Arm namespace objects or
as Custom/OEM namespace objects.

The configuration manager objects provides a convenient
way for wrapping up the namespaces using a well defined
configuration manager object Id.

The configuration manager is a platform specific component
that collates the platform information required for generating
firmware tables and represents them as configuration manager
objects.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/ConfigurationManagerObject.h | 176 

 1 file changed, 176 insertions(+)

diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h 
b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
new file mode 100644
index 
..d1682c7066365bee6206f7de2b801be53a971750
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
@@ -0,0 +1,176 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+**/
+
+#ifndef CONFIGURATION_MANAGER_OBJECT_H_
+#define CONFIGURATION_MANAGER_OBJECT_H_
+
+#include 
+#include 
+
+#pragma pack(1)
+
+/** The CM_OBJECT_ID type is used to identify the Configuration Manager
+objects.
+
+ Description of Configuration Manager Object ID
+___
+|31 |30 |29 |28 || 27 | 26 | 25 | 24 || 23 | 22 | 21 | 20 || 19 | 18 | 17 | 16|
+---
+| Name Space ID ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0|
+___
+
+Bits: [31:28] - Name Space ID
+ - Standard
+0001 - ARM
+1000 - Custom/OEM
+All other values are reserved.
+
+Bits: [27:16] - Reserved.
+___
+|15 |14 |13 |12 || 11 | 10 |  9 |  8 ||  7 |  6 |  5 |  4 ||  3 |  2 |  1 |  0|
+---
+| 0 | 0 | 0 | 0 ||  0 |  0 |  0 |  0 || Object ID |
+___
+
+Bits: [15:8] - Are reserved and must be zero.
+
+Bits: [7:0] - Object ID
+
+Object ID's in the Standard Namespace:
+  0 - Configuration Manager Revision
+  1 - ACPI Table List
+  2 - SMBIOS Table List
+
+Object ID's in the ARM Namespace:
+   0 - Reserved
+   1 - Boot Architecture Info
+   2 - CPU Info
+   3 - Power Management Profile Info
+   4 - GICC Info
+   5 - GICD Info
+   6 - GIC MSI Frame Info
+   7 - GIC Redistributor Info
+   8 - GIC ITS Info
+   9 - Serial Console Port Info
+  10 - Serial Debug Port Info
+  11 - Generic Timer Info
+  12 - Platform GT Block Info
+  13 - Platform Generic Watchdog
+  14 - PCI Configuration Space Info
+  15 - Hypervisor Vendor Id
+  16 - Fixed feature flags for FADT
+*/
+typedef UINT32  CM_OBJECT_ID;
+
+/** A mask for Object ID
+*/
+#define OBJECT_ID_MASK0xFF
+
+/** A mask for Namespace ID
+*/
+#define NAMESPACE_ID_MASK 0xF
+
+/** Starting bit position for Namespace ID
+*/
+#define NAMESPACE_ID_BIT_SHIFT28
+
+/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces
+for the Configuration Manager Objects.
+*/
+typedef enum ObjectNameSpaceID {
+  EObjNameSpaceStandard,  ///< Standard Objects Namespace
+  EObjNameSpaceArm,   ///< ARM Objects Namespace
+  EObjNameSpaceOem = 0x8, ///< OEM Objects Namespace
+  EObjNameSpaceMax
+} EOBJECT_NAMESPACE_ID;
+
+/** A descriptor for Configuration Manager Objects.
+
+  The Configuration Manager Protocol interface uses this descriptor
+  to return the Configuration Manager Objects.
+*/
+typedef struct CmObjDescriptor {
+  /// sizeof the described Object or Object List.
+  UINT32   Size;
+
+  /// Pointer to the described Object or Object List.
+  VOID   * Data;
+} CM_OBJ_DESCRIPTOR;
+
+#pragma pack()
+
+/** This macro returns the namespace ID from the 

[edk2] [PATCH v1 16/22] DynamicTablesPkg: Arm ACPI FADT Generator

2018-12-21 Thread Sami Mujawar via edk2-devel
The FADT generator collates the relevant information required
for generating a FADT table from configuration manager using
the configuration manager protocol. It then updates a template
FADT table structure. This table data is used by the Table
Manager to install the FADT table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c| 668 

 3 files changed, 711 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
9b733d39776d183122815aa850747fba8110b643..742bd1e1d87f9c2ce82abd705ef0a501fd294fba
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -27,6 +27,7 @@ [Components.common]
   #
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   }
 
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
new file mode 100644
index 
..e772409069caad8563e37be43ec2841f9d22e62d
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  FADT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiFadtLibArm
+  FILE_GUID  = 686FE5FE-B944-485F-8B1C-7D60E0056487
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiFadtLibConstructor
+  DESTRUCTOR = AcpiFadtLibDestructor
+
+[Sources]
+  FadtGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
new file mode 100644
index 
..07bedfc14fd2f14bbebc72bd4b4be9eb5b8682eb
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c
@@ -0,0 +1,668 @@
+/** @file
+  FADT Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - ACPI 6.2 Specification - Errata A, September 2017
+
+**/
+
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard FADT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjPowerManagementProfileInfo
+  - EArmObjBootArchInfo
+  - EArmObjHypervisorVendorIdentity (OPTIONAL)
+*/
+
+/** This macro defines the FADT flag options for ARM Platforms.
+*/
+#define FADT_FLAGS  (EFI_ACPI_6_2_HW_REDUCED_ACPI |  \
+ EFI_ACPI_6_2_LOW_POWER_S0_IDLE_CAPABLE)
+
+/** This macro defines the valid mask for the FADT flag option
+if HW_REDUCED_ACPI flag in the table is set.
+
+  Invalid bits are: 1, 2, 3,7, 8, 13, 14,16, 17 and
+22-31 (reserved).
+
+  Valid bits are:
+EFI_ACPI_6_2_WBINVD   BIT0
+EFI_ACPI_6_2_PWR_BUTTON   BIT4
+EFI_ACPI_6_2_SLP_BUTTON   BIT5
+EFI_ACPI_6_2_FIX_RTC  BIT6
+EFI_ACPI_6_2_DCK_CAP  BIT9
+EFI_ACPI_6_2_RESET_REG_SUPBIT10
+EFI_ACPI_6_2_SEALED_CASE  BIT11
+EFI_ACPI_6_2_HEADLESS BIT12
+EFI_ACPI_6_2_USE_PLATFORM_CLOCK

[edk2] [PATCH v1 18/22] DynamicTablesPkg: Arm ACPI GTDT Generator

2018-12-21 Thread Sami Mujawar via edk2-devel
The GTDT generator uses the configuration manager protocol to
obtain information about the architectural and platform timers
available on the platform and generates the ACPI GTDT table.
This table data is then used by the Table Manager to install
the GTDT table.

The Table Manager then invokes the generator interface to free
any resources allocated by the GTDT table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c| 674 

 3 files changed, 717 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
43e0f564af51cd6327b210af363488ed2a788cc4..056a1293c93268a6203fc3711079880d11cbc1bc
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -28,6 +28,7 @@ [Components.common]
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   }
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
new file mode 100644
index 
..da3db2b1ff882a9e3a71810eff3d76681ec9d208
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  GTDT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiGtdtLibArm
+  FILE_GUID  = 26490F7A-7FA2-423C-8939-C6206329BC37
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiGtdtLibConstructor
+  DESTRUCTOR = AcpiGtdtLibDestructor
+
+[Sources]
+  GtdtGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[FixedPcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
new file mode 100644
index 
..8414225291a68a888f13799e92e0c39b7f3bffc2
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c
@@ -0,0 +1,674 @@
+/** @file
+  GTDT Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - ACPI 6.2 Specification - Errata A, September 2017
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard GTDT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjGenericTimerInfo
+  - EArmObjPlatformGenericWatchdogInfo (OPTIONAL)
+  - EArmObjPlatformGTBlockInfo (OPTIONAL)
+  - EArmObjGTBlockTimerFrameInfo (OPTIONAL)
+*/
+
+/** This macro expands to a function that retrieves the Generic
+Timer Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGenericTimerInfo,
+  CM_ARM_GENERIC_TIMER_INFO
+  );
+
+/** This macro expands to a function that retrieves the SBSA Generic
+Watchdog Timer Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjPlatformGenericWatchdogInfo,
+  CM_ARM_GENERIC_WATCHDOG_INFO
+  );
+
+/** This macro expands to a function that retrieves the Platform Generic
+Timer Block Information from the Configuration 

[edk2] [PATCH v1 17/22] DynamicTablesPkg: Arm ACPI MADT Generator

2018-12-21 Thread Sami Mujawar via edk2-devel
The MADT generator uses the configuration manager protocol to
obtain information about the Arm interrupt controllers (GICC,
GICD, etc.) and generates the ACPI MADT table. This table data
is then used by the Table Manager to install the MADT table.

The Table Manager then invokes the generator interface to free
any resources allocated by the MADT table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc  |   1 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c| 719 

 3 files changed, 762 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
742bd1e1d87f9c2ce82abd705ef0a501fd294fba..43e0f564af51cd6327b210af363488ed2a788cc4
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -28,6 +28,7 @@ [Components.common]
   DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
 
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
   NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
   }
 
diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
new file mode 100644
index 
..6ba8af4632c25e97b948893c344517ac447ce01a
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/AcpiMadtLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  MADT Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiMadtLibArm
+  FILE_GUID  = AF76C93B-41B5-454D-83CD-D2A80A1C1E38
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiMadtLibConstructor
+  DESTRUCTOR = AcpiMadtLibDestructor
+
+[Sources]
+  MadtGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
new file mode 100644
index 
..76e1712c3bf7f9343ac56d2534ba53b4bdc6d71f
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c
@@ -0,0 +1,719 @@
+/** @file
+  MADT Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Reference(s):
+  - ACPI 6.2 Specification - Errata A, September 2017
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** ARM standard MADT Generator
+
+Requirements:
+  The following Configuration Manager Object(s) are required by
+  this Generator:
+  - EArmObjGicCInfo
+  - EArmObjGicDInfo
+  - EArmObjGicMsiFrameInfo (OPTIONAL)
+  - EArmObjGicRedistributorInfo (OPTIONAL)
+  - EArmObjGicItsInfo (OPTIONAL)
+*/
+
+/** This macro expands to a function that retrieves the GIC
+CPU interface Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicCInfo,
+  CM_ARM_GICC_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+Distributor Information from the Configuration Manager.
+*/
+
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicDInfo,
+  CM_ARM_GICD_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+MSI Frame Information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjGicMsiFrameInfo,
+  CM_ARM_GIC_MSI_FRAME_INFO
+  );
+
+/** This macro expands to a function that retrieves the GIC
+

[edk2] [PATCH v1 14/22] DynamicTablesPkg: Dynamic Table Manager Dxe

2018-12-21 Thread Sami Mujawar via edk2-devel
The dynamic table manager implements the top level component
that drives the table generation and installation process.
It uses the configuration manager protocol to get the list
of tables to be installed from the configuration manager.
It iterates through the list of tables, requests the table
factories for corresponding generators and invokes the
generator interface to build the tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c   | 
735 
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf |  
50 ++
 DynamicTablesPkg/DynamicTables.dsc.inc |   
4 +
 DynamicTablesPkg/DynamicTables.fdf.inc |   
4 +
 4 files changed, 793 insertions(+)

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
new file mode 100644
index 
..090f102fae0d45040ae2a60003dc84bab1271416
--- /dev/null
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -0,0 +1,735 @@
+/** @file
+  Dynamic Table Manager Dxe
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** This macro expands to a function that retrieves the ACPI Table
+List from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceStandard,
+  EStdObjAcpiTableList,
+  CM_STD_OBJ_ACPI_TABLE_INFO
+  )
+
+/** A helper function to build and install a single ACPI table.
+
+  This is a helper function that invokes the Table generator interface
+  for building an ACPI table. It uses the AcpiTableProtocol to install the
+  table, then frees the resources allocated for generating it.
+
+  @param [in]  TableFactoryProtocol Pointer to the Table Factory Protocol
+interface.
+  @param [in]  CfgMgrProtocol   Pointer to the Configuration Manager
+Protocol Interface.
+  @param [in]  GeneratorPointer to the AcpiTable generator.
+  @param [in]  AcpiTableProtocolPointer to the AcpiTable protocol.
+  @param [in]  AcpiTableInfoPointer to the ACPI table Info.
+
+  @retval EFI_SUCCESS   Success.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+  @retval EFI_NOT_FOUND Required object is not found.
+  @retval EFI_BAD_BUFFER_SIZE   Size returned by the Configuration Manager
+is less than the Object size for the
+requested object.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+BuildAndInstallSingleAcpiTable (
+  IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL  * CONST TableFactoryProtocol,
+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  IN CONST ACPI_TABLE_GENERATOR  * CONST Generator,
+  IN   EFI_ACPI_TABLE_PROTOCOL   *   AcpiTableProtocol,
+  IN CONST CM_STD_OBJ_ACPI_TABLE_INFO* CONST AcpiTableInfo
+  )
+{
+  EFI_STATUSStatus;
+  EFI_STATUSStatus1;
+  EFI_ACPI_DESCRIPTION_HEADER * AcpiTable;
+  UINTN TableHandle;
+
+  AcpiTable = NULL;
+  Status = Generator->BuildAcpiTable (
+Generator,
+AcpiTableInfo,
+CfgMgrProtocol,
+
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: Failed to Build Table." \
+  " TableGeneratorId = 0x%x. Status = %r\n",
+  AcpiTableInfo->TableGeneratorId,
+  Status
+  ));
+// Free any allocated resources.
+goto exit_handler;
+  }
+
+  if (AcpiTable == NULL) {
+Status = EFI_NOT_FOUND;
+goto exit_handler;
+  }
+
+  // Dump ACPI Table Header
+  DUMP_ACPI_TABLE_HEADER (AcpiTable);
+
+  // Install ACPI table
+  Status = AcpiTableProtocol->InstallAcpiTable (
+AcpiTableProtocol,
+AcpiTable,
+AcpiTable->Length,
+
+);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "ERROR: Failed to Install 

[edk2] [PATCH v1 15/22] DynamicTablesPkg: Arm Raw/DSDT/SSDT Generator

2018-12-21 Thread Sami Mujawar via edk2-devel
A Raw generator is a simple generator. This generator provides
the ability to install a binary blob (that contains ACPI table
data) as an ACPI table. The binary blob could be pre-generated
ACPI table data or it may be the pre-compiled output from an
iAsl compiler for a DSDT or SSDT table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTables.dsc.inc|   8 +-
 DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf |  42 ++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c| 143 

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

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 
c419c63bc1b2a6a5efa549061837adaf4ed6e8a3..9b733d39776d183122815aa850747fba8110b643
 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -15,6 +15,9 @@
 
 [Defines]
 
+[BuildOptions]
+  *_*_*_ASL_FLAGS  = -tc -li -so
+
 [LibraryClasses.common]
   
TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
 
@@ -22,7 +25,10 @@ [Components.common]
   #
   # Dynamic Table Factory Dxe
   #
-  DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf
+  DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf {
+
+  NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
+  }
 
   #
   # Dynamic Tables Manager Dxe
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
new file mode 100644
index 
..213dbd1cd7b69b3088afb09bdaaf1355c81d8f35
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/AcpiRawLibArm.inf
@@ -0,0 +1,42 @@
+## @file
+#  Raw Table Generator
+#
+#  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = AcpiRawLibArm
+  FILE_GUID  = 20F31568-D687-49BA-B326-CCD9D38EDE16
+  VERSION_STRING = 1.0
+  MODULE_TYPE= DXE_DRIVER
+  LIBRARY_CLASS  = NULL|DXE_DRIVER
+  CONSTRUCTOR= AcpiRawLibConstructor
+  DESTRUCTOR = AcpiRawLibDestructor
+
+[Sources]
+  RawGenerator.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  DynamicTablesPkg/DynamicTablesPkg.dec
+
+[LibraryClasses]
+  BaseLib
+
+[Pcd]
+
+[Protocols]
+
+[Guids]
+
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
new file mode 100644
index 
..5059af5bb054853fb391ff7af3c43162cfb13614
--- /dev/null
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c
@@ -0,0 +1,143 @@
+/** @file
+  MCFG Table Generator
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#include 
+#include 
+#include 
+
+// Module specific include files.
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** Construct the ACPI table using the ACPI table data provided.
+
+  This function invokes the Configuration Manager protocol interface
+  to get the required hardware information for generating the ACPI
+  table.
+
+  If this function allocates any resources then they must be freed
+  in the FreeTableResources function.
+
+  @param [in]  This   Pointer to the table generator.
+  @param [in]  AcpiTableInfo  Pointer to the ACPI Table Info.
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+  @param [out] Table  Pointer to the constructed ACPI Table.
+
+  @retval EFI_SUCCESS   Table generated successfully.
+  @retval EFI_INVALID_PARAMETER A parameter is invalid.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+BuildRawTable (
+  IN  CONST ACPI_TABLE_GENERATOR  * CONST This,
+  IN  CONST CM_STD_OBJ_ACPI_TABLE_INFO* CONST AcpiTableInfo,
+  IN  CONST 

[edk2] [PATCH v1 07/22] DynamicTablesPkg: Arm NameSpace Objects

2018-12-21 Thread Sami Mujawar
The dynamic tables frameworks core communicates with the
platform specific implementation using the configuration
manager protocol interface. The dynamic tables framework
core uses this interface to retrieve information required
for generating the firmware tables. This information is
represented in the form of objects, which are classified
as standard namespace objects, Arm namespace objects or
as Custom/OEM namespace objects.

This patch introduces the definitions for the Arm namespace
objects.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h | 591 
 1 file changed, 591 insertions(+)

diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
new file mode 100644
index 
..93cb6949f0eb2ac2ad3524494e4a14c7a6fab4b8
--- /dev/null
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -0,0 +1,591 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef ARM_NAMESPACE_OBJECTS_H_
+#define ARM_NAMESPACE_OBJECTS_H_
+
+#include 
+
+#pragma pack(1)
+
+/** The EARM_OBJECT_ID enum describes the Object IDs
+in the ARM Namespace
+*/
+typedef enum ArmObjectID {
+  EArmObjReserved,///<  0 - Reserved
+  EArmObjBootArchInfo,///<  1 - Boot Architecture Info
+  EArmObjCpuInfo, ///<  2 - CPU Info
+  EArmObjPowerManagementProfileInfo,  ///<  3 - Power Management Profile Info
+  EArmObjGicCInfo,///<  4 - GIC CPU Interface Info
+  EArmObjGicDInfo,///<  5 - GIC Distributor Info
+  EArmObjGicMsiFrameInfo, ///<  6 - GIC MSI Frame Info
+  EArmObjGicRedistributorInfo,///<  7 - GIC Redistributor Info
+  EArmObjGicItsInfo,  ///<  8 - GIC ITS Info
+  EArmObjSerialConsolePortInfo,   ///<  9 - Serial Console Port Info
+  EArmObjSerialDebugPortInfo, ///< 10 - Serial Debug Port Info
+  EArmObjGenericTimerInfo,///< 11 - Generic Timer Info
+  EArmObjPlatformGTBlockInfo, ///< 12 - Platform GT Block Info
+  EArmObjGTBlockTimerFrameInfo,   ///< 13 - Generic Timer Block Frame Info
+  EArmObjPlatformGenericWatchdogInfo, ///< 14 - Platform Generic Watchdog
+  EArmObjPciConfigSpaceInfo,  ///< 15 - PCI Configuration Space Info
+  EArmObjHypervisorVendorIdentity,///< 16 - Hypervisor Vendor Id
+  EArmObjFixedFeatureFlags,   ///< 17 - Fixed feature flags for FADT
+  EArmObjItsGroup,///< 18 - ITS Group
+  EArmObjNamedComponent,  ///< 19 - Named Component
+  EArmObjRootComplex, ///< 20 - Root Complex
+  EArmObjSmmuV1SmmuV2,///< 21 - SMMUv1 or SMMUv2
+  EArmObjSmmuV3,  ///< 22 - SMMUv3
+  EArmObjPmcg,///< 23 - PMCG
+  EArmObjGicItsIdentifierArray,   ///< 24 - GIC ITS Identifier Array
+  EArmObjIdMapping,   ///< 25 - ID Mapping
+  EArmObjSmmuInterruptArray,  ///< 26 - SMMU Interrupt Array
+  EArmObjMax
+} EARM_OBJECT_ID;
+
+/** A structure that describes the
+ARM Boot Architecture flags.
+*/
+typedef struct CmArmBootArchInfo {
+  /** This is the ARM_BOOT_ARCH flags field of the FADT Table
+  described in the ACPI Table Specification.
+  */
+  UINT32  BootArchFlags;
+} CM_ARM_BOOT_ARCH_INFO;
+
+typedef struct CmArmCpuInfo {
+  // Reserved for use when SMBIOS tables are implemented
+} CM_ARM_CPU_INFO;
+
+typedef struct CmArmCpuInfoList {
+  UINT32 CpuCount;
+  CM_ARM_CPU_INFO  * CpuInfo;
+} CM_ARM_CPU_INFO_LIST;
+
+/** A structure that describes the
+Power Management Profile Information for the Platform.
+*/
+typedef struct CmArmPowerManagementProfileInfo {
+  /** This is the Preferred_PM_Profile field of the FADT Table
+  described in the ACPI Specification
+  */
+  UINT8  PowerManagementProfile;
+} CM_ARM_POWER_MANAGEMENT_PROFILE_INFO;
+
+/** A structure that describes the
+GIC CPU Interface for the Platform.
+*/
+typedef struct CmArmGicCInfo {
+  /// The GIC CPU Interface number.
+  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.
+  */
+  UINT32  AcpiProcessorUid;
+
+  /** The flags field as described by 

[edk2] [PATCH v1 06/22] DynamicTablesPkg: Standard NameSpace Objects

2018-12-21 Thread Sami Mujawar
The dynamic tables frameworks core communicates with the
platform specific implementation using the configuration
manager protocol interface. The dynamic tables framework
core uses this interface to retrieve information required
for generating the firmware tables. This information is
represented in the form of objects, which are classified
as standard namespace objects, Arm namespace objects or
as Custom/OEM namespace objects.

This patch introduces the definitions for standard
namespace objects.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/StandardNameSpaceObjects.h | 116 
 1 file changed, 116 insertions(+)

diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h 
b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
new file mode 100644
index 
..4f682a52dad4059b0d768d7765c4dbd875cc5d53
--- /dev/null
+++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h
@@ -0,0 +1,116 @@
+/** @file
+
+  Copyright (c) 2017, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef STANDARD_NAMESPACE_OBJECTS_H_
+#define STANDARD_NAMESPACE_OBJECTS_H_
+
+#include 
+#include 
+
+#pragma pack(1)
+
+/** A macro defining a reserved zero/NULL token value that
+does not identify any object.
+*/
+#define CM_NULL_TOKEN  0
+
+/** A reference token that the Configuration Manager can use
+to identify a Configuration Manager object.
+
+  This can be used to differentiate between instances of
+  objects of the same types. The identification scheme is
+  implementation defined and is defined by the Configuration
+  Manager.
+
+  Typically the token is used to identify a specific instance
+  from a set of objects in a call to the GetObject()/SetObject(),
+  implemented by the Configuration Manager protocol.
+
+  Note: The token value 0 is reserved for a NULL token and does
+not identify any object.
+**/
+typedef UINTN   CM_OBJECT_TOKEN;
+
+/** The ESTD_OBJECT_ID enum describes the Object IDs
+in the Standard Namespace.
+*/
+typedef enum StdObjectID {
+  EStdObjCfgMgrInfo = 0x, ///< 0 - Configuration Manager Info
+  EStdObjAcpiTableList,   ///< 1 - ACPI table Info List
+  EStdObjSmbiosTableList, ///< 2 - SMBIOS table Info List
+  EStdObjMax
+} ESTD_OBJECT_ID;
+
+/** A structure that describes the Configuration Manager Information.
+*/
+typedef struct CmStdObjConfigurationManagerInfo {
+  /// The Configuration Manager Revision.
+  UINT32  Revision;
+
+  /** The OEM ID. This information is used to
+  populate the ACPI table header information.
+  */
+  UINT8   OemId[6];
+} CM_STD_OBJ_CONFIGURATION_MANAGER_INFO;
+
+/** A structure used to describe the ACPI table generators to be invoked.
+
+  The AcpiTableData member of this structure may be used to directly provide
+  the binary ACPI table data which is required by the following standard
+  generators:
+- RAW
+- DSDT
+- SSDT
+
+  Providing the ACPI table data is optional and depends on the generator
+  that is being invoked. If unused, set AcpiTableData to NULL.
+*/
+typedef struct CmAStdObjAcpiTableInfo {
+  /// The signature of the ACPI Table to be installed.
+  UINT32 AcpiTableSignature;
+
+  /// The ACPI Table Generator ID.
+  ACPI_TABLE_GENERATOR_IDTableGeneratorId;
+
+  /// Optional pointer to the ACPI table data.
+  EFI_ACPI_DESCRIPTION_HEADER  * AcpiTableData;
+
+} CM_STD_OBJ_ACPI_TABLE_INFO;
+
+/** A structure used to describe the SMBIOS table generators to be invoked.
+
+  The SmbiosTableData member of this structure is used to provide
+  the SMBIOS table data which is required by the following standard
+  generator(s):
+- RAW
+
+  Providing the SMBIOS table data is optional and depends on the
+  generator that is being invoked. If unused, set the SmbiosTableData
+  to NULL.
+*/
+typedef struct CmStdObjSmbiosTableInfo {
+  /// The SMBIOS Table Generator ID.
+  SMBIOS_TABLE_GENERATOR_ID   TableGeneratorId;
+
+  /// Optional pointer to the SMBIOS table data.
+  SMBIOS_STRUCTURE   * SmbiosTableData;
+} CM_STD_OBJ_SMBIOS_TABLE_INFO;
+
+#pragma pack()
+
+#endif // STANDARD_NAMESPACE_OBJECTS_H_
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v1 05/22] DynamicTablesPkg: DT Table Generator

2018-12-21 Thread Sami Mujawar
This patch introduces the interfaces and definitions for
implementing a Device Tree table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/DeviceTreeTableGenerator.h | 182 
 1 file changed, 182 insertions(+)

diff --git a/DynamicTablesPkg/Include/DeviceTreeTableGenerator.h 
b/DynamicTablesPkg/Include/DeviceTreeTableGenerator.h
new file mode 100644
index 
..458b0578e7e872ac61aef792f220db4b3fea0384
--- /dev/null
+++ b/DynamicTablesPkg/Include/DeviceTreeTableGenerator.h
@@ -0,0 +1,182 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef DEVICETREE_TABLE_GENERATOR_H_
+#define DEVICETREE_TABLE_GENERATOR_H_
+
+#include 
+
+#pragma pack(1)
+
+/** The DT_TABLE_GENERATOR_ID type describes Device Tree table generator ID.
+*/
+typedef TABLE_GENERATOR_ID DT_TABLE_GENERATOR_ID;
+
+/** The ESTD_DT_TABLE_ID enum describes the DT table IDs reserved for
+  the standard generators.
+*/
+typedef enum StdDtTableId {
+  ESTD_DT_TABLE_ID_RESERVED = 0x, ///< Reserved.
+  ESTD_DT_TABLE_ID_RAW,   ///< RAW Generator.
+  ESTD_DT_TABLE_ID_MAX
+} ESTD_DT_TABLE_ID;
+
+/** This macro checks if the Table Generator ID is for an DT Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the table generator ID is for an DT Table
+Generator.
+**/
+#define IS_GENERATOR_TYPE_DT(TableGeneratorId) \
+  (GET_TABLE_TYPE(TableGeneratorId) == ETableGeneratorTypeDt)
+
+/** This macro checks if the Table Generator ID is for a standard DT
+Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the table generator ID is for a standard DT
+Table Generator.
+**/
+#define IS_VALID_STD_DT_GENERATOR_ID(TableGeneratorId)   \
+  (  \
+  IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) &&\
+  IS_GENERATOR_TYPE_DT(TableGeneratorId)   &&\
+  ((GET_TABLE_ID(GeneratorId) >= ESTD_DT_TABLE_ID_RAW) &&\
+   (GET_TABLE_ID(GeneratorId) < ESTD_DT_TABLE_ID_MAX))   \
+  )
+
+/** This macro creates a standard DT Table Generator ID.
+
+  @param [in] TableId  The table generator ID.
+
+  @return a standard DT table generator ID.
+**/
+#define CREATE_STD_DT_TABLE_GEN_ID(TableId) \
+  CREATE_TABLE_GEN_ID ( \
+ETableGeneratorTypeDt,  \
+ETableGeneratorNameSpaceStd,\
+TableId \
+)
+
+/** Forward declarations.
+*/
+typedef struct ConfigurationManagerProtocol 
EDKII_CONFIGURATION_MANAGER_PROTOCOL;
+typedef struct CmAStdObjDtTableInfo CM_STD_OBJ_DT_TABLE_INFO;
+typedef struct DtTableGenerator DT_TABLE_GENERATOR;
+
+/** This function pointer describes the interface to DT table build
+functions provided by the DT table generator and called by the
+Table Manager to build an DT table.
+
+  @param [in]  Generator   Pointer to the DT table generator.
+  @param [in]  DtTableInfo Pointer to the DT table information.
+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager
+   Protocol interface.
+  @param [out] Table   Pointer to the generated DT table.
+
+  @return EFI_SUCCESS  If the table is generated successfully or other
+failure codes as returned by the generator.
+**/
+typedef EFI_STATUS (*DT_TABLE_GENERATOR_BUILD_TABLE) (
+  IN  CONST DT_TABLE_GENERATOR*   Generator,
+  IN  CONST CM_STD_OBJ_DT_TABLE_INFO  * CONST DtTableInfo,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST CfgMgrProtocol,
+  OUT   VOID **   Table
+  );
+
+/** This function pointer describes the interface to used by the
+Table Manager to give the generator an opportunity to free
+any resources allocated for building the DT table.
+
+  @param [in]  Generator   Pointer to the DT table generator.
+  @param [in]  DtTableInfo Pointer to the DT table information.
+  @param [in]  CfgMgrProtocol  Pointer to the Configuration Manager
+   Protocol interface.
+  @param [in]  

[edk2] [PATCH v1 04/22] DynamicTablesPkg: SMBIOS Table Generator

2018-12-21 Thread Sami Mujawar
This patch introduces the required interfaces and definitions
for implementing a SMBIOS table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/SmbiosTableGenerator.h | 240 
 1 file changed, 240 insertions(+)

diff --git a/DynamicTablesPkg/Include/SmbiosTableGenerator.h 
b/DynamicTablesPkg/Include/SmbiosTableGenerator.h
new file mode 100644
index 
..4e9193e381d051f60689e27daf84c382835d2c9f
--- /dev/null
+++ b/DynamicTablesPkg/Include/SmbiosTableGenerator.h
@@ -0,0 +1,240 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef SMBIOS_TABLE_GENERATOR_H_
+#define SMBIOS_TABLE_GENERATOR_H_
+
+#include 
+
+#include 
+
+#pragma pack(1)
+
+/** The SMBIOS_TABLE_GENERATOR_ID type describes SMBIOS table generator ID.
+*/
+typedef TABLE_GENERATOR_ID SMBIOS_TABLE_GENERATOR_ID;
+
+/** The ESTD_SMBIOS_TABLE_ID enum describes the SMBIOS table IDs reserved for
+  the standard generators.
+
+  NOTE: The SMBIOS Generator IDs do not match the table type numbers!
+  This allows 0 to be used to catch invalid parameters.
+*/
+typedef enum StdSmbiosTableGeneratorId {
+  ESTD_SMBIOS_TABLE_ID_RESERVED = 0x,
+  ESTD_SMBIOS_TABLE_ID_RAW,
+  ESTD_SMBIOS_TABLE_ID_TYPE00,
+  ESTD_SMBIOS_TABLE_ID_TYPE01,
+  ESTD_SMBIOS_TABLE_ID_TYPE02,
+  ESTD_SMBIOS_TABLE_ID_TYPE03,
+  ESTD_SMBIOS_TABLE_ID_TYPE04,
+  ESTD_SMBIOS_TABLE_ID_TYPE05,
+  ESTD_SMBIOS_TABLE_ID_TYPE06,
+  ESTD_SMBIOS_TABLE_ID_TYPE07,
+  ESTD_SMBIOS_TABLE_ID_TYPE08,
+  ESTD_SMBIOS_TABLE_ID_TYPE09,
+  ESTD_SMBIOS_TABLE_ID_TYPE10,
+  ESTD_SMBIOS_TABLE_ID_TYPE11,
+  ESTD_SMBIOS_TABLE_ID_TYPE12,
+  ESTD_SMBIOS_TABLE_ID_TYPE13,
+  ESTD_SMBIOS_TABLE_ID_TYPE14,
+  ESTD_SMBIOS_TABLE_ID_TYPE15,
+  ESTD_SMBIOS_TABLE_ID_TYPE16,
+  ESTD_SMBIOS_TABLE_ID_TYPE17,
+  ESTD_SMBIOS_TABLE_ID_TYPE18,
+  ESTD_SMBIOS_TABLE_ID_TYPE19,
+  ESTD_SMBIOS_TABLE_ID_TYPE20,
+  ESTD_SMBIOS_TABLE_ID_TYPE21,
+  ESTD_SMBIOS_TABLE_ID_TYPE22,
+  ESTD_SMBIOS_TABLE_ID_TYPE23,
+  ESTD_SMBIOS_TABLE_ID_TYPE24,
+  ESTD_SMBIOS_TABLE_ID_TYPE25,
+  ESTD_SMBIOS_TABLE_ID_TYPE26,
+  ESTD_SMBIOS_TABLE_ID_TYPE27,
+  ESTD_SMBIOS_TABLE_ID_TYPE28,
+  ESTD_SMBIOS_TABLE_ID_TYPE29,
+  ESTD_SMBIOS_TABLE_ID_TYPE30,
+  ESTD_SMBIOS_TABLE_ID_TYPE31,
+  ESTD_SMBIOS_TABLE_ID_TYPE32,
+  ESTD_SMBIOS_TABLE_ID_TYPE33,
+  ESTD_SMBIOS_TABLE_ID_TYPE34,
+  ESTD_SMBIOS_TABLE_ID_TYPE35,
+  ESTD_SMBIOS_TABLE_ID_TYPE36,
+  ESTD_SMBIOS_TABLE_ID_TYPE37,
+  ESTD_SMBIOS_TABLE_ID_TYPE38,
+  ESTD_SMBIOS_TABLE_ID_TYPE39,
+  ESTD_SMBIOS_TABLE_ID_TYPE40,
+  ESTD_SMBIOS_TABLE_ID_TYPE41,
+  ESTD_SMBIOS_TABLE_ID_TYPE42,
+
+  // IDs 43 - 125 are reserved
+
+  ESTD_SMBIOS_TABLE_ID_TYPE126 = (ESTD_SMBIOS_TABLE_ID_TYPE00 + 126),
+  ESTD_SMBIOS_TABLE_ID_TYPE127,
+  ESTD_SMBIOS_TABLE_ID_MAX
+} ESTD_SMBIOS_TABLE_ID;
+
+/** This macro checks if the Table Generator ID is for an SMBIOS Table
+Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return  TRUE if the table generator ID is for an SMBIOS Table
+Generator.
+**/
+#define IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId) \
+  (\
+  GET_TABLE_TYPE (TableGeneratorId) == \
+  ETableGeneratorTypeSmbios\
+  )
+
+/** This macro checks if the Table Generator ID is for a standard SMBIOS
+Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return  TRUE if the table generator ID is for a standard SMBIOS
+Table Generator.
+**/
+#define IS_VALID_STD_SMBIOS_GENERATOR_ID(TableGeneratorId)\
+  (   \
+  IS_GENERATOR_NAMESPACE_STD(TableGeneratorId) && \
+  IS_GENERATOR_TYPE_SMBIOS(TableGeneratorId)   && \
+  ((GET_TABLE_ID(GeneratorId) >= ESTD_SMBIOS_TABLE_ID_RAW) && \
+   (GET_TABLE_ID(GeneratorId) < ESTD_SMIOS_TABLE_ID_MAX)) \
+  )
+
+/** This macro creates a standard SMBIOS Table Generator ID.
+
+  @param [in] TableId  The table generator ID.
+
+  @return a standard SMBIOS table generator ID.
+**/
+#define CREATE_STD_SMBIOS_TABLE_GEN_ID(TableId) \
+  CREATE_TABLE_GEN_ID ( \
+ETableGeneratorTypeSmbios,  \
+ETableGeneratorNameSpaceStd,\
+TableId \
+)
+
+/** Forward declarations.
+*/
+typedef struct 

[edk2] [PATCH v1 03/22] DynamicTablesPkg: Acpi Table Generator

2018-12-21 Thread Sami Mujawar
This patch introduces the required interfaces and definitions
for implementing an ACPI table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Include/AcpiTableGenerator.h | 357 
 1 file changed, 357 insertions(+)

diff --git a/DynamicTablesPkg/Include/AcpiTableGenerator.h 
b/DynamicTablesPkg/Include/AcpiTableGenerator.h
new file mode 100644
index 
..ad4d0732197f25bf43f3fb3cdf0cc9321e9d2030
--- /dev/null
+++ b/DynamicTablesPkg/Include/AcpiTableGenerator.h
@@ -0,0 +1,357 @@
+/** @file
+
+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- Cm or CM   - Configuration Manager
+- Obj or OBJ - Object
+- Std or STD - Standard
+**/
+
+#ifndef ACPI_TABLE_GENERATOR_H_
+#define ACPI_TABLE_GENERATOR_H_
+
+#include 
+
+// Module specific include files.
+#include 
+
+#pragma pack(1)
+
+/**
+The Dynamic Tables Framework provisions two classes of ACPI table
+generators.
+ - Standard generators: The ACPI table generators implemented by the
+Dynamic Tables Framework.
+ - OEM generators:  The ACPI table generators customized by the OEM.
+
+The Dynamic Tables Framework implements the following ACPI table generators:
+  - RAW   : This is the simplest ACPI table generator. It simply installs
+the ACPI table provided in the AcpiTableData member of the
+CM_STD_OBJ_ACPI_TABLE_INFO. The ACPI table data is provided by
+the Configuration Manager and is generated using an implementation
+defined mechanism.
+  - DSDT  : The DSDT generator is a clone of the RAW generator. The difference
+is in the way the ACPI Table Data is generated from an AML file.
+  - SSDT  : The SSDT generator is a clone of the RAW generator. The difference
+is in the way the ACPI Table Data is generated from an AML file.
+  - FADT  : The FADT generator collates the required platform information from
+the Configuration Manager and builds the FADT table.
+  - MADT  : The MADT generator collates the GIC information  from the
+Configuration Manager and builds the MADT table.
+  - GTDT  : The GTDT generator collates the Timer information from the
+Configuration Manager and builds the GTDT table.
+  - DBG2  : The DBG2 generator collates the debug serial port information from
+the Configuration Manager and builds the DBG2 table.
+  - SPCR  : The SPCR generator collates the serial port information from the
+Configuration Manager and builds the SPCR table.
+  - MCFG  : The MCFG generator collates the PCI configuration space information
+from the Configuration Manager and builds the MCFG table.
+  - IORT  : The IORT generator collates the IO Topology information from the
+Configuration Manager and builds the IORT table.
+*/
+
+/** The ACPI_TABLE_GENERATOR_ID type describes ACPI table generator ID.
+*/
+typedef TABLE_GENERATOR_ID ACPI_TABLE_GENERATOR_ID;
+
+/** The ESTD_ACPI_TABLE_ID enum describes the ACPI table IDs reserved for
+  the standard generators.
+*/
+typedef enum StdAcpiTableId {
+  ESTD_ACPI_TABLE_ID_RESERVED = 0x, ///< Reserved
+  ESTD_ACPI_TABLE_ID_RAW,   ///< RAW Generator
+  ESTD_ACPI_TABLE_ID_DSDT = ESTD_ACPI_TABLE_ID_RAW, ///< DSDT Generator
+  ESTD_ACPI_TABLE_ID_SSDT = ESTD_ACPI_TABLE_ID_RAW, ///< SSDT Generator
+  ESTD_ACPI_TABLE_ID_FADT,  ///< FADT Generator
+  ESTD_ACPI_TABLE_ID_MADT,  ///< MADT Generator
+  ESTD_ACPI_TABLE_ID_GTDT,  ///< GTDT Generator
+  ESTD_ACPI_TABLE_ID_DBG2,  ///< DBG2 Generator
+  ESTD_ACPI_TABLE_ID_SPCR,  ///< SPCR Generator
+  ESTD_ACPI_TABLE_ID_MCFG,  ///< MCFG Generator
+  ESTD_ACPI_TABLE_ID_IORT,  ///< IORT Generator
+  ESTD_ACPI_TABLE_ID_MAX
+} ESTD_ACPI_TABLE_ID;
+
+/** This macro checks if the Table Generator ID is for an ACPI Table Generator.
+
+  @param [in] TableGeneratorId  The table generator ID.
+
+  @return TRUE if the table generator ID is for an ACPI Table
+Generator.
+**/
+#define IS_GENERATOR_TYPE_ACPI(TableGeneratorId) \
+  (GET_TABLE_TYPE (TableGeneratorId) == ETableGeneratorTypeAcpi)
+
+/** This macro checks if the Table Generator ID is for a standard ACPI
+Table Generator.
+
+  @param [in] TableGeneratorId  

[edk2] [PATCH v1 02/22] DynamicTablesPkg: Table Generator definition

2018-12-21 Thread Sami Mujawar
A Table generator is a component that implements the logic
for building a firmware table. This is typically implemented
as a library and registers itself with a table factory.

Table generators are further classified based on type of table
it generates, a namespace that signifies if the implementation
is standard or an OEM specific implementation and a table Id.

This patch introduces the definitions used for describing a
table generator.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/DynamicTablesPkg.dec |  24 ++
 DynamicTablesPkg/Include/TableGenerator.h | 252 
 2 files changed, 276 insertions(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
new file mode 100644
index 
..b1a6c64948d01426fc95b8599fc17adaa8c35f3d
--- /dev/null
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -0,0 +1,24 @@
+## @file
+# dec file for Dynamic Tables Framework.
+#
+# Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+#
+# This program and the accompanying materials are licensed and made available 
under
+# the terms and conditions of the BSD License that accompanies this 
distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+  DEC_SPECIFICATION  = 0x00010005
+  PACKAGE_NAME   = DynamicTablesPkg
+  PACKAGE_GUID   = 188EB346-8ABA-460E-A105-0F9D76F7324A
+  PACKAGE_VERSION= 1.0
+
+[Includes]
+  Include
+
diff --git a/DynamicTablesPkg/Include/TableGenerator.h 
b/DynamicTablesPkg/Include/TableGenerator.h
new file mode 100644
index 
..ea996085683ff6a783ec9a676efce6604b956d8e
--- /dev/null
+++ b/DynamicTablesPkg/Include/TableGenerator.h
@@ -0,0 +1,252 @@
+/** @file
+
+  Copyright (c) 2017, ARM Limited. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Glossary:
+- ACPI   - Advanced Configuration and Power Interface
+- SMBIOS - System Management BIOS
+- DT - Device Tree
+**/
+
+#ifndef TABLE_GENERATOR_H_
+#define TABLE_GENERATOR_H_
+
+/** The TABLE_GENERATOR_ID type describes the Table Generator ID
+
+  Table Generator ID
+
+___
+|  31 | 30 |29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17| 16|
+---
+|TNSID|  0 |   TT   |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0 |  0|  0|
+___
+___
+|15 | 14 | 13 | 12 | 11 | 10 |  9 |  8 |  7 |  6 |  5 |  4 |  3 |  2 |  1 |  0|
+---
+| Table ID|
+___
+
+  Bit [31] - Table NameSpace ID (TNSID)
+  0 - Standard
+  1 - Custom/OEM
+
+  Bit [30] - Reserved, Must be Zero
+
+  Bit [29:28] - Table Type (TT)
+   0 - ACPI Table
+   1 - SMBIOS Table
+   2 - DT (Device Tree) Table
+   3 - Reserved (INVALID)
+
+  Bit [27:16] - Reserved, Must Be Zero
+
+  Bit [15:0] - Table ID
+
+Standard ACPI Table IDs:
+   0 - Reserved
+   1 - RAW
+   2 - FADT
+   3 - DSDT
+   4 - SSDT
+   5 - MADT
+   6 - GTDT
+   7 - DBG2
+   8 - SPCR
+   9 - MCFG
+
+Standard SMBIOS Table IDs:
+   0 - Reserved
+   1 - RAW
+   2 - Table Type00
+   3 - Table Type01
+   4 - Table Type02
+   5 - Table Type03
+   6 - Table Type04
+   7 - Table Type05
+   8 - Table Type06
+   9 - Table Type07
+  10 - Table Type08
+  11 - Table Type09
+  12 - Table Type10
+  13 - Table Type11
+  14 - Table Type12
+  15 - Table Type13
+  16 - Table Type14
+  17 - Table Type15
+  18 - Table Type16
+  19 - Table Type17
+  20 - Table Type18
+  21 - Table Type19
+  22 - Table Type20
+  23 - Table Type21
+  24 - Table Type22
+  25 - Table Type23
+  26 - Table Type24
+  27 - Table Type25
+  28 - Table Type26
+  29 - Table Type27

[edk2] [PATCH v1 01/22] DynamicTablesPkg: Dynamic Tables Framework

2018-12-21 Thread Sami Mujawar
The dynamic tables framework is designed to generate standardised
firmware tables that describe the hardware information at
run-time. A goal of standardised firmware is to have a common
firmware for a platform capable of booting both Windows and Linux
operating systems.

Traditionally the firmware tables are handcrafted using ACPI
Source Language (ASL), Table Definition Language (TDL) and
C-code. This approach can be error prone and involves time
consuming debugging.

In addition, it may be desirable to configure platform hardware
at runtime such as: configuring the number of cores available
for use by the OS, or turning SoC features ON or OFF.

This patch introduces Dynamic Tables Framework which also provides
mechanisms to reduce the amount of effort required in porting
firmware to new platforms. A more detailed description is in
the Readme.md file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 
---
 DynamicTablesPkg/Readme.md | 139 
 1 file changed, 139 insertions(+)

diff --git a/DynamicTablesPkg/Readme.md b/DynamicTablesPkg/Readme.md
new file mode 100644
index 
..93fd1f313aa5227df5c1ccc82dfe17cb4c8f9e0a
--- /dev/null
+++ b/DynamicTablesPkg/Readme.md
@@ -0,0 +1,139 @@
+Dynamic Tables Framework
+
+
+Dynamic Tables Framework provides mechanisms to reduce the amount
+of effort required in porting firmware to new platforms. The aim is
+to provide an implementation capable of generating the firmware
+tables from an external source.  This is potentially a management
+node, either local or remote, or, where suitable, a file that might
+be generated from the system construction.  This initial release
+does not fully implement that - the configuration is held in local
+UEFI modules.
+
+Feature Summary
+---
+The dynamic tables framework is designed to generate standardised
+firmware tables that describe the hardware information at
+run-time. A goal of standardised firmware is to have a common
+firmware for a platform capable of booting both Windows and Linux
+operating systems.
+
+Traditionally the firmware tables are handcrafted using ACPI
+Source Language (ASL), Table Definition Language (TDL) and
+C-code. This approach can be error prone and involves time
+consuming debugging. In addition, it may be desirable to configure
+platform hardware at runtime such as: configuring the number of
+cores available for use by the OS, or turning SoC features ON or
+OFF.
+
+The dynamic tables framework simplifies this by providing a set
+of standard table generators, that are implemented as libraries.
+These generators query a platform specific component, the
+'Configuration Manager', to collate the information required
+for generating the tables at run-time.
+
+The framework also provides the ability to implement custom/OEM
+generators; thereby facilitating support for custom tables. The
+custom generators can also utilize the existing standard generators
+and override any functionality if needed.
+
+The framework currently implements a set of standard ACPI table
+generators for ARM architecture, that can generate Server Base Boot
+Requirement (SBBR) compliant tables. Although, the set of standard
+generators implement the functionality required for ARM architecture;
+the framework is extensible, and support for other architectures can
+be added easily.
+
+The framework currently supports the following table generators for ARM:
+* DBG2 - Debug Port Table 2
+* DSDT - Differentiated system description table. This is essentially
+ a RAW table generator.
+* FADT - Fixed ACPI Description Table
+* GTDT - Generic Timer Description Table
+* IORT - IO Remapping Table
+* MADT - Multiple APIC Description Table
+* MCFG - PCI Express memory mapped configuration space base address
+ Description Table
+* SPCR - Serial Port Console Redirection Table
+* SSDT - Secondary System Description Table. This is essentially
+ a RAW table generator.
+
+Roadmap
+---
+The current implementation of the Configuration Manager populates the
+platform information statically as a C structure. Further enhancements
+to introduce runtime loading of platform information from a platform
+information file is planned.
+
+Also support for generating SMBIOS tables is planned and will be added
+subsequently.
+
+Related Modules
+---
+
+### ACPICA iASL compiler
+The RAW table generator, used to process the DSDT/SSDT files depends on
+the iASL compiler to convert the DSDT/SSDT ASL files to a C array containing
+the hex AML code. The "-tc" option of the iASL compiler has been enhanced to
+support generation of an AML hex file (C header) with a unique symbol name
+so that it is suitable for inclusion from a C source file.
+
+Related Links
+--
+
+
+
+
+Supported Platforms
+---
+1. Juno
+2. FVP Models
+
+Build Instructions

[edk2] [PATCH v1 00/22] DynamicTablesPkg: Introduce Dynamic Tables Framework

2018-12-21 Thread Sami Mujawar
Dynamic Tables Framework aims to reduce the amount of effort
required for porting firmware to new platforms by simplifying
the generation of firmware tables based on hardware description
provided by a platform specific component.
 
The Dynamic Tables Framework core queries the platform specific
component to retrieve the required hardware information for
generating standardised firmware tables at run-time.
 
This patch series introduce the Dynamic Tables Framework.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Sami Mujawar 

The changes can be seen at:
https://github.com/samimujawar/edk2/tree/365_dynamic_tables_framework_v1

Sami Mujawar (22):
  DynamicTablesPkg: Dynamic Tables Framework
  DynamicTablesPkg: Table Generator definition
  DynamicTablesPkg: Acpi Table Generator
  DynamicTablesPkg: SMBIOS Table Generator
  DynamicTablesPkg: DT Table Generator
  DynamicTablesPkg: Standard NameSpace Objects
  DynamicTablesPkg: Arm NameSpace Objects
  DynamicTablesPkg: Configuration Manager Objects
  DynamicTablesPkg: Configuration Manager Protocol
  DynamicTablesPkg: Configuration Manager Helper
  DynamicTablesPkg: Table Helper Library
  DynamicTablesPkg: Dynamic Table Factory Protocol
  DynamicTablesPkg: Dynamic Table Factory Dxe
  DynamicTablesPkg: Dynamic Table Manager Dxe
  DynamicTablesPkg: Arm Raw/DSDT/SSDT Generator
  DynamicTablesPkg: Arm ACPI FADT Generator
  DynamicTablesPkg: Arm ACPI MADT Generator
  DynamicTablesPkg: Arm ACPI GTDT Generator
  DynamicTablesPkg: Arm SPCR Table Generator
  DynamicTablesPkg: Arm DBG2 Table Generator
  DynamicTablesPkg: Arm PCI MCFG Table Generator
  DynamicTablesPkg: Arm IORT Table Generator

 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/AcpiTableFactory/AcpiTableFactory.c
 |  226 +++
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DeviceTreeTableFactory/DeviceTreeTableFactory.c
 |  225 +++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h  
 |  125 ++
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.c   
 |   90 +
 DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDxe.inf 
 |   60 +
 
DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/SmbiosTableFactory.c
 |  226 +++
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c   
 |  735 +++
 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.inf 
 |   50 +
 DynamicTablesPkg/DynamicTables.dsc.inc 
 |   43 +
 DynamicTablesPkg/DynamicTables.fdf.inc 
 |   24 +
 DynamicTablesPkg/DynamicTablesPkg.dec  
 |   43 +
 DynamicTablesPkg/Include/AcpiTableGenerator.h  
 |  357 
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
 |  591 ++
 DynamicTablesPkg/Include/ConfigurationManagerHelper.h  
 |  119 ++
 DynamicTablesPkg/Include/ConfigurationManagerObject.h  
 |  176 ++
 DynamicTablesPkg/Include/DeviceTreeTableGenerator.h
 |  182 ++
 DynamicTablesPkg/Include/Library/TableHelperLib.h  
 |   66 +
 DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h   
 |  128 ++
 DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h
 |  269 +++
 DynamicTablesPkg/Include/SmbiosTableGenerator.h
 |  240 +++
 DynamicTablesPkg/Include/StandardNameSpaceObjects.h
 |  116 ++
 DynamicTablesPkg/Include/TableGenerator.h  
 |  252 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/AcpiDbg2LibArm.inf
 |   48 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c   
 |  442 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/AcpiFadtLibArm.inf
 |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c   
 |  668 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/AcpiGtdtLibArm.inf
 |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c   
 |  674 +++
 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/AcpiIortLibArm.inf
 |   42 +
 DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c   
 | 2055 
 

Re: [edk2] [PATCH v3] ArmPkg/ArmScmiDxe: Add clock enable function

2018-12-21 Thread Girish Pathak
Apart from some minor indentation errors in function parameter declarations in 
ArmScmiClock2Protocol.h , this looks fine.


-Original Message-
From: Ard Biesheuvel 
Sent: 21 December 2018 14:55
To: Jeff Brasen ; Girish Pathak 
Cc: edk2-devel@lists.01.org; Leif Lindholm 
Subject: Re: [PATCH v3] ArmPkg/ArmScmiDxe: Add clock enable function

On Fri, 14 Dec 2018 at 00:48, Jeff Brasen  wrote:
>
> Add function to allow enabling and disabling of the clock using the
> SCMI interface. Add gArmScmiClock2ProtocolGuid to distinguish
> platforms that support new API from those that just have the older protocol.
>
> SCMI_CLOCK2_PROTOCOL also adds a version parameter to allow for future
> changes. It is placed after the functions that are present in the
> existing protocol to allow SCMI_CLOCK2_PROTOCOL to be cast to
> SCMI_CLOCK_PROTOCOL so that only a single implementation of those
> function are needed.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jeff Brasen 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Grish Pathak 

I'd like to hear from Girish as well, since he contributed this code originally.

> ---
>  ArmPkg/ArmPkg.dec  |   1 +
>  .../ArmScmiDxe/ArmScmiClockProtocolPrivate.h   |   7 +
>  ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf   |   1 +
>  ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c  |  62 +++
>  ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h| 198 
> +
>  5 files changed, 269 insertions(+)
>  create mode 100644 ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec index
> d99eb67..2f5e5b3 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -59,6 +59,7 @@
>## Arm System Control and Management Interface(SCMI) Clock management 
> protocol
>## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
>gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9,
> 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
> +  gArmScmiClock2ProtocolGuid = { 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8,
> + 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } }
>
>## Arm System Control and Management Interface(SCMI) Clock management 
> protocol
>## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> index 0d1ec6f..c135bac 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> @@ -59,6 +59,13 @@ typedef struct {
>CLOCK_RATE_DWORD Rate;
>  } CLOCK_RATE_SET_ATTRIBUTES;
>
> +
> +// Message parameters for CLOCK_CONFIG_SET command.
> +typedef struct {
> +  UINT32 ClockId;
> +  UINT32 Attributes;
> +} CLOCK_CONFIG_SET_ATTRIBUTES;
> +
>  //  if ClockAttr Bit[0] is set then clock device is enabled.
>  #define CLOCK_ENABLE_MASK 0x1
>  #define CLOCK_ENABLED(ClockAttr)  ((ClockAttr & CLOCK_ENABLE_MASK) ==
> 1) diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> index 05ce9c0..9b29b9f 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> @@ -46,6 +46,7 @@
>  [Protocols]
>gArmScmiBaseProtocolGuid
>gArmScmiClockProtocolGuid
> +  gArmScmiClock2ProtocolGuid
>gArmScmiPerformanceProtocolGuid
>
>  [Depex]
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> index 64d2afa..c7f27a3 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> @@ -19,6 +19,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "ArmScmiClockProtocolPrivate.h"
>  #include "ScmiPrivate.h"
> @@ -388,6 +389,53 @@ ClockRateSet (
>return Status;
>  }
>
> +/** Enable/Disable specified clock.
> +
> +  @param[in]  ThisA Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +  @param[in]  ClockId Identifier for the clock device.
> +  @param[in]  Enable  TRUE to enable, FALSE to disable.
> +
> +  @retval EFI_SUCCESS  Clock enable/disable successful.
> +  @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> +  @retval !(EFI_SUCCESS)   Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockEnable (
> +  IN SCMI_CLOCK2_PROTOCOL *This,
> +  IN UINT32   ClockId,
> +  IN BOOLEAN  Enable
> +  )
> +{
> +  EFI_STATUS  Status;
> +  CLOCK_CONFIG_SET_ATTRIBUTES *ClockConfigSetAttributes;
> +  SCMI_COMMANDCmd;
> +  UINT32  PayloadLength;
> +
> +  Status = ScmiCommandGetPayload
> + ((UINT32**));
> +  if (EFI_ERROR (Status)) {
> +return Status;
> +  }
> +
> +  // Fill arguments for clock protocol command.
> +  ClockConfigSetAttributes->ClockId= ClockId;
> +  ClockConfigSetAttributes->Attributes = Enable ? BIT0 : 0;
> +
> +  Cmd.ProtocolId = 

[edk2] [PATCH] ArmPkg/ArmGicV3Dxe: use correct value for ARM_GICD_IROUTER

2018-12-21 Thread Ard Biesheuvel
Use the correct value for ARM_GICD_IROUTER as per the GIC spec,
and fix the code that relies on the value being skewed by 32 x 8
bytes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Include/Library/ArmGicLib.h| 2 +-
 ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Include/Library/ArmGicLib.h 
b/ArmPkg/Include/Library/ArmGicLib.h
index 5775905ca91b..b52b77628ae1 100644
--- a/ArmPkg/Include/Library/ArmGicLib.h
+++ b/ArmPkg/Include/Library/ArmGicLib.h
@@ -43,7 +43,7 @@
 #define ARM_GIC_ICDSGIR 0xF00 // Software Generated Interrupt Register
 
 // GICv3 specific registers
-#define ARM_GICD_IROUTER0x6100 // Interrupt Routing Registers
+#define ARM_GICD_IROUTER0x6000 // Interrupt Routing Registers
 
 // GICD_CTLR bits
 #define ARM_GIC_ICDDCR_ARE  (1 << 4) // Affinity Routing Enable (ARE)
diff --git a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c 
b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
index 1558db31713a..7d891873ba82 100644
--- a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
@@ -466,7 +466,7 @@ GicV3DxeInitialize (
 }
 
 // Route the SPIs to the primary CPU. SPIs start at the INTID 32
-for (Index = 0; Index < (mGicNumInterrupts - 32); Index++) {
+for (Index = 32; Index < mGicNumInterrupts; Index++) {
   MmioWrite32 (
 mGicDistributorBase + ARM_GICD_IROUTER + (Index * 8),
 CpuTarget
-- 
2.19.2

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v3] ArmPkg/ArmScmiDxe: Add clock enable function

2018-12-21 Thread Ard Biesheuvel
On Fri, 14 Dec 2018 at 00:48, Jeff Brasen  wrote:
>
> Add function to allow enabling and disabling of the clock using the SCMI
> interface. Add gArmScmiClock2ProtocolGuid to distinguish platforms that
> support new API from those that just have the older protocol.
>
> SCMI_CLOCK2_PROTOCOL also adds a version parameter to allow for future
> changes. It is placed after the functions that are present in the
> existing protocol to allow SCMI_CLOCK2_PROTOCOL to be cast to
> SCMI_CLOCK_PROTOCOL so that only a single implementation of those
> function are needed.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jeff Brasen 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Grish Pathak 

I'd like to hear from Girish as well, since he contributed this code originally.

> ---
>  ArmPkg/ArmPkg.dec  |   1 +
>  .../ArmScmiDxe/ArmScmiClockProtocolPrivate.h   |   7 +
>  ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf   |   1 +
>  ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c  |  62 +++
>  ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h| 198 
> +
>  5 files changed, 269 insertions(+)
>  create mode 100644 ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> index d99eb67..2f5e5b3 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -59,6 +59,7 @@
>## Arm System Control and Management Interface(SCMI) Clock management 
> protocol
>## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
>gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, 0x9f, 
> 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
> +  gArmScmiClock2ProtocolGuid = { 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0x34, 
> 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } }
>
>## Arm System Control and Management Interface(SCMI) Clock management 
> protocol
>## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h 
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> index 0d1ec6f..c135bac 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiClockProtocolPrivate.h
> @@ -59,6 +59,13 @@ typedef struct {
>CLOCK_RATE_DWORD Rate;
>  } CLOCK_RATE_SET_ATTRIBUTES;
>
> +
> +// Message parameters for CLOCK_CONFIG_SET command.
> +typedef struct {
> +  UINT32 ClockId;
> +  UINT32 Attributes;
> +} CLOCK_CONFIG_SET_ATTRIBUTES;
> +
>  //  if ClockAttr Bit[0] is set then clock device is enabled.
>  #define CLOCK_ENABLE_MASK 0x1
>  #define CLOCK_ENABLED(ClockAttr)  ((ClockAttr & CLOCK_ENABLE_MASK) == 1)
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf 
> b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> index 05ce9c0..9b29b9f 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
> @@ -46,6 +46,7 @@
>  [Protocols]
>gArmScmiBaseProtocolGuid
>gArmScmiClockProtocolGuid
> +  gArmScmiClock2ProtocolGuid
>gArmScmiPerformanceProtocolGuid
>
>  [Depex]
> diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c 
> b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> index 64d2afa..c7f27a3 100644
> --- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> +++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
> @@ -19,6 +19,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "ArmScmiClockProtocolPrivate.h"
>  #include "ScmiPrivate.h"
> @@ -388,6 +389,53 @@ ClockRateSet (
>return Status;
>  }
>
> +/** Enable/Disable specified clock.
> +
> +  @param[in]  ThisA Pointer to SCMI_CLOCK_PROTOCOL Instance.
> +  @param[in]  ClockId Identifier for the clock device.
> +  @param[in]  Enable  TRUE to enable, FALSE to disable.
> +
> +  @retval EFI_SUCCESS  Clock enable/disable successful.
> +  @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
> +  @retval !(EFI_SUCCESS)   Other errors.
> +**/
> +STATIC
> +EFI_STATUS
> +ClockEnable (
> +  IN SCMI_CLOCK2_PROTOCOL *This,
> +  IN UINT32   ClockId,
> +  IN BOOLEAN  Enable
> +  )
> +{
> +  EFI_STATUS  Status;
> +  CLOCK_CONFIG_SET_ATTRIBUTES *ClockConfigSetAttributes;
> +  SCMI_COMMANDCmd;
> +  UINT32  PayloadLength;
> +
> +  Status = ScmiCommandGetPayload ((UINT32**));
> +  if (EFI_ERROR (Status)) {
> +return Status;
> +  }
> +
> +  // Fill arguments for clock protocol command.
> +  ClockConfigSetAttributes->ClockId= ClockId;
> +  ClockConfigSetAttributes->Attributes = Enable ? BIT0 : 0;
> +
> +  Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
> +  Cmd.MessageId  = SCMI_MESSAGE_ID_CLOCK_CONFIG_SET;
> +
> +  PayloadLength = sizeof (CLOCK_CONFIG_SET_ATTRIBUTES);
> +
> +  // Execute and wait for response on a SCMI channel.
> +  Status = ScmiCommandExecute (
> + ,
> + ,
> + NULL
> + );
> +
> +  return Status;
> +}
> +
>  // 

Re: [edk2] [PATCH edk2-platforms 34/41] Silicon/NXP: Implement PciSegmentLib to support multiple RCs

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:48PM +0530, Meenakshi Aggarwal wrote:
> From: Vabhav 
> 
> Multiple root complex support is not provided by standard library
> PciLib/PciExpressLib/PciSegmentLib, Reimplementing it and provide
> function for reading/writing into PCIe configuration Space.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Silicon/NXP/Include/NxpPcie.h  | 146 +
>  Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c  | 611 
> +
>  .../NXP/Library/PciSegmentLib/PciSegmentLib.inf|  41 ++
>  3 files changed, 798 insertions(+)
>  create mode 100644 Silicon/NXP/Include/NxpPcie.h
>  create mode 100644 Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c
>  create mode 100644 Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
> 
> diff --git a/Silicon/NXP/Include/NxpPcie.h b/Silicon/NXP/Include/NxpPcie.h
> new file mode 100644
> index 000..a0beefe
> --- /dev/null
> +++ b/Silicon/NXP/Include/NxpPcie.h
> @@ -0,0 +1,146 @@
> +/** @file
> +  PCI memory configuration for NXP
> +
> +  Copyright 2018 NXP
> +
> +  This program and the accompanying materials are licensed and made available
> +  under the terms and conditions of the BSD License which accompanies this
> +  distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
> WITHOUT
> +  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __NXP_PCIE_H__
> +#define __NXP_PCIE_H__
> +
> +// Segment 0
> +#define PCI_SEG0_NUM  0
> +#define PCI_SEG0_MMIO32_MIN   0x4000
> +#define PCI_SEG0_MMIO32_MAX   0x4fff
> +#define PCI_SEG0_MMIO64_MIN   PCI_SEG0_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG0_MMIO64_MAX   PCI_SEG0_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG0_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp1BaseAddr)
> +#define PCI_SEG0_DBI_BASE 0x0340
> +#define PCI_SEG0_MMIO_OFFSET  0x0
> +#define PCI_SEG0_PORTIO_MEMBASE   PCI_SEG0_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG0_PORTIO_OFFSET0x0
> +
> +// Segment 1
> +#define PCI_SEG1_NUM  1
> +#define PCI_SEG1_MMIO32_MIN   0x4000
> +#define PCI_SEG1_MMIO32_MAX   0x4fff
> +#define PCI_SEG1_MMIO64_MIN   PCI_SEG1_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG1_MMIO64_MAX   PCI_SEG1_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG1_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp2BaseAddr)
> +#define PCI_SEG1_DBI_BASE 0x0350
> +#define PCI_SEG1_MMIO_OFFSET  0x1000
> +#define PCI_SEG1_PORTIO_MEMBASE   PCI_SEG1_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG1_PORTIO_OFFSET0x1
> +
> +// Segment 2
> +#define PCI_SEG2_NUM  2
> +#define PCI_SEG2_MMIO32_MIN   0x4000
> +#define PCI_SEG2_MMIO32_MAX   0x4fff
> +#define PCI_SEG2_MMIO64_MIN   PCI_SEG2_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG2_MMIO64_MAX   PCI_SEG2_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG2_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp3BaseAddr)
> +#define PCI_SEG2_DBI_BASE 0x0360
> +#define PCI_SEG2_MMIO_OFFSET  0x2000
> +#define PCI_SEG2_PORTIO_MEMBASE   PCI_SEG2_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG2_PORTIO_OFFSET0x2
> +
> +// Segment 3
> +#define PCI_SEG3_NUM  3
> +#define PCI_SEG3_MMIO32_MIN   0x4000
> +#define PCI_SEG3_MMIO32_MAX   0x4fff
> +#define PCI_SEG3_MMIO64_MIN   PCI_SEG3_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG3_MMIO64_MAX   PCI_SEG3_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG3_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp4BaseAddr)
> +#define PCI_SEG3_DBI_BASE 0x0370
> +#define PCI_SEG3_MMIO_OFFSET  0x3000
> +#define PCI_SEG3_PORTIO_MEMBASE   PCI_SEG3_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG3_PORTIO_OFFSET0x3
> +
> +// Segment configuration
> +#define PCI_SEG_BUSNUM_MIN0x0
> +#define PCI_SEG_BUSNUM_MAX0xff
> +#define PCI_SEG_PORTIO_MIN0x0
> +#define PCI_SEG_PORTIO_MAX0x
> +#define PCI_SEG_MMIO32_MIN0x4000
> +#define PCI_SEG_MMIO32_MAX0x4fff
> +#define PCI_SEG_MMIO32_DIFF   0x1000
> +#define PCI_SEG_MMIO64_MAX_DIFF   0x3fff
> +#define SEG_CFG_SIZE  0x1000
> +#define SEG_CFG_BUS   0x
> +#define SEG_MEM_SIZE  0x4000
> +#define SEG_MEM_LIMIT 0x7fff
> +#define SEG_MEM_BUS   0x4000
> +#define 

Re: [edk2] Question about hotplugging NIC devices to an empty pci-bridge

2018-12-21 Thread Zhoujian (jay)
> -Original Message-
> From: Yao, Jiewen [mailto:jiewen@intel.com]
> Sent: Friday, December 21, 2018 1:28 PM
> To: Zhoujian (jay) ; edk2-devel@lists.01.org;
> ler...@redhat.com
> Cc: Huangweidong (C) ; liujunjie (A)
> ; wangxin (U) ; wujing (O)
> ; dengkai (A) 
> Subject: RE: Question about hotplugging NIC devices to an empty pci-bridge
> 
> You need have a PciHotPlug driver to produce the
> EFI_PCI_HOT_PLUG_INIT_PROTOCOL
> 
> One example:
> https://github.com/tianocore/edk2/tree/master/OvmfPkg/PciHotPlugInitDxe
> Laszlo added it. He may provide comment on how to use it.
> 
> Another example:
> https://github.com/tianocore/edk2-platforms/tree/devel-
> MinPlatform/Platform/Intel/KabylakeOpenBoardPkg/Features/PciHotPlug
> This is to add Thunderbolt support in Kabylake platform.

I've checked the dsc, and confirmed that the OVMF.fd already had the PciHotPlug 
driver.
Then I found the resource info through the debug log like below:

InitRootBridge: populated root bus 0, with room for 255 subordinate bus(es)
RootBridge: PciRoot(0x0)
  Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes
 AllocAttr: 3 (CombineMemPMem Mem64Decode)
   Bus: 0 - FF Translation=0
Io: C000 -  Translation=0
   Mem: C000 - FBFF Translation=0
MemAbove4G: 418 - 41F Translation=0
  PMem:  - 0 Translation=0
   PMemAbove4G:  - 0 Translation=0

In the OvmfPkg/PlatformPei/Platform.c, the function MemMapInitialization sets 
the PciIoBase=0xC000 and PciIoSize=0x4000(On Q35, the PciIoBase=0x6000 and 
PciIoSize=0xA000).

So my question are:
1)Why the default value of PciIoBase is 0xC000, each pci-bridges needs 0x0fff 
IO window, which means only 4 pci-bridges can be reserved?
2)If I set the PciIoBase=0x1000, PciIoSize=0xA000 and start a vm with 8 empty 
pci-bridges, hotpluging a virtual nic to the pci-bridge, the problem is 
disappearing.
  But will this cause any side effects?
  
[4.552337] pci_bus :00: resource 4 [io  0x-0x0cf7 window]
[4.552341] pci_bus :00: resource 5 [io  0x0d00-0x window]
[4.552343] pci_bus :00: resource 6 [mem 0x000a-0x000b window]
[4.552344] pci_bus :00: resource 7 [mem 0xc000-0xfebf window]
[4.552346] pci_bus :00: resource 8 [mem 0x418-0x418001270ff 
window]
[4.552348] pci_bus :01: resource 0 [io  0x8000-0x8fff]
[4.552350] pci_bus :01: resource 1 [mem 0xc2e0-0xc2ff]
[4.552351] pci_bus :02: resource 0 [io  0x7000-0x7fff]
[4.552353] pci_bus :02: resource 1 [mem 0xc2c0-0xc2df]
[4.552354] pci_bus :02: resource 2 [mem 0x418-0x418000f 
64bit pref]
[4.552356] pci_bus :03: resource 0 [io  0x6000-0x6fff]
[4.552357] pci_bus :03: resource 1 [mem 0xc2a0-0xc2bf]
[4.552359] pci_bus :04: resource 0 [io  0x5000-0x5fff]
[4.552360] pci_bus :04: resource 1 [mem 0xc280-0xc29f]
[4.552362] pci_bus :05: resource 0 [io  0x4000-0x4fff]
[4.552363] pci_bus :05: resource 1 [mem 0xc260-0xc27f]
[4.552364] pci_bus :06: resource 0 [io  0x3000-0x3fff]
[4.552366] pci_bus :06: resource 1 [mem 0xc240-0xc25f]
[4.552368] pci_bus :07: resource 0 [io  0x2000-0x2fff]
[4.552369] pci_bus :07: resource 1 [mem 0xc220-0xc23f]
[4.552370] pci_bus :08: resource 0 [io  0x1000-0x1fff]
[4.552372] pci_bus :08: resource 1 [mem 0xc200-0xc21f]


Regards,
Jay Zhou

> 
> Thank you
> Yao Jiewen
> 
> 
> > -Original Message-
> > From: Zhoujian (jay) [mailto:jianjay.z...@huawei.com]
> > Sent: Friday, December 21, 2018 11:04 AM
> > To: Yao, Jiewen ; edk2-devel@lists.01.org;
> > ler...@redhat.com
> > Cc: Huangweidong (C) ; liujunjie (A)
> > ; wangxin (U) ;
> > wujing (O) ; dengkai (A) 
> > Subject: RE: Question about hotplugging NIC devices to an empty
> > pci-bridge
> >
> > I've tried to set PcdPciBusHotplugDeviceSupport to be true in
> > MdeModulePkg.dec like below:
> > gEfiMdeModulePkgTokenSpaceGuid.PcdPciBusHotplugDeviceSupport|TRUE
> > |BOOLEAN|0x0001003d
> > But the problem still exists. Is there any steps I missed? Or some
> > infos need to populate to OVMF by Qemu?
> >
> > Could you give me more infos?
> >
> > Thanks,
> > Jay Zhou
> >
> > > -Original Message-
> > > From: Yao, Jiewen [mailto:jiewen@intel.com]
> > > Sent: Thursday, December 20, 2018 8:09 PM
> > > To: Zhoujian (jay) ;
> > > edk2-devel@lists.01.org
> > > Cc: Huangweidong (C) ; liujunjie (A)
> > > ; wangxin (U)
> > ; wujing (O)
> > > ; dengkai (A) 
> > > Subject: RE: Question about hotplugging NIC devices to an empty
> > pci-bridge
> > >
> > > Maybe you can use EFI_PCI_HOT_PLUG_INIT_PROTOCOL to reserve some
> > resource.
> > >
> > > See MdePkg\Include\Protocol\PciHotPlugInit.h
> > >
> > > Thank you
> > > Yao Jiewen
> > >
> > > > -Original Message-
> > > > From: edk2-devel 

Re: [edk2] [PATCH v2] BaseTools/tools_def ARM: use softfloat target for CLANG3x

2018-12-21 Thread Gao, Liming
I have no other comments. Reviewed-by: Liming Gao 

> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Friday, December 21, 2018 7:02 PM
> To: edk2-devel@lists.01.org
> Cc: Leif Lindholm ; Gao, Liming 
> 
> Subject: Re: [PATCH v2] BaseTools/tools_def ARM: use softfloat target for 
> CLANG3x
> 
> On Thu, 20 Dec 2018 at 12:03, Ard Biesheuvel  
> wrote:
> >
> > The 'arm-linux-gnueabihf' target triplet we use for CLANG35 and
> > CLANG38 specifies a hardfloat target, and so the binaries that are
> > emitted are annotated as using VFP registers for passing floating
> > point arguments, even though no VFP is used anywhere in the code.
> >
> > This works fine as long as we don't try to link against code
> > that uses software floating point, but combining object files
> > with different floating point calling conventions is not permitted.
> >
> > So switch to the softfloat arm-linux-gnueabi triplet instead.
> > This affects both the name Clang uses when invoking the linker,
> > and the arguments it passes to it, and we are mostly interested
> > in the latter (since any version of GNU ld.bfd will do the right
> > thing as long as it targets EABI ARM)
> >
> > For native builds, this change has no effect, since the unprefixed
> > system linker will take priority, and so Clang will pass the right
> > arguments to whichever linker happens to be the system linker.
> >
> > For cross builds, the fact that Clang composes the name of the
> > linker by prefixing '-ld' with the target triplet implies that
> > users will have to switch to a version of binutils that targets
> > arm-linux-gnueabi rather than arm-linux-gnueabihf. Note that the
> > GCCx toolchain targets can use either when building for ARM so this
> > does not create a need to install two versions of the ARM cross
> > toolchain. Also, note that all ARM toolchains in the GCC family
> > are already documented as requiring a toolchain that targets
> > arm-linux-gnueabi and not arm-linux-gnueabihf.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel 
> > ---
> > v2: improve commit log
> >
> 
> Liming, Leif: are there any remaining concerns with this patch?
> 
> 
> >  BaseTools/Conf/tools_def.template | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template 
> > b/BaseTools/Conf/tools_def.template
> > index 902680c24c85..f7eb87af14c2 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -5231,7 +5231,7 @@ RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z 
> > common-page-size=0x20
> >  *_CLANG35_*_DLINK_PATH   = ENV(CLANG35_BIN)clang
> >  *_CLANG35_*_ASLDLINK_PATH= ENV(CLANG35_BIN)clang
> >
> > -DEFINE CLANG35_ARM_TARGET= -target arm-linux-gnueabihf
> > +DEFINE CLANG35_ARM_TARGET= -target arm-linux-gnueabi
> >  DEFINE CLANG35_AARCH64_TARGET= -target aarch64-linux-gnu
> >
> >  DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality 
> > -Wno-tautological-compare
> -Wno-tautological-constant-out-of-range-compare -Wno-empty-body 
> -Wno-unknown-warning-option
> > @@ -5384,7 +5384,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS = 
> > DEF(GCC5_X64_DLINK2_FLAGS) -O0
> >  ##
> >  # CLANG38 ARM definitions
> >  ##
> > -DEFINE CLANG38_ARM_TARGET= -target arm-linux-gnueabihf
> > +DEFINE CLANG38_ARM_TARGET= -target arm-linux-gnueabi
> >  DEFINE CLANG38_ARM_CC_FLAGS  = DEF(GCC_ARM_CC_FLAGS) 
> > DEF(CLANG38_ARM_TARGET)
> DEF(CLANG38_WARNING_OVERRIDES) -mno-movt
> >  DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET) 
> > DEF(GCC_ARM_DLINK_FLAGS)
> >
> > --
> > 2.19.2
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 0/5] Ues arch-generic API SpeculationBarrier() to replace AsmLfence()

2018-12-21 Thread Ard Biesheuvel
On Fri, 21 Dec 2018 at 04:11, Hao Wu  wrote:
>
> X86 specific BaseLib API AsmLfence() was introduced to address the Spectre
> Variant 1 (CVE-2017-5753) issue. The purpose of this API is to insert
> barriers to stop speculative execution. However, the API is highly
> architecture (X86) specific, and thus should be avoided using across
> generic code.
>
> To address this issue, this series will add a new BaseLib API called
> SpeculationBarrier(). Different architectures will have different
> implementations for this API. And the series will replace the usage of
> AsmLfence() in generic codes with this newly added SpeculationBarrier().
>
> For the implementations of API SpeculationBarrier() among different
> architectures, this series will:
>
> * For IA32 and x64, SpeculationBarrier() will directly call AsmLfence().
> * For ARM and EBC architectures, an empty implementation is temporarily
>   added as a placeholder. We hope experts in those domains can help to
>   contribute the actual implementation.
>
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Michael D Kinney 
> Cc: Jiewen Yao 
> Cc: Laszlo Ersek 
> Cc: Jian J Wang 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Cc: Ruiyu Ni 
>
> Hao Wu (5):
>   MdePkg/BaseLib: Introduce new SpeculationBarrier API
>   MdeModulePkg/FaultTolerantWrite: Update to consume SpeculationBarrier
>   MdeModulePkg/SmmLockBox: Update to consume SpeculationBarrier
>   MdeModulePkg/Variable: Update to consume SpeculationBarrier
>   UefiCpuPkg/PiSmmCpuDxeSmm: Update to consume SpeculationBarrier
>

Thanks Hao, this looks fine to me.

We've raised this with people in ARM, so we'll try and contribute the
missing pieces as soon as we can. In the mean time, please go ahead
and merge this as is.


>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
>   |  2 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf   
>   |  2 +-
>  MdePkg/Library/BaseLib/BaseLib.inf   
>   |  5 +++
>  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
>   | 10 +++---
>  MdePkg/Include/Library/BaseLib.h 
>   | 15 +
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c 
>   |  8 ++---
>  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.c   
>   | 12 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/{LoadFenceDxe.c => 
> SpeculationBarrierDxe.c} | 12 +---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/{LoadFenceSmm.c => 
> SpeculationBarrierSmm.c} | 14 +
>  MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>   |  6 ++--
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c 
>   | 24 +++
>  MdePkg/Library/BaseLib/Arm/SpeculationBarrier.c  
>   | 30 ++
>  MdePkg/Library/BaseLib/Ebc/SpeculationBarrier.c  
>   | 30 ++
>  MdePkg/Library/BaseLib/X86SpeculationBarrier.c   
>   | 32 
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c   
>   |  6 ++--
>  15 files changed, 163 insertions(+), 45 deletions(-)
>  rename MdeModulePkg/Universal/Variable/RuntimeDxe/{LoadFenceDxe.c => 
> SpeculationBarrierDxe.c} (62%)
>  rename MdeModulePkg/Universal/Variable/RuntimeDxe/{LoadFenceSmm.c => 
> SpeculationBarrierSmm.c} (61%)
>  create mode 100644 MdePkg/Library/BaseLib/Arm/SpeculationBarrier.c
>  create mode 100644 MdePkg/Library/BaseLib/Ebc/SpeculationBarrier.c
>  create mode 100644 MdePkg/Library/BaseLib/X86SpeculationBarrier.c
>
> --
> 2.12.0.windows.1
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 36/41] Silicon/NXP: Implement EFI_CPU_IO2_PROTOCOL

2018-12-21 Thread Ard Biesheuvel
On Wed, 28 Nov 2018 at 10:16, Meenakshi Aggarwal
 wrote:
>
> From: Vabhav 
>
> NXP SOC has mutiple PCIe RCs,Adding respective implementation of
> EFI_CPU_IO2_PROTOCOL to provide Memory Space Read/Write functions
> used by generic Host Bridge Driver including correct value for
> the translation offset during MMIO accesses
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.c   | 633 
> ++
>  Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf |  49 ++
>  2 files changed, 682 insertions(+)
>  create mode 100644 Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.c
>  create mode 100644 Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.inf
>
> diff --git a/Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.c 
> b/Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.c
> new file mode 100644
> index 000..b5c175b
> --- /dev/null
> +++ b/Silicon/NXP/Drivers/PciCpuIo2Dxe/PciCpuIo2Dxe.c
> @@ -0,0 +1,633 @@
> +/** @file
> +  Produces the CPU I/O 2 Protocol.
> +
> +  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
> +  Copyright (c) 2016, Linaro Ltd. All rights reserved.
> +  Copyright 2018 NXP
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD 
> License
> +  which accompanies this distribution.  The full text of the license may be 
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define MAX_IO_PORT_ADDRESS PCI_SEG_PORTIO_LIMIT
> +
> +//
> +// Handle for the CPU I/O 2 Protocol
> +//
> +STATIC EFI_HANDLE  mHandle;
> +
> +//
> +// Lookup table for increment values based on transfer widths
> +//
> +STATIC CONST UINT8 mInStride[] = {
> +  1, // EfiCpuIoWidthUint8
> +  2, // EfiCpuIoWidthUint16
> +  4, // EfiCpuIoWidthUint32
> +  8, // EfiCpuIoWidthUint64
> +  0, // EfiCpuIoWidthFifoUint8
> +  0, // EfiCpuIoWidthFifoUint16
> +  0, // EfiCpuIoWidthFifoUint32
> +  0, // EfiCpuIoWidthFifoUint64
> +  1, // EfiCpuIoWidthFillUint8
> +  2, // EfiCpuIoWidthFillUint16
> +  4, // EfiCpuIoWidthFillUint32
> +  8  // EfiCpuIoWidthFillUint64
> +};
> +
> +//
> +// Lookup table for increment values based on transfer widths
> +//
> +STATIC CONST UINT8 mOutStride[] = {
> +  1, // EfiCpuIoWidthUint8
> +  2, // EfiCpuIoWidthUint16
> +  4, // EfiCpuIoWidthUint32
> +  8, // EfiCpuIoWidthUint64
> +  1, // EfiCpuIoWidthFifoUint8
> +  2, // EfiCpuIoWidthFifoUint16
> +  4, // EfiCpuIoWidthFifoUint32
> +  8, // EfiCpuIoWidthFifoUint64
> +  0, // EfiCpuIoWidthFillUint8
> +  0, // EfiCpuIoWidthFillUint16
> +  0, // EfiCpuIoWidthFillUint32
> +  0  // EfiCpuIoWidthFillUint64
> +};
> +
> +/**
> +  Check parameters to a CPU I/O 2 Protocol service request.
> +
> +  The I/O operations are carried out exactly as requested. The caller is 
> responsible
> +  for satisfying any alignment and I/O width restrictions that a PI System 
> on a
> +  platform might require. For example on some platforms, width requests of
> +  EfiCpuIoWidthUint64 do not work.
> +
> +  @param[in] MmioOperation  TRUE for an MMIO operation, FALSE for I/O Port 
> operation.
> +  @param[in] Width  Signifies the width of the I/O or Memory 
> operation.
> +  @param[in] AddressThe base address of the I/O operation.
> +  @param[in] Count  The number of I/O operations to perform. The 
> number of
> +bytes moved is Width size * Count, starting at 
> Address.
> +  @param[in] Buffer For read operations, the destination buffer to 
> store the results.
> +For write operations, the source buffer from 
> which to write data.
> +
> +  @retval EFI_SUCCESSThe parameters for this request pass the 
> checks.
> +  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.
> +  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
> +  @retval EFI_UNSUPPORTEDThe Buffer is not aligned for the given 
> Width.
> +  @retval EFI_UNSUPPORTEDThe address range specified by Address, 
> Width,
> + and Count is not valid for this PI system.
> +
> +**/
> +STATIC
> +EFI_STATUS
> +CpuIoCheckParameter (
> +  IN BOOLEANMmioOperation,
> +  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,
> +  IN UINT64 Address,
> +  IN UINTN  Count,
> +  IN VOID   *Buffer
> +  )
> +{
> +  UINT64  MaxCount;
> +  UINT64  Limit;
> +
> +  //
> +  // Check to see if Buffer is NULL
> +  //
> +  if (Buffer == NULL) {
> +ASSERT (FALSE);
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  //
> +  // Check to see if Width 

Re: [edk2] [PATCH 11/13] ArmPlatformPkg/NorFlashDxe: allow reusability as a MM driver

2018-12-21 Thread Ard Biesheuvel
On Fri, 14 Dec 2018 at 13:14, Jagadeesh Ujja  wrote:
>
> Adapt the NorFlashDxe driver to be used as a MM_STANDALONE driver to
> allow access to NOR flash for code executing in MM_STANDALONE mode.
> This allows storing of EFI variables on NOR flash which is accessible
> only via the MM STANDALONE mode software.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c |   2 +-
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c| 210 
> 
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.h|   5 +-
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf  |   2 +
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashFvbDxe.c |  96 -
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  76 +++
>  6 files changed, 302 insertions(+), 89 deletions(-)
>

Instead of these huge if() blocks, could you please factor out the
functionality for each, and put two different versions in
NorFlashDxeBase.c and NorFlashDxeSmm.c, and include the appropriate
one in the .inf files.

> diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c 
> b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
> index 279b77c..4c002c7 100644
> --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
> +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashBlockIoDxe.c
> @@ -1,6 +1,6 @@
>  /** @file  NorFlashBlockIoDxe.c
>
> -  Copyright (c) 2011-2013, ARM Ltd. All rights reserved.
> +  Copyright (c) 2011-2018, ARM Ltd. All rights reserved.
>
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of the BSD 
> License
> diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c 
> b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
> index af40a4c..9c56010 100644
> --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
> +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
> @@ -1,6 +1,6 @@
>  /** @file  NorFlashDxe.c
>
> -  Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
> +  Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.
>
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -138,29 +138,102 @@ NorFlashCreateInstance (
>
>if (SupportFvb) {
>  NorFlashFvbInitialize (Instance);
> +if (!InMm ()) {
> +Status = gBS->InstallMultipleProtocolInterfaces (
> +>Handle,
> +, >DevicePath,
> +,  
> >BlockIoProtocol,
> +, 
> >FvbProtocol,
> +NULL
> +);
> +if (EFI_ERROR(Status)) {
> +  FreePool (Instance);
> +  return Status;
> +}
> +} else {
> +  //Install DevicePath Protocol
> +  Status = gMmst->MmInstallProtocolInterface (
> +>Handle,
> +,
> +EFI_NATIVE_INTERFACE,
> +>DevicePath
> +);
> +  if (EFI_ERROR(Status)) {
> +FreePool (Instance);
> +return Status;
> +  }
> +  //Install BlockIo Protocol
> +  Status = gMmst->MmInstallProtocolInterface (
> +>Handle,
> +,
> +EFI_NATIVE_INTERFACE,
> +>BlockIoProtocol
> +);
> +  if (EFI_ERROR(Status)) {
> +FreePool (Instance);
> +return Status;
> +  }
>
> -Status = gBS->InstallMultipleProtocolInterfaces (
> -  >Handle,
> -  , >DevicePath,
> -  ,  >BlockIoProtocol,
> -  , 
> >FvbProtocol,
> -  NULL
> -  );
> -if (EFI_ERROR(Status)) {
> -  FreePool (Instance);
> -  return Status;
> +  //Install FirmwareVolumeBlock Protocol
> +  Status = gMmst->MmInstallProtocolInterface (
> +>Handle,
> +,
> +EFI_NATIVE_INTERFACE,
> +>FvbProtocol
> +);
> +  if (EFI_ERROR(Status)) {
> +FreePool (Instance);
> +return Status;
> +  }
>  }
>} else {
> -Status = gBS->InstallMultipleProtocolInterfaces (
> ->Handle,
> -, >DevicePath,
> -,  >BlockIoProtocol,
> -, >DiskIoProtocol,
> -NULL
> -);
> -if (EFI_ERROR(Status)) {
> -  FreePool (Instance);
> -  return Status;
> +if (!InMm ()) {
> +  Status = gBS->InstallMultipleProtocolInterfaces (
> +  >Handle,
> +  , >DevicePath,
> +  ,  >BlockIoProtocol,
> +  , 

Re: [edk2] [PATCH v2] BaseTools/tools_def ARM: use softfloat target for CLANG3x

2018-12-21 Thread Ard Biesheuvel
On Thu, 20 Dec 2018 at 12:03, Ard Biesheuvel  wrote:
>
> The 'arm-linux-gnueabihf' target triplet we use for CLANG35 and
> CLANG38 specifies a hardfloat target, and so the binaries that are
> emitted are annotated as using VFP registers for passing floating
> point arguments, even though no VFP is used anywhere in the code.
>
> This works fine as long as we don't try to link against code
> that uses software floating point, but combining object files
> with different floating point calling conventions is not permitted.
>
> So switch to the softfloat arm-linux-gnueabi triplet instead.
> This affects both the name Clang uses when invoking the linker,
> and the arguments it passes to it, and we are mostly interested
> in the latter (since any version of GNU ld.bfd will do the right
> thing as long as it targets EABI ARM)
>
> For native builds, this change has no effect, since the unprefixed
> system linker will take priority, and so Clang will pass the right
> arguments to whichever linker happens to be the system linker.
>
> For cross builds, the fact that Clang composes the name of the
> linker by prefixing '-ld' with the target triplet implies that
> users will have to switch to a version of binutils that targets
> arm-linux-gnueabi rather than arm-linux-gnueabihf. Note that the
> GCCx toolchain targets can use either when building for ARM so this
> does not create a need to install two versions of the ARM cross
> toolchain. Also, note that all ARM toolchains in the GCC family
> are already documented as requiring a toolchain that targets
> arm-linux-gnueabi and not arm-linux-gnueabihf.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel 
> ---
> v2: improve commit log
>

Liming, Leif: are there any remaining concerns with this patch?


>  BaseTools/Conf/tools_def.template | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/BaseTools/Conf/tools_def.template 
> b/BaseTools/Conf/tools_def.template
> index 902680c24c85..f7eb87af14c2 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -5231,7 +5231,7 @@ RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z 
> common-page-size=0x20
>  *_CLANG35_*_DLINK_PATH   = ENV(CLANG35_BIN)clang
>  *_CLANG35_*_ASLDLINK_PATH= ENV(CLANG35_BIN)clang
>
> -DEFINE CLANG35_ARM_TARGET= -target arm-linux-gnueabihf
> +DEFINE CLANG35_ARM_TARGET= -target arm-linux-gnueabi
>  DEFINE CLANG35_AARCH64_TARGET= -target aarch64-linux-gnu
>
>  DEFINE CLANG35_WARNING_OVERRIDES = -Wno-parentheses-equality 
> -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare 
> -Wno-empty-body -Wno-unknown-warning-option
> @@ -5384,7 +5384,7 @@ NOOPT_CLANG38_X64_DLINK2_FLAGS = 
> DEF(GCC5_X64_DLINK2_FLAGS) -O0
>  ##
>  # CLANG38 ARM definitions
>  ##
> -DEFINE CLANG38_ARM_TARGET= -target arm-linux-gnueabihf
> +DEFINE CLANG38_ARM_TARGET= -target arm-linux-gnueabi
>  DEFINE CLANG38_ARM_CC_FLAGS  = DEF(GCC_ARM_CC_FLAGS) 
> DEF(CLANG38_ARM_TARGET) DEF(CLANG38_WARNING_OVERRIDES) -mno-movt
>  DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET) 
> DEF(GCC_ARM_DLINK_FLAGS)
>
> --
> 2.19.2
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 35/41] Silicon/NXP: Implement PciHostBridgeLib support

2018-12-21 Thread Ard Biesheuvel
On Wed, 28 Nov 2018 at 10:16, Meenakshi Aggarwal
 wrote:
>
> From: Vabhav 
>
> Implement the library that exposes the PCIe root complexes to the
> generic PCI host bridge driver,Putting SoC Specific low level init
> code for the RCs.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> ---
>  .../Library/PciHostBridgeLib/PciHostBridgeLib.c| 639 
> +
>  .../Library/PciHostBridgeLib/PciHostBridgeLib.inf  |  51 ++
>  2 files changed, 690 insertions(+)
>  create mode 100644 Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
>  create mode 100644 Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.inf
>
> diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c 
> b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> new file mode 100644
> index 000..a543d7d
> --- /dev/null
> +++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
> @@ -0,0 +1,639 @@
> +/** @file
> +  PCI Host Bridge Library instance for NXP SoCs
> +
> +  Copyright 2018 NXP
> +
> +  This program and the accompanying materials are licensed and made available
> +  under the terms and conditions of the BSD License which accompanies this
> +  distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
> WITHOUT
> +  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#pragma pack(1)
> +typedef struct {
> +  ACPI_HID_DEVICE_PATH AcpiDevicePath;
> +  EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
> +} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;
> +#pragma pack ()
> +
> +STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath[] = 
> {
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG0_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  },
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG1_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  },
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG2_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  },
> +  {
> +{
> +  {
> +ACPI_DEVICE_PATH,
> +ACPI_DP,
> +{
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
> +  (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
> +}
> +  },
> +  EISA_PNP_ID (0x0A08), // PCI Express
> +  PCI_SEG3_NUM
> +},
> +
> +{
> +  END_DEVICE_PATH_TYPE,
> +  END_ENTIRE_DEVICE_PATH_SUBTYPE,
> +  {
> +END_DEVICE_PATH_LENGTH,
> +0
> +  }
> +}
> +  }
> +};
> +
> +STATIC
> +GLOBAL_REMOVE_IF_UNREFERENCED
> +CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
> +  L"Mem", L"I/O", L"Bus"
> +};
> +
> +#define PCI_ALLOCATION_ATTRIBUTES   EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM 
> | \
> +EFI_PCI_HOST_BRIDGE_MEM64_DECODE
> +
> +#define PCI_SUPPORT_ATTRIBUTES  EFI_PCI_ATTRIBUTE_ISA_IO_16 | \
> +EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 
> | \
> +EFI_PCI_ATTRIBUTE_VGA_MEMORY | \
> +EFI_PCI_ATTRIBUTE_VGA_IO_16  | \
> +EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16
> +
> +PCI_ROOT_BRIDGE mPciRootBridges[NUM_PCIE_CONTROLLER];
> +
> +/**
> +  Function to set-up iATU outbound window for PCIe controller
> +
> +  @param Dbi Address of PCIe host controller.
> +  @param Idx Index of iATU outbound window.
> +  @param TypeType(Cfg0/Cfg1/Mem/IO) of iATU outbound window.
> +  @param PhysPCIe controller phy address for outbound window.
> +  @param BusAdr  PCIe controller bus address for outbound window.
> + 

Re: [edk2] [PATCH edk2-platforms 34/41] Silicon/NXP: Implement PciSegmentLib to support multiple RCs

2018-12-21 Thread Ard Biesheuvel
On Wed, 28 Nov 2018 at 10:16, Meenakshi Aggarwal
 wrote:
>
> From: Vabhav 
>
> Multiple root complex support is not provided by standard library
> PciLib/PciExpressLib/PciSegmentLib, Reimplementing it and provide
> function for reading/writing into PCIe configuration Space.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Vabhav 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Silicon/NXP/Include/NxpPcie.h  | 146 +
>  Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c  | 611 
> +
>  .../NXP/Library/PciSegmentLib/PciSegmentLib.inf|  41 ++
>  3 files changed, 798 insertions(+)
>  create mode 100644 Silicon/NXP/Include/NxpPcie.h
>  create mode 100644 Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.c
>  create mode 100644 Silicon/NXP/Library/PciSegmentLib/PciSegmentLib.inf
>
> diff --git a/Silicon/NXP/Include/NxpPcie.h b/Silicon/NXP/Include/NxpPcie.h
> new file mode 100644
> index 000..a0beefe
> --- /dev/null
> +++ b/Silicon/NXP/Include/NxpPcie.h
> @@ -0,0 +1,146 @@
> +/** @file
> +  PCI memory configuration for NXP
> +
> +  Copyright 2018 NXP
> +
> +  This program and the accompanying materials are licensed and made available
> +  under the terms and conditions of the BSD License which accompanies this
> +  distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
> WITHOUT
> +  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __NXP_PCIE_H__
> +#define __NXP_PCIE_H__
> +
> +// Segment 0
> +#define PCI_SEG0_NUM  0
> +#define PCI_SEG0_MMIO32_MIN   0x4000
> +#define PCI_SEG0_MMIO32_MAX   0x4fff
> +#define PCI_SEG0_MMIO64_MIN   PCI_SEG0_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG0_MMIO64_MAX   PCI_SEG0_MMIO64_MIN + MEM64_LIMIT

Please use () around expressions (throughout)

> +#define PCI_SEG0_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp1BaseAddr)
> +#define PCI_SEG0_DBI_BASE 0x0340
> +#define PCI_SEG0_MMIO_OFFSET  0x0
> +#define PCI_SEG0_PORTIO_MEMBASE   PCI_SEG0_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG0_PORTIO_OFFSET0x0
> +
> +// Segment 1
> +#define PCI_SEG1_NUM  1
> +#define PCI_SEG1_MMIO32_MIN   0x4000
> +#define PCI_SEG1_MMIO32_MAX   0x4fff
> +#define PCI_SEG1_MMIO64_MIN   PCI_SEG1_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG1_MMIO64_MAX   PCI_SEG1_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG1_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp2BaseAddr)
> +#define PCI_SEG1_DBI_BASE 0x0350
> +#define PCI_SEG1_MMIO_OFFSET  0x1000
> +#define PCI_SEG1_PORTIO_MEMBASE   PCI_SEG1_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG1_PORTIO_OFFSET0x1
> +
> +// Segment 2
> +#define PCI_SEG2_NUM  2
> +#define PCI_SEG2_MMIO32_MIN   0x4000
> +#define PCI_SEG2_MMIO32_MAX   0x4fff
> +#define PCI_SEG2_MMIO64_MIN   PCI_SEG2_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG2_MMIO64_MAX   PCI_SEG2_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG2_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp3BaseAddr)
> +#define PCI_SEG2_DBI_BASE 0x0360
> +#define PCI_SEG2_MMIO_OFFSET  0x2000
> +#define PCI_SEG2_PORTIO_MEMBASE   PCI_SEG2_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG2_PORTIO_OFFSET0x2
> +
> +// Segment 3
> +#define PCI_SEG3_NUM  3
> +#define PCI_SEG3_MMIO32_MIN   0x4000
> +#define PCI_SEG3_MMIO32_MAX   0x4fff
> +#define PCI_SEG3_MMIO64_MIN   PCI_SEG3_MMIO_MEMBASE + \
> +  SEG_MEM_SIZE + \
> +  MEM64_BASE
> +#define PCI_SEG3_MMIO64_MAX   PCI_SEG3_MMIO64_MIN + MEM64_LIMIT
> +#define PCI_SEG3_MMIO_MEMBASE FixedPcdGet64 (PcdPciExp4BaseAddr)
> +#define PCI_SEG3_DBI_BASE 0x0370
> +#define PCI_SEG3_MMIO_OFFSET  0x3000
> +#define PCI_SEG3_PORTIO_MEMBASE   PCI_SEG3_MMIO_MEMBASE + SEG_IO_SIZE
> +#define PCI_SEG3_PORTIO_OFFSET0x3
> +
> +// Segment configuration
> +#define PCI_SEG_BUSNUM_MIN0x0
> +#define PCI_SEG_BUSNUM_MAX0xff
> +#define PCI_SEG_PORTIO_MIN0x0
> +#define PCI_SEG_PORTIO_MAX0x
> +#define PCI_SEG_MMIO32_MIN0x4000
> +#define PCI_SEG_MMIO32_MAX0x4fff
> +#define PCI_SEG_MMIO32_DIFF   0x1000
> +#define PCI_SEG_MMIO64_MAX_DIFF   0x3fff
> +#define SEG_CFG_SIZE  0x1000
> +#define SEG_CFG_BUS   0x
> +#define SEG_MEM_SIZE  0x4000
> +#define SEG_MEM_LIMIT 0x7fff
> +#define SEG_MEM_BUS  

Re: [edk2] [PATCH edk2-platforms 33/41] LS2088ARDB: Enable NOR driver and Runtime Services

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:47PM +0530, Meenakshi Aggarwal wrote:
> Enable NOR driver and Runtime Services for LS2088ARDB Platform
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> Signed-off-by: Meenakshi Aggarwal 

Reviewed-by: Leif Lindholm 

> ---
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc | 15 -
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf |  6 +-
>  Platform/NXP/LS2088aRdbPkg/VarStore.fdf.inc  | 99 
> 
>  3 files changed, 118 insertions(+), 2 deletions(-)
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/VarStore.fdf.inc
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> index 76d51a2..e788581 100755
> --- a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> @@ -42,6 +42,7 @@
>IfcLib|Silicon/NXP/Library/IfcLib/IfcLib.inf
>BoardLib|Platform/NXP/LS2088aRdbPkg/Library/BoardLib/BoardLib.inf
>FpgaLib|Platform/NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.inf
> +  NorFlashLib|Silicon/NXP/Library/NorFlashLib/NorFlashLib.inf
>  
>  [PcdsFixedAtBuild.common]
>  
> @@ -84,6 +85,13 @@
>gDs3232RtcLibTokenSpaceGuid.PcdMuxRtcChannelValue|0x09
>gDs3232RtcLibTokenSpaceGuid.PcdMuxDefaultChannelValue|0x08
>  
> +  #
> +  # NV Storage PCDs
> +  #
> +  gArmTokenSpaceGuid.PcdVFPEnabled|1
> +  gNxpQoriqLsTokenSpaceGuid.PcdFlashDeviceBase64|0x58000
> +  gNxpQoriqLsTokenSpaceGuid.PcdFlashReservedRegionBase64|0x58030
> +
>  
> 
>  #
>  # Components Section - list of all EDK II Modules needed by this Platform
> @@ -93,7 +101,12 @@
>#
># Architectural Protocols
>#
> -  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
> +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf{
> + 
> + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
> +  }
> +  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
>ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
>Silicon/NXP/Drivers/I2cDxe/I2cDxe.inf
>Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> +  Silicon/NXP/Drivers/NorFlashDxe/NorFlashDxe.inf
> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
> index b526be1..61bb160 100644
> --- a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
> @@ -55,6 +55,7 @@ 
> gArmTokenSpaceGuid.PcdFvBaseAddress|gArmTokenSpaceGuid.PcdFvSize
>  FV = FVMAIN_COMPACT
>  
>  !include Platform/NXP/FVRules.fdf.inc
> +!include VarStore.fdf.inc
>  
> 
>  #
>  # FV Section
> @@ -103,7 +104,8 @@ READ_LOCK_STATUS   = TRUE
>INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
>INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
>INF EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
> -  INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
> +  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> +  INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
>INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
>  
>INF Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> @@ -124,6 +126,8 @@ READ_LOCK_STATUS   = TRUE
>INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
>INF EmbeddedPkg/SimpleTextInOutSerial/SimpleTextInOutSerial.inf
>  
> +  INF Silicon/NXP/Drivers/NorFlashDxe/NorFlashDxe.inf
> +
>#
># Network modules
>#
> diff --git a/Platform/NXP/LS2088aRdbPkg/VarStore.fdf.inc 
> b/Platform/NXP/LS2088aRdbPkg/VarStore.fdf.inc
> new file mode 100644
> index 000..7d35042
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/VarStore.fdf.inc
> @@ -0,0 +1,99 @@
> +## @file
> +#  FDF include file with FD definition that defines an empty variable store.
> +#
> +#  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
> +#  Copyright (C) 2014, Red Hat, Inc.
> +#  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
> +#  Copyright (c) 2016, Freescale Semiconductor. All rights reserved.
> +#  Copyright 2017-2018 NXP.
> +#
> +#  This program and the accompanying materials are licensed and made 
> available
> +#  under the terms and conditions of the BSD License which accompanies this
> +#  distribution. The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
> +#  IMPLIED.
> +#
> +##
> +
> +[FD.LS2088aRdbNv_EFI]
> +
> +BaseAddress = 0x58030|gNxpQoriqLsTokenSpaceGuid.PcdNvFdBase #The base 
> address of the 

Re: [edk2] [PATCH edk2-platforms 32/41] LS2088 : Enable support of FpgaLib

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:46PM +0530, Meenakshi Aggarwal wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal 
> Signed-off-by: Wasim Khan 
> Reviewed-by: Leif Lindholm 
> ---
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc |  3 +++
>  Silicon/NXP/Include/Chassis3/Soc.h   |  1 -
>  Silicon/NXP/LS2088A/LS2088A.dsc.inc  |  1 +
>  Silicon/NXP/Library/SocLib/Chassis3/Soc.c| 13 -
>  Silicon/NXP/Library/SocLib/LS2088aSocLib.inf |  2 ++
>  5 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> index 465c59e..76d51a2 100755
> --- a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> @@ -39,6 +39,9 @@
>SerialPortLib|Silicon/NXP/Library/DUartPortLib/DUartPortLib.inf
>IoAccessLib|Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
>RealTimeClockLib|Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.inf
> +  IfcLib|Silicon/NXP/Library/IfcLib/IfcLib.inf
> +  BoardLib|Platform/NXP/LS2088aRdbPkg/Library/BoardLib/BoardLib.inf
> +  FpgaLib|Platform/NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.inf
>  
>  [PcdsFixedAtBuild.common]
>  
> diff --git a/Silicon/NXP/Include/Chassis3/Soc.h 
> b/Silicon/NXP/Include/Chassis3/Soc.h
> index 8d967e7..0dd9eee 100644
> --- a/Silicon/NXP/Include/Chassis3/Soc.h
> +++ b/Silicon/NXP/Include/Chassis3/Soc.h
> @@ -22,7 +22,6 @@
>  #define FSL_CLUSTER_CLOCKS { 1, 1, 4, 4 } /* LS208x */
>  #define TP_CLUSTER_EOC_MASK0x8000  /* Mask for End of 
> clusters */
>  #define NUM_CC_PLLS6
> -#define CLK_FREQ   1
>  #define MAX_CPUS   16
>  #define CHECK_CLUSTER(Cluster) ((Cluster & TP_CLUSTER_EOC_MASK) != 
> TP_CLUSTER_EOC_MASK)
>  
> diff --git a/Silicon/NXP/LS2088A/LS2088A.dsc.inc 
> b/Silicon/NXP/LS2088A/LS2088A.dsc.inc
> index 8f7dbb5..2cff40f 100644
> --- a/Silicon/NXP/LS2088A/LS2088A.dsc.inc
> +++ b/Silicon/NXP/LS2088A/LS2088A.dsc.inc
> @@ -67,5 +67,6 @@
>gNxpQoriqLsTokenSpaceGuid.PcdI2c0BaseAddr|0x0200
>gNxpQoriqLsTokenSpaceGuid.PcdI2cSize|0x1
>gNxpQoriqLsTokenSpaceGuid.PcdNumI2cController|4
> +  gNxpQoriqLsTokenSpaceGuid.PcdIfcBaseAddr|0x0224
>  
>  ##
> diff --git a/Silicon/NXP/Library/SocLib/Chassis3/Soc.c 
> b/Silicon/NXP/Library/SocLib/Chassis3/Soc.c
> index 0fc92f4..d334bb7 100644
> --- a/Silicon/NXP/Library/SocLib/Chassis3/Soc.c
> +++ b/Silicon/NXP/Library/SocLib/Chassis3/Soc.c
> @@ -19,11 +19,15 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  
> +extern VOID PrintBoardPersonality (VOID);
> +extern UINTN GetBoardSysClk (VOID);

Please import these through an include file.

/
Leif

> +
>  VOID
>  GetSysInfo (
>OUT SYS_INFO *PtrSysInfo
> @@ -82,7 +86,7 @@ GetSysInfo (
>  
>GurBase = (VOID *)PcdGet64 (PcdGutsBaseAddr);
>ClkBase = (VOID *)PcdGet64 (PcdClkBaseAddr);
> -  SysClk = CLK_FREQ;
> +  SysClk = GetBoardSysClk ();
>  
>PtrSysInfo->FreqSystemBus = SysClk;
>PtrSysInfo->FreqDdrBus = PcdGet64 (PcdDdrClk);
> @@ -151,6 +155,8 @@ SocInit (
>//
>SmmuInit ();
>  
> +  IfcInit ();
> +
>//
>//  Initialize the Serial Port.
>//  Early serial port initialization is required to print RCW,
> @@ -177,4 +183,9 @@ SocInit (
>// Print Soc Personality information
>//
>PrintSoc ();
> +
> +  //
> +  // Print Board Personality information
> +  //
> +  PrintBoardPersonality ();
>  }
> diff --git a/Silicon/NXP/Library/SocLib/LS2088aSocLib.inf 
> b/Silicon/NXP/Library/SocLib/LS2088aSocLib.inf
> index 3d9237d..9547f5a 100644
> --- a/Silicon/NXP/Library/SocLib/LS2088aSocLib.inf
> +++ b/Silicon/NXP/Library/SocLib/LS2088aSocLib.inf
> @@ -29,6 +29,8 @@
>  [LibraryClasses]
>BaseLib
>DebugLib
> +  FpgaLib
> +  IfcLib
>IoAccessLib
>SerialPortLib
>  
> -- 
> 1.9.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 31/41] Platform/NXP: LS2088 RDB Board FPGA library

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:45PM +0530, Meenakshi Aggarwal wrote:
> From: Wasim Khan 
> 
> Library to provide functions for accessing FPGA
> on LS2088ARDB board.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> ---
>  .../NXP/LS2088aRdbPkg/Include/Library/FpgaLib.h| 166 
> +
>  .../NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.c| 115 ++
>  .../NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.inf  |  31 
>  3 files changed, 312 insertions(+)
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/Include/Library/FpgaLib.h
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.c
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.inf
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/Include/Library/FpgaLib.h 
> b/Platform/NXP/LS2088aRdbPkg/Include/Library/FpgaLib.h
> new file mode 100644
> index 000..84d1f02
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/Include/Library/FpgaLib.h
> @@ -0,0 +1,166 @@
> +/** FpgaLib.h
> +*  Header defining the LS2088a Fpga specific constants (Base addresses, 
> sizes, flags)
> +*
> +*  Copyright 2017-2018 NXP
> +*
> +*  This program and the accompanying materials
> +*  are licensed and made available under the terms and conditions of the BSD 
> License
> +*  which accompanies this distribution.  The full text of the license may be 
> found at
> +*  http://opensource.org/licenses/bsd-license.php
> +*
> +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +*
> +**/
> +
> +#ifndef __LS2088A_FPGA_H__
> +#define __LS2088A_FPGA_H__
> +
> +typedef enum {
> +  CLK_66,
> +  CLK_83,
> +  CLK_100,
> +  CLK_125,
> +  CLK_133

CamelCase names for enum members.

> +} SYSTEM_CLOCK;
> +
> +/*
> + * FPGA register set of LS2088ARDB board-specific.
> + */
> +typedef struct {
> +  UINT8 Id;   // ID value uniquely identifying each QorIQ board type
> +  UINT8 Arch; // Board Version
> +  UINT8 Ver;  // FPGA Version
> +  UINT8 Model;// Programming Model
> +  UINT8 Minor;// Minor Revision Number
> +  UINT8 CtlSys;
> +  UINT8 Aux;
> +  UINT8 ClkSpd;
> +  UINT8 StatDut;
> +  UINT8 StatSys;
> +  UINT8 StatAlrm;
> +  UINT8 Present;
> +  UINT8 Present2;
> +  UINT8 RcwCtl;
> +  UINT8 CtlLed;
> +  UINT8 I2cBlk;
> +  UINT8 RcfgCtl;
> +  UINT8 RcfgSt;
> +  UINT8 DcmAd;
> +  UINT8 DcmDa;
> +  UINT8 Dcmd;
> +  UINT8 Dmsg;
> +  UINT8 Gdc;
> +  UINT8 Gdd;
> +  UINT8 Dmack;
> +  UINT8 Res1[6];

Please write out Reserved, throughout.

> +  UINT8 Watch;
> +  UINT8 PwrCtl[2];
> +  UINT8 Res2[2];
> +  UINT8 PwrStat[4];
> +  UINT8 Res3[8];
> +  UINT8 ClkSpd2[2];
> +  UINT8 Res4[2];
> +  UINT8 Sclk[3];
> +  UINT8 Res5;
> +  UINT8 Dclk[3];
> +  UINT8 Res6;
> +  UINT8 ClkDspd[3];
> +  UINT8 Res7;
> +  UINT8 RstCtl;
> +  UINT8 RstStat;
> +  UINT8 RstRsn;
> +  UINT8 RstFrc[2];
> +  UINT8 Res8[11];
> +  UINT8 BrdCfg[16];
> +  UINT8 DutCfg[16];
> +  UINT8 RcwAd[2];
> +  UINT8 RcwData;
> +  UINT8 Res9[5];
> +  UINT8 PostCtl;
> +  UINT8 PostStat;
> +  UINT8 PostDat[2];
> +  UINT8 Pid[4];
> +  UINT8 GpioIo[4];
> +  UINT8 GpioDir[4];
> +  UINT8 Res10[20];
> +  UINT8 RjtagCtl;
> +  UINT8 RjtagDat;
> +  UINT8 Res11[2];
> +  UINT8 TrigSrc[4];
> +  UINT8 TrigDst[4];
> +  UINT8 TrigStat;
> +  UINT8 Res12[3];
> +  UINT8 TrigCtr[4];
> +  UINT8 Res13[16];
> +  UINT8 ClkFreq[6];
> +  UINT8 ResC6[8];
> +  UINT8 ClkBase[2];
> +  UINT8 ResD0[8];
> +  UINT8 Cms[2];
> +  UINT8 ResC0[6];
> +  UINT8 Aux2[4];
> +  UINT8 Res14[10];
> +  UINT8 AuxAd;
> +  UINT8 AuxDa;
> +  UINT8 Res15[16];
> +} FPGA_REG_SET;
> +
> +/**
> +   Function to read FPGA register.
> +**/
> +UINT8
> +FpgaRead (
> +  UINTN  Reg
> +  );
> +
> +/**
> +   Function to write FPGA register.
> +**/
> +VOID
> +FpgaWrite (
> +  UINTN  Reg,
> +  UINT8  Value
> +  );
> +
> +/**
> +   Function to initialize FPGA timings.
> +**/
> +VOID
> +FpgaInit (
> +  VOID
> +  );
> +
> +/**
> +   Function to get system clock frequency.
> +**/
> +UINTN
> +GetBoardSysClk (
> +  VOID
> +  );
> +
> +/**
> +   Function to print board personality.
> +**/
> +VOID
> +PrintBoardPersonality (
> +  VOID
> +  );
> +
> +#define FPGA_BASE_PHYS   0x52000
> +
> +//SYSCLK
> +#define FPGA_CLK_MASK0x0F // FPGA Clock Mask
> +#define SYSCLK_66_MHZ6600
> +#define SYSCLK_83_MHZ8300
> +#define SYSCLK_100_MHZ   1
> +#define SYSCLK_125_MHZ   12500
> +#define SYSCLK_133_MHZ   13300
> +
> +#define FPGA_VBANK_MASK  0x07
> +#define FPGA_CS_MASK 0x08
> +
> +#define FPGA_READ(Reg)   FpgaRead (OFFSET_OF (FPGA_REG_SET, Reg))
> +#define FPGA_WRITE(Reg, Value)   FpgaWrite (OFFSET_OF (FPGA_REG_SET, Reg), 
> Value)
> +
> +#endif // __LS2088A_FPGA_H__
> diff --git a/Platform/NXP/LS2088aRdbPkg/Library/FpgaLib/FpgaLib.c 
> 

Re: [edk2] [PATCH edk2-platforms 30/41] Platform/NXP: LS2088A RDB Board Library

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:44PM +0530, Meenakshi Aggarwal wrote:
> From: Wasim Khan 
> 
> Library to provide board specific timings for LS2088ARDB
> board with interfacing to IFC controller for accessing

Expand IFC in commit message.

> NOR, NAND and FPGA.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> Reviewed-by: Leif Lindholm 
> ---
>  .../NXP/LS2088aRdbPkg/Include/IfcBoardSpecific.h   | 114 
> +
>  .../NXP/LS2088aRdbPkg/Library/BoardLib/BoardLib.c  |  69 +
>  .../LS2088aRdbPkg/Library/BoardLib/BoardLib.inf|  28 +
>  3 files changed, 211 insertions(+)
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/Include/IfcBoardSpecific.h
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/Library/BoardLib/BoardLib.c
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/Library/BoardLib/BoardLib.inf
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/Include/IfcBoardSpecific.h 
> b/Platform/NXP/LS2088aRdbPkg/Include/IfcBoardSpecific.h
> new file mode 100644
> index 000..174a242
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/Include/IfcBoardSpecific.h

Nxp prefix?

> @@ -0,0 +1,114 @@
> +/** IfcBoardSpecificLib.h
> +
> +  IFC Flash Board Specific Macros and structure
> +
> +  Copyright 2017-2018 NXP
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD 
> License
> +  which accompanies this distribution. The full text of the license may be 
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +
> +**/
> +#ifndef __IFC__BOARD_SPECIFIC_H__
> +#define __IFC__BOARD_SPECIFIC_H__

NXP_ prefix?

> +
> +#include 
> +
> +// On board flash support
> +#define IFC_NAND_BUF_BASE0x53000ULL
> +
> +// On board Inegrated flash Controller chip select configuration
> +#define IFC_NOR_CSIFC_CS0
> +#define IFC_NAND_CS   IFC_CS2
> +#define IFC_FPGA_CS   IFC_CS3
> +
> +
> +/* board-specific NAND timing */
> +#define NAND_FTIM0 (IFC_FTIM0_NAND_TCCST(0x0e) | \
> +   IFC_FTIM0_NAND_TWP(0x30)   | \
> +   IFC_FTIM0_NAND_TWCHT(0x0e) | \
> +   IFC_FTIM0_NAND_TWH(0x14))
> +
> +#define NAND_FTIM1 (IFC_FTIM1_NAND_TADLE(0x64) | \
> +   IFC_FTIM1_NAND_TWBE(0xab)  | \
> +   IFC_FTIM1_NAND_TRR(0x1c)   | \
> +   IFC_FTIM1_NAND_TRP(0x30))
> +
> +#define NAND_FTIM2 (IFC_FTIM2_NAND_TRAD(0x1e) | \
> +   IFC_FTIM2_NAND_TREH(0x14) | \
> +   IFC_FTIM2_NAND_TWHRE(0x3c))
> +
> +#define NAND_FTIM3 0x0
> +
> +#define IFC_NAND_BASE_PHYS0x3000
> +#define NAND_CSPR  (IFC_CSPR_PHYS_ADDR(IFC_NAND_BASE_PHYS) \
> +   | IFC_CSPR_PORT_SIZE_8 \
> +   | IFC_CSPR_MSEL_NAND \
> +   | IFC_CSPR_V)
> +
> +#define NAND_CSPR_EXT  0x0
> +#define NAND_AMASK 0x
> +
> +#define NAND_CSOR  (IFC_CSOR_NAND_ECC_ENC_EN /* ECC on encode */ \
> +   | IFC_CSOR_NAND_ECC_DEC_EN /* ECC on decode */ \
> +   | IFC_CSOR_NAND_ECC_MODE_4 /* 4-bit ECC */ \
> +   | IFC_CSOR_NAND_RAL_3   /* RAL = 3 Bytes */ \
> +   | IFC_CSOR_NAND_PGS_4K  /* Page Size = 4K */ \
> +   | IFC_CSOR_NAND_SPRZ_224 /* Spare size = 224 */ \
> +   | IFC_CSOR_NAND_PB(7)) /* 2^7 Pages Per Block */
> +
> +// board-specific NOR timing
> +#define NOR_FTIM0  (IFC_FTIM0_NOR_TACSE(0x4) | \
> +   IFC_FTIM0_NOR_TEADC(0x5) | \
> +   IFC_FTIM0_NOR_TEAHC(0x5))
> +
> +#define NOR_FTIM1  (IFC_FTIM1_NOR_TACO(0x35) | \
> +   IFC_FTIM1_NOR_TRAD_NOR(0x1a) | \
> +   IFC_FTIM1_NOR_TSEQRAD_NOR(0x13))
> +
> +#define NOR_FTIM2  (IFC_FTIM2_NOR_TCS(0x4) | \
> +   IFC_FTIM2_NOR_TCH(0x4) | \
> +   IFC_FTIM2_NOR_TWPH(0xe) | \
> +   IFC_FTIM2_NOR_TWP(0x1c))
> +
> +#define NOR_FTIM3  0x0400
> +
> +#define IFC_FLASH_BASE_PHYS   0x8000
> +#define NOR_CSPR   (IFC_CSPR_PHYS_ADDR(IFC_FLASH_BASE_PHYS) \
> +   | IFC_CSPR_PORT_SIZE_16 \
> +   | IFC_CSPR_MSEL_NOR\
> +   | IFC_CSPR_V)
> +
> +#define NOR_CSPR_EXT   0x0
> +#define NOR_AMASK  IFC_AMASK(128*1024*1024)
> +#define NOR_CSOR   IFC_CSOR_NOR_ADM_SHIFT(12)
> +
> +// board-specific fpga timing
> +#define FPGA_BASE_PHYS 0x2000
> +#define FPGA_CSPR_EXT  0x0
> +#define FPGA_CSPR  (IFC_CSPR_PHYS_ADDR(FPGA_BASE_PHYS) | \
> +   IFC_CSPR_PORT_SIZE_8 | \
> +   IFC_CSPR_MSEL_GPCM | \
> +  

Re: [edk2] [PATCH edk2-platforms 29/41] Compilation : Add the fdf, dsc and dec files

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:43PM +0530, Meenakshi Aggarwal wrote:
> The firmware device, description and declaration files for LS2088 board
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dec |  29 
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc |  96 +
>  Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf | 200 
> +++

No 'Pkg' for dsc/fdf.

>  Silicon/NXP/LS2088A/LS2088A.dec  |  22 +++

Whereas this .dec should probably be a Pkg.

>  Silicon/NXP/LS2088A/LS2088A.dsc.inc  |  71 ++
>  Silicon/NXP/NxpQoriqLs.dec   |  13 ++

And this one (although I didn't spot this when added).

>  6 files changed, 431 insertions(+)
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dec
>  create mode 100755 Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
>  create mode 100644 Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf
>  create mode 100644 Silicon/NXP/LS2088A/LS2088A.dec
>  create mode 100644 Silicon/NXP/LS2088A/LS2088A.dsc.inc
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dec 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dec
> new file mode 100644
> index 000..93d2e5a
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dec
> @@ -0,0 +1,29 @@
> +#  LS2088aRdbPkg.dec
> +#  LS2088a board package.
> +#
> +#  Copyright 2017 NXP
> +#
> +#  This program and the accompanying materials are licensed and made 
> available under
> +#  the terms and conditions of the BSD License which accompanies this 
> distribution.
> +#  The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#
> +
> +[Defines]
> +  PACKAGE_NAME   = LS2088aRdbPkg
> +  PACKAGE_GUID   = 474e0c59-5f77-4060-82dd-9025ee4f4939
> +
> +
> +#
> +# Include Section - list of Include Paths that are provided by this package.
> +#   Comments are used for Keywords and Module Types.
> +#
> +# Supported Module Types:
> +#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
> DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
> +#
> +
> +[Includes.common]
> +  Include# Root include for the package

If needed, this file should have been added with the files added to
that directory.

> diff --git a/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc 
> b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> new file mode 100755
> index 000..465c59e
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.dsc
> @@ -0,0 +1,96 @@
> +#  LS2088aRdbPkg.dsc
> +#
> +#  LS2088ARDB Board package.
> +#
> +#  Copyright 2017 NXP
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD 
> License
> +#  which accompanies this distribution. The full text of the license may be 
> found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#
> +
> +
> +#
> +# Defines Section - statements that will be processed to create a Makefile.
> +#
> +
> +[Defines]
> +  #
> +  # Defines for default states.  These can be changed on the command line.
> +  # -D FLAG=VALUE
> +  #
> +  PLATFORM_NAME  = LS2088aRdbPkg

Drop the 'Pkg'.

> +  PLATFORM_GUID  = be06d8bc-05eb-44d6-b39f-191e93617ebd
> +  OUTPUT_DIRECTORY   = Build/LS2088aRdbPkg
> +  FLASH_DEFINITION   = 
> Platform/NXP/LS2088aRdbPkg/LS2088aRdbPkg.fdf

Please use $(PLATFORM_NAME) instead of repeating the string in the two
lines above.

> +  DEFINE MC_HIGH_MEM = TRUE
> +
> +!include Platform/NXP/NxpQoriqLs.dsc.inc
> +!include Silicon/NXP/LS2088A/LS2088A.dsc.inc
> +
> +[LibraryClasses.common]
> +  SocLib|Silicon/NXP/Library/SocLib/LS2088aSocLib.inf
> +  
> ArmPlatformLib|Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> +  
> ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf
> +  SerialPortLib|Silicon/NXP/Library/DUartPortLib/DUartPortLib.inf
> +  IoAccessLib|Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
> +  RealTimeClockLib|Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.inf
> +
> +[PcdsFixedAtBuild.common]
> +
> +!if $(MC_HIGH_MEM) == 

Re: [edk2] [PATCH 13/13] CryptoPkg/BaseCryptLib: allow MM_STANDALONE drivers to use this library

2018-12-21 Thread Ard Biesheuvel
On Fri, 14 Dec 2018 at 13:14, Jagadeesh Ujja  wrote:
>
> “BaseCryptLib” library can be used by MM_STANDALONE drivers as well.
> So add MM_STANDALONE as the module type this library supports.
>

This patch affects other drivers as well. Also, shouldn't we be using
SmmCryptLib for MM_STANDALONE?

The MODULE_TYPE of SmmCryptLib can be changed to BASE since it doesn't
have a constructor. I think that should also address your time()
issue, no?

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf   |  7 ++-
>  CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf|  4 
>  CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 15 +--
>  3 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 
> b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> index f29445c..b6ebac5 100644
> --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> @@ -7,6 +7,7 @@
>  #  buffer overflow or integer overflow.
>  #
>  #  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2018, ARM Limited. All rights reserved.
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD 
> License
>  #  which accompanies this distribution.  The full text of the license may be 
> found at
> @@ -24,7 +25,7 @@
>FILE_GUID  = be3bb803-91b6-4da0-bd91-a8b21c18ca5d
>MODULE_TYPE= DXE_DRIVER
>VERSION_STRING = 1.0
> -  LIBRARY_CLASS  = BaseCryptLib|DXE_DRIVER DXE_CORE 
> UEFI_APPLICATION UEFI_DRIVER
> +  LIBRARY_CLASS  = BaseCryptLib|DXE_DRIVER DXE_CORE 
> UEFI_APPLICATION UEFI_DRIVER MM_STANDALONE
>
>  #
>  # The following information is for reference only and not required by the 
> build tools.
> @@ -85,6 +86,10 @@
>OpensslLib
>IntrinsicLib
>PrintLib
> +  PcdLib
> +
> +[Pcd]
> +  gEfiMdePkgTokenSpaceGuid.PcdStandaloneMmCodeEnabled
>
>  #
>  # Remove these [BuildOptions] after this library is cleaned up
> diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf 
> b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> index 32628c8..fb16451 100644
> --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> @@ -91,6 +91,10 @@
>OpensslLib
>IntrinsicLib
>PrintLib
> +  PcdLib
> +
> +[Pcd]
> +  gEfiMdePkgTokenSpaceGuid.PcdStandaloneMmCodeEnabled
>
>  #
>  # Remove these [BuildOptions] after this library is cleaned up
> diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c 
> b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> index 5f9b0c2..de8e756 100644
> --- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> @@ -3,6 +3,7 @@
>for OpenSSL-based Cryptographic Library (used in DXE & RUNTIME).
>
>  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2018, ARM Limited. All rights reserved.
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD 
> License
>  which accompanies this distribution.  The full text of the license may be 
> found at
> @@ -77,12 +78,14 @@ time_t time (time_t *timer)
>time_t  CalTime;
>UINTN   Year;
>
> -  //
> -  // Get the current time and date information
> -  //
> -  Status = gRT->GetTime (, NULL);
> -  if (EFI_ERROR (Status) || (Time.Year < 1970)) {
> -return 0;
> +  if (!PcdGetBool (PcdStandaloneMmCodeEnabled)) {
> +//
> +// Get the current time and date information
> +//
> +Status = gRT->GetTime (, NULL);
> +if (EFI_ERROR (Status) || (Time.Year < 1970)) {
> +  return 0;
> +}
>}
>
>//
> --
> 2.7.4
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1] Maintainers.txt: Change DynamicTablesPkg maintainer

2018-12-21 Thread Sami Mujawar
Hi All,

This patch has been acked by:
Reviewed by: Alexei Fedorov 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Leif Lindholm 
Reviewed-by: Michael D Kinney 

The Github account details for Alexei are as below:
GitHub ID: AlexeiFedorov
Email: Alexei Fedorov 

I can confirm that Evan is no longer evan.ll...@arm.com, so that account can't 
give an r-b on the change.

Is there anything else that is needed before this patch is accepted?

Regards,

Sami Mujawar

-Original Message-
From: Kinney, Michael D  
Sent: 13 November 2018 10:13 PM
To: Leif Lindholm ; Sami Mujawar 
; Kinney, Michael D 
Cc: edk2-devel@lists.01.org; ard.biesheu...@linaro.org; Matteo Carlini 
; Stephanie Hughes-Fitt 
; Alexei Fedorov ; 
Andrew Fish ; Laszlo Ersek 
Subject: RE: [PATCH v1] Maintainers.txt: Change DynamicTablesPkg maintainer

Reviewed-by: Michael D Kinney 

> -Original Message-
> From: Leif Lindholm [mailto:leif.lindh...@linaro.org]
> Sent: Tuesday, November 13, 2018 2:08 PM
> To: Sami Mujawar 
> Cc: edk2-devel@lists.01.org; ard.biesheu...@linaro.org; 
> matteo.carl...@arm.com; stephanie.hughes-f...@arm.com; 
> alexei.fedo...@arm.com; Andrew Fish ; Laszlo Ersek 
> ; Kinney, Michael D 
> Subject: Re: [PATCH v1] Maintainers.txt: Change DynamicTablesPkg 
> maintainer
> 
> +Andrew, Laszlo and Mike.
> 
> Hi Sami,
> 
> For my part, I can confirm that Evan is no longer evan.ll...@arm.com, 
> so that account can't give an r-b on the change.
> 
> Reviewed-by: Leif Lindholm 
> 
> On Mon, Nov 12, 2018 at 04:27:46PM +, Sami Mujawar
> wrote:
> > Removing Evan and adding Alexei as the co-maintainer.
> >
> > Contributed-under: TianoCore Contribution Agreement
> 1.1
> > Signed-off-by: Sami Mujawar 
> > ---
> >  Maintainers.txt | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/Maintainers.txt b/Maintainers.txt index
> cd2a310cbd8c17a8d893c5c747025d1cef1ac433..7b3cb9a0255bf
> 7c249c8202666332e3c4fd83e6c 100644
> > --- a/Maintainers.txt
> > +++ b/Maintainers.txt
> > @@ -106,8 +106,8 @@ M: Hao Wu 
> >
> >  DynamicTablesPkg
> >  W:
> https://github.com/tianocore/tianocore.github.io/wiki/D
> ynamicTablesPkg
> > -M: Evan Lloyd 
> >  M: Sami Mujawar 
> > +M: Alexei Fedorov 
> >
> >  EdkCompatibilityPkg
> >  W:
> https://github.com/tianocore/tianocore.github.io/wiki/E
> dkCompatibilityPkg
> > --
> > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> >
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms 28/41] Silicon/Maxim: DS3232 RTC Library Support

2018-12-21 Thread Ard Biesheuvel
On Fri, 21 Dec 2018 at 10:56, Leif Lindholm  wrote:
>
> On Wed, Nov 28, 2018 at 08:31:42PM +0530, Meenakshi Aggarwal wrote:
> > From: Wasim Khan 
> >
> > Add Maxim DS3232 RTC Library support
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Wasim Khan 
> > Signed-off-by: Meenakshi Aggarwal 
> > Reviewed-by: Leif Lindholm 
> > ---
> >  Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h |  49 +++
> >  Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c  | 420 
> > +
> >  .../Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.dec|  34 ++
> >  .../Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.inf|  50 +++
> >  4 files changed, 553 insertions(+)
> >  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h
> >  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c
> >  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.dec
> >  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.inf
> >
> > diff --git a/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h 
> > b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h
> > new file mode 100644
> > index 000..cd1a321
> > --- /dev/null
> > +++ b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h
> > @@ -0,0 +1,49 @@
> > +/** Ds3232Rtc.h
> > +*
> > +*  Copyright 2017 NXP
> > +*
> > +*  This program and the accompanying materials
> > +*  are licensed and made available under the terms and conditions of the 
> > BSD License
> > +*  which accompanies this distribution.  The full text of the license may 
> > be found at
> > +*  http://opensource.org/licenses/bsd-license.php
> > +*
> > +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> > IMPLIED.
> > +*
> > +**/
> > +
> > +#ifndef __DS3232RTC_H__
> > +#define __DS3232RTC_H__
> > +
> > +//RTC time register
> > +#define DS3232_SEC_REG_ADDR0x00
> > +#define DS3232_MIN_REG_ADDR0x01
> > +#define DS3232_HR_REG_ADDR 0x02
> > +#define DS3232_DAY_REG_ADDR0x03
> > +#define DS3232_DATE_REG_ADDR   0x04
> > +#define DS3232_MON_REG_ADDR0x05
> > +#define DS3232_YR_REG_ADDR 0x06
> > +
> > +#define DS3232_SEC_BIT_CH  0x80  // Clock Halt (in Register 0)
> > +
> > +//RTC control register
> > +#define DS3232_CTL_REG_ADDR0x0e
> > +#define DS3232_STAT_REG_ADDR   0x0f
> > +
> > +#define START_YEAR 1970
> > +#define END_YEAR   2070
> > +
> > +//TIME MASKS
> > +#define MASK_SEC   0x7F
> > +#define MASK_MIN   0x7F
> > +#define MASK_HOUR  0x3F
> > +#define MASK_DAY   0x3F
> > +#define MASK_MONTH 0x1F
> > +
> > +typedef struct {
> > +  UINTN   OperationCount;
> > +  EFI_I2C_OPERATION   SetAddressOp;
> > +  EFI_I2C_OPERATION   GetSetDateTimeOp;
> > +} RTC_I2C_REQUEST;
> > +
> > +#endif // __DS3232RTC_H__
> > diff --git a/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c 
> > b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c
> > new file mode 100644
> > index 000..3ab94a8
> > --- /dev/null
> > +++ b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c
> > @@ -0,0 +1,420 @@
> > +/** Ds3232RtcLib.c
> > +*  Implement EFI RealTimeClock via RTC Lib for DS3232 RTC.
> > +*
> > +*  Based on RTC implementation available in
> > +*  EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
> > +*
> > +*  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > +*  Copyright 2017 NXP
> > +*
> > +*  This program and the accompanying materials
> > +*  are licensed and made available under the terms and conditions of the 
> > BSD License
> > +*  which accompanies this distribution.  The full text of the license may 
> > be found at
> > +*  http://opensource.org/licenses/bsd-license.php
> > +*
> > +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> > IMPLIED.
> > +*
> > +**/
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "Ds3232Rtc.h"
> > +
> > +STATIC VOID   *mDriverEventRegistration;
> > +STATIC EFI_HANDLE mI2cMasterHandle;
> > +STATIC EFI_I2C_MASTER_PROTOCOL*mI2cMaster;
> > +
> > +/**
> > +  Read RTC register.
> > +
> > +  @param  SlaveDeviceAddress   Slave device address offset of RTC to be 
> > read.
> > +  @param  RtcRegAddr   Register offset of RTC to be read.
> > +
> > +  @retval  Register Value read
> > +
> > +**/
> > +STATIC
> > +UINT8
> > +RtcRead (
> > +  IN  UINT8SlaveDeviceAddress,
> > +  IN  UINT8RtcRegAddr
> > +  )
> > +{
> > +  RTC_I2C_REQUEST  Req;
> > +  EFI_STATUS   Status;
> > +  UINT8

Re: [edk2] [PATCH edk2-platforms 28/41] Silicon/Maxim: DS3232 RTC Library Support

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:42PM +0530, Meenakshi Aggarwal wrote:
> From: Wasim Khan 
> 
> Add Maxim DS3232 RTC Library support
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> Signed-off-by: Meenakshi Aggarwal 
> Reviewed-by: Leif Lindholm 
> ---
>  Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h |  49 +++
>  Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c  | 420 
> +
>  .../Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.dec|  34 ++
>  .../Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.inf|  50 +++
>  4 files changed, 553 insertions(+)
>  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h
>  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c
>  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.dec
>  create mode 100644 Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.inf
> 
> diff --git a/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h 
> b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h
> new file mode 100644
> index 000..cd1a321
> --- /dev/null
> +++ b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232Rtc.h
> @@ -0,0 +1,49 @@
> +/** Ds3232Rtc.h
> +*
> +*  Copyright 2017 NXP
> +*
> +*  This program and the accompanying materials
> +*  are licensed and made available under the terms and conditions of the BSD 
> License
> +*  which accompanies this distribution.  The full text of the license may be 
> found at
> +*  http://opensource.org/licenses/bsd-license.php
> +*
> +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +*
> +**/
> +
> +#ifndef __DS3232RTC_H__
> +#define __DS3232RTC_H__
> +
> +//RTC time register
> +#define DS3232_SEC_REG_ADDR0x00
> +#define DS3232_MIN_REG_ADDR0x01
> +#define DS3232_HR_REG_ADDR 0x02
> +#define DS3232_DAY_REG_ADDR0x03
> +#define DS3232_DATE_REG_ADDR   0x04
> +#define DS3232_MON_REG_ADDR0x05
> +#define DS3232_YR_REG_ADDR 0x06
> +
> +#define DS3232_SEC_BIT_CH  0x80  // Clock Halt (in Register 0)
> +
> +//RTC control register
> +#define DS3232_CTL_REG_ADDR0x0e
> +#define DS3232_STAT_REG_ADDR   0x0f
> +
> +#define START_YEAR 1970
> +#define END_YEAR   2070
> +
> +//TIME MASKS
> +#define MASK_SEC   0x7F
> +#define MASK_MIN   0x7F
> +#define MASK_HOUR  0x3F
> +#define MASK_DAY   0x3F
> +#define MASK_MONTH 0x1F
> +
> +typedef struct {
> +  UINTN   OperationCount;
> +  EFI_I2C_OPERATION   SetAddressOp;
> +  EFI_I2C_OPERATION   GetSetDateTimeOp;
> +} RTC_I2C_REQUEST;
> +
> +#endif // __DS3232RTC_H__
> diff --git a/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c 
> b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c
> new file mode 100644
> index 000..3ab94a8
> --- /dev/null
> +++ b/Silicon/Maxim/Library/Ds3232RtcLib/Ds3232RtcLib.c
> @@ -0,0 +1,420 @@
> +/** Ds3232RtcLib.c
> +*  Implement EFI RealTimeClock via RTC Lib for DS3232 RTC.
> +*
> +*  Based on RTC implementation available in
> +*  EmbeddedPkg/Library/TemplateRealTimeClockLib/RealTimeClockLib.c
> +*
> +*  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> +*  Copyright 2017 NXP
> +*
> +*  This program and the accompanying materials
> +*  are licensed and made available under the terms and conditions of the BSD 
> License
> +*  which accompanies this distribution.  The full text of the license may be 
> found at
> +*  http://opensource.org/licenses/bsd-license.php
> +*
> +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +*
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "Ds3232Rtc.h"
> +
> +STATIC VOID   *mDriverEventRegistration;
> +STATIC EFI_HANDLE mI2cMasterHandle;
> +STATIC EFI_I2C_MASTER_PROTOCOL*mI2cMaster;
> +
> +/**
> +  Read RTC register.
> +
> +  @param  SlaveDeviceAddress   Slave device address offset of RTC to be read.
> +  @param  RtcRegAddr   Register offset of RTC to be read.
> +
> +  @retval  Register Value read
> +
> +**/
> +STATIC
> +UINT8
> +RtcRead (
> +  IN  UINT8SlaveDeviceAddress,
> +  IN  UINT8RtcRegAddr
> +  )
> +{
> +  RTC_I2C_REQUEST  Req;
> +  EFI_STATUS   Status;
> +  UINT8Val;
> +
> +  Val = 0;
> +
> +  Req.OperationCount = 2;
> +
> +  Req.SetAddressOp.Flags = 0;
> +  Req.SetAddressOp.LengthInBytes = sizeof (RtcRegAddr);
> +  Req.SetAddressOp.Buffer = 
> +
> +  Req.GetSetDateTimeOp.Flags = I2C_FLAG_READ;
> +  Req.GetSetDateTimeOp.LengthInBytes = sizeof (Val);
> +  Req.GetSetDateTimeOp.Buffer = 
> +
> +  

Re: [edk2] [PATCH edk2-platforms 27/41] Platform/NXP: Add Platform driver for LS2088 RDB board

2018-12-21 Thread Leif Lindholm
Add a commit message describing what the driver does, please.

On Wed, Nov 28, 2018 at 08:31:41PM +0530, Meenakshi Aggarwal wrote:
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  .../Drivers/PlatformDxe/PlatformDxe.c  | 119 
> +
>  .../Drivers/PlatformDxe/PlatformDxe.inf|  58 ++
>  2 files changed, 177 insertions(+)
>  create mode 100644 
> Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
>  create mode 100644 
> Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c 
> b/Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
> new file mode 100644
> index 000..667e750
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.c
> @@ -0,0 +1,119 @@
> +/** @file
> +  LS2088 RDB board DXE platform driver.
> +
> +  Copyright 2018 NXP
> +
> +  This program and the accompanying materials are licensed and made available
> +  under the terms and conditions of the BSD License which accompanies this
> +  distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +typedef struct {
> +  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR StartDesc;
> +  UINT8 EndDesc;
> +} ADDRESS_SPACE_DESCRIPTOR;
> +
> +STATIC ADDRESS_SPACE_DESCRIPTOR mI2cDesc[FixedPcdGet64 
> (PcdNumI2cController)];
> +
> +STATIC
> +EFI_STATUS
> +RegisterDevice (
> +  IN  EFI_GUID*TypeGuid,
> +  IN  ADDRESS_SPACE_DESCRIPTOR*Desc,
> +  OUT EFI_HANDLE  *Handle
> +  )
> +{
> +  NON_DISCOVERABLE_DEVICE *Device;
> +  EFI_STATUS  Status;
> +
> +  Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device));
> +  if (Device == NULL) {
> +return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  Device->Type = TypeGuid;
> +  Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent;
> +  Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Desc;
> +
> +  Status = gBS->InstallMultipleProtocolInterfaces (Handle,
> +  , Device,
> +  NULL);
> +  if (EFI_ERROR (Status)) {
> +goto FreeDevice;
> +  }
> +  return EFI_SUCCESS;
> +
> +FreeDevice:
> +  FreePool (Device);
> +
> +  return Status;
> +}
> +
> +VOID
> +PopulateI2cInformation (
> +  IN VOID
> +  )
> +{
> +  UINT32 Index;
> +
> +  for (Index = 0; Index < FixedPcdGet32 (PcdNumI2cController); Index++) {
> +mI2cDesc[Index].StartDesc.Desc = ACPI_ADDRESS_SPACE_DESCRIPTOR;
> +mI2cDesc[Index].StartDesc.Len = sizeof 
> (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3;
> +mI2cDesc[Index].StartDesc.ResType = ACPI_ADDRESS_SPACE_TYPE_MEM;
> +mI2cDesc[Index].StartDesc.GenFlag = 0;
> +mI2cDesc[Index].StartDesc.SpecificFlag = 0;
> +mI2cDesc[Index].StartDesc.AddrSpaceGranularity = 32;
> +mI2cDesc[Index].StartDesc.AddrRangeMin = FixedPcdGet64 (PcdI2c0BaseAddr) 
> +
> + (Index * FixedPcdGet32 
> (PcdI2cSize));
> +mI2cDesc[Index].StartDesc.AddrRangeMax = 
> mI2cDesc[Index].StartDesc.AddrRangeMin +
> + FixedPcdGet32 (PcdI2cSize) - 1;
> +mI2cDesc[Index].StartDesc.AddrTranslationOffset = 0;
> +mI2cDesc[Index].StartDesc.AddrLen = FixedPcdGet32 (PcdI2cSize);
> +
> +mI2cDesc[Index].EndDesc = ACPI_END_TAG_DESCRIPTOR;

This comes with the same problem I mentioned in a similar place for
another platform. Among other things, that gives the impression this
could be broken out into a separate helper library and fixed once
rather than several times.

/
Leif

> +  }
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +PlatformDxeEntryPoint (
> +  IN EFI_HANDLE ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_HANDLE  Handle;
> +
> +  Handle = NULL;
> +
> +  PopulateI2cInformation ();
> +
> +  Status = RegisterDevice (,
> + [0], );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  //
> +  // Install the DS3232 I2C Master protocol on this handle so the RTC driver
> +  // can identify it as the I2C master it can invoke directly.
> +  //
> +  Status = gBS->InstallProtocolInterface (,
> +  ,
> +  EFI_NATIVE_INTERFACE, NULL);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  return EFI_SUCCESS;
> +}
> diff --git a/Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf 
> b/Platform/NXP/LS2088aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> new file mode 100644
> index 000..1972022
> --- /dev/null
> +++ 

Re: [edk2] [PATCH edk2-platforms 26/41] Platform/NXP/LS2088aRdbPkg: ArmPlatformLib Support for LS2088ARDB

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:40PM +0530, Meenakshi Aggarwal wrote:
> From: Wasim Khan 
> 
> Add support of ArmPlatformLib for NXP LS2088ARDB board
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> Signed-off-by: Meenakshi Aggarwal 
> Reviewed-by: Leif Lindholm 
> ---
>  .../Library/PlatformLib/ArmPlatformLib.c   | 106 
>  .../Library/PlatformLib/ArmPlatformLib.inf |  77 +
>  .../Library/PlatformLib/NxpQoriqLsHelper.S |  35 
>  .../Library/PlatformLib/NxpQoriqLsMem.c| 189 
> +
>  4 files changed, 407 insertions(+)
>  create mode 100644 
> Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.c
>  create mode 100644 
> Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
>  create mode 100644 
> Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsHelper.S
>  create mode 100644 
> Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/NxpQoriqLsMem.c
> 
> diff --git a/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.c 
> b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.c
> new file mode 100644
> index 000..90f14ba
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.c
> @@ -0,0 +1,106 @@
> +/** ArmPlatformLib.c
> +*
> +*  Contains board initialization functions.
> +*
> +*  Based on BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoard.c
> +*
> +*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.
> +*  Copyright (c) 2016, Freescale Semiconductor, Inc. All rights reserved.
> +*  Copyright 2017 NXP
> +*
> +*  This program and the accompanying materials
> +*  are licensed and made available under the terms and conditions of the BSD 
> License
> +*  which accompanies this distribution.  The full text of the license may be 
> found at
> +*  http://opensource.org/licenses/bsd-license.php
> +*
> +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +*
> +**/
> +
> +#include 
> +#include 
> +
> +extern VOID SocInit (VOID);

Pull in declaration from some header file.

> +
> +/**
> +  Return the current Boot Mode
> +
> +  This function returns the boot reason on the platform
> +
> +**/
> +EFI_BOOT_MODE
> +ArmPlatformGetBootMode (
> +  VOID
> +  )
> +{
> +  return BOOT_WITH_FULL_CONFIGURATION;
> +}
> +
> +/**
> +  Placeholder for Platform Initialization
> +
> +**/
> +EFI_STATUS
> +ArmPlatformInitialize (
> +  IN  UINTN   MpId
> +  )
> +{
> + SocInit ();
> +
> + return EFI_SUCCESS;
> +}
> +
> +ARM_CORE_INFO LS2088aMpCoreInfoCTA72x4[] = {

STATIC.
m-prefix.
Move before all function definitions.

> +  {
> +// Cluster 0, Core 0
> +0x0, 0x0,
> +
> +// MP Core MailBox Set/Get/Clear Addresses and Clear Value
> +(EFI_PHYSICAL_ADDRESS)0,
> +(EFI_PHYSICAL_ADDRESS)0,
> +(EFI_PHYSICAL_ADDRESS)0,
> +(UINT64)0x
> +  },
> +};
> +
> +EFI_STATUS
> +PrePeiCoreGetMpCoreInfo (
> +  OUT UINTN   *CoreCount,
> +  OUT ARM_CORE_INFO   **ArmCoreTable
> +  )
> +{
> +  *CoreCount= sizeof (LS2088aMpCoreInfoCTA72x4) / sizeof (ARM_CORE_INFO);
> +  *ArmCoreTable = LS2088aMpCoreInfoCTA72x4;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };

STATIC.
Move before all function definitions.

> +
> +EFI_PEI_PPI_DESCRIPTOR  gPlatformPpiTable[] = {

STATIC.
m-prefix sufficient.
Move before all function definitions.

> +  {
> +EFI_PEI_PPI_DESCRIPTOR_PPI,
> +,
> +
> +  }
> +};
> +
> +VOID
> +ArmPlatformGetPlatformPpiList (
> +  OUT UINTN   *PpiListSize,
> +  OUT EFI_PEI_PPI_DESCRIPTOR  **PpiList
> +  )
> +{
> +  *PpiListSize = sizeof (gPlatformPpiTable);
> +  *PpiList = gPlatformPpiTable;
> +}
> +
> +
> +UINTN
> +ArmPlatformGetCorePosition (
> +  IN UINTN MpId
> +  )
> +{
> +  return 1;
> +}
> diff --git 
> a/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf 
> b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> new file mode 100644
> index 000..f5e5abd
> --- /dev/null
> +++ b/Platform/NXP/LS2088aRdbPkg/Library/PlatformLib/ArmPlatformLib.inf
> @@ -0,0 +1,77 @@
> +#/**  @file
> +#
> +#  Copyright (c) 2016, Freescale Semiconductor, Inc. All rights reserved.
> +#  Copyright 2017 NXP
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD 
> License
> +#  which accompanies this distribution.  The full text of the license may be 
> found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +#**/
> +
> +[Defines]
> +  INF_VERSION= 0x0001001A
> +  BASE_NAME  = PlatformLib
> +  

Re: [edk2] [PATCH edk2-platforms 25/41] Silicon/NXP:SocLib support for initialization of peripherals

2018-12-21 Thread Leif Lindholm
On Wed, Nov 28, 2018 at 08:31:39PM +0530, Meenakshi Aggarwal wrote:
> From: Wasim Khan 
> 
> Added SocInit function that initializes peripherals
> and print board and soc information for LS2088ARDB Board.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wasim Khan 
> Signed-off-by: Meenakshi Aggarwal 
> ---
>  Silicon/NXP/Include/Chassis3/SerDes.h|  91 ++
>  Silicon/NXP/Include/Chassis3/Soc.h   | 144 +
>  Silicon/NXP/LS2088A/Include/SocSerDes.h  |  67 ++
>  Silicon/NXP/Library/SocLib/Chassis.c |  38 ++
>  Silicon/NXP/Library/SocLib/Chassis.h |  17 +++
>  Silicon/NXP/Library/SocLib/Chassis3/Soc.c| 180 
> +++
>  Silicon/NXP/Library/SocLib/LS2088aSocLib.inf |  50 
>  Silicon/NXP/Library/SocLib/SerDes.c  |   3 +
>  8 files changed, 590 insertions(+)
>  create mode 100644 Silicon/NXP/Include/Chassis3/SerDes.h
>  create mode 100644 Silicon/NXP/Include/Chassis3/Soc.h
>  create mode 100644 Silicon/NXP/LS2088A/Include/SocSerDes.h
>  create mode 100644 Silicon/NXP/Library/SocLib/Chassis3/Soc.c
>  create mode 100644 Silicon/NXP/Library/SocLib/LS2088aSocLib.inf
> 
> diff --git a/Silicon/NXP/Include/Chassis3/SerDes.h 
> b/Silicon/NXP/Include/Chassis3/SerDes.h
> new file mode 100644
> index 000..a77ddd5
> --- /dev/null
> +++ b/Silicon/NXP/Include/Chassis3/SerDes.h
> @@ -0,0 +1,91 @@
> +/** SerDes.h
> + The Header file of SerDes Module for Chassis 3
> +
> + Copyright 2017 NXP
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD 
> License
> + which accompanies this distribution. The full text of the license may be 
> found
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +
> +**/
> +
> +#ifndef __SERDES_H__
> +#define __SERDES_H__

NXP_ prefix?

> +
> +#include 
> +
> +#define SRDS_MAX_LANES8
> +
> +//
> +// SerDes lane protocols/devices
> +//
> +typedef enum {
> +  NONE = 0,
> +  PCIE1,
> +  PCIE2,
> +  PCIE3,
> +  PCIE4,
> +  SATA1,
> +  SATA2,
> +  XAUI1,
> +  XAUI2,
> +  XFI1,
> +  XFI2,
> +  XFI3,
> +  XFI4,
> +  XFI5,
> +  XFI6,
> +  XFI7,
> +  XFI8,
> +  SGMII1,
> +  SGMII2,
> +  SGMII3,
> +  SGMII4,
> +  SGMII5,
> +  SGMII6,
> +  SGMII7,
> +  SGMII8,
> +  SGMII9,
> +  SGMII10,
> +  SGMII11,
> +  SGMII12,
> +  SGMII13,
> +  SGMII14,
> +  SGMII15,
> +  SGMII16,
> +  QSGMII_A,
> +  QSGMII_B,
> +  QSGMII_C,
> +  QSGMII_D,
> +  // Number of entries in this enum
> +  SERDES_PRTCL_COUNT

CamelCase for enum member names - throughout.

> +} SERDES_PROTOCOL;
> +
> +typedef enum {
> +  SRDS_1  = 0,
> +  SRDS_2,
> +  SRDS_MAX_NUM
> +} SERDES_NUMBER;
> +
> +typedef struct {
> +  UINT16 Protocol;
> +  UINT8  SrdsLane[SRDS_MAX_LANES];
> +} SERDES_CONFIG;
> +
> +typedef VOID
> +(*SERDES_PROBE_LANES_CALLBACK) (
> +  IN SERDES_PROTOCOL LaneProtocol,
> +  IN VOID *Arg
> +  );
> +
> +VOID
> +SerDesProbeLanes(
> +  IN SERDES_PROBE_LANES_CALLBACK SerDesLaneProbeCallback,
> +  IN VOID *Arg
> +  );
> +
> +#endif /* __SERDES_H */
> diff --git a/Silicon/NXP/Include/Chassis3/Soc.h 
> b/Silicon/NXP/Include/Chassis3/Soc.h
> new file mode 100644
> index 000..8d967e7
> --- /dev/null
> +++ b/Silicon/NXP/Include/Chassis3/Soc.h
> @@ -0,0 +1,144 @@
> +/** Soc.h
> +*  Header defining the Base addresses, sizes, flags etc for chassis 1
> +*
> +*  Copyright 2017 NXP
> +*
> +*  This program and the accompanying materials
> +*  are licensed and made available under the terms and conditions of the BSD 
> License
> +*  which accompanies this distribution.  The full text of the license may be 
> found at
> +*  http://opensource.org/licenses/bsd-license.php
> +*
> +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
> IMPLIED.
> +*
> +**/
> +
> +#ifndef __SOC_H__
> +#define __SOC_H__

NXP_ prefix?

> +
> +#define FSL_CLK_GRPA_ADDR  0x0130
> +#define FSL_CLK_GRPB_ADDR  0x0131
> +
> +#define FSL_CLUSTER_CLOCKS { 1, 1, 4, 4 } /* LS208x */
> +#define TP_CLUSTER_EOC_MASK0x8000  /* Mask for End of 
> clusters */
> +#define NUM_CC_PLLS6
> +#define CLK_FREQ   1
> +#define MAX_CPUS   16
> +#define CHECK_CLUSTER(Cluster) ((Cluster & TP_CLUSTER_EOC_MASK) != 
> TP_CLUSTER_EOC_MASK)
> +
> +/* RCW SERDES MACRO */
> +#define RCWSR_INDEX28
> +#define RCWSR_SRDS1_PRTCL_MASK 0x00ff
> +#define RCWSR_SRDS1_PRTCL_SHIFT16
> +#define RCWSR_SRDS2_PRTCL_MASK 0xff00
> +#define RCWSR_SRDS2_PRTCL_SHIFT24
> +
> +/* SMMU Defintions */
> +#define SMMU_BASE_ADDR 0x0500
> +#define SMMU_REG_SCR0  (SMMU_BASE_ADDR + 0x0)
> 

Re: [edk2] [PATCH 03/13] MdeModulePkg: Add a PCD to indicate Standalone MM supports secure variable

2018-12-21 Thread Ard Biesheuvel
On Fri, 14 Dec 2018 at 13:13, Jagadeesh Ujja  wrote:
>
> Add a flag that indicates whether Standalone MM mode supports
> secure storage of variables.
>

Why? And why does it need to reside in MdeModulePkg?


> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
> index 41d2b04..badea4a 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1041,6 +1041,11 @@
># @Prompt Enable UEFI Stack Guard.
>gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
>
> +  ## This flag indicates secure variable functionality is implemented by 
> Standalone MM
> +  #  TRUE  - Secure variable storage supported by Standalone MM code.
> +  #  FALSE - Standalone MM code does not support secure storage of variables
> +  
> gEfiMdeModulePkgTokenSpaceGuid.PcdStandaloneMmVariableEnabled|FALSE|BOOLEAN|0x30001056
> +
>  [PcdsFixedAtBuild, PcdsPatchableInModule]
>## Dynamic type PCD can be registered callback function for Pcd setting 
> action.
>#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of 
> callback function
> --
> 2.7.4
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 02/13] MdePkg: Add a PCD that indicates presence of Standalone MM mode

2018-12-21 Thread Ard Biesheuvel
On Fri, 14 Dec 2018 at 13:13, Jagadeesh Ujja  wrote:
>
> Add a flag to indicate the presence of Standalone MM mode. For existing
> library and/or drivers that can be refactored to be used as a Standalone
> MM component, this flag can be used to choose the portions of the code
> that gets executed in Standalone MM.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  MdePkg/MdePkg.dec | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> index 712bd46..af694fc 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -2073,6 +2073,11 @@
># @Prompt Fixed Debug Message Print Level.
>
> gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel|0x|UINT32|0x30001016
>
> +  ## This flag indicates Standalone MM execution mode is enabled
> +  #  TRUE  - Standalone MM execution mode is enabled
> +  #  FALSE - Standalone MM execution mode is not enabled
> +  
> gEfiMdePkgTokenSpaceGuid.PcdStandaloneMmCodeEnabled|FALSE|BOOLEAN|0x30001017
> +

Shouldn't this be implied by the chosen library resolution?

>  [PcdsFixedAtBuild,PcdsPatchableInModule]
>## Indicates the maximum length of unicode string used in the following
>#  BaseLib functions: StrLen(), StrSize(), StrCmp(), StrnCmp(), StrCpy(), 
> StrnCpy()
> --
> 2.7.4
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 01/13] StandaloneMmPkg: Pull in additonal libraries from staging branch

2018-12-21 Thread Ard Biesheuvel
Hello Jagadeesh,

Please drop the reference to the staging branch from the subject and
from below, it is not relevant.

On Fri, 14 Dec 2018 at 13:13, Jagadeesh Ujja  wrote:
>
> Three additional library packages are being pulled into StandaloneMmPkg
> from the staging area in order to support the secure variable service.
> The three packages being pulled in are
>   - StandaloneMmHobLib
>   - StandaloneMmMemoryAllocationLib
>   - StandaloneMmServicesTableLib
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
>|   2 +-
>  
> StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
>  |  64 ++
>  StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c  
>| 655 
>  StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>|  48 ++
>  
> StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.c
>| 824 
>  
> StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
>  |  45 ++
>  
> StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c
>  |  64 ++
>  
> StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
>|  36 +
>  8 files changed, 1737 insertions(+), 1 deletion(-)
>
> diff --git 
> a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf 
> b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
> index db19d3c..ac036e3 100644
> --- 
> a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
> +++ 
> b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
> @@ -24,7 +24,7 @@
>MODULE_TYPE= MM_CORE_STANDALONE
>VERSION_STRING = 1.0
>PI_SPECIFICATION_VERSION   = 0x00010032
> -  LIBRARY_CLASS  = HobLib|MM_CORE_STANDALONE MM_STANDALONE
> +  LIBRARY_CLASS  = HobLib|MM_CORE_STANDALONE
>
>  #
>  #  VALID_ARCHITECTURES   = AARCH64

This is an unrelated change.

> diff --git 
> a/StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
>  
> b/StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
> new file mode 100644
> index 000..ac5a1c0
> --- /dev/null
> +++ 
> b/StandaloneMmPkg/Library/StandaloneMmHobLib/AArch64/StandaloneMmCoreHobLibInternal.c
> @@ -0,0 +1,64 @@
> +/** @file
> +  HOB Library implementation for Standalone MM Core.
> +
> +Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
> +Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
> +
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD 
> License
> +which accompanies this distribution.  The full text of the license may be 
> found at
> +http://opensource.org/licenses/bsd-license.php.
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +//
> +// Cache copy of HobList pointer.
> +//
> +extern VOID *gHobList;
> +
> +EFI_HOB_HANDOFF_INFO_TABLE*
> +HobConstructor (
> +  IN VOID   *EfiMemoryBegin,
> +  IN UINTN  EfiMemoryLength,
> +  IN VOID   *EfiFreeMemoryBottom,
> +  IN VOID   *EfiFreeMemoryTop
> +  )
> +{
> +  EFI_HOB_HANDOFF_INFO_TABLE  *Hob;
> +  EFI_HOB_GENERIC_HEADER  *HobEnd;
> +
> +  Hob= EfiFreeMemoryBottom;
> +  HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
> +
> +  Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
> +  Hob->Header.HobLength   = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
> +  Hob->Header.Reserved= 0;
> +
> +  HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
> +  HobEnd->HobLength   = sizeof(EFI_HOB_GENERIC_HEADER);
> +  HobEnd->Reserved= 0;
> +
> +  Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
> +  Hob->BootMode= BOOT_WITH_FULL_CONFIGURATION;
> +
> +  Hob->EfiMemoryTop= (UINTN)EfiMemoryBegin + EfiMemoryLength;
> +  Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
> +  Hob->EfiFreeMemoryTop= (UINTN)EfiFreeMemoryTop;
> +  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
> +  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
> +
> +  gHobList = Hob;
> +
> +  return Hob;
> +}
> diff --git a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c 
> b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
> new file mode 100644
> index 000..591a78c
> --- /dev/null
> +++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
> @@ -0,0 +1,655 @@
> +/** @file
> +  HOB Library