Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer

2018-05-09 Thread Bi, Dandan
Hi Ray,

Thanks for your suggestion. But we have committed this patch yesterday. :(
I will pay more attention to the commit message in the future work.


Thanks,
Dandan

-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, May 10, 2018 11:34 AM
To: Gary Lin ; Bi, Dandan 
Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao, Liming 

Subject: RE: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized 
pointer

Dandan,
Can you describe the build failure met by Gary Lin in final commit message?
The current commit message is not very clear about which issue it may fix.

Thanks/Ray

> -Original Message-
> From: edk2-devel  On Behalf Of Gary 
> Lin
> Sent: Wednesday, May 9, 2018 4:20 PM
> To: Bi, Dandan 
> Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao, 
> Liming 
> Subject: Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using 
> uninitialized pointer
> 
> On Wed, May 09, 2018 at 01:02:11PM +0800, Dandan Bi wrote:
> > V2:
> > Add function _INIT_OPHDR_COND () for variable initialization.
> > Make code logic more clean.
> >
> > Previously _CLEAR_SAVED_OPHDR () is used for variable 
> > initialization, and we updated it to clean memory.
> > But _CLEAR_SAVED_OPHDR () is still called for variable initialization.
> > This will cause uninitialized pointer will be checked to free and 
> > cause unexpected issue.
> >
> > This patch is to add new function for variable initialization and 
> > keep _CLEAR_SAVED_OPHDR () to clean memory which is aligned with its 
> > function name.
> >
> This patch fixes the build errors I had :)
> 
> Tested-by: Gary Lin 
> 
> > Cc: Eric Dong 
> > Cc: Liming Gao 
> > Cc: Gary Lin 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Dandan Bi 
> > ---
> >  BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23
> > ---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> >
> > diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > index 4b0a43606ea..84dd2c3ed3f 100644
> > --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > @@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults :
> >
> >  //
> >  // Root expression extension function called by other function.
> >  //
> >  vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
> > -  << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex 
> > >=
> > MAX_IFR_EXPRESSION_DEPTH) _PCATCH
> (VFR_RETURN_INVALID_PARAMETER, 0,
> > "The depth of expression exceeds the max supported level 8!"); 
> > _CLEAR_SAVED_OPHDR ();} >>
> > +   <<
> > +  if ($RootLevel 
> > == 0) {
> > +
> > mCIfrOpHdrIndex ++;
> > +if 
> > + (mCIfrOpHdrIndex >=
> MAX_IFR_EXPRESSION_DEPTH) {
> > +  
> > + _PCATCH
> (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the 
> max supported level 8!");
> > +}
> > +
> > _INIT_OPHDR_COND ();
> > +  }
> > +   >>
> >andTerm[$RootLevel, $ExpOpCount]
> >(
> >  L:OR andTerm[$RootLevel, $ExpOpCount]  << $ExpOpCount++;
> CIfrOr OObj(L->getLine()); >>
> >)*
> > << @@ 
> > -4988,10
> > +4996,11 @@ private:
> >CIfrOpHeader *  mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];
> >UINT32  mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];
> >UINT8   mCIfrOpHdrIndex;
> >VOID_SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN,
> UINT32 LineNo = 0);
> >VOID_CLEAR_SAVED_OPHDR (VOID);
> > +  VOID_INIT_OPHDR_COND (VOID);
> >BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID);
> >
> >
> >EFI_VARSTORE_INFO   mCurrQestVarInfo;
> >EFI_GUID*mOverrideClassGuid;
> > @@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND (
> >  mCIfrOpHdr[mCIfrOpHdrIndex]   = new CIfrOpHeader(OpHdr);
> >  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;
> >}
> >  }
> >
> > +VOID
> > +EfiVfrParser::_INIT_OPHDR_COND (
> > +  VOID
> > +  )
> > +{
> > +  mCIfrOpHdr[mCIfrOpHdrIndex]   = NULL;
> > +  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; }
> > +
> >  VOID
> >  EfiVfrParser::_CLEAR_SAVED_OPHDR (
> >VOID
> >)
> 

Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer

2018-05-09 Thread Ni, Ruiyu
Dandan,
Can you describe the build failure met by Gary Lin in final commit message?
The current commit message is not very clear about which issue it may fix.

Thanks/Ray

> -Original Message-
> From: edk2-devel  On Behalf Of Gary Lin
> Sent: Wednesday, May 9, 2018 4:20 PM
> To: Bi, Dandan 
> Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao, Liming
> 
> Subject: Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using
> uninitialized pointer
> 
> On Wed, May 09, 2018 at 01:02:11PM +0800, Dandan Bi wrote:
> > V2:
> > Add function _INIT_OPHDR_COND () for variable initialization.
> > Make code logic more clean.
> >
> > Previously _CLEAR_SAVED_OPHDR () is used for variable initialization,
> > and we updated it to clean memory.
> > But _CLEAR_SAVED_OPHDR () is still called for variable initialization.
> > This will cause uninitialized pointer will be checked to free and
> > cause unexpected issue.
> >
> > This patch is to add new function for variable initialization and keep
> > _CLEAR_SAVED_OPHDR () to clean memory which is aligned with its
> > function name.
> >
> This patch fixes the build errors I had :)
> 
> Tested-by: Gary Lin 
> 
> > Cc: Eric Dong 
> > Cc: Liming Gao 
> > Cc: Gary Lin 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Dandan Bi 
> > ---
> >  BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23
> > ---
> >  1 file changed, 20 insertions(+), 3 deletions(-)
> >
> > diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > index 4b0a43606ea..84dd2c3ed3f 100644
> > --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> > @@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults :
> >
> >  //
> >  // Root expression extension function called by other function.
> >  //
> >  vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
> > -  << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >=
> > MAX_IFR_EXPRESSION_DEPTH) _PCATCH
> (VFR_RETURN_INVALID_PARAMETER, 0,
> > "The depth of expression exceeds the max supported level 8!");
> > _CLEAR_SAVED_OPHDR ();} >>
> > +   <<
> > +  if ($RootLevel 
> > == 0) {
> > +
> > mCIfrOpHdrIndex ++;
> > +if 
> > (mCIfrOpHdrIndex >=
> MAX_IFR_EXPRESSION_DEPTH) {
> > +  _PCATCH
> (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds
> the max supported level 8!");
> > +}
> > +
> > _INIT_OPHDR_COND ();
> > +  }
> > +   >>
> >andTerm[$RootLevel, $ExpOpCount]
> >(
> >  L:OR andTerm[$RootLevel, $ExpOpCount]  << $ExpOpCount++;
> CIfrOr OObj(L->getLine()); >>
> >)*
> > << @@ -4988,10
> > +4996,11 @@ private:
> >CIfrOpHeader *  mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];
> >UINT32  mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];
> >UINT8   mCIfrOpHdrIndex;
> >VOID_SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN,
> UINT32 LineNo = 0);
> >VOID_CLEAR_SAVED_OPHDR (VOID);
> > +  VOID_INIT_OPHDR_COND (VOID);
> >BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID);
> >
> >
> >EFI_VARSTORE_INFO   mCurrQestVarInfo;
> >EFI_GUID*mOverrideClassGuid;
> > @@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND (
> >  mCIfrOpHdr[mCIfrOpHdrIndex]   = new CIfrOpHeader(OpHdr);
> >  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;
> >}
> >  }
> >
> > +VOID
> > +EfiVfrParser::_INIT_OPHDR_COND (
> > +  VOID
> > +  )
> > +{
> > +  mCIfrOpHdr[mCIfrOpHdrIndex]   = NULL;
> > +  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; }
> > +
> >  VOID
> >  EfiVfrParser::_CLEAR_SAVED_OPHDR (
> >VOID
> >)
> >  {
> >if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
> >  delete mCIfrOpHdr[mCIfrOpHdrIndex];
> > -mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
> > +mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
> >}
> > -  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;  }
> >
> >  BOOLEAN
> >  EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
> >VOID
> > --
> > 2.14.3.windows.1
> >
> > ___
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel
> >
> 

Re: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib LibraryClass.

2018-05-09 Thread Ni, Ruiyu
I don't see much needs for a PlatformAcpiLib.
Platform can call AcpiTable protocol to install ACPI table itself.
The PlatformAcpiLib adds additional program interfaces but doesn't seem to be 
very helpful.

Any new program interfaces need to be carefully reviewed and only added when 
necessary.
Otherwise, people new to this project would be lost in many interfaces.

Thanks/Ray

> -Original Message-
> From: edk2-devel  On Behalf Of Marvin
> H?user
> Sent: Wednesday, May 9, 2018 11:38 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Dong, Eric ; Yao,
> Jiewen ; Kinney, Michael D
> ; Laszlo Ersek ; Zeng,
> Star 
> Subject: Re: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib
> LibraryClass.
> 
> I continued to CC all people that were CC'd in Star's mail, even if I am not 
> sure
> if those are interested in this patch. If anyone doesn't want to be CC'd, I 
> will
> drop them of course.
> 
> Hey Star,
> 
> Indeed I expected it to be just for reference, however as most of the drivers
> you linked share the FV-loading code with AcpiPlatformDxe, having it
> "mainlined" makes sense to me.
> Especially as the "Intel platform forks" of this driver seem to all have a
> common memory leak which the sample driver does not have:
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Universal
> /Acpi/AcpiPlatformDxe/AcpiPlatform.c#L244
> If they were using the mainlined driver, the fix could be made once for
> MdeModulePkg and all other platforms would profit.
> Furthermore, I think it is a good idea to have the platform code not rely on
> where the tables come from (here FV), but instead just be requested to
> perform the required updates, not having to care about table origin,
> checksum fixup, etc.
> If I am not mistaken, all the additional platform code seen in those drivers
> can be implemented well via a library constructor.
> 
> Maybe the driver deserves a new name though, I'm not sure whether
> "AcpiPlatformDxe" is actually fitting.
> MinPlatform uses the "AcpiPlatform"  name to generate fundamental ACPI
> tables, while "BoardAcpiDxe" is the "AcpiPlatformDxe" + "PlatformAcpiLib"
> equivalent, if I am not mistaken.
> 
> Thanks in advance.
> 
> Best regards,
> Marvin
> 
> > -Original Message-
> > From: Zeng, Star 
> > Sent: Wednesday, May 9, 2018 11:33 AM
> > To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> > Cc: Yao, Jiewen ; Kinney, Michael D
> > ; Laszlo Ersek (ler...@redhat.com)
> > ; Ni, Ruiyu ; Dong, Eric
> > ; Zeng, Star 
> > Subject: RE: [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib LibraryClass.
> >
> > Marvin,
> >
> > It is good direction to reuse more code.
> > What am I concerning about are
> > 1. There are comments "Sample ACPI Platform Driver" in
> > AcpiPlatformDxe.inf and AcpiPlatformDxe.c, the current position of
> > AcpiPlatformDxe seems just for reference.
> > 2. Almost all the platforms have their own AcpiPlatformDxe, for
> > example
> >
> https://github.com/tianocore/edk2/tree/master/OvmfPkg/AcpiPlatformDxe
> >
> https://github.com/tianocore/edk2/tree/master/QuarkPlatformPkg/Acpi/Dx
> > e/AcpiPlatform
> > https://github.com/tianocore/edk2/tree/master/Vlv2TbltDevicePkg/AcpiPl
> > a
> > tform
> > ...
> >
> > Should more evaluation be done on them to see whether we can do more
> > or we just suggest platform should implement its own AcpiPlatformDxe?
> >
> > Including more experts.
> >
> >
> > Thanks,
> > Star
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Marvin H?user
> > Sent: Wednesday, May 9, 2018 7:26 AM
> > To: edk2-devel@lists.01.org
> > Cc: Ni, Ruiyu ; Dong, Eric ;
> > Zeng, Star 
> > Subject: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib
> > LibraryClass.
> >
> > PlatformAcpiLib can be consumed by the generic ACPI Platform driver to
> > allow platform specific updates to the ACPI tables loaded from the
> > configured Firmware Volume. This allows for more platforms to
> > incorporate the generic ACPI Platform driver.
> >
> > This commit also provides a NULL implementation of PlatformAcpiLib.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Marvin Haeuser 
> > ---
> >
> >
> MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c
> > | 36 
> >  MdeModulePkg/Include/Library/PlatformAcpiLib.h   | 
> > 36
> > 
> >
> >
> MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.i
> > nf | 35 +++
> >
> 

Re: [edk2] [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs

2018-05-09 Thread Ni, Ruiyu
Roman,
Can you point to me the spec content which states the “Offset” instead of “Base 
+ Offset” should be written to the BAR?
Does the policy apply to all PCI devices in a system, or certain PCI devices in 
a system?

Thanks/Ray

From: Roman Bacik 
Sent: Thursday, May 10, 2018 4:25 AM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Vladimir Olovyannikov 

Subject: [edk2] [PATCH v2] MdeModulePkg/Bus: Enable to use device address when 
programming BARs

Some SoCs require to use device address when BARs are programmed:
https://bugzilla.tianocore.org/show_bug.cgi?id=948

Cc: Ruiyu Ni >
Cc: Vladimir Olovyannikov 
>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Roman Bacik 
>
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf| 1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +---
 MdeModulePkg/MdeModulePkg.dec   | 3 +++
 MdeModulePkg/MdeModulePkg.dsc   | 1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 97608bfcf245..1368e5068574 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -110,6 +110,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration## 
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress## CONSUMES

 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c 
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index 2f713fcee95e..a23bd1e258ef 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -1269,6 +1269,7 @@ ProgramBar (
   EFI_PCI_IO_PROTOCOL *PciIo;
   UINT64  Address;
   UINT32  Address32;
+  BOOLEAN UseDeviceAddress;

   ASSERT (Node->Bar < PCI_MAX_BAR);

@@ -1282,8 +1283,9 @@ ProgramBar (

   Address = 0;
   PciIo   = &(Node->PciDev->PciIo);
+  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);

-  Address = Base + Node->Offset;
+  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;

   //
   // Indicate pci bus driver has allocated
@@ -1308,7 +1310,7 @@ ProgramBar (
  
  );

-Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + 
Address: Address;

 break;

@@ -1335,7 +1337,7 @@ ProgramBar (
  
  );

-Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base + 
Address: Address;

 break;

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cc397185f7b9..58425ee0d57f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1005,6 +1005,9 @@
   # @Prompt Enable UEFI Stack Guard.
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055

+  ## Indicates whether the device address should be used for BAR programming
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|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
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ec24a50c7d0a..39b397cb13d9 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -200,6 +200,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE

 [PcdsFixedAtBuild.IPF]
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0c00
[https://ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif]

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


[edk2] [PATCH edk2-platforms v3 2/6] Platform/HiKey960: do basic initialization

2018-05-09 Thread Haojian Zhuang
Do some basic initliazation on peripherals, such as pins and
regulators.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   2 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   2 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 179 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  91 +++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  47 ++
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 175 
 Silicon/Hisilicon/Hi3660/Include/Hkadc.h   |  68 
 8 files changed, 596 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hkadc.h

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 3da1b8556321..6cc1c1edf453 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,8 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 162dbaaf2646..b7d70b010598 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,8 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
new file mode 100644
index ..154996026737
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -0,0 +1,179 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. 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 "HiKey960Dxe.h"
+
+STATIC UINTNmBoardId;
+
+STATIC
+VOID
+InitSdCard (
+  IN VOID
+  )
+{
+  UINT32Data;
+
+  //
+  // LDO16
+  //
+  Data = MmioRead32 (PMU_REG_BASE + (0x79 << 2)) & 7;
+  Data |= 6;
+  MmioWrite32 (PMU_REG_BASE + (0x79 << 2), Data);
+  MmioOr32 (PMU_REG_BASE + (0x78 << 2), 2);
+  //
+  // wait regulator stable
+  //
+  MicroSecondDelay (100);
+
+  //
+  // LDO9
+  //
+  Data = MmioRead32 (PMU_REG_BASE + (0x6b << 2)) & 7;
+  Data |= 5;
+  MmioWrite32 (PMU_REG_BASE + (0x6b << 2), Data);
+  MmioOr32 (PMU_REG_BASE + (0x6a << 2), 2);
+  //
+  // wait regulator stable
+  //
+  MicroSecondDelay (100);
+
+  //
+  // GPIO203
+  //
+  MmioWrite32 (0xfff11000 + (24 << 2), 0); // GPIO function
+
+  //
+  // SD pinmux
+  //
+  MmioWrite32 (IOMG_MMC0_000_REG, IOMG_FUNC1); // SD_CLK
+  MmioWrite32 (IOMG_MMC0_001_REG, IOMG_FUNC1); // SD_CMD
+  MmioWrite32 (IOMG_MMC0_002_REG, IOMG_FUNC1); // SD_DATA0
+  MmioWrite32 (IOMG_MMC0_003_REG, IOMG_FUNC1); // SD_DATA1
+  MmioWrite32 (IOMG_MMC0_004_REG, IOMG_FUNC1); // SD_DATA2
+  MmioWrite32 (IOMG_MMC0_005_REG, IOMG_FUNC1); // SD_DATA3
+  MmioWrite32 (IOCG_MMC0_000_REG, IOCG_DRIVE (15)); // SD_CLK float with 32mA
+  MmioWrite32 (IOCG_MMC0_001_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_CMD
+  MmioWrite32 (IOCG_MMC0_002_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA0
+  MmioWrite32 (IOCG_MMC0_003_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA1
+  MmioWrite32 (IOCG_MMC0_004_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA2
+  MmioWrite32 (IOCG_MMC0_005_REG, IOCG_PULLUP | IOCG_DRIVE (8)); // SD_DATA3
+
+  do {
+MmioOr32 (CRG_REG_BASE + 0xb8, (1 << 6) | (1 << 6 << 16) | (0 << 4) | (3 
<< 4 << 16));
+Data = MmioRead32 (CRG_REG_BASE + 0xb8);
+  } while ((Data & ((1 << 6) | (3 << 4))) != ((1 << 6) | (0 << 4)));
+
+  //
+  // Unreset SD controller
+  //
+  MmioWrite32 (CRG_PERRSTDIS4, PERRSTEN4_SD);
+  do {
+Data = MmioRead32 (CRG_PERRSTSTAT4);
+  } while 

[edk2] [PATCH edk2-platforms v3 6/6] Platform/HiKey: enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
Enable virtual keyboard on HiKey platform. It detects the pattern
in memory and GPIO pin setting, and simulates them into virtual
key.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc |  5 ++
 Platform/Hisilicon/HiKey/HiKey.fdf |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 98 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  5 ++
 4 files changed, 113 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5cc4ff27f01b..83dd68a820b1 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -192,6 +192,11 @@ [Components.common]
   Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 39020d27dbcd..2bca7232b6e5 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index 19987e0b29c3..8f4f9157835c 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -12,10 +12,15 @@
 *
 **/
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -31,6 +36,8 @@
 #define ADB_REBOOT_BOOTLOADER0x77665500
 #define ADB_REBOOT_NONE  0x77665501
 
+STATIC EMBEDDED_GPIO*mGpio;
+
 STATIC
 VOID
 UartInit (
@@ -104,6 +111,90 @@ HiKeyInitPeripherals (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKeyEntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -115,5 +206,12 @@ HiKeyEntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
index 34734391b45a..41aa7f8081ed 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -28,11 +28,16 @@ [Packages]
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
+  CacheMaintenanceLib
   DebugLib
   IoLib
   UefiLib
   UefiDriverEntryPoint
 
+[Protocols]
+  gEmbeddedGpioProtocolGuid
+  gPlatformVirtualKeyboardProtocolGuid
+
 [Guids]
   gEfiEndOfDxeEventGroupGuid
 
-- 

[edk2] [PATCH edk2-platforms v3 4/6] Platform/Hisilicon/HiKey: add gpio platform driver

2018-05-09 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c| 74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 36 +++
 2 files changed, 110 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index ..be535f8f1903
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,74 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xf8011000, 0, 8 },// GPIO0
+  { 0xf8012000, 8, 8 },// GPIO1
+  { 0xf8013000, 16, 8 },   // GPIO2
+  { 0xf8014000, 24, 8 },   // GPIO3
+  { 0xf702, 32, 8 },   // GPIO4
+  { 0xf7021000, 40, 8 },   // GPIO5
+  { 0xf7022000, 48, 8 },   // GPIO6
+  { 0xf7023000, 56, 8 },   // GPIO7
+  { 0xf7024000, 64, 8 },   // GPIO8
+  { 0xf7025000, 72, 8 },   // GPIO9
+  { 0xf7026000, 80, 8 },   // GPIO10
+  { 0xf7027000, 88, 8 },   // GPIO11
+  { 0xf7028000, 96, 8 },   // GPIO12
+  { 0xf7029000, 104, 8 },  // GPIO13
+  { 0xf702a000, 112, 8 },  // GPIO14
+  { 0xf702b000, 120, 8 },  // GPIO15
+  { 0xf702c000, 128, 8 },  // GPIO16
+  { 0xf702d000, 136, 8 },  // GPIO17
+  { 0xf702e000, 144, 8 },  // GPIO18
+  { 0xf702f000, 152, 8 }   // GPIO19
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
+  //
+  160, 20, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  ,
+  , ,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
new file mode 100644
index ..2791b9f44cad
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,36 @@
+#
+#  Copyright (c) 2018, Linaro. 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= 0x0001001a
+  BASE_NAME  = HiKeyGpio
+  FILE_GUID  = b51a851c-7bf7-463f-b261-cfb158b7f699
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyGpioEntryPoint
+
+[Sources.common]
+  HiKeyGpioDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v3 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-09 Thread Haojian Zhuang
Do some basic initialization on HiKey platform, such as pin
setting, regulators and making peripherals out of reset mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
 Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 119 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 +
 6 files changed, 221 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5c1604d7f689..5cc4ff27f01b 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -189,8 +189,11 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # MMC/SD
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2a5c5a4d6e79..39020d27dbcd 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -120,8 +120,11 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # Multimedia Card Interface
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
new file mode 100644
index ..19987e0b29c3
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -0,0 +1,119 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. 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 
+
+#define SERIAL_NUMBER_SIZE   17
+#define SERIAL_NUMBER_BLOCK_SIZE EFI_PAGE_SIZE
+#define SERIAL_NUMBER_LBA1024
+#define RANDOM_MAX   0x7FFF
+#define RANDOM_MAGIC 0x9A4DBEAF
+
+#define DETECT_J15_FASTBOOT  24   // GPIO3_0
+
+#define ADB_REBOOT_ADDRESS   0x05F01000
+#define ADB_REBOOT_BOOTLOADER0x77665500
+#define ADB_REBOOT_NONE  0x77665501
+
+STATIC
+VOID
+UartInit (
+  IN VOID
+  )
+{
+  UINT32 Val;
+
+  /* make UART1 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART1);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART1);
+  /* make UART2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART2);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART2);
+  /* make UART3 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART3);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART3);
+  /* make UART4 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART4);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART4);
+
+  /* make DW_MMC2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS0, PERIPH_RST0_MMC2);
+
+  /* enable clock for BT/WIFI */
+  Val = MmioRead32 (PMUSSI_ONOFF8_REG) | PMUSSI_ONOFF8_EN_32KB;
+  MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
+}
+
+STATIC
+VOID
+MtcmosInit (
+  IN VOID
+  )
+{
+  UINT32 Data;
+
+  /* enable MTCMOS for GPU */
+  MmioWrite32 (AO_CTRL_BASE + SC_PW_MTCMOS_EN0, PW_EN0_G3D);
+  do {
+Data = MmioRead32 (AO_CTRL_BASE + SC_PW_MTCMOS_ACK_STAT0);
+  } while ((Data & PW_EN0_G3D) == 0);
+}
+
+EFI_STATUS
+HiKeyInitPeripherals (
+  IN VOID
+  )
+{
+  UINT32 Data, Bits;
+
+  /* make I2C0/I2C1/I2C2/SPI0 out of reset */
+  Bits = PERIPH_RST3_I2C0 | PERIPH_RST3_I2C1 | PERIPH_RST3_I2C2 | \
+ PERIPH_RST3_SSP;
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, Bits);
+
+  do {
+Data = MmioRead32 (PERI_CTRL_BASE + SC_PERIPH_RSTSTAT3);
+  } while (Data & Bits);
+
+  UartInit ();
+  /* MTCMOS -- Multi-threshold CMOS */
+  MtcmosInit ();
+
+  /* Set 

[edk2] [PATCH edk2-platforms v3 3/6] Platform/HiKey960: enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
Enable virtual keyboard on HiKey960 platform. It checks two
conditions, such as pattern in memory and GPIO pin setting.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  5 ++
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  5 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 98 +-
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  3 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  1 +
 5 files changed, 111 insertions(+), 1 deletion(-)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 6cc1c1edf453..79e68754976d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,11 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index b7d70b010598..d65f77878575 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index 154996026737..6ac0d220cf58 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -14,7 +14,8 @@
 
 #include "HiKey960Dxe.h"
 
-STATIC UINTNmBoardId;
+STATIC UINTN   mBoardId;
+STATIC EMBEDDED_GPIO   *mGpio;
 
 STATIC
 VOID
@@ -142,6 +143,94 @@ OnEndOfDxe (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  //
+  // Configure GPIO68 as GPIO function
+  //
+  MmioWrite32 (0xe896c108, 0);
+  Status = mGpio->Set (mGpio, DETECT_SW_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_SW_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKey960EntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -175,5 +264,12 @@ HiKey960EntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
index 2e89d10e2723..2d5349888ed5 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
@@ -33,6 +33,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 #define ADC_ADCIN0   0
 #define ADC_ADCIN1   1
 

[edk2] [PATCH edk2-platforms v3 1/6] Platform/Hisilicon/HiKey960: add gpio platform driver

2018-05-09 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey960 platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  1 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  1 +
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c | 83 ++
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf   | 35 +
 4 files changed, 120 insertions(+)
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 36f43956ab40..3da1b8556321 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -179,6 +179,7 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 655032a36c53..162dbaaf2646 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -120,6 +120,7 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
new file mode 100644
index ..b196455072cc
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
@@ -0,0 +1,83 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xe8a0b000, 0, 8 },// GPIO0
+  { 0xe8a0c000, 8, 8 },// GPIO1
+  { 0xe8a0d000, 16, 8 },   // GPIO2
+  { 0xe8a0e000, 24, 8 },   // GPIO3
+  { 0xe8a0f000, 32, 8 },   // GPIO4
+  { 0xe8a1, 40, 8 },   // GPIO5
+  { 0xe8a11000, 48, 8 },   // GPIO6
+  { 0xe8a12000, 56, 8 },   // GPIO7
+  { 0xe8a13000, 64, 8 },   // GPIO8
+  { 0xe8a14000, 72, 8 },   // GPIO9
+  { 0xe8a15000, 80, 8 },   // GPIO10
+  { 0xe8a16000, 88, 8 },   // GPIO11
+  { 0xe8a17000, 96, 8 },   // GPIO12
+  { 0xe8a18000, 104, 8 },  // GPIO13
+  { 0xe8a19000, 112, 8 },  // GPIO14
+  { 0xe8a1a000, 120, 8 },  // GPIO15
+  { 0xe8a1b000, 128, 8 },  // GPIO16
+  { 0xe8a1c000, 136, 8 },  // GPIO17
+  { 0xff3b4000, 144, 8 },  // GPIO18
+  { 0xff3b5000, 152, 8 },  // GPIO19
+  { 0xe8a1f000, 160, 8 },  // GPIO20
+  { 0xe8a2, 168, 8 },  // GPIO21
+  { 0xfff0b000, 176, 8 },  // GPIO22
+  { 0xfff0c000, 184, 8 },  // GPIO23
+  { 0xfff0d000, 192, 8 },  // GPIO24
+  { 0xfff0e000, 200, 8 },  // GPIO25
+  { 0xfff0f000, 208, 8 },  // GPIO26
+  { 0xfff1, 216, 8 },  // GPIO27
+  { 0xfff1d000, 224, 8 },  // GPIO28
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller count, GPIO_CONTROLLER }
+  //
+  232, 29, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKey960GpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  ,
+  , ,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
new file mode 100644
index ..5ea3747321d8
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
@@ -0,0 +1,35 @@
+#
+#  Copyright (c) 2018, Linaro. 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 

[edk2] [PATCH edk2-platforms v3 0/6] enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
Changelog:
v3:
  * Remove ADC and boardid, since it's not really used yet.
  * Add more comments.
v2:
  * Split HiKeyDxe & HiKey960Dxe into smaller patches.
  * Replace hardcoding register with macro.
v1:
  * Enable GPIO driver.
  * Enable virtual keyboard driver.

Haojian Zhuang (6):
  Platform/Hisilicon/HiKey960: add gpio platform driver
  Platform/HiKey960: do basic initialization
  Platform/HiKey960: enable virtual keyboard
  Platform/Hisilicon/HiKey: add gpio platform driver
  Platform/HiKey: do basic initialization on hikey
  Platform/HiKey: enable virtual keyboard

 Platform/Hisilicon/HiKey/HiKey.dsc |   8 +
 Platform/Hisilicon/HiKey/HiKey.fdf |   8 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 217 
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  45 
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c|  74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  |  36 +++
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   8 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   8 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 275 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  94 +++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  48 
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c |  83 +++
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf   |  35 +++
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 +++
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 175 +
 Silicon/Hisilicon/Hi3660/Include/Hkadc.h   |  68 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h  |   6 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h  |  50 
 18 files changed, 1270 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hkadc.h
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
-- 
2.7.4

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


Re: [edk2] [Patch] BaseTools: Fix generating array's size is incorrect in AutoGen.c

2018-05-09 Thread Zhu, Yonghong
Reviewed-by: Yonghong Zhu  

Best Regards,
Zhu Yonghong


-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Yonghong 
Zhu
Sent: Wednesday, May 09, 2018 3:41 PM
To: edk2-devel@lists.01.org
Cc: Feng, YunhuaX ; Gao, Liming 
Subject: [edk2] [Patch] BaseTools: Fix generating array's size is incorrect in 
AutoGen.c

From: Yunhua Feng 

case example:
DSC:
 [PcdsFixedAtBuild]
  PcdToken.PcdName | "A"
 [Components]
 TestPkg/TestDriver.inf {
  PcdToken.PcdName | {0x41,0x42,0x43,0x44}  }

Generating the size of array is incorrect in AutoGen.c  
GLOBAL_REMOVE_IF_UNREFERENCED const UINT8  _gPcd_FixedAtBuild_PcdName[2] = 
{0x41,0x42,0x43,0x44};

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=950
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/AutoGen/GenC.py | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index d062588..35ebd60 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1055,42 +1055,43 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 "Too large PCD value for datum type [%s] 
of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
 ExtraData="[%s]" % str(Info))
 if not Value.endswith('U'):
 Value += 'U'
 if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES:
-if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':
+if not Pcd.MaxDatumSize:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "Unknown [MaxDatumSize] of PCD [%s.%s]" % 
(Pcd.TokenSpaceGuidCName, TokenCName),
 ExtraData="[%s]" % str(Info))
 
 ArraySize = int(Pcd.MaxDatumSize, 0)
 if Value[0] == '{':
 Type = '(VOID *)'
+ValueSize = len(Value.split(','))
 else:
 if Value[0] == 'L':
 Unicode = True
 Value = Value.lstrip('L')   #.strip('"')
 Value = eval(Value) # translate escape character
+ValueSize = len(Value) + 1
 NewValue = '{'
 for Index in range(0,len(Value)):
 if Unicode:
 NewValue = NewValue + str(ord(Value[Index]) % 0x1) 
+ ', '
 else:
 NewValue = NewValue + str(ord(Value[Index]) % 0x100) + 
', '
 if Unicode:
-ArraySize = ArraySize / 2;
-
-if ArraySize < (len(Value) + 1):
-if Pcd.MaxSizeUserSet:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"The maximum size of VOID* type PCD 
'%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, 
TokenCName),
-ExtraData="[%s]" % str(Info))
-else:
-ArraySize = Pcd.GetPcdSize()
-if Unicode:
-ArraySize = ArraySize / 2
+ArraySize = ArraySize / 2
 Value = NewValue + '0 }'
+if ArraySize < ValueSize:
+if Pcd.MaxSizeUserSet:
+EdkLogger.error("build", AUTOGEN_ERROR,
+"The maximum size of VOID* type PCD '%s.%s' is 
less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName),
+ExtraData="[%s]" % str(Info))
+else:
+ArraySize = Pcd.GetPcdSize()
+if Unicode:
+ArraySize = ArraySize / 2
 Array = '[%d]' % ArraySize
 #
 # skip casting for fixed at build since it breaks ARM assembly.
 # Long term we need PCD macros that work in assembly
 #
--
2.6.1.windows.1

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


Re: [edk2] OVMF Logo

2018-05-09 Thread Blibbet
| [...] Is it possible to tune Logo's behavior in OVMF? [...]

FYI, the HackBGRT tool exists, and may be helpful [on some bare-metal
systems, unclear about OVMF-based usefulness]. I've never used it.

https://github.com/Metabolix/HackBGRT
https://firmwaresecurity.com/2018/03/22/hackbgrt-how-to-change-windows-boot-logo-using-hackbgrt/

HTH,
Lee Fisher

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


Re: [edk2] [PATCH v1 1/1] BaseTools: loop to retry remove when it fails.

2018-05-09 Thread Kinney, Michael D
Jaben,

Instead of while TRUE, a timeout count be added so
the loop can exit if the file is not released in a 
reasonable period of time.  Perhaps 5 seconds.

   Timeout = 0.0
   while Timeout < 5.0:
   try:
   return os.remove(LongFilePath(path))
   except:
   time.sleep(0.1)
   Timeout = Timeout + 0.1
   return os.remove(LongFilePath(path))

Thanks,

Mike

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-
> boun...@lists.01.org] On Behalf Of Jaben Carsey
> Sent: Wednesday, May 9, 2018 1:51 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH v1 1/1] BaseTools: loop to retry
> remove when it fails.
> 
> There is a common race condition when the OS fails to
> release a file
> fast enough.  this adds a retry loop.
> 
> Cc: Liming Gao 
> Cc: Yonghong Zhu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jaben Carsey 
> ---
>  BaseTools/Source/Python/Common/LongFilePathOs.py | 9
> +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git
> a/BaseTools/Source/Python/Common/LongFilePathOs.py
> b/BaseTools/Source/Python/Common/LongFilePathOs.py
> index 2e530f9dd774..a595de2648b7 100644
> --- a/BaseTools/Source/Python/Common/LongFilePathOs.py
> +++ b/BaseTools/Source/Python/Common/LongFilePathOs.py
> @@ -1,7 +1,7 @@
>  ## @file
>  # Override built in module os to provide support for
> long file path
>  #
> -# Copyright (c) 2014, Intel Corporation. All rights
> reserved.
> +# Copyright (c) 2014 - 2018, Intel Corporation. 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
> @@ -15,6 +15,7 @@ import os
>  import LongFilePathOsPath
>  from Common.LongFilePathSupport import LongFilePath
>  from Common.LongFilePathSupport import UniToStr
> +import time
> 
>  path = LongFilePathOsPath
> 
> @@ -22,7 +23,11 @@ def access(path, mode):
>  return os.access(LongFilePath(path), mode)
> 
>  def remove(path):
> -return os.remove(LongFilePath(path))
> +while True:
> +try:
> +return os.remove(LongFilePath(path))
> +except:
> +time.sleep(0.1)
> 
>  def removedirs(name):
>  return os.removedirs(LongFilePath(name))
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] SecurityPkg: fix sha256 signature check

2018-05-09 Thread James Bottomley
commit c035e37335ae43229d7e68de74a65f2c01ebc0af
Author: Zhang Lubo 
Date:   Thu Jan 5 14:58:05 2017 +0800

SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariable.

Added a check for sha256 being the ownly allowed signature hash.
Unfortuantely this commit assumed the form of the signature data was a
raw SignedData sequence.  Most tools actually generate a ContentInfo
sequence instead which contains a header identifying the content as
pkcs7-SignedData.  Fix this check to allow either format to work.

This fix is needed at least for efitools because we generate signed
variable updates with the ContentInfo header.

Signed-off-by: James Bottomley 
---
 CryptoPkg/Library/OpensslLib/openssl  |  2 +-
 SecurityPkg/Library/AuthVariableLib/AuthService.c | 11 ++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CryptoPkg/Library/OpensslLib/openssl 
b/CryptoPkg/Library/OpensslLib/openssl
index b2758a2292..d4e4bd2a81 16
--- a/CryptoPkg/Library/OpensslLib/openssl
+++ b/CryptoPkg/Library/OpensslLib/openssl
@@ -1 +1 @@
-Subproject commit b2758a2292aceda93e9f44c219b94fe21bb9a650
+Subproject commit d4e4bd2a8163f355fa8a3884077eaec7adc75ff7
diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 213a524f27..855ea3350a 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -1908,10 +1908,19 @@ VerifyTimeBasedPayload (
   //in VARIABLE_AUTHENTICATION_2 descriptor.
   //This field has the fixed offset (+13) and be calculated based on two 
bytes of length encoding.
   //
+  // However the data may also begin
+  //   ContentInfo ::= SEQUENCE {
+  //  contentType ContentType,
+  //  content
+  //[0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
+  //
+  // In which case the fixed offset is +32
+  //
   if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
 if (SigDataSize >= (13 + sizeof (mSha256OidValue))) {
   if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) || 
-   (CompareMem (SigData + 13, , sizeof 
(mSha256OidValue)) != 0)) {
+ (CompareMem (SigData + 13, , sizeof 
(mSha256OidValue)) != 0 &&
+  CompareMem (SigData + 32, , sizeof 
(mSha256OidValue)) != 0)) {
   return EFI_SECURITY_VIOLATION;
 }
 }
-- 
2.13.6

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


Re: [edk2] [PATCH edk2-platforms v1] Platform/ARM: Add PeiReportStatusCodeLib

2018-05-09 Thread Leif Lindholm
On Wed, May 09, 2018 at 04:58:52PM +, Alexei Fedorov wrote:
> Hi Leif,
> 
> You wrote:
> > Yes, this fixes a bug, however I am still unable to build FVP with
> > -D ARM_FVP_RUN_NORFLASH:
> > ---
> > In file included from
> > /work/git/edk2-platforms/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c:22:0:
> > /work/git/edk2-platforms/Platform/ARM/VExpressPkg/Include/Platform/RTSM/ArmPlatform.h:19:33:
> > fatal error: VExpressMotherBoard.h: No such file or directory
> >  #include 
> >  ^
> > compilation terminated.
> > ---
> > 
> > Presumably this has been broken since commit 8ad58788b5c did not carry 
> > across
> > -I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include in
> > GCC:*_*_AARCH64_PLATFORM_FLAGS when migrating ArmVExpressPkg from edk2.
> > 
> > Can you confirm whether you can reproduce this?"
> > 
> 
> Yes, & it was fixed it by adding
> 
> -I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include
> 
> in GCC:*_*_AARCH64_PLATFORM_FLAGS of ArmVExpress-FVP-AArch64.dsc:
> 
> GCC:*_*_AARCH64_PLATFORM_FLAGS == 
> -I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include 
> -I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include/Platform/RTSM

I still prefer the .dec way over ading more explicit platform-specific
-I flags.

Could you fold that into the patch and update the subject line to
something like "fix FVP build with -D ARM_FVP_RUN_NORFLASH"?

Regards,

Leif

> 
> Regards.
> 
> Alexei
> 
> 
> From: Leif Lindholm 
> Sent: 09 May 2018 17:24:23
> To: Alexei Fedorov
> Cc: edk2-devel@lists.01.org; Arvind Chauhan; Daniil Egranov; Thomas Abraham; 
> ard.biesheu...@linaro.org; Matteo Carlini; Stephanie Hughes-Fitt; nd; Evan 
> Lloyd; Sami Mujawar
> Subject: Re: [PATCH edk2-platforms v1] Platform/ARM: Add 
> PeiReportStatusCodeLib
> 
> Hi Alexei,
> 
> On Thu, May 03, 2018 at 10:24:21AM +0100, Alexei Fedorov wrote:
> > From: Alexei Fedorov 
> >
> > UEFI build fails for ArmVExpress-FVP-AArch64 when using
> > "-D ARM_FVP_RUN_NORFLASH" build option, which prevents
> > EDK2_SKIP_PEICORE macro from being defined in
> > ArmVExpress-FVP-AArch64.dsc:
> >
> > !ifndef ARM_FVP_RUN_NORFLASH
> >   DEFINE EDK2_SKIP_PEICORE=1
> > !endif
> >
> > When EDK2_SKIP_PEICORE macro is not defined, build fails with
> > errors 1001:
> > Module type [PEI_CORE] is not supported by library instance
> > [MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf]
> > consumed by [n:\edk2\MdeModulePkg\Core\Pei\PeiMain.inf]
> > and
> > Module type [PEIM] is not supported by library instance
> > [MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf]
> > consumed by [n:\edk2\MdeModulePkg\Core\DxeIplPeim\DxeIpl.inf]
> >
> > This patch fixes the above build errors by adding
> > MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
> > in [LibraryClasses.common.PEI_CORE] and [LibraryClasses.common.PEIM]
> > sections of ArmVExpress.dsc.inc.
> 
> Yes, this fixes a bug, however I am still unable to build FVP with
> -D ARM_FVP_RUN_NORFLASH:
> ---
> In file included from
> /work/git/edk2-platforms/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c:22:0:
> /work/git/edk2-platforms/Platform/ARM/VExpressPkg/Include/Platform/RTSM/ArmPlatform.h:19:33:
> fatal error: VExpressMotherBoard.h: No such file or directory
>  #include 
>  ^
> compilation terminated.
> ---
> 
> Presumably this has been broken since commit 8ad58788b5c did not carry across
> -I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include in
> GCC:*_*_AARCH64_PLATFORM_FLAGS when migrating ArmVExpressPkg from edk2.
> 
> Can you confirm whether you can reproduce this?
> 
> If so, the following stanza resolves the issue for me:
> diff --git
> a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
> b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
> index 2287756cf8..ed9720e8ce 100644
> --- 
> a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
> +++ 
> b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
> @@ -22,6 +22,7 @@ [Defines]
>  [Packages]
>MdePkg/MdePkg.dec
>MdeModulePkg/MdeModulePkg.dec
> +  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
>EmbeddedPkg/EmbeddedPkg.dec
>ArmPkg/ArmPkg.dec
>ArmPlatformPkg/ArmPlatformPkg.dec
> 
> Best Regards,
> 
> Leif
> 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Alexei Fedorov 
> > Reviewed-by:   Evan Lloyd 
> > ---
> > All the changes can be reviewed at:
> > https://github.com/AlexeiFedorov/edk2-platforms/tree/237_add_peireportstatuscodelib_v1
> >
> > Notes:
> > v1:
> > - Add PeiReportStatusCodeLib in PEI_CORE and PEIM sections   [Alexei]
> >
> >  Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git 

Re: [edk2] [PATCH v2 04/17] ArmPkg/ArmMmuLib: Add MMU Library suitable for use in S-EL0.

2018-05-09 Thread Udit Kumar
Hi Supreeth, 
One question on this patch 
We are asking permission on base-address and changing the permission of 
memory based upon base and size. 
I haven't looked at other part of code which manage this , 
But will there be possibility that, base address is given correctly and length 
may over-lap the other MMU entry.

Regards
Udit 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Supreeth Venkatesh
> Sent: Saturday, May 5, 2018 2:11 AM
> To: edk2-devel@lists.01.org
> Cc: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; jiewen@intel.com;
> liming@intel.com; michael.d.kin...@intel.com
> Subject: [edk2] [PATCH v2 04/17] ArmPkg/ArmMmuLib: Add MMU Library
> suitable for use in S-EL0.
> 
> The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard
> Platforms. Privileged firmware e.g. ARM Trusted Firmware sets up its
> architectural context including the initial translation tables for the
> S-EL1/EL0 translation regime. The MM environment will still request ARM
> TF to change the memory attributes of memory regions during
> initialization.
> 
> The Standalone MM image is a FV that encapsulates the MM foundation
> and drivers. These are PE-COFF images with data and text segments.
> To initialise the MM environment, Arm Trusted Firmware has to create
> translation tables with sane default attributes for the memory
> occupied by the FV. This library sends SVCs to ARM Trusted Firmware
> to request memory permissions change for data and text segments.
> 
> This patch adds a simple MMU library suitable for execution in S-EL0 and
> requesting memory permissions change operations from Arm Trusted Firmware.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  .../ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c  | 195
> +
>  1 file changed, 195 insertions(+)
>  create mode 100644
> ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
> 
> diff --git
> a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
> b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
> new file mode 100644
> index 00..0f5e68d2d4
> --- /dev/null
> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuStandaloneMmCoreLib.c
> @@ -0,0 +1,195 @@
> +/** @file
> +*  File managing the MMU for ARMv8 architecture in S-EL0
> +*
> +*  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
> +*
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopenso
> urce.org%2Flicenses%2Fbsd-
> license.php=02%7C01%7Cudit.kumar%40nxp.com%7C776b728240f7402b
> 029708d5b1ff7179%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63
> 6610633113917388=KGmnTNpIKqIXyS2sdVH1I2EaCd8rhm%2BKI05JuxYv8
> Aw%3D=0
> +*
> +*  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 
> +
> +EFI_STATUS
> +GetMemoryPermissions (
> +  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
> +  OUT UINT32*MemoryAttributes
> +  )
> +{
> +  ARM_SVC_ARGS  GetMemoryPermissionsSvcArgs = {0};
> +
> +  GetMemoryPermissionsSvcArgs.Arg0 =
> ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64;
> +  GetMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
> +  GetMemoryPermissionsSvcArgs.Arg2 = 0;
> +  GetMemoryPermissionsSvcArgs.Arg3 = 0;
> +
> +  ArmCallSvc ();
> +  if (GetMemoryPermissionsSvcArgs.Arg0 ==
> ARM_SVC_SPM_RET_INVALID_PARAMS) {
> +*MemoryAttributes = 0;
> +return EFI_INVALID_PARAMETER;
> +  }
> +
> +  *MemoryAttributes = GetMemoryPermissionsSvcArgs.Arg0;
> +  return EFI_SUCCESS;
> +}
> +
> +EFI_STATUS
> +RequestMemoryPermissionChange (
> +  IN  EFI_PHYSICAL_ADDRESS  BaseAddress,
> +  IN  UINT64Length,
> +  IN  UINTN Permissions
> +  )
> +{
> +  EFI_STATUSStatus;
> +  ARM_SVC_ARGS  ChangeMemoryPermissionsSvcArgs = {0};
> +
> +  ChangeMemoryPermissionsSvcArgs.Arg0 =
> ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64;
> +  ChangeMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
> +  ChangeMemoryPermissionsSvcArgs.Arg2 = (Length >= EFI_PAGE_SIZE) ? \
> + Length >> EFI_PAGE_SHIFT : 1;
> +  ChangeMemoryPermissionsSvcArgs.Arg3 = Permissions;
> +
> +  ArmCallSvc ();
> +
> +  Status = ChangeMemoryPermissionsSvcArgs.Arg0;
> +
> +  switch (Status) {
> +  case ARM_SVC_SPM_RET_SUCCESS:
> +Status = EFI_SUCCESS;
> +break;
> +
> +  case ARM_SVC_SPM_RET_NOT_SUPPORTED:
> +Status = EFI_UNSUPPORTED;
> +  

Re: [edk2] [PATCH v2 03/17] ArmPkg/Include: Add MM interface SVC return codes.

2018-05-09 Thread Udit Kumar


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Supreeth Venkatesh
> Sent: Saturday, May 5, 2018 2:11 AM
> To: edk2-devel@lists.01.org
> Cc: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; jiewen@intel.com;
> liming@intel.com; michael.d.kin...@intel.com
> Subject: [edk2] [PATCH v2 03/17] ArmPkg/Include: Add MM interface SVC return
> codes.
> 
> This patch adds the Management Mode(MM) - Secure Partition Manager(SPM)
> SVC return codes.
> Also, It corrects SVC ID for retrieving SPM version information.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  ArmPkg/Include/IndustryStandard/ArmMmSvc.h | 9 -
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
> b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
> index 4c7b6c3386..a64b9ec23c 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmMmSvc.h
> @@ -20,7 +20,7 @@
>   * delegated events and request the Secure partition manager to perform
>   * privileged operations on its behalf.
>   */
> -#define ARM_SVC_ID_SPM_VERSION_AARCH64 0xC460
> +#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x8460
>  #define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64   0xC461
>  #define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64   0xC464
>  #define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64   0xC465
> @@ -40,4 +40,11 @@
>  c_perm) & SET_MEM_ATTR_CODE_PERM_MASK) <<
> SET_MEM_ATTR_CODE_PERM_SHIFT) | \
>  (( (d_perm) & SET_MEM_ATTR_DATA_PERM_MASK) <<
> SET_MEM_ATTR_DATA_PERM_SHIFT))
> 
> +/* MM SVC Return error codes */
> +#define ARM_SVC_SPM_RET_SUCCESS   0
> +#define ARM_SVC_SPM_RET_NOT_SUPPORTED-1
> +#define ARM_SVC_SPM_RET_INVALID_PARAMS   -2
> +#define ARM_SVC_SPM_RET_DENIED   -3
> +#define ARM_SVC_SPM_RET_NO_MEMORY-5

Please see if you want to define errors as negative.
AFAIK, in edk2 negative errors are not used 

> +
>  #endif
> --
> 2.16.2
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01
> .org%2Fmailman%2Flistinfo%2Fedk2-
> devel=02%7C01%7Cudit.kumar%40nxp.com%7Ca6dc7d4a80e24bad73b80
> 8d5b1ff6f28%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63661063
> 3010245207=IHWYNFk0W2OKDQ%2BYEkJFmpi14mkXJyhblAdZQK7jM%2
> B0%3D=0
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v1 1/1] BaseTools: incorrect calculation for 16M

2018-05-09 Thread Carsey, Jaben
Ignore.  Duplicate. Already sent out.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jaben Carsey
> Sent: Wednesday, May 09, 2018 1:51 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH v1 1/1] BaseTools: incorrect calculation for 16M
> Importance: High
> 
> the "0x" was missing.
> 
> Cc: Liming Gao 
> Cc: Yonghong Zhu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jaben Carsey 
> ---
>  BaseTools/Source/Python/GenFds/FvImageSection.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py
> b/BaseTools/Source/Python/GenFds/FvImageSection.py
> index eb84b44bbec4..57ecea0377bf 100644
> --- a/BaseTools/Source/Python/GenFds/FvImageSection.py
> +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py
> @@ -1,7 +1,7 @@
>  ## @file
>  # process FV image section generation
>  #
> -#  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the
> BSD License
> @@ -83,7 +83,7 @@ class FvImageSection(FvImageSectionClassObject):
>  if MaxFvAlignment >= 0x400:
>  if MaxFvAlignment >= 0x10:
>  #The max alignment supported by FFS is 16M.
> -if MaxFvAlignment >=100:
> +if MaxFvAlignment >= 0x100:
>  self.Alignment = "16M"
>  else:
>  self.Alignment = str(MaxFvAlignment / 0x10) + "M"
> --
> 2.16.2.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add EFI_MM_COMMUNICATION_PROTOCOL DXE driver.

2018-05-09 Thread Udit Kumar


> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Supreeth Venkatesh
> Sent: Saturday, May 5, 2018 2:11 AM
> To: edk2-devel@lists.01.org
> Cc: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; jiewen@intel.com;
> liming@intel.com; michael.d.kin...@intel.com
> Subject: [edk2] [PATCH v2 02/17] ArmPkg/Drivers: Add
> EFI_MM_COMMUNICATION_PROTOCOL DXE driver.
> 
> PI v1.5 Specification Volume 4 defines Management Mode Core Interface
> and defines EFI_MM_COMMUNICATION_PROTOCOL. This protocol provides a
> means of communicating between drivers outside of MM and MMI
> handlers inside of MM.
> 
> This patch implements the EFI_MM_COMMUNICATION_PROTOCOL DXE
> runtime
> driver for AARCH64 platforms. It uses SMCs allocated from the standard
> SMC range defined in DEN0060A_ARM_MM_Interface_Specification.pdf
> to communicate with the standalone MM environment in the secure world.
> 
> This patch also adds the MM Communication driver (.inf) file to
> define entry point for this driver and other compile
> related information the driver needs.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Achin Gupta 
> Signed-off-by: Supreeth Venkatesh 
> ---
>  .../Drivers/MmCommunicationDxe/MmCommunication.c   | 408
> +
>  .../Drivers/MmCommunicationDxe/MmCommunication.inf |  50 +++
>  2 files changed, 458 insertions(+)
>  create mode 100644
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
>  create mode 100644
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> 
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> new file mode 100644
> index 00..8ba1790af9
> --- /dev/null
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -0,0 +1,408 @@
> +/** @file
> +
> +  Copyright (c) 2016-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
> +
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopenso
> urce.org%2Flicenses%2Fbsd-
> license.php=02%7C01%7Cudit.kumar%40nxp.com%7Cc6986ed63017483b
> 89dd08d5b1ff6c2d%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63
> 6610632972644435=CoYRxTy3iCIKcy2xXEF6BJl1qNQEPZTLHBX9pXmrHR
> w%3D=0
> +
> +  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 
> +
> +#define MM_MAJOR_VER_MASK0x
> +#define MM_MINOR_VER_MASK0x
> +#define MM_MAJOR_VER_SHIFT   16
> +
> +const UINT32 MM_MAJOR_VER = 1;
> +const UINT32 MM_MINOR_VER = 0;

This should be UINT16 , as compare is done against UINT16 

> +
> +//
> +// Address, Length of the pre-allocated buffer for communication with the
> secure
> +// world.
> +//
> +STATIC ARM_MEMORY_REGION_DESCRIPTOR  mNsCommBuffMemRegion;
> +
> +// Notification event when virtual address map is set.
> +STATIC EFI_EVENT  mSetVirtualAddressMapEvent;
> +
> +//
> +// Handle to install the MM Communication Protocol
> +//
> +STATIC EFI_HANDLE  mMmCommunicateHandle;
> +
> +/**
> +  Communicates with a registered handler.
> +
> +  This function provides an interface to send and receive messages to the
> +  Standalone MM environment on behalf of UEFI services.  This function is 
> part
> +  of the MM Communication Protocol that may be called in physical mode prior
> to
> +  SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap().
> +
> +  @param[in]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL
> +  instance.
> +  @param[in, out] CommBuffer  A pointer to the buffer to convey
> +  into MMRAM.
> +  @param[in, out] CommSizeThe size of the data buffer being
> +  passed in. This is optional.
> +
> +  @retval EFI_SUCCESS The message was successfully posted.
> +  @retval EFI_INVALID_PARAMETER   The CommBuffer was NULL.
> +  @retval EFI_BAD_BUFFER_SIZE The buffer size is incorrect for the MM
> +  implementation. If this error is
> +  returned, the MessageLength field in
> +  the CommBuffer header or the integer
> +  pointed by CommSize are updated to 
> reflect
> +  the maximum payload size the
> +  implementation 

[edk2] [PATCH v1 1/1] BaseTools: loop to retry remove when it fails.

2018-05-09 Thread Jaben Carsey
There is a common race condition when the OS fails to release a file
fast enough.  this adds a retry loop.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey 
---
 BaseTools/Source/Python/Common/LongFilePathOs.py | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py 
b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 2e530f9dd774..a595de2648b7 100644
--- a/BaseTools/Source/Python/Common/LongFilePathOs.py
+++ b/BaseTools/Source/Python/Common/LongFilePathOs.py
@@ -1,7 +1,7 @@
 ## @file
 # Override built in module os to provide support for long file path
 #
-# Copyright (c) 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2018, Intel Corporation. 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
@@ -15,6 +15,7 @@ import os
 import LongFilePathOsPath
 from Common.LongFilePathSupport import LongFilePath
 from Common.LongFilePathSupport import UniToStr
+import time
 
 path = LongFilePathOsPath
 
@@ -22,7 +23,11 @@ def access(path, mode):
 return os.access(LongFilePath(path), mode)
 
 def remove(path):
-return os.remove(LongFilePath(path))
+while True:
+try:
+return os.remove(LongFilePath(path))
+except:
+time.sleep(0.1)
 
 def removedirs(name):
 return os.removedirs(LongFilePath(name))
-- 
2.16.2.windows.1

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


[edk2] [PATCH v2] MdeModulePkg/Bus: Enable to use device address when programming BARs

2018-05-09 Thread Roman Bacik
Some SoCs require to use device address when BARs are programmed:
https://bugzilla.tianocore.org/show_bug.cgi?id=948

Cc: Ruiyu Ni 
Cc: Vladimir Olovyannikov 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Roman Bacik 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf| 1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +---
 MdeModulePkg/MdeModulePkg.dec   | 3 +++
 MdeModulePkg/MdeModulePkg.dsc   | 1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 97608bfcf245..1368e5068574 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -110,6 +110,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration##
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress## CONSUMES

 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index 2f713fcee95e..a23bd1e258ef 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -1269,6 +1269,7 @@ ProgramBar (
   EFI_PCI_IO_PROTOCOL *PciIo;
   UINT64  Address;
   UINT32  Address32;
+  BOOLEAN UseDeviceAddress;

   ASSERT (Node->Bar < PCI_MAX_BAR);

@@ -1282,8 +1283,9 @@ ProgramBar (

   Address = 0;
   PciIo   = &(Node->PciDev->PciIo);
+  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);

-  Address = Base + Node->Offset;
+  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;

   //
   // Indicate pci bus driver has allocated
@@ -1308,7 +1310,7 @@ ProgramBar (
  
  );

-Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
Address: Address;

 break;

@@ -1335,7 +1337,7 @@ ProgramBar (
  
  );

-Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
Address: Address;

 break;

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cc397185f7b9..58425ee0d57f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1005,6 +1005,9 @@
   # @Prompt Enable UEFI Stack Guard.
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055

+  ## Indicates whether the device address should be used for BAR
programming
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|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
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ec24a50c7d0a..39b397cb13d9 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -200,6 +200,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE

 [PcdsFixedAtBuild.IPF]
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0c00

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


Re: [edk2] [PATCH] Enable using device address when programming BARs

2018-05-09 Thread Roman Bacik
I will upload v2 with the corrected subject - add package name MdeModulePkg/Bus
.



*From:* Roman Bacik [mailto:roman.ba...@broadcom.com]
*Sent:* Thursday, May 3, 2018 3:55 PM
*To:* edk2-devel@lists.01.org
*Cc:* Ruiyu Ni; Vladimir Olovyannikov
*Subject:* [edk2] [PATCH] Enable using device address when programming BARs



Some SoCs require to use device address when BARs are programmed:
https://bugzilla.tianocore.org/show_bug.cgi?id=948

Cc: Ruiyu Ni 
Cc: Vladimir Olovyannikov 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Roman Bacik 
---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf| 1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c | 8 +---
 MdeModulePkg/MdeModulePkg.dec   | 3 +++
 MdeModulePkg/MdeModulePkg.dsc   | 1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
index 97608bfcf245..1368e5068574 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
@@ -110,6 +110,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport  ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration##
SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress## CONSUMES

 [UserExtensions.TianoCore."ExtraFiles"]
   PciBusDxeExtra.uni
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
index 2f713fcee95e..a23bd1e258ef 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciResourceSupport.c
@@ -1269,6 +1269,7 @@ ProgramBar (
   EFI_PCI_IO_PROTOCOL *PciIo;
   UINT64  Address;
   UINT32  Address32;
+  BOOLEAN UseDeviceAddress;

   ASSERT (Node->Bar < PCI_MAX_BAR);

@@ -1282,8 +1283,9 @@ ProgramBar (

   Address = 0;
   PciIo   = &(Node->PciDev->PciIo);
+  UseDeviceAddress = FeaturePcdGet (PcdUseDeviceAddress);

-  Address = Base + Node->Offset;
+  Address = UseDeviceAddress? Node->Offset: Base + Node->Offset;

   //
   // Indicate pci bus driver has allocated
@@ -1308,7 +1310,7 @@ ProgramBar (
  
  );

-Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
Address: Address;

 break;

@@ -1335,7 +1337,7 @@ ProgramBar (
  
  );

-Node->PciDev->PciBar[Node->Bar].BaseAddress = Address;
+Node->PciDev->PciBar[Node->Bar].BaseAddress = UseDeviceAddress? Base +
Address: Address;

 break;

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cc397185f7b9..58425ee0d57f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1005,6 +1005,9 @@
   # @Prompt Enable UEFI Stack Guard.
   gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055

+  ## Indicates whether the device address should be used for BAR
programming
+
 gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|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
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index ec24a50c7d0a..39b397cb13d9 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -200,6 +200,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x0
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|28
+  gEfiMdeModulePkgTokenSpaceGuid.PcdUseDeviceAddress|FALSE

 [PcdsFixedAtBuild.IPF]
   gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0c00
-- 
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 v1] Platform/ARM: Add PeiReportStatusCodeLib

2018-05-09 Thread Alexei Fedorov
Hi Leif,


You wrote:

"Yes, this fixes a bug, however I am still unable to build FVP with
-D ARM_FVP_RUN_NORFLASH:
---
In file included from
/work/git/edk2-platforms/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c:22:0:
/work/git/edk2-platforms/Platform/ARM/VExpressPkg/Include/Platform/RTSM/ArmPlatform.h:19:33:
fatal error: VExpressMotherBoard.h: No such file or directory
 #include 
 ^
compilation terminated.
---

Presumably this has been broken since commit 8ad58788b5c did not carry across
-I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include in
GCC:*_*_AARCH64_PLATFORM_FLAGS when migrating ArmVExpressPkg from edk2.

Can you confirm whether you can reproduce this?"


Yes, & it was fixed it by adding

-I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include

in GCC:*_*_AARCH64_PLATFORM_FLAGS of ArmVExpress-FVP-AArch64.dsc:

GCC:*_*_AARCH64_PLATFORM_FLAGS == 
-I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include 
-I$(WORKSPACE)/Platform/ARM/VExpressPkg/Include/Platform/RTSM


Regards.

Alexei


From: Leif Lindholm 
Sent: 09 May 2018 17:24:23
To: Alexei Fedorov
Cc: edk2-devel@lists.01.org; Arvind Chauhan; Daniil Egranov; Thomas Abraham; 
ard.biesheu...@linaro.org; Matteo Carlini; Stephanie Hughes-Fitt; nd; Evan 
Lloyd; Sami Mujawar
Subject: Re: [PATCH edk2-platforms v1] Platform/ARM: Add PeiReportStatusCodeLib

Hi Alexei,

On Thu, May 03, 2018 at 10:24:21AM +0100, Alexei Fedorov wrote:
> From: Alexei Fedorov 
>
> UEFI build fails for ArmVExpress-FVP-AArch64 when using
> "-D ARM_FVP_RUN_NORFLASH" build option, which prevents
> EDK2_SKIP_PEICORE macro from being defined in
> ArmVExpress-FVP-AArch64.dsc:
>
> !ifndef ARM_FVP_RUN_NORFLASH
>   DEFINE EDK2_SKIP_PEICORE=1
> !endif
>
> When EDK2_SKIP_PEICORE macro is not defined, build fails with
> errors 1001:
> Module type [PEI_CORE] is not supported by library instance
> [MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf]
> consumed by [n:\edk2\MdeModulePkg\Core\Pei\PeiMain.inf]
> and
> Module type [PEIM] is not supported by library instance
> [MdeModulePkg\Library\DxeReportStatusCodeLib\DxeReportStatusCodeLib.inf]
> consumed by [n:\edk2\MdeModulePkg\Core\DxeIplPeim\DxeIpl.inf]
>
> This patch fixes the above build errors by adding
> MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
> in [LibraryClasses.common.PEI_CORE] and [LibraryClasses.common.PEIM]
> sections of ArmVExpress.dsc.inc.

Yes, this fixes a bug, however I am still unable to build FVP with
-D ARM_FVP_RUN_NORFLASH:
---
In file included from
/work/git/edk2-platforms/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c:22:0:
/work/git/edk2-platforms/Platform/ARM/VExpressPkg/Include/Platform/RTSM/ArmPlatform.h:19:33:
fatal error: VExpressMotherBoard.h: No such file or directory
 #include 
 ^
compilation terminated.
---

Presumably this has been broken since commit 8ad58788b5c did not carry across
-I$(WORKSPACE)/ArmPlatformPkg/ArmVExpressPkg/Include in
GCC:*_*_AARCH64_PLATFORM_FLAGS when migrating ArmVExpressPkg from edk2.

Can you confirm whether you can reproduce this?

If so, the following stanza resolves the issue for me:
diff --git
a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
index 2287756cf8..ed9720e8ce 100644
--- a/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
+++ b/Platform/ARM/VExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressLibSec.inf
@@ -22,6 +22,7 @@ [Defines]
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   ArmPkg/ArmPkg.dec
   ArmPlatformPkg/ArmPlatformPkg.dec

Best Regards,

Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Alexei Fedorov 
> Reviewed-by:   Evan Lloyd 
> ---
> All the changes can be reviewed at:
> https://github.com/AlexeiFedorov/edk2-platforms/tree/237_add_peireportstatuscodelib_v1
>
> Notes:
> v1:
> - Add PeiReportStatusCodeLib in PEI_CORE and PEIM sections   [Alexei]
>
>  Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc 
> b/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
> index 
> de201b0c81d020e1e06ee320cf0f14f186723657..bb899b91c525ee821b9506cca75224f4bc41e3ae
>  100644
> --- a/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
> +++ b/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
> @@ -166,6 +166,7 @@ [LibraryClasses.common.PEI_CORE]
>
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
>PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
>PerformanceLib|MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf

Re: [edk2] [platforms PATCH v2 4/4] Marvell/Library: ComPhyLib: Fix configuration for PCIE x4 and x2

2018-05-09 Thread Leif Lindholm
A couple of minor style comments.

If you don't disagree, I can fix that up before pushing and you can
have Reviewed-by: Leif Lindholm  for 1,3-4.

On Wed, May 09, 2018 at 03:51:11PM +0200, Marcin Wojtas wrote:
> From: Evan Wang 
> 
> PCIE clock direction (input/output) has implications on comphy settings.
> There are 2 PCIe clocks in CP110:
> -   Ref clock 0 for lanes 1,2 and 3

Space after ,.

> -   Ref clock 1 for lanes 4 and 5
> A proper handling of above had to be added, using newly introduced
> sample at reset library class for Marvell SoCs.
> 
> Other than that, update HPIPE settings and the reset sequence,
> which differ from one used in x1 link.
> 
> This patch fixes PCIE x4 and x2 configuration, which helps
> to overcome link establishing issue for multi-lane end points.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Evan Wang 
> Signed-off-by: Marcin Wojtas 
> ---
>  Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc   |   1 +
>  Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c | 216 +++-
>  Silicon/Marvell/Library/ComPhyLib/ComPhyLib.c   |   1 +
>  Silicon/Marvell/Library/ComPhyLib/ComPhyLib.h   |  36 
>  Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf |   1 +
>  5 files changed, 203 insertions(+), 52 deletions(-)
> 
> diff --git a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc 
> b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
> index a147b6e..4129742 100644
> --- a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
> +++ b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
> @@ -36,6 +36,7 @@
>ComPhyLib|Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
>MppLib|Silicon/Marvell/Library/MppLib/MppLib.inf
>NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf
> +  
> SampleAtResetLib|Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.inf
>UtmiPhyLib|Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
>  
>DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> diff --git a/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c 
> b/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
> index 40a7b99..5c7e769 100755
> --- a/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
> +++ b/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
> @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>  
>  #include "ComPhyLib.h"
>  #include 
> +#include 
>  
>  #define SD_LANE_ADDR_WIDTH  0x1000
>  #define HPIPE_ADDR_OFFSET   0x800
> @@ -42,6 +43,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>  #define HPIPE_ADDR(base, Lane)  (SD_ADDR(base, Lane) + HPIPE_ADDR_OFFSET)
>  #define COMPHY_ADDR(base, Lane) (base + COMPHY_ADDR_LANE_WIDTH * Lane)
>  
> +#define CP110_PCIE_REF_CLK_TYPE00
> +#define CP110_PCIE_REF_CLK_TYPE12   1
> +
>  DECLARE_A7K8K_NONDISCOVERABLE_TEMPLATE;
>  
>  /*
> @@ -99,11 +103,26 @@ COMPHY_MUX_DATA Cp110ComPhyPipeMuxData[] = {
>  STATIC
>  VOID
>  ComPhyPcieRFUConfiguration (
> +  IN UINT32 Lane,
> +  IN UINT32 PcieWidth,
>IN EFI_PHYSICAL_ADDRESS ComPhyAddr
>  )
>  {
>UINT32 Mask, Data;
>  
> +  /* Enable PCIe by4 and by2 */
> +  if (Lane == 0) {
> +if (PcieWidth == 4) {
> +  RegSet (ComPhyAddr + COMMON_PHY_SD_CTRL1,
> +COMMON_PHY_SD_CTRL1_PCIE_X4_EN,
> +COMMON_PHY_SD_CTRL1_PCIE_X4_EN_MASK);
> +} else if (PcieWidth == 2) {
> +  RegSet (ComPhyAddr + COMMON_PHY_SD_CTRL1,
> +COMMON_PHY_SD_CTRL1_PCIE_X2_EN,
> +COMMON_PHY_SD_CTRL1_PCIE_X2_EN_MASK);
> +}
> +  }
> +
>/* RFU configurations - hard reset ComPhy */
>Mask = COMMON_PHY_CFG1_PWR_UP_MASK;
>Data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET;
> @@ -132,11 +151,14 @@ ComPhyPcieRFUConfiguration (
>  STATIC
>  VOID
>  ComPhyPciePhyConfiguration (
> +  IN UINT32 Lane,
> +  IN UINT32 PcieWidth,
> +  IN UINT32 PcieClk,
>IN EFI_PHYSICAL_ADDRESS ComPhyAddr,
>IN EFI_PHYSICAL_ADDRESS HpipeAddr
>  )
>  {
> -  UINT32 Mask, Data, PcieClk = 0;
> +  UINT32 Mask, Data;
>  
>/* Set PIPE soft reset */
>Mask = HPIPE_RST_CLK_CTRL_PIPE_RST_MASK;
> @@ -156,13 +178,31 @@ ComPhyPciePhyConfiguration (
>RegSet (HpipeAddr + HPIPE_RST_CLK_CTRL_REG, Data, Mask);
>  
>/* Set PLL ready delay for 0x2 */
> -  RegSet (HpipeAddr + HPIPE_CLK_SRC_LO_REG,
> -0x2 << HPIPE_CLK_SRC_LO_PLL_RDY_DL_OFFSET,
> -HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK);
> +  Data = HPIPE_CLK_SRC_LO_PLL_RDY_DL_DEFAULT;
> +  Mask = HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK;
> +  if (PcieWidth != 1) {
> +Data |= HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SEL_DEFAULT |
> +HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SCALE_DEFAULT;
> +Mask |= HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SEL_MASK |
> +HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SCALE_MASK;
> +  }
> +  RegSet (HpipeAddr + HPIPE_CLK_SRC_LO_REG, Data, Mask);
>  
>/* Set PIPE mode interface to PCIe3 - 0x1 */
> -  RegSet 

Re: [edk2] [platforms PATCH v2 2/4] Marvell/Armada70x0Db: Use more generic output fd file name

2018-05-09 Thread Leif Lindholm
On Wed, May 09, 2018 at 03:51:09PM +0200, Marcin Wojtas wrote:
> Unification of output file name will ease handling build scripts
> (e.g. for CI purpose) when multiple board support will be added.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marcin Wojtas 

I have no objections to this patch, but please repost it with the set
that adds multiple board support. When you do, you can add
Reviewed-by: Leif Lindholm 

> ---
>  Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf 
> b/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf
> index befb107..e165d90 100644
> --- a/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf
> +++ b/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf
> @@ -24,7 +24,7 @@
>  #
>  
> 
>  
> -[FD.Armada70x0Db_EFI]
> +[FD.Armada_EFI]
>  BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # The base 
> address of the Firmware in NOR Flash.
>  Size  = 0x0040|gArmTokenSpaceGuid.PcdFdSize # The size 
> in bytes of the FLASH Device
>  ErasePolarity = 1
> -- 
> 2.7.4
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v1] Platform/ARM: Correct GIC naming

2018-05-09 Thread Leif Lindholm
On Wed, May 02, 2018 at 05:26:42PM +0100, Alexei Fedorov wrote:
> From: Alexei Fedorov 
> 
> ARM Generic Interrupt Controller is incorrectly named as
> "ARM General Interrupt Controller" in ArmJuno.dsc,
> ArmVExpress-CTA15-A7.dsc and ArmVExpress-FVP-AArch64.dsc.
> 
> This patch corrects the comment by changing "General" to "Generic".
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Alexei Fedorov 
> Reviewed-by:   Evan Lloyd 

Like I asked Sami today, please let Evan send his own r-b on the list
in future. I'll keep it in here for now.

For the patch:
Reviewed-by: Leif Lindholm 

> ---
> All the changes can be reviewed at:
> https://github.com/AlexeiFedorov/edk2-platforms/tree/261_correct_gic_naming_v1

This is much appreciated - however, please link to the actual version
you send out. That one contains a "Change-ID" tag that was not present
in this email, and it also lacks the Evan Reviewed-by (also it messes
with the commit hash).

Thanks for the cleanup - pushed as 5cfda16b1a.


> 
> Notes:
> v1:
> - Change ARM "General" Interrupt Controller to "Generic" [Alexei]
> 
>  Platform/ARM/JunoPkg/ArmJuno.dsc | 2 +-
>  Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc| 4 ++--
>  Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/Platform/ARM/JunoPkg/ArmJuno.dsc 
> b/Platform/ARM/JunoPkg/ArmJuno.dsc
> index 
> 5ec563cefbcd9d97614dc9944bfaeb3822c4634d..8d6dd0207db5f16d7fcc0c5fd59fea38498f3034
>  100644
> --- a/Platform/ARM/JunoPkg/ArmJuno.dsc
> +++ b/Platform/ARM/JunoPkg/ArmJuno.dsc
> @@ -150,7 +150,7 @@ [PcdsFixedAtBuild.common]
>gEmbeddedTokenSpaceGuid.PcdLan9118DefaultNegotiationTimeout|4
>  
>#
> -  # ARM General Interrupt Controller
> +  # ARM Generic Interrupt Controller
>#
>gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C01
>gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C02F000
> diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc 
> b/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
> index 
> ef737670126db980abcc0e0ac9b84321bfa97584..6405d955f15a87c8d7b379f8c05b43f3e0830c54
>  100644
> --- a/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
> +++ b/Platform/ARM/VExpressPkg/ArmVExpress-CTA15-A7.dsc
> @@ -1,5 +1,5 @@
>  #
> -#  Copyright (c) 2012-2017, ARM Limited. All rights reserved.
> +#  Copyright (c) 2012-2018, ARM Limited. All rights reserved.
>  #  Copyright (c) 2015, Intel Corporation. All rights reserved.
>  #
>  #  This program and the accompanying materials
> @@ -156,7 +156,7 @@ [PcdsFixedAtBuild.common]
>  
>  
>#
> -  # ARM General Interrupt Controller
> +  # ARM Generic Interrupt Controller
>#
>gArmTokenSpaceGuid.PcdGicDistributorBase|0x2C001000
>gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C002000
> diff --git a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc 
> b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
> index 
> 600bffb66703305f4a6baec930cd044998744c24..ca19fd65265a531e8c0869460aa9b6358b70bf91
>  100644
> --- a/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
> +++ b/Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc
> @@ -147,7 +147,7 @@ [PcdsFixedAtBuild.common]
>gArmPlatformTokenSpaceGuid.PcdPL180MciBaseAddress|0x1C05
>  
>#
> -  # ARM General Interrupt Controller
> +  # ARM Generic Interrupt Controller
>#
>gArmTokenSpaceGuid.PcdGicDistributorBase|0x2f00
>gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x2f10
> -- 
> '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] BaseTools: Remove the redundant code

2018-05-09 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

Gotta love removing code.

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Yonghong Zhu
> Sent: Wednesday, May 9, 2018 5:32 AM
> To: edk2-devel@lists.01.org
> Subject: [edk2] [Patch] BaseTools: Remove the redundant code
> 
> the ArraySize and Array already be got in line 1093, so this code are
> redundant.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yonghong Zhu 
> ---
>  BaseTools/Source/Python/AutoGen/GenC.py | 10 --
>  1 file changed, 10 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
> b/BaseTools/Source/Python/AutoGen/GenC.py
> index 6192e86..40a343c 100644
> --- a/BaseTools/Source/Python/AutoGen/GenC.py
> +++ b/BaseTools/Source/Python/AutoGen/GenC.py
> @@ -1096,20 +1096,10 @@ def CreateModulePcdCode(Info, AutoGenC,
> AutoGenH, Pcd):
>  # Long term we need PCD macros that work in assembly
>  #
>  elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in
> TAB_PCD_NUMERIC_TYPES_VOID:
>  Value = "((%s)%s)" % (Pcd.DatumType, Value)
> 
> -if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES_VOID:
> -# handle structure PCD
> -if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':
> -EdkLogger.error("build", AUTOGEN_ERROR,
> -"Unknown [MaxDatumSize] of PCD [%s.%s]" %
> (Pcd.TokenSpaceGuidCName, TokenCName),
> -ExtraData="[%s]" % str(Info))
> -
> -ArraySize = int(Pcd.MaxDatumSize, 0)
> -Array = '[%d]' % ArraySize
> -
>  if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
>  PcdValueName = '_PCD_PATCHABLE_VALUE_' + TokenCName
>  else:
>  PcdValueName = '_PCD_VALUE_' + TokenCName
> 
> --
> 2.6.1.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [staging/dynamictables PATCH v1] Update Readme.md to reflect ACPICA compiler update

2018-05-09 Thread Leif Lindholm
On Fri, Apr 27, 2018 at 04:24:59PM +0100, Sami Mujawar wrote:
> The ACPICA iASL compiler has been enhanced to support the
> generation of an AML hex file which is required by the
> Dynamic Tables Framework. The patch for this enhancement
> has been integrated in the ACPICA repository. Therefore
> the Prerequisites section in the Readme has been updated
> accordingly.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sami Mujawar 
> Reviewed-by: Evan Lloyd 
> ---
> The changes can be seen at
> https://github.com/samimujawar/edk2-staging/tree/258_reflect_acpica_compiler_enhancement_v1
> 
> Notes:
> v1:
> - Update ACPICA iAsl compiler usage guidelines. [SAMI]
> 
>  Readme.md | 21 +++-
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/Readme.md b/Readme.md
> index 
> b72efca18e8ab5de17cab06f0a1a0725991256d4..2300fa6be9f83525e8c0ee21800751d9067b02e0
>  100644
> --- a/Readme.md
> +++ b/Readme.md
> @@ -87,9 +87,9 @@ contains the Dynamic Tables Framework.
>  ### 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 current implementation of the iASL compiler does not
> -support generation of a C header file suitable for including from a C source
> -file.
> +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
>  --
> @@ -135,16 +135,19 @@ or
>  
>  Prerequisites
>  -
> -ACPICA iASL compiler with support for generating a C header file.
> +ACPICA iASL compiler with the enhanced "-tc" option to support generation of
> +AML hex (C header) files with unique symbol names.
>  
> -A patch ***'Modify hex AML C header file generation'***, to enable
> -this support has been submitted to the ACPICA source repository.
> -
> +A patch ***'[iASL: Enhance the -tc option (create AML hex file in 
> C)](https://github.com/acpica/acpica/commit/f9a88a4c1cd020b6a5475d63b29626852a0b5f37)'***,
> +to enable this support has been integrated to the ACPICA source repository.

Same comment as the related patches - can you put the commitdate of
that patch in here as well?

> +
> +
> +Ensure that the iASL compiler used for building *Dynamic Tables Framework*
> +has this feature enabled.
>  
>  Documentation
>  -
> -A description document is in preparation, and should be available in the
> -near future.
> +[Dynamic Tables Framework: A Step Towards Automatic Generation of Advanced 
> Configuration and Power Interface (ACPI) & System Management BIOS (SMBIOS) 
> Tables – Sami Mujawar 
> (Arm).](http://www.uefi.org/sites/default/files/resources/Arm_Dynamic%20Tables%20Framework%20A%20Step%20Towards%20Automatic%20Generation%20of%20Advanced%20Configuration%20and%20Power%20Interface%20%28ACPI%29%20%26%20System%20Management%20BIOS%20%28SMBIOS%29%20Tables%20_0.pdf)

And can you point out that this was a presentation at UEFI Plugfest
Seattle 2018?

/
Leif

>  
>  Miscellaneous
>  -
> -- 
> '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] [staging/dynamictables PATCH v1 0/2] IORT Generator update

2018-05-09 Thread Leif Lindholm
On Fri, Apr 27, 2018 at 04:53:53PM +0100, Sami Mujawar wrote:
> This patchset contains the changes necessary for supporting the IORT
> specification Revision D, March 2018 update.
> 
> The "MdePkg: IORT Specification Rev D updates" patch has already been
> ACKed by Ard Biesheuve and Liming Gao; however has not yet been merged
> in the tianorcore\edk2 repository. Since this patch is a precursor for
> the IORT Generator update it has been included in this patchset.
> For more details see 
> https://lists.01.org/pipermail/edk2-devel/2018-April/024267.html

Liming, Mike - any chance of getting that one pushed?

> Sami Mujawar (2):
>   MdePkg: IORT Specification Rev D updates
>   DynamicTablesPkg: Update IORT generator

For the series:
Reviewed-by: Leif Lindholm 

Pushed as c47bc46170..67fd6a2c5e.

Side note - you can put the published branch in 0/* only, it doesn't
need to be repeated for each patch.

> 
>  DynamicTablesPkg/Include/ArmNameSpaceObjects.h   |  6 +-
>  DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 19 
> ++-
>  MdePkg/Include/IndustryStandard/IoRemappingTable.h   | 10 
> ++
>  3 files changed, 21 insertions(+), 14 deletions(-)
> 
> -- 
> '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] MdePkg/BaseLib: Globally include ChkStk.c

2018-05-09 Thread Tim Lewis
Marvin -

My suggestion would be the same as yours: to generate a runtime error.

Tim

-Original Message-
From: edk2-devel  On Behalf Of Marvin
Häuser
Sent: Wednesday, May 9, 2018 1:45 AM
To: edk2-devel@lists.01.org
Cc: Yao, Jiewen ; Tim Lewis 
Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c

Hey Tim,

The compiler has no information regarding the size of the stack and hence
cannot determine an overflow.
This is basically a warning that stack of a single function is big enough to
reach past the Guard Page and ensures it will be accessed.

Yao,

I just realized there already is Stack protection code in edk2, I was only
aware of Heap protection.
Wouldn't a proper implementation make sense now to maybe not expand the
stack, but at least runtime-error?

Regards,
Marvin

> -Original Message-
> From: Tim Lewis 
> Sent: Wednesday, May 9, 2018 3:28 AM
> To: 'Yao, Jiewen' ; marvin.haeu...@outlook.com; 
> edk2-devel@lists.01.org
> Subject: RE: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> 
> I think that this is a fatal error in EDK2. It basically says, "we are 
> out of stack space." The alternative is: the system hangs in an 
> unexpected way since the stack overflows into other pages.
> 
> Tim
> 
> -Original Message-
> From: edk2-devel  On Behalf Of Yao, 
> Jiewen
> Sent: Tuesday, May 8, 2018 5:25 PM
> To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> 
> We discussed internally in Intel.
> 
> The quick workaround is: use /Gs65536. :-)
> 
> At the same time, our recommendation is to revisit the code which 
> triggers this error. Why this function need such a big stack? And try 
> to reduce the local stack usage.
> 
> What is why we still use /Gs32768 as default, instead of /Gs65536.
> 
> Thank you
> Yao Jiewen
> 
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf 
> > Of Marvin H?user
> > Sent: Tuesday, May 8, 2018 5:21 PM
> > To: edk2-devel@lists.01.org
> > Cc: Yao, Jiewen 
> > Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include 
> > ChkStk.c
> >
> > Oh, if you are prefering a good implementation, I will be all for 
> > that. This was just a 'quick workaround', same as currently done for
GCC.
> > I'm actually unsure whether a good implementation is possible with a 
> > flat memory model. It will likely be mere luck whether there is 
> > enough space free below the stack, except for maybe when it's 
> > located very high (preferably past the 32-bit space).
> > Has there been any prior discussion on this topic? Would be 
> > interested to follow up if there was.
> >
> > Thanks,
> > Marvin
> >
> > > -Original Message-
> > > From: Yao, Jiewen 
> > > Sent: Wednesday, May 9, 2018 2:13 AM
> > > To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> > > Cc: Gao, Liming 
> > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> > >
> > > There are some open source implementation:
> > > MSVC: https://github.com/ispc/ispc/issues/542
> > > GCC:
> > >
> https://android.googlesource.com/toolchain/gcc/+/b094d6c4bf572654a03
> > > 1e cc4afe675154c886dc5/gcc-4.4.3/gcc/config/i386/chkstk.asm
> > >
> > > The compiler generated code assumes the stack is enlarged after we 
> > > can chkstk.
> > >
> > > I agree empty function can make build pass.
> > > But more important, we need make it work if there is a need to 
> > > increase the stack.
> > > The potential issue is that the later code (after chkstk) assumes 
> > > the stack is increased, but actually it is not.
> > >
> > > That is why I ask how this is validated.
> > >
> > > Thank you
> > > Yao Jiewen
> > >
> > >
> > > > -Original Message-
> > > > From: Marvin Häuser [mailto:marvin.haeu...@outlook.com]
> > > > Sent: Tuesday, May 8, 2018 4:58 PM
> > > > To: edk2-devel@lists.01.org
> > > > Cc: Yao, Jiewen ; Gao, Liming 
> > > > 
> > > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> > > >
> > > > Hey Yao,
> > > >
> > > > As far as I am aware, all __chkstk does is access the stack in 4 
> > > > KB intervals from the current location to the maximum requested 
> > > > location to eventually hit the Windows Guard Page, which then 
> > > > triggers the stack
> > > increase.
> > > > Because I do not know of any equivalent concept in edk2 and the 
> > > > intrinsic was already disabled for GCC, I supposed it was a good 
> > > > idea to do so globally. Are the potential issues I am not aware of?
> > > >
> > > > Thanks,
> > > > Marvin.
> > > >
> > > > > -Original Message-
> > > > > From: Yao, Jiewen 
> > > > > Sent: Wednesday, May 9, 2018 1:52 AM
> > > > 

[edk2] [platforms PATCH v2 4/4] Marvell/Library: ComPhyLib: Fix configuration for PCIE x4 and x2

2018-05-09 Thread Marcin Wojtas
From: Evan Wang 

PCIE clock direction (input/output) has implications on comphy settings.
There are 2 PCIe clocks in CP110:
-   Ref clock 0 for lanes 1,2 and 3
-   Ref clock 1 for lanes 4 and 5
A proper handling of above had to be added, using newly introduced
sample at reset library class for Marvell SoCs.

Other than that, update HPIPE settings and the reset sequence,
which differ from one used in x1 link.

This patch fixes PCIE x4 and x2 configuration, which helps
to overcome link establishing issue for multi-lane end points.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Evan Wang 
Signed-off-by: Marcin Wojtas 
---
 Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc   |   1 +
 Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c | 216 +++-
 Silicon/Marvell/Library/ComPhyLib/ComPhyLib.c   |   1 +
 Silicon/Marvell/Library/ComPhyLib/ComPhyLib.h   |  36 
 Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf |   1 +
 5 files changed, 203 insertions(+), 52 deletions(-)

diff --git a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc 
b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
index a147b6e..4129742 100644
--- a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
+++ b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
@@ -36,6 +36,7 @@
   ComPhyLib|Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
   MppLib|Silicon/Marvell/Library/MppLib/MppLib.inf
   NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf
+  
SampleAtResetLib|Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.inf
   UtmiPhyLib|Silicon/Marvell/Library/UtmiPhyLib/UtmiPhyLib.inf
 
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
diff --git a/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c 
b/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
index 40a7b99..5c7e769 100755
--- a/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
+++ b/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "ComPhyLib.h"
 #include 
+#include 
 
 #define SD_LANE_ADDR_WIDTH  0x1000
 #define HPIPE_ADDR_OFFSET   0x800
@@ -42,6 +43,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define HPIPE_ADDR(base, Lane)  (SD_ADDR(base, Lane) + HPIPE_ADDR_OFFSET)
 #define COMPHY_ADDR(base, Lane) (base + COMPHY_ADDR_LANE_WIDTH * Lane)
 
+#define CP110_PCIE_REF_CLK_TYPE00
+#define CP110_PCIE_REF_CLK_TYPE12   1
+
 DECLARE_A7K8K_NONDISCOVERABLE_TEMPLATE;
 
 /*
@@ -99,11 +103,26 @@ COMPHY_MUX_DATA Cp110ComPhyPipeMuxData[] = {
 STATIC
 VOID
 ComPhyPcieRFUConfiguration (
+  IN UINT32 Lane,
+  IN UINT32 PcieWidth,
   IN EFI_PHYSICAL_ADDRESS ComPhyAddr
 )
 {
   UINT32 Mask, Data;
 
+  /* Enable PCIe by4 and by2 */
+  if (Lane == 0) {
+if (PcieWidth == 4) {
+  RegSet (ComPhyAddr + COMMON_PHY_SD_CTRL1,
+COMMON_PHY_SD_CTRL1_PCIE_X4_EN,
+COMMON_PHY_SD_CTRL1_PCIE_X4_EN_MASK);
+} else if (PcieWidth == 2) {
+  RegSet (ComPhyAddr + COMMON_PHY_SD_CTRL1,
+COMMON_PHY_SD_CTRL1_PCIE_X2_EN,
+COMMON_PHY_SD_CTRL1_PCIE_X2_EN_MASK);
+}
+  }
+
   /* RFU configurations - hard reset ComPhy */
   Mask = COMMON_PHY_CFG1_PWR_UP_MASK;
   Data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET;
@@ -132,11 +151,14 @@ ComPhyPcieRFUConfiguration (
 STATIC
 VOID
 ComPhyPciePhyConfiguration (
+  IN UINT32 Lane,
+  IN UINT32 PcieWidth,
+  IN UINT32 PcieClk,
   IN EFI_PHYSICAL_ADDRESS ComPhyAddr,
   IN EFI_PHYSICAL_ADDRESS HpipeAddr
 )
 {
-  UINT32 Mask, Data, PcieClk = 0;
+  UINT32 Mask, Data;
 
   /* Set PIPE soft reset */
   Mask = HPIPE_RST_CLK_CTRL_PIPE_RST_MASK;
@@ -156,13 +178,31 @@ ComPhyPciePhyConfiguration (
   RegSet (HpipeAddr + HPIPE_RST_CLK_CTRL_REG, Data, Mask);
 
   /* Set PLL ready delay for 0x2 */
-  RegSet (HpipeAddr + HPIPE_CLK_SRC_LO_REG,
-0x2 << HPIPE_CLK_SRC_LO_PLL_RDY_DL_OFFSET,
-HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK);
+  Data = HPIPE_CLK_SRC_LO_PLL_RDY_DL_DEFAULT;
+  Mask = HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK;
+  if (PcieWidth != 1) {
+Data |= HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SEL_DEFAULT |
+HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SCALE_DEFAULT;
+Mask |= HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SEL_MASK |
+HPIPE_CLK_SRC_LO_BUNDLE_PERIOD_SCALE_MASK;
+  }
+  RegSet (HpipeAddr + HPIPE_CLK_SRC_LO_REG, Data, Mask);
 
   /* Set PIPE mode interface to PCIe3 - 0x1 */
-  RegSet (HpipeAddr + HPIPE_CLK_SRC_HI_REG,
-0x1 << HPIPE_CLK_SRC_HI_MODE_PIPE_OFFSET, HPIPE_CLK_SRC_HI_MODE_PIPE_MASK);
+  Data = HPIPE_CLK_SRC_HI_MODE_PIPE_EN;
+  Mask = HPIPE_CLK_SRC_HI_MODE_PIPE_MASK;
+  if (PcieWidth != 1) {
+Mask |= HPIPE_CLK_SRC_HI_LANE_STRT_MASK |
+HPIPE_CLK_SRC_HI_LANE_MASTER_MASK |
+HPIPE_CLK_SRC_HI_LANE_BREAK_MASK;
+if (Lane == 0) {
+  Data |= HPIPE_CLK_SRC_HI_LANE_STRT_EN |
+  HPIPE_CLK_SRC_HI_LANE_MASTER_EN;
+} else if (Lane == 

[edk2] [platforms PATCH v2 0/4] Armada7k8k x4/x2 PCIE fix and misc improvements

2018-05-09 Thread Marcin Wojtas
Hi,

After long break, here's v2 of PCIE serdes fix with all review remarks
applied. 2, very small additional patches are added, which
restore proper compilation and change output file name.

More details can be found in the commit messages and the
changelog below. The code is also available in the github:
https://github.com/MarvellEmbeddedProcessors/edk2-open-platform/commits/x4pcie-upstream-r20180509

I'm looking forward to your feedback.

Best regards,
Marcin

Changelog:
v1 -> v2

[1/4] - new patch

[2/4] - new patch

[3/4]:
- add glossary sections under licences paragraphs
- change library name from SAR to SampleAtReset
- use structures in the tables
- simplify obtaining values
- move structures/defines to header
- cleanup macros name and dependencies (mask/offset)

[4/4]:
- clean-up new macros usage (use dedicated ones instead
  of 'value << offset'
- remove magic numbers
- improve comments
- simplify sanity check of lanes status after enabling


Evan Wang (1):
  Marvell/Library: ComPhyLib: Fix configuration for PCIE x4 and x2

Igal Liberman (1):
  Marvell/Armada7k8k: Add basic sample at reset library

Marcin Wojtas (2):
  Marvell/Armada7k8k: Remove Intel BDS dependency
  Marvell/Armada70x0Db: Use more generic output fd file name

 Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf 
  |   2 +-
 Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc  
  |   2 +-
 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.c
   | 111 ++
 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.h
   | 109 ++
 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.inf
 |  54 +
 Silicon/Marvell/Include/Library/SampleAtResetLib.h 
  |  57 ++
 Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
  | 216 +++-
 Silicon/Marvell/Library/ComPhyLib/ComPhyLib.c  
  |   1 +
 Silicon/Marvell/Library/ComPhyLib/ComPhyLib.h  
  |  36 
 Silicon/Marvell/Library/ComPhyLib/ComPhyLib.inf
  |   1 +
 Silicon/Marvell/Marvell.dec
  |   3 +
 11 files changed, 538 insertions(+), 54 deletions(-)
 create mode 100644 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.c
 create mode 100644 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.h
 create mode 100644 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.inf
 create mode 100644 Silicon/Marvell/Include/Library/SampleAtResetLib.h

-- 
2.7.4

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


[edk2] [platforms PATCH v2 1/4] Marvell/Armada7k8k: Remove Intel BDS dependency

2018-05-09 Thread Marcin Wojtas
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile is no
longer needed due to usage of generic BDS and its
presence results in build error. Remove it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas 
---
 Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc 
b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
index cd58107..a147b6e 100644
--- a/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
+++ b/Silicon/Marvell/Armada7k8k/Armada7k8k.dsc.inc
@@ -236,7 +236,6 @@
 
   # Required for Intel BDS
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
 
   # ARM Generic Interrupt Controller
   gArmTokenSpaceGuid.PcdGicDistributorBase|0xF021
-- 
2.7.4

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


[edk2] [platforms PATCH v2 3/4] Marvell/Armada7k8k: Add basic sample at reset library

2018-05-09 Thread Marcin Wojtas
From: Igal Liberman 

The sample at reset library adds the following functionalities:
- MvSARGetCpuFreq - Get the CPU frequency
- MvSARGetDramFreq - Get the DRAM frequency
- MvSARGetPcieClkDirection - Determine the PCIe clock direction
  for two types specified in CP110 HW block. It will be needed
  for proper configuration during the PCIE SerDes training.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Igal Liberman 
Signed-off-by: Marcin Wojtas 
---
 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.c
   | 111 
 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.h
   | 109 +++
 
Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.inf
 |  54 ++
 Silicon/Marvell/Include/Library/SampleAtResetLib.h 
  |  57 ++
 Silicon/Marvell/Marvell.dec
  |   3 +
 5 files changed, 334 insertions(+)

diff --git 
a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.c
 
b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.c
new file mode 100644
index 000..3ebff56
--- /dev/null
+++ 
b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSampleAtResetLib/Armada7k8kSampleAtResetLib.c
@@ -0,0 +1,111 @@
+/
+Copyright (C) 2018 Marvell International Ltd.
+
+Marvell BSD License Option
+
+If you received this File from Marvell, you may opt to use, redistribute and/or
+modify this File under the following licensing terms.
+Redistribution and use in source and binary forms, with or without 
modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must Retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in the
+  documentation and/or other materials provided with the distribution.
+
+* Neither the name of Marvell nor the names of its contributors may be
+  used to endorse or promote products derived from this software without
+  specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Glossary - abbreviations used in Marvell SampleAtReset library implementation:
+AP - Application Processor hardware block (Armada 7k8k incorporates AP806)
+CP - South Bridge hardware blocks (Armada 7k8k incorporates CP110)
+SAR - Sample At Reset
+
+***/
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "Armada7k8kSampleAtResetLib.h"
+
+UINT32
+EFIAPI
+SampleAtResetGetCpuFrequency (
+  VOID
+  )
+{
+  CONST PLL_FREQUENCY_DESCRIPTION *PllFrequencies;
+  UINT32 ClockValue;
+  UINT32 Index;
+
+  ClockValue = MmioAnd32 (AP806_SAR_BASE, SAR_CLOCK_FREQUENCY_MODE_MASK);
+
+  PllFrequencies = PllFrequencyTable;
+
+  for (Index = 0; Index < SAR_MAX_OPTIONS; Index++, PllFrequencies++) {
+if (PllFrequencies->ClockingOption == ClockValue) {
+  break;
+}
+  }
+
+  return PllFrequencies->CpuFrequency;
+}
+
+UINT32
+EFIAPI
+SampleAtResetGetDramFrequency (
+  VOID
+  )
+{
+  CONST PLL_FREQUENCY_DESCRIPTION *PllFrequencies;
+  UINT32 ClockValue;
+  UINT32 Index;
+
+  ClockValue = MmioAnd32 (AP806_SAR_BASE, SAR_CLOCK_FREQUENCY_MODE_MASK);
+
+  PllFrequencies = PllFrequencyTable;
+
+  for (Index = 0; Index < SAR_MAX_OPTIONS; Index++, PllFrequencies++) {
+if (PllFrequencies->ClockingOption == ClockValue) {
+  break;
+}
+  }
+
+  return PllFrequencies->DdrFrequency;
+}
+
+UINT32
+EFIAPI
+SampleAtResetGetPcieClockDirection (
+  IN UINT32 CpIndex,
+  IN UINT32 PcieIndex
+  )
+{
+  UINT32 ClockDirection;
+
+  ASSERT (CpIndex < MAX_CP_COUNT);
+  ASSERT (PcieIndex < MAX_PCIE_CLK_TYPE_COUNT);
+
+  ClockDirection = MmioAnd32 (CP110_SAR_BASE (CpIndex),
+ PcieClockMask[CpIndex][PcieIndex] >>
+

[edk2] [platforms PATCH v2 2/4] Marvell/Armada70x0Db: Use more generic output fd file name

2018-05-09 Thread Marcin Wojtas
Unification of output file name will ease handling build scripts
(e.g. for CI purpose) when multiple board support will be added.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas 
---
 Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf 
b/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf
index befb107..e165d90 100644
--- a/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf
+++ b/Platform/Marvell/Armada70x0Db/Armada70x0Db.fdf
@@ -24,7 +24,7 @@
 #
 

 
-[FD.Armada70x0Db_EFI]
+[FD.Armada_EFI]
 BaseAddress   = 0x|gArmTokenSpaceGuid.PcdFdBaseAddress  # The base 
address of the Firmware in NOR Flash.
 Size  = 0x0040|gArmTokenSpaceGuid.PcdFdSize # The size in 
bytes of the FLASH Device
 ErasePolarity = 1
-- 
2.7.4

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


Re: [edk2] [PATCH v2 edk-platforms 2/4] Platform/Hisilicon/HiKey960: enable virtual keyboard

2018-05-09 Thread Leif Lindholm
On Wed, May 09, 2018 at 06:59:53PM +0800, Haojian Zhuang wrote:
> On 3 May 2018 at 06:49, Leif Lindholm  wrote:
> > On Thu, Mar 08, 2018 at 09:30:04PM +0800, Haojian Zhuang wrote:
> >> Enable virtual keyboard on HiKey960 platform. The platform
> >> driver read pattern from memory or GPIO pin. When the value
> >> is matched, it simulates a hotkey that is used to adjust
> >> sequence of boot options.
> >
> > This patch looks like it contains an awful lot more than described
> > here. Can it be split up?
> >
> >> Cc: Leif Lindholm 
> >> Cc: Ard Biesheuvel 
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Haojian Zhuang 
> >> ---
> >>  Platform/Hisilicon/HiKey960/HiKey960.dsc|  10 +
> >>  Platform/Hisilicon/HiKey960/HiKey960.fdf|   7 +
> >>  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  54 +++
> >>  Silicon/Hisilicon/Hi3660/Include/Hi3660.h   | 147 ++
> >>  Silicon/Hisilicon/Hi3660/Include/Hkadc.h|  66 +++
> >>  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 491 
> >> 
> >>  6 files changed, 775 insertions(+)
> >>
> >> +STATIC
> >> +VOID
> >> +InitAdc (
> >> +  VOID
> >> +  )
> >> +{
> >> +  // reset hkadc
> >> +  MmioWrite32 (CRG_PERRSTEN2, PERRSTEN2_HKADCSSI);
> >> +  // wait a few clock cycles
> >> +  MicroSecondDelay (2);
> >> +  MmioWrite32 (CRG_PERRSTDIS2, PERRSTEN2_HKADCSSI);
> >> +  MicroSecondDelay (2);
> >> +  // enable hkadc clock
> >> +  MmioWrite32 (CRG_PERDIS2, PEREN2_HKADCSSI);
> >> +  MicroSecondDelay (2);
> >> +  MmioWrite32 (CRG_PEREN2, PEREN2_HKADCSSI);
> >> +  MicroSecondDelay (2);
> >
> > Why the need for a few clock cycles? Why was 2 chosen? Barriers needed?
> >
> 
> Need to wait hardware stabilization. Barriers don't help at here.

Understood, but please add a comment to that effect.
One comment for each block of these.

> >> +  Adcin1Remap = AdcinDataRemap (Adcin1);
> >> +  DEBUG ((DEBUG_INFO, "[BDID]Adcin1Remap:%d\n", Adcin1Remap));
> >> +  if (Adcin1Remap == BOARDID_UNKNOW) {
> >> +return EFI_INVALID_PARAMETER;
> >> +  }
> >> +  // read ADC channel2 data
> >> +  AdcGetValue (ADC_ADCIN2, );
> >> +  DEBUG ((DEBUG_INFO, "[BDID]Adcin2:%d\n", Adcin2));
> >> +  Adcin2Remap = AdcinDataRemap (Adcin2);
> >> +  DEBUG ((DEBUG_INFO, "[BDID]Adcin2Remap:%d\n", Adcin2Remap));
> >> +  if (Adcin2Remap == BOARDID_UNKNOW) {
> >> +return EFI_INVALID_PARAMETER;
> >> +  }
> >> +  *Id = BOARDID3_BASE * 1000 + (Adcin2Remap * 100) + (Adcin1Remap * 10) + 
> >> Adcin0Remap;
> >
> > 1) Please use parentheses consistently.
> > 2) This is the only use of BOARDID3_BASE - why is it being multiplied?
> 
> It's used to generate the same prefix of board family.
> 
> > 3) What is the format of this ID? Is it described somewhere or is it
> >completely arbitrary?
> 
> BoardID is based on the voltage of a resistor. Since the resistor
> value is fixed,
> the BoardID is same on all HiKey960 platforms.
> 
> For example, BoardID v1 is different from BoardID v2. But the prefix is same.

Can you add a comment describing this before the assignment to *Id?
I would like to understand how we can ensure analog errors do not
cause misidentification.

And this would be easier with hex values and masks, but if the
algorithm is already defined and used, we could have max/min values
for each, test against them, and return error if invalid values are
found.

Trying to make sense of the code, I also think these should all be
AcdIn... rather than Acdin... (upper case I)
Functions and variables.

> > 4) What is the purpose of this Id? This function is used to populate
> >mBoardId, but that variable is not used anywhere.
> 
> It'll be used later. It will fill different DTB contents according to
> different versions
> of the HiKey960 platforms.

Then could it be postponed until we get those patches as well, so we
can see its use and not just its definition?

> >> +  DEBUG ((DEBUG_INFO, "[BDID]boardid: %d\n", *Id));
> >> +  return EFI_SUCCESS;
> >> +}
> >> +
> >> +STATIC
> >> +VOID
> >> +InitSdCard (
> >> +  IN VOID
> >> +  )
> >> +{
> >> +  UINT32Data;
> >> +
> >> +  // LDO16
> >> +  Data = MmioRead32 (PMU_REG_BASE + (0x79 << 2)) & 7;
> >> +  Data |= 6;
> >> +  MmioWrite32 (PMU_REG_BASE + (0x79 << 2), Data);
> >> +  MmioOr32 (PMU_REG_BASE + (0x78 << 2), 2);
> >
> > Please replace all live-coded values with #defines.
> 
> I'll try to replace the hard-coded values as I could. But I can't get 
> everything
> with document.

Thanks.

> >> +  MicroSecondDelay (100);
> >
> > Why this delay?
> > Does this need a barrier?
> 
> Barrier doesn't help. Just wait regulator stable.

Add comment please.

> >> +
> >> +  // LDO9
> >> +  Data = MmioRead32 (PMU_REG_BASE + (0x6b << 2)) & 7;
> >> +  Data |= 5;
> >> +  MmioWrite32 (PMU_REG_BASE + (0x6b << 2), Data);
> >> +  MmioOr32 (PMU_REG_BASE + 

[edk2] [Patch] BaseTools: Remove the redundant code

2018-05-09 Thread Yonghong Zhu
the ArraySize and Array already be got in line 1093, so this code are
redundant.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Source/Python/AutoGen/GenC.py | 10 --
 1 file changed, 10 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 6192e86..40a343c 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1096,20 +1096,10 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 # Long term we need PCD macros that work in assembly
 #
 elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in 
TAB_PCD_NUMERIC_TYPES_VOID:
 Value = "((%s)%s)" % (Pcd.DatumType, Value)
 
-if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES_VOID:
-# handle structure PCD
-if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':
-EdkLogger.error("build", AUTOGEN_ERROR,
-"Unknown [MaxDatumSize] of PCD [%s.%s]" % 
(Pcd.TokenSpaceGuidCName, TokenCName),
-ExtraData="[%s]" % str(Info))
-
-ArraySize = int(Pcd.MaxDatumSize, 0)
-Array = '[%d]' % ArraySize
-
 if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
 PcdValueName = '_PCD_PATCHABLE_VALUE_' + TokenCName
 else:
 PcdValueName = '_PCD_VALUE_' + TokenCName
 
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib LibraryClass.

2018-05-09 Thread Laszlo Ersek
Hi,

On 05/09/18 11:32, Zeng, Star wrote:
> Marvin,
> 
> It is good direction to reuse more code.
> What am I concerning about are
> 1. There are comments "Sample ACPI Platform Driver" in AcpiPlatformDxe.inf 
> and AcpiPlatformDxe.c, the current position of AcpiPlatformDxe seems just for 
> reference.
> 2. Almost all the platforms have their own AcpiPlatformDxe, for example
> https://github.com/tianocore/edk2/tree/master/OvmfPkg/AcpiPlatformDxe
> https://github.com/tianocore/edk2/tree/master/QuarkPlatformPkg/Acpi/Dxe/AcpiPlatform
> https://github.com/tianocore/edk2/tree/master/Vlv2TbltDevicePkg/AcpiPlatform
> ...
> 
> Should more evaluation be done on them to see whether we can do more or we 
> just suggest platform should implement its own AcpiPlatformDxe?
> 
> Including more experts.

I can't really comment on other platforms, but for OvmfPkg and
ArmVirtPkg, the ACPI platform driver(s) are totally custom. The ACPI
payload is generated by VMM software (on the host), the driver loads the
blobs and processes them in various ways (also controlled by the VMM),
and finally the driver installs the tables.

Marvin writes below:

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Marvin 
> H?user
> Sent: Wednesday, May 9, 2018 7:26 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Dong, Eric ; Zeng, 
> Star 
> Subject: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib LibraryClass.
> 
> PlatformAcpiLib can be consumed by the generic ACPI Platform driver
> to allow platform specific updates to the ACPI tables loaded from the
> configured Firmware Volume.

In our use case, the ACPI tables are not loaded from firmware volumes at
all. (OVMF still has such a fallback for extremely old QEMU versions,
but that fallback should rather be removed than modified in any way.)

Thanks,
Laszlo

> This allows for more platforms to
> incorporate the generic ACPI Platform driver.
> 
> This commit also provides a NULL implementation of PlatformAcpiLib.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Marvin Haeuser 
> ---
>  MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c   | 
> 36 
>  MdeModulePkg/Include/Library/PlatformAcpiLib.h   | 
> 36 
>  MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.inf | 
> 35 +++
>  MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.uni | 
> 18 ++
>  MdeModulePkg/MdeModulePkg.dec|  
> 4 +++
>  MdeModulePkg/MdeModulePkg.dsc|  
> 2 ++
>  6 files changed, 131 insertions(+)
> 
> diff --git 
> a/MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c 
> b/MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c
> new file mode 100644
> index ..5d5d0d051e1b
> --- /dev/null
> +++ b/MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c
> @@ -0,0 +1,36 @@
> +/** @file
> +  Null Platform ACPI Library instance.
> +
> +Copyright (c) 2018, Intel Corporation. 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.
> +
> +**/
> +
> +#include 
> +
> +#include 
> +
> +/**
> +  Performs platform specific updates to CurrentTable.
> +
> +  @param[in,out] CurrentTable  The table to perform updates on.
> +
> +  @retval RETURN_SUCCESS  The platform specific ACPI table updates were 
> applied
> +  successfully.
> +  @retval other   The platform specific ACPI table updates could not 
> be
> +  applied.
> +  
> +**/
> +RETURN_STATUS
> +PlatformAcpiUpdateTable (
> +  IN OUT EFI_ACPI_COMMON_HEADER  *CurrentTable
> +  )
> +{
> +  return RETURN_SUCCESS;
> +}
> diff --git a/MdeModulePkg/Include/Library/PlatformAcpiLib.h 
> b/MdeModulePkg/Include/Library/PlatformAcpiLib.h
> new file mode 100644
> index ..a3e367f3ab61
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/PlatformAcpiLib.h
> @@ -0,0 +1,36 @@
> +/** @file
> +  Platform ACPI library. Platform can provide an implementation of this
> +  library class to provide an ACPI table update routine that may be required
> +  for some type of platform initialization.
> +
> +Copyright (c) 2018, Intel Corporation. All rights reserved.
> +This program and the accompanying materials are licensed and 

Re: [edk2] Dynamic Pci configuration devices

2018-05-09 Thread Laszlo Ersek
On 05/09/18 07:50, Guy Raviv wrote:
> Thanks for the detailed answer.
> 
> if i choose the 2nd approach would it be possible to modify the structrue
> itself of the pci tree,
> and not only a specific device number?
> example: if i add a pci bridge between my board and a graphic card.

I can't answer this off-hand, but I don't need to: please check the
documentation of EFI_ACPI_SDT_PROTOCOL in the PI spec. After you review
the member functions that the protocol has, you can likely determine the
answer.

Thanks,
Laszlo


> On Tue, May 8, 2018 at 5:47 PM, Laszlo Ersek  wrote:
> 
>> On 05/08/18 16:16, Guy Raviv wrote:
>>> Hi all,
>>>
>>> currently in
>>>
>>> \Vlv2DeviceRefCodePkg\AcpiTablesPCAT\HOST_BUS.ASL
>>>
>>> The PCI devices are declared statically.
>>>
>>> i want to make this declaration dynamic - so that the device number can
>> change
>>>
>>> according according to my hardware setup. Is it possible?
>>
>> There are generally two ways for this.
>>
>> One is to write the bulk of the ASL like seen here, statically, but all
>> the customizable values are referenced as external objects / fields.
>> Then, a platform ACPI DXE driver in the firmware computes those values,
>> and installs a small SSDT with just those objects. The AML is generated
>> manually by the firmware, which is super awkward, but due to the small
>> size of the integer objects etc, it is tolerable.
>>
>> A similar approach can be seen e.g. in "OvmfPkg/AcpiPlatformDxe/Qemu.c",
>> function QemuInstallAcpiSsdtTable(). And the referring ASL code is in
>> "OvmfPkg/AcpiTables/Dsdt.asl". (Search both for "FWDT".)
>>
>> (Note however that said function is not used nowadays on QEMU, because
>> now QEMU generates *all* of the AML dynamically.)
>>
>> The other approach is to process the (static) AML before installing it
>> with EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable(). If you know the exact
>> path to / structure of the AML node that you want to modify, the
>> EFI_ACPI_SDT_PROTOCOL lets you navigate to the node, and patch it
>> in-place, in a memory array. Then you can install the modified table
>> blob with EFI_ACPI_TABLE_PROTOCOL. (Important: do not modify a table
>> *after* it is installed.)
>>
>> One example for the 2nd approach should be
>> "QuarkPlatformPkg/Acpi/Dxe/AcpiPlatform/AcpiPciUpdate.c".
>>
>> Thanks
>> Laszlo
>>
> 

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


Re: [edk2] [PATCH edk2-platforms v1 1/3][platforms/devel-dynamictables] Platform/ARM: Match asl compiler output for Juno

2018-05-09 Thread Leif Lindholm
On Fri, Apr 27, 2018 at 03:58:14PM +0100, Sami Mujawar wrote:
> The iASL compiler's -tc option has been updated to generate
> output that is suitable for including from a C file. The iASL
> compiler uniquely names the C array containing the processed
> table data as _aml_code. This update can be seen
> in the ACPICA git repository at
> https://github.com/acpica/acpica/commit/f9a88a4c1cd020b6a5475d63b29626852a0b5f37

For both 1-2/3, please add a date here, like in the Readme.md.
No further comments on this set.

/
Leif

> A corresponding change is required in the ConfigurationManager
> and this patch contains the necessary changes to adapt to the
> generated iASL compiler output.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sami Mujawar 
> Reviewed-by: Evan Lloyd 
> ---
> The changes can be seen at
> https://github.com/samimujawar/edk2-platforms/tree/258_reflect_acpica_compiler_enhancement_v1
> 
> Notes:
> v1:
> - Update Configuration Manager to match iASL compiler output.   [SAMI]
> 
>  
> Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
>  | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git 
> a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
>  
> b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> index 
> 0e67dfa1f47cc3004b775ec43d02e07754675e26..4c878f663ab247307a17582c07f303ddb11b7d41
>  100644
> --- 
> a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> +++ 
> b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> @@ -74,7 +74,7 @@ EFI_PLATFORM_REPOSITORY_INFO ArmJunoPlatformRepositoryInfo 
> = {
>  {
>EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
>CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_DSDT),
> -  (EFI_ACPI_DESCRIPTION_HEADER*)dsdt_AmlCode
> +  (EFI_ACPI_DESCRIPTION_HEADER*)dsdt_aml_code
>  },
>  // DBG2 Table
>  {
> @@ -86,13 +86,13 @@ EFI_PLATFORM_REPOSITORY_INFO 
> ArmJunoPlatformRepositoryInfo = {
>  {
>EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
>CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_SSDT),
> -  (EFI_ACPI_DESCRIPTION_HEADER*)ssdtjunousb_AmlCode
> +  (EFI_ACPI_DESCRIPTION_HEADER*)ssdtjunousb_aml_code
>  },
>  // SSDT table describing the PL011 UART
>  {
>EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
>CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_SSDT),
> -  (EFI_ACPI_DESCRIPTION_HEADER*)ssdtuart_AmlCode
> +  (EFI_ACPI_DESCRIPTION_HEADER*)ssdtuart_aml_code
>  },
>  
>  /* PCI MCFG Table
> @@ -109,7 +109,7 @@ EFI_PLATFORM_REPOSITORY_INFO 
> ArmJunoPlatformRepositoryInfo = {
>  {
>EFI_ACPI_6_2_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
>CREATE_STD_ACPI_TABLE_GEN_ID (ESTD_ACPI_TABLE_ID_SSDT),
> -  (EFI_ACPI_DESCRIPTION_HEADER*)ssdtpci_AmlCode
> +  (EFI_ACPI_DESCRIPTION_HEADER*)ssdtpci_aml_code
>  }
>},
>  
> -- 
> '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 v1 3/3][platforms/devel-dynamictables] Update Readme.md to reflect ACPICA compiler update

2018-05-09 Thread Leif Lindholm
On Fri, Apr 27, 2018 at 03:58:16PM +0100, Sami Mujawar wrote:
> The ACPICA iASL compiler has been enhanced to support the
> generation of an AML hex file which is required by the
> Dynamic Tables Framework. The patch for this enhancement
> has been integrated in the ACPICA repository. Therefore
> the Prerequisites section in the Readme has been updated
> accordingly.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sami Mujawar 
> Reviewed-by: Evan Lloyd 
> ---
> The changes can be seen at
> https://github.com/samimujawar/edk2-platforms/tree/258_reflect_acpica_compiler_enhancement_v1
> 
> Notes:
> v1:
> - Update ACPICA iAsl compiler usage guidelines. [SAMI]
> 
>  Readme.md | 21 +++-
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/Readme.md b/Readme.md
> index 
> b72efca18e8ab5de17cab06f0a1a0725991256d4..2300fa6be9f83525e8c0ee21800751d9067b02e0
>  100644
> --- a/Readme.md
> +++ b/Readme.md
> @@ -87,9 +87,9 @@ contains the Dynamic Tables Framework.
>  ### 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 current implementation of the iASL compiler does not
> -support generation of a C header file suitable for including from a C source
> -file.
> +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
>  --
> @@ -135,16 +135,19 @@ or
>  
>  Prerequisites
>  -
> -ACPICA iASL compiler with support for generating a C header file.
> +ACPICA iASL compiler with the enhanced "-tc" option to support generation of
> +AML hex (C header) files with unique symbol names.
>  
> -A patch ***'Modify hex AML C header file generation'***, to enable
> -this support has been submitted to the ACPICA source repository.
> -
> +A patch ***'[iASL: Enhance the -tc option (create AML hex file in 
> C)](https://github.com/acpica/acpica/commit/f9a88a4c1cd020b6a5475d63b29626852a0b5f37)'***,
> +to enable this support has been integrated to the ACPICA source repository.

Linux distributions tend to use dates to refer to what particular
point a version is based on, since snapshot updates are frequently
necessary.

In this case, that is 16 March 2018 - please mention that as well in
the message.

> +
> +
> +Ensure that the iASL compiler used for building *Dynamic Tables Framework*
> +has this feature enabled.
>  
>  Documentation
>  -
> -A description document is in preparation, and should be available in the
> -near future.
> +[Dynamic Tables Framework: A Step Towards Automatic Generation of Advanced 
> Configuration and Power Interface (ACPI) & System Management BIOS (SMBIOS) 
> Tables – Sami Mujawar 
> (Arm).](http://www.uefi.org/sites/default/files/resources/Arm_Dynamic%20Tables%20Framework%20A%20Step%20Towards%20Automatic%20Generation%20of%20Advanced%20Configuration%20and%20Power%20Interface%20%28ACPI%29%20%26%20System%20Management%20BIOS%20%28SMBIOS%29%20Tables%20_0.pdf)

Add a description?
I.e.: "Presentation from UEFI Plugfest Seattle 2018"?

>  
>  Miscellaneous
>  -
> -- 
> '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 v2 edk-platforms 2/4] Platform/Hisilicon/HiKey960: enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
On 3 May 2018 at 06:49, Leif Lindholm  wrote:
> On Thu, Mar 08, 2018 at 09:30:04PM +0800, Haojian Zhuang wrote:
>> Enable virtual keyboard on HiKey960 platform. The platform
>> driver read pattern from memory or GPIO pin. When the value
>> is matched, it simulates a hotkey that is used to adjust
>> sequence of boot options.
>
> This patch looks like it contains an awful lot more than described
> here. Can it be split up?
>
>> Cc: Leif Lindholm 
>> Cc: Ard Biesheuvel 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Haojian Zhuang 
>> ---
>>  Platform/Hisilicon/HiKey960/HiKey960.dsc|  10 +
>>  Platform/Hisilicon/HiKey960/HiKey960.fdf|   7 +
>>  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  54 +++
>>  Silicon/Hisilicon/Hi3660/Include/Hi3660.h   | 147 ++
>>  Silicon/Hisilicon/Hi3660/Include/Hkadc.h|  66 +++
>>  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 491 
>> 
>>  6 files changed, 775 insertions(+)
>>
>> +STATIC
>> +VOID
>> +InitAdc (
>> +  VOID
>> +  )
>> +{
>> +  // reset hkadc
>> +  MmioWrite32 (CRG_PERRSTEN2, PERRSTEN2_HKADCSSI);
>> +  // wait a few clock cycles
>> +  MicroSecondDelay (2);
>> +  MmioWrite32 (CRG_PERRSTDIS2, PERRSTEN2_HKADCSSI);
>> +  MicroSecondDelay (2);
>> +  // enable hkadc clock
>> +  MmioWrite32 (CRG_PERDIS2, PEREN2_HKADCSSI);
>> +  MicroSecondDelay (2);
>> +  MmioWrite32 (CRG_PEREN2, PEREN2_HKADCSSI);
>> +  MicroSecondDelay (2);
>
> Why the need for a few clock cycles? Why was 2 chosen? Barriers needed?
>

Need to wait hardware stabilization. Barriers don't help at here.

>> +  Adcin1Remap = AdcinDataRemap (Adcin1);
>> +  DEBUG ((DEBUG_INFO, "[BDID]Adcin1Remap:%d\n", Adcin1Remap));
>> +  if (Adcin1Remap == BOARDID_UNKNOW) {
>> +return EFI_INVALID_PARAMETER;
>> +  }
>> +  // read ADC channel2 data
>> +  AdcGetValue (ADC_ADCIN2, );
>> +  DEBUG ((DEBUG_INFO, "[BDID]Adcin2:%d\n", Adcin2));
>> +  Adcin2Remap = AdcinDataRemap (Adcin2);
>> +  DEBUG ((DEBUG_INFO, "[BDID]Adcin2Remap:%d\n", Adcin2Remap));
>> +  if (Adcin2Remap == BOARDID_UNKNOW) {
>> +return EFI_INVALID_PARAMETER;
>> +  }
>> +  *Id = BOARDID3_BASE * 1000 + (Adcin2Remap * 100) + (Adcin1Remap * 10) + 
>> Adcin0Remap;
>
> 1) Please use parentheses consistently.
> 2) This is the only use of BOARDID3_BASE - why is it being multiplied?

It's used to generate the same prefix of board family.

> 3) What is the format of this ID? Is it described somewhere or is it
>completely arbitrary?

BoardID is based on the voltage of a resistor. Since the resistor
value is fixed,
the BoardID is same on all HiKey960 platforms.

For example, BoardID v1 is different from BoardID v2. But the prefix is same.

> 4) What is the purpose of this Id? This function is used to populate
>mBoardId, but that variable is not used anywhere.
>

It'll be used later. It will fill different DTB contents according to
different versions
of the HiKey960 platforms.

>> +  DEBUG ((DEBUG_INFO, "[BDID]boardid: %d\n", *Id));
>> +  return EFI_SUCCESS;
>> +}
>> +
>> +STATIC
>> +VOID
>> +InitSdCard (
>> +  IN VOID
>> +  )
>> +{
>> +  UINT32Data;
>> +
>> +  // LDO16
>> +  Data = MmioRead32 (PMU_REG_BASE + (0x79 << 2)) & 7;
>> +  Data |= 6;
>> +  MmioWrite32 (PMU_REG_BASE + (0x79 << 2), Data);
>> +  MmioOr32 (PMU_REG_BASE + (0x78 << 2), 2);
>
> Please replace all live-coded values with #defines.

I'll try to replace the hard-coded values as I could. But I can't get everything
with document.

>
>> +  MicroSecondDelay (100);
>
> Why this delay?
> Does this need a barrier?
>

Barrier doesn't help. Just wait regulator stable.

>> +
>> +  // LDO9
>> +  Data = MmioRead32 (PMU_REG_BASE + (0x6b << 2)) & 7;
>> +  Data |= 5;
>> +  MmioWrite32 (PMU_REG_BASE + (0x6b << 2), Data);
>> +  MmioOr32 (PMU_REG_BASE + (0x6a << 2), 2);
>
> Please replace all live-coded values with #defines.
>
>> +  MicroSecondDelay (100);
>
> Why this delay?
> Does this need a barrier?
>

Barrier doesn't help. Just wait regulator stable.

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


Re: [edk2] [PATCH v1] Platforms/ARM: Enable acpiview support

2018-05-09 Thread Leif Lindholm
On Thu, Apr 26, 2018 at 02:01:21PM +0100, Sami Mujawar wrote:
> Acpiview is a program that allows examination of ACPI table
> contents from the UEFI Shell.
> 
> Enable acpiview support as this can help with investigations,
> especially at that stage where the tables are not enabling an
> OS to boot.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sami Mujawar 
> Reviewed-by: Evan Lloyd 

Please keep reviewed-by to what has been reviewed on the mailing list.
(I know Evan has reviewed this and would confirm on list if asked to,
so I'll keep it in for patches currently in my queue.)

> ---
> The patch can be seen at:
> https://github.com/samimujawar/edk2-platforms/tree/254_enable_acpiview_v1
> 
> Notes:
> v1:
> - Enable acpiview support in the UEFI shell for ARM platforms.  [SAMI]
> 
>  Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc 
> b/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
> index 
> 7cb47937329efa1944ec4c156e2be995a755ce6f..0badb24f030a58363e7bee22a7cc1e03040b60aa
>  100644
> --- a/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
> +++ b/Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
> @@ -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
> @@ -450,6 +450,7 @@ [Components.common]
>
> NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
>
> NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
>
> NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
> +  
> NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf

Unless you object to my moving that line 3 rows up before I push:
Reviewed-by: Leif Lindholm 

>
> HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
>PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
>
> BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
> -- 
> '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 1/1] MdeModulePkg/Sd: append CMD12 for multiple blocks

2018-05-09 Thread Haojian Zhuang
Hi Hao,

OK. I tried to enable auto stop command in Designware MMC driver. So this
patch could be ignored.

Thanks
Haojian

On 3 May 2018 at 10:45, Wu, Hao A  wrote:
> Hi Haojian,
>
> Sorry for the delayed response.
>
> As far as I know, we enabled the auto CMD12 feature within:
> SdMmcExecTrb(), MdeModulePkg\Bus\Pci\SdMmcPciHcDxe\SdMmcPciHci.c
>
> //
> // Only SD memory card needs to use AUTO CMD12 feature.
> //
> if (Private->Slot[Trb->Slot].CardType == SdCardType) {
>   if (BlkCount > 1) {
> TransMode |= BIT2;
>   }
> }
>
> So I think the explicitly sending CMD12 in SdRwMultiBlocks() is not needed.
>
> Have you met problems when using SdRwMultiBlocks()? Could you help to
> provide detailed device information when you meet the problem?
>
> Thanks in advance.
>
> Best Regards,
> Hao Wu
>
>> -Original Message-
>> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>> Haojian Zhuang
>> Sent: Saturday, April 28, 2018 1:24 PM
>> To: edk2-devel@lists.01.org
>> Cc: Ni, Ruiyu; Dong, Eric; Ard Biesheuvel; Leif Lindholm; Haojian Zhuang; 
>> Zeng,
>> Star
>> Subject: [edk2] [PATCH 1/1] MdeModulePkg/Sd: append CMD12 for multiple
>> blocks
>>
>> Send CMD12 to stop transimission for accessing multiple blocks. It's
>> required by SD Card protocol.
>>
>> Cc: Star Zeng 
>> Cc: Eric Dong 
>> Cc: Ruiyu Ni 
>> Cc: Leif Lindholm 
>> Cc: Ard Biesheuvel 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Haojian Zhuang 
>> ---
>>  MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c | 35
>> +++
>>  1 file changed, 35 insertions(+)
>>
>> diff --git a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
>> b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
>> index 516c3e704288..64259f99f9bc 100644
>> --- a/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
>> +++ b/MdeModulePkg/Bus/Sd/SdDxe/SdBlockIo.c
>> @@ -426,6 +426,36 @@ Error:
>>return Status;
>>  }
>>
>> +EFI_STATUS
>> +SdStopTrans (
>> +  IN  SD_DEVICE *Device
>> +  )
>> +{
>> +  EFI_STATUS   Status;
>> +  EFI_SD_MMC_PASS_THRU_PROTOCOL*PassThru;
>> +  EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
>> +  EFI_SD_MMC_STATUS_BLOCK  SdMmcStatusBlk;
>> +  EFI_SD_MMC_PASS_THRU_COMMAND_PACKET  Packet;
>> +
>> +  PassThru = Device->Private->PassThru;
>> +
>> +  ZeroMem (, sizeof (SdMmcCmdBlk));
>> +  ZeroMem (, sizeof (SdMmcStatusBlk));
>> +  ZeroMem (, sizeof (Packet));
>> +
>> +  Packet.SdMmcCmdBlk= 
>> +  Packet.SdMmcStatusBlk = 
>> +  Packet.Timeout= SD_GENERIC_TIMEOUT;
>> +
>> +  SdMmcCmdBlk.CommandIndex = SD_STOP_TRANSMISSION;
>> +  SdMmcCmdBlk.CommandType  = SdMmcCommandTypeAc;
>> +  SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;
>> +  SdMmcCmdBlk.CommandArgument = 0;
>> +
>> +  Status = PassThru->PassThru (PassThru, Device->Slot, , NULL);
>> +  return Status;
>> +}
>> +
>>  /**
>>Read/write multiple blocks through sync or async I/O request.
>>
>> @@ -555,6 +585,11 @@ Error:
>>  }
>>}
>>
>> +  if (EFI_ERROR (Status)) {
>> +return Status;
>> +  }
>> +
>> +  Status = SdStopTrans (Device);
>>return Status;
>>  }
>>
>> --
>> 2.7.4
>>
>> ___
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v2 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-09 Thread Haojian Zhuang
Do some basic initialization on HiKey platform, such as pin
setting, regulators and making peripherals out of reset mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
 Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 119 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 +
 6 files changed, 221 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5c1604d7f689..5cc4ff27f01b 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -189,8 +189,11 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # MMC/SD
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2a5c5a4d6e79..39020d27dbcd 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -120,8 +120,11 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # Multimedia Card Interface
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
new file mode 100644
index ..19987e0b29c3
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -0,0 +1,119 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. 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 
+
+#define SERIAL_NUMBER_SIZE   17
+#define SERIAL_NUMBER_BLOCK_SIZE EFI_PAGE_SIZE
+#define SERIAL_NUMBER_LBA1024
+#define RANDOM_MAX   0x7FFF
+#define RANDOM_MAGIC 0x9A4DBEAF
+
+#define DETECT_J15_FASTBOOT  24   // GPIO3_0
+
+#define ADB_REBOOT_ADDRESS   0x05F01000
+#define ADB_REBOOT_BOOTLOADER0x77665500
+#define ADB_REBOOT_NONE  0x77665501
+
+STATIC
+VOID
+UartInit (
+  IN VOID
+  )
+{
+  UINT32 Val;
+
+  /* make UART1 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART1);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART1);
+  /* make UART2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART2);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART2);
+  /* make UART3 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART3);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART3);
+  /* make UART4 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, PERIPH_RST3_UART4);
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_CLKEN3, PERIPH_RST3_UART4);
+
+  /* make DW_MMC2 out of reset */
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS0, PERIPH_RST0_MMC2);
+
+  /* enable clock for BT/WIFI */
+  Val = MmioRead32 (PMUSSI_ONOFF8_REG) | PMUSSI_ONOFF8_EN_32KB;
+  MmioWrite32 (PMUSSI_ONOFF8_REG, Val);
+}
+
+STATIC
+VOID
+MtcmosInit (
+  IN VOID
+  )
+{
+  UINT32 Data;
+
+  /* enable MTCMOS for GPU */
+  MmioWrite32 (AO_CTRL_BASE + SC_PW_MTCMOS_EN0, PW_EN0_G3D);
+  do {
+Data = MmioRead32 (AO_CTRL_BASE + SC_PW_MTCMOS_ACK_STAT0);
+  } while ((Data & PW_EN0_G3D) == 0);
+}
+
+EFI_STATUS
+HiKeyInitPeripherals (
+  IN VOID
+  )
+{
+  UINT32 Data, Bits;
+
+  /* make I2C0/I2C1/I2C2/SPI0 out of reset */
+  Bits = PERIPH_RST3_I2C0 | PERIPH_RST3_I2C1 | PERIPH_RST3_I2C2 | \
+ PERIPH_RST3_SSP;
+  MmioWrite32 (PERI_CTRL_BASE + SC_PERIPH_RSTDIS3, Bits);
+
+  do {
+Data = MmioRead32 (PERI_CTRL_BASE + SC_PERIPH_RSTSTAT3);
+  } while (Data & Bits);
+
+  UartInit ();
+  /* MTCMOS -- Multi-threshold CMOS */
+  MtcmosInit ();
+
+  /* Set 

[edk2] [PATCH edk2-platforms v2 3/6] Platform/HiKey960: enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
Enable virtual keyboard on HiKey960 platform. It checks two
conditions, such as pattern in memory and GPIO pin setting.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  5 ++
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  5 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 98 +-
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  3 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  1 +
 5 files changed, 111 insertions(+), 1 deletion(-)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 6cc1c1edf453..79e68754976d 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,11 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index b7d70b010598..d65f77878575 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index fc4cc24724e5..400f6d0196eb 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -14,7 +14,8 @@
 
 #include "HiKey960Dxe.h"
 
-STATIC UINTNmBoardId;
+STATIC UINTN   mBoardId;
+STATIC EMBEDDED_GPIO   *mGpio;
 
 STATIC
 VOID
@@ -315,6 +316,94 @@ OnEndOfDxe (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  //
+  // Configure GPIO68 as GPIO function
+  //
+  MmioWrite32 (0xe896c108, 0);
+  Status = mGpio->Set (mGpio, DETECT_SW_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_SW_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKey960EntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -348,5 +437,12 @@ HiKey960EntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
index 2e89d10e2723..2d5349888ed5 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
@@ -33,6 +33,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 #define ADC_ADCIN0   0
 #define ADC_ADCIN1   1
 

[edk2] [PATCH edk2-platforms v2 6/6] Platform/HiKey: enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
Enable virtual keyboard on HiKey platform. It detects the pattern
in memory and GPIO pin setting, and simulates them into virtual
key.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc |  5 ++
 Platform/Hisilicon/HiKey/HiKey.fdf |  5 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 98 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  5 ++
 4 files changed, 113 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5cc4ff27f01b..83dd68a820b1 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -192,6 +192,11 @@ [Components.common]
   Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 39020d27dbcd..2bca7232b6e5 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -123,6 +123,11 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  #
+  # Virtual Keyboard
+  #
+  INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
+
   INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index 19987e0b29c3..8f4f9157835c 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -12,10 +12,15 @@
 *
 **/
 
+#include 
 #include 
 #include 
+#include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -31,6 +36,8 @@
 #define ADB_REBOOT_BOOTLOADER0x77665500
 #define ADB_REBOOT_NONE  0x77665501
 
+STATIC EMBEDDED_GPIO*mGpio;
+
 STATIC
 VOID
 UartInit (
@@ -104,6 +111,90 @@ HiKeyInitPeripherals (
 
 EFI_STATUS
 EFIAPI
+VirtualKeyboardRegister (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **) 
+  );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardReset (
+  IN VOID
+  )
+{
+  EFI_STATUS   Status;
+
+  if (mGpio == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  Status = mGpio->Set (mGpio, DETECT_J15_FASTBOOT, GPIO_MODE_INPUT);
+  return Status;
+}
+
+BOOLEAN
+EFIAPI
+VirtualKeyboardQuery (
+  IN VIRTUAL_KBD_KEY *VirtualKey
+  )
+{
+  EFI_STATUS   Status;
+  UINTNValue = 0;
+
+  if ((VirtualKey == NULL) || (mGpio == NULL)) {
+return FALSE;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+goto Done;
+  } else {
+Status = mGpio->Get (mGpio, DETECT_J15_FASTBOOT, );
+if (EFI_ERROR (Status) || (Value != 0)) {
+  return FALSE;
+}
+  }
+Done:
+  VirtualKey->Signature = VIRTUAL_KEYBOARD_KEY_SIGNATURE;
+  VirtualKey->Key.ScanCode = SCAN_NULL;
+  VirtualKey->Key.UnicodeChar = L'f';
+  return TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+VirtualKeyboardClear (
+  IN VIRTUAL_KBD_KEY*VirtualKey
+  )
+{
+  if (VirtualKey == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+  if (MmioRead32 (ADB_REBOOT_ADDRESS) == ADB_REBOOT_BOOTLOADER) {
+MmioWrite32 (ADB_REBOOT_ADDRESS, ADB_REBOOT_NONE);
+WriteBackInvalidateDataCacheRange ((VOID *)ADB_REBOOT_ADDRESS, 4);
+  }
+  return EFI_SUCCESS;
+}
+
+PLATFORM_VIRTUAL_KBD_PROTOCOL mVirtualKeyboard = {
+  VirtualKeyboardRegister,
+  VirtualKeyboardReset,
+  VirtualKeyboardQuery,
+  VirtualKeyboardClear
+};
+
+EFI_STATUS
+EFIAPI
 HiKeyEntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
@@ -115,5 +206,12 @@ HiKeyEntryPoint (
   if (EFI_ERROR (Status)) {
 return Status;
   }
+
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  
+  );
   return Status;
 }
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
index 34734391b45a..41aa7f8081ed 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -28,11 +28,16 @@ [Packages]
   MdePkg/MdePkg.dec
 
 [LibraryClasses]
+  CacheMaintenanceLib
   DebugLib
   IoLib
   UefiLib
   UefiDriverEntryPoint
 
+[Protocols]
+  gEmbeddedGpioProtocolGuid
+  gPlatformVirtualKeyboardProtocolGuid
+
 [Guids]
   gEfiEndOfDxeEventGroupGuid
 
-- 

[edk2] [PATCH edk2-platforms v2 4/6] Platform/Hisilicon/HiKey: add gpio platform driver

2018-05-09 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c| 74 ++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 36 +++
 2 files changed, 110 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index ..be535f8f1903
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,74 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xf8011000, 0, 8 },// GPIO0
+  { 0xf8012000, 8, 8 },// GPIO1
+  { 0xf8013000, 16, 8 },   // GPIO2
+  { 0xf8014000, 24, 8 },   // GPIO3
+  { 0xf702, 32, 8 },   // GPIO4
+  { 0xf7021000, 40, 8 },   // GPIO5
+  { 0xf7022000, 48, 8 },   // GPIO6
+  { 0xf7023000, 56, 8 },   // GPIO7
+  { 0xf7024000, 64, 8 },   // GPIO8
+  { 0xf7025000, 72, 8 },   // GPIO9
+  { 0xf7026000, 80, 8 },   // GPIO10
+  { 0xf7027000, 88, 8 },   // GPIO11
+  { 0xf7028000, 96, 8 },   // GPIO12
+  { 0xf7029000, 104, 8 },  // GPIO13
+  { 0xf702a000, 112, 8 },  // GPIO14
+  { 0xf702b000, 120, 8 },  // GPIO15
+  { 0xf702c000, 128, 8 },  // GPIO16
+  { 0xf702d000, 136, 8 },  // GPIO17
+  { 0xf702e000, 144, 8 },  // GPIO18
+  { 0xf702f000, 152, 8 }   // GPIO19
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller counter, GPIO_CONTROLLER }
+  //
+  160, 20, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  ,
+  , ,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
new file mode 100644
index ..2791b9f44cad
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,36 @@
+#
+#  Copyright (c) 2018, Linaro. 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= 0x0001001a
+  BASE_NAME  = HiKeyGpio
+  FILE_GUID  = b51a851c-7bf7-463f-b261-cfb158b7f699
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyGpioEntryPoint
+
+[Sources.common]
+  HiKeyGpioDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v2 2/6] Platform/HiKey960: initialize for board id

2018-05-09 Thread Haojian Zhuang
Do some basic initliazation on peripherals, such as pins and
regulators. Read board id of HiKey960.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   2 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   2 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 352 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  91 ++
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  47 +++
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 ++
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 175 ++
 Silicon/Hisilicon/Hi3660/Include/Hkadc.h   |  68 
 8 files changed, 769 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hkadc.h

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 3da1b8556321..6cc1c1edf453 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -182,6 +182,8 @@ [Components.common]
   Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 162dbaaf2646..b7d70b010598 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -123,6 +123,8 @@ [FV.FvMain]
   INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+
   #
   # USB Host Support
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
new file mode 100644
index ..fc4cc24724e5
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -0,0 +1,352 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. 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 "HiKey960Dxe.h"
+
+STATIC UINTNmBoardId;
+
+STATIC
+VOID
+InitAdc (
+  VOID
+  )
+{
+  //
+  // reset hkadc
+  //
+  MmioWrite32 (CRG_PERRSTEN2, PERRSTEN2_HKADCSSI);
+  //
+  // wait a few clock cycles for stabilization
+  //
+  MicroSecondDelay (2);
+  MmioWrite32 (CRG_PERRSTDIS2, PERRSTEN2_HKADCSSI);
+  MicroSecondDelay (2);
+  //
+  // enable hkadc clock
+  //
+  MmioWrite32 (CRG_PERDIS2, PEREN2_HKADCSSI);
+  MicroSecondDelay (2);
+  MmioWrite32 (CRG_PEREN2, PEREN2_HKADCSSI);
+  MicroSecondDelay (2);
+}
+
+STATIC
+EFI_STATUS
+AdcGetAdc (
+  IN  UINTN Channel,
+  OUT UINTN *Value
+  )
+{
+  UINT32Data;
+  UINT16Value1, Value0;
+
+  if (Channel > HKADC_CHANNEL_MAX) {
+DEBUG ((DEBUG_ERROR, "invalid channel:%d\n", Channel));
+return EFI_OUT_OF_RESOURCES;
+  }
+  //
+  // configure the read/write operation for external HKADC
+  //
+  MmioWrite32 (HKADC_WR01_DATA, HKADC_WR01_VALUE | Channel);
+  MmioWrite32 (HKADC_WR23_DATA, HKADC_WR23_VALUE);
+  MmioWrite32 (HKADC_WR45_DATA, HKADC_WR45_VALUE);
+  //
+  // configure the number of accessing registers
+  //
+  MmioWrite32 (HKADC_WR_NUM, HKADC_WR_NUM_VALUE);
+  //
+  // configure delay of accessing registers
+  //
+  MmioWrite32 (HKADC_DELAY01, HKADC_CHANNEL0_DELAY01_VALUE);
+  MmioWrite32 (HKADC_DELAY23, HKADC_DELAY23_VALUE);
+
+  //
+  // start HKADC
+  //
+  MmioWrite32 (HKADC_DSP_START, DSP_START_BIT);
+  do {
+Data = MmioRead32 (HKADC_DSP_START);
+  } while (Data & DSP_START_BIT);
+
+  //
+  // convert AD result
+  //
+  Value1 = (UINT16)MmioRead32 (HKADC_DSP_RD2_DATA);
+  Value0 = (UINT16)MmioRead32 (HKADC_DSP_RD3_DATA);
+
+  //
+  // get 20-bit data
+  //
+  Data = ((Value1 << 4) & HKADC_VALUE_HIGH) | ((Value0 >> 4) & 
HKADC_VALUE_LOW);
+  *Value = Data;
+  return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+AdcGetValue (
+  IN UINTN Channel,
+  IN OUT UINTN *Value
+  )
+{
+  EFI_STATUS   Status;

[edk2] [PATCH edk2-platforms v2 1/6] Platform/Hisilicon/HiKey960: add gpio platform driver

2018-05-09 Thread Haojian Zhuang
Add gpio platform driver to enable GPIO in HiKey960 platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |  1 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |  1 +
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c | 83 ++
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf   | 35 +
 4 files changed, 120 insertions(+)
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc 
b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index 36f43956ab40..3da1b8556321 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -179,6 +179,7 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf 
b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index 655032a36c53..162dbaaf2646 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -120,6 +120,7 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
new file mode 100644
index ..b196455072cc
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
@@ -0,0 +1,83 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. 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 
+
+GPIO_CONTROLLER gGpioDevice[] = {
+  //
+  // { base address, gpio index, gpio count }
+  //
+  { 0xe8a0b000, 0, 8 },// GPIO0
+  { 0xe8a0c000, 8, 8 },// GPIO1
+  { 0xe8a0d000, 16, 8 },   // GPIO2
+  { 0xe8a0e000, 24, 8 },   // GPIO3
+  { 0xe8a0f000, 32, 8 },   // GPIO4
+  { 0xe8a1, 40, 8 },   // GPIO5
+  { 0xe8a11000, 48, 8 },   // GPIO6
+  { 0xe8a12000, 56, 8 },   // GPIO7
+  { 0xe8a13000, 64, 8 },   // GPIO8
+  { 0xe8a14000, 72, 8 },   // GPIO9
+  { 0xe8a15000, 80, 8 },   // GPIO10
+  { 0xe8a16000, 88, 8 },   // GPIO11
+  { 0xe8a17000, 96, 8 },   // GPIO12
+  { 0xe8a18000, 104, 8 },  // GPIO13
+  { 0xe8a19000, 112, 8 },  // GPIO14
+  { 0xe8a1a000, 120, 8 },  // GPIO15
+  { 0xe8a1b000, 128, 8 },  // GPIO16
+  { 0xe8a1c000, 136, 8 },  // GPIO17
+  { 0xff3b4000, 144, 8 },  // GPIO18
+  { 0xff3b5000, 152, 8 },  // GPIO19
+  { 0xe8a1f000, 160, 8 },  // GPIO20
+  { 0xe8a2, 168, 8 },  // GPIO21
+  { 0xfff0b000, 176, 8 },  // GPIO22
+  { 0xfff0c000, 184, 8 },  // GPIO23
+  { 0xfff0d000, 192, 8 },  // GPIO24
+  { 0xfff0e000, 200, 8 },  // GPIO25
+  { 0xfff0f000, 208, 8 },  // GPIO26
+  { 0xfff1, 216, 8 },  // GPIO27
+  { 0xfff1d000, 224, 8 },  // GPIO28
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  //
+  // { global gpio count, gpio controller count, GPIO_CONTROLLER }
+  //
+  232, 29, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKey960GpioEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces(
+  ,
+  , ,
+  NULL
+ );
+  if (EFI_ERROR(Status)) {
+Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf 
b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
new file mode 100644
index ..5ea3747321d8
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
@@ -0,0 +1,35 @@
+#
+#  Copyright (c) 2018, Linaro. 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 

[edk2] [PATCH edk2-platforms v2 0/6] enable virtual keyboard

2018-05-09 Thread Haojian Zhuang
Changelog:
v2:
  * Split HiKeyDxe & HiKey960Dxe into smaller patches.
  * Replace hardcoding register with macro.
v1:
  * Enable GPIO driver.
  * Enable virtual keyboard driver.

Haojian Zhuang (6):
  Platform/Hisilicon/HiKey960: add gpio platform driver
  Platform/HiKey960: initialize for board id
  Platform/HiKey960: enable virtual keyboard
  Platform/Hisilicon/HiKey: add gpio platform driver
  Platform/HiKey: do basic initialization on hikey
  Platform/HiKey: enable virtual keyboard

 Platform/Hisilicon/HiKey/HiKey.dsc |   8 +
 Platform/Hisilicon/HiKey/HiKey.fdf |   8 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c   | 217 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf |  45 +++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c|  74 
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  |  36 ++
 Platform/Hisilicon/HiKey960/HiKey960.dsc   |   8 +
 Platform/Hisilicon/HiKey960/HiKey960.fdf   |   8 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c   | 448 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h   |  94 +
 .../Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf |  48 +++
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c |  83 
 .../HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf   |  35 ++
 Silicon/Hisilicon/Hi3660/Hi3660.dec|  32 ++
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h  | 175 
 Silicon/Hisilicon/Hi3660/Include/Hkadc.h   |  68 
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h  |   6 +
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h  |  50 +++
 18 files changed, 1443 insertions(+)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.h
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.c
 create mode 100644 
Platform/Hisilicon/HiKey960/HiKey960GpioDxe/HiKey960GpioDxe.inf
 create mode 100644 Silicon/Hisilicon/Hi3660/Hi3660.dec
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hi3660.h
 create mode 100644 Silicon/Hisilicon/Hi3660/Include/Hkadc.h
 create mode 100644 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
-- 
2.7.4

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


[edk2] [PATCH] MdePkg/SmmPeriodicSmiLib: Get Periodic SMI Context More Robustly

2018-05-09 Thread Ruiyu Ni
The PeriodicSmiDispatchFunction() in SmmPeriodicSmiLib may assert
with "Bad CR signature".

Currently, the SetActivePeriodicSmiLibraryHandler() function
(invoked at the beginning of the PeriodicSmiDispatchFunction()
function) attempts to locate the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
structure pointer for the current periodic SMI from a given
EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT (RegiserContext) structure
pointer (using the CR macro).

The RegisterContext structure pointer passed to the
PeriodicSmiDispatchFunction() is assumed to point to the same
RegisterContext structure address given to the
SmmPeriodicTimerDispatch2 protocol Register() API in
PeriodicSmiEnable().

However, certain SmmPeriodicTimerDispatch2 implementation may copy
the RegisterContext to a local buffer and pass that address as the
context to PeriodicSmiDispatchFunction() in which case usage of the
CR macro to find the parent structure base fails.

The patch uses the LookupPeriodicSmiLibraryHandler() function to
find the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure pointer.
This works even in this scenario since the DispatchHandle returned
from the SmmPeriodicTimerDispatch2 Register() function uniquely
identifies that registration.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Michael D Kinney 
Cc: Liming Gao 
---
 .../Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c  | 38 +-
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c 
b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
index 2016af60d8..ca6967c9be 100644
--- a/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
+++ b/MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c
@@ -1,7 +1,7 @@
 /** @file
   SMM Periodic SMI Library.
 
-  Copyright (c) 2011, Intel Corporation. All rights reserved.
+  Copyright (c) 2011 - 2018, Intel Corporation. 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
@@ -144,19 +144,6 @@ typedef struct {
   UINT64   ElapsedTime;
 } PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT;
 
-/**
- Macro that returns a pointer to a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT 
- structure based on a pointer to a RegisterContext field.
-
-**/
-#define PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_REGISTER_CONTEXT(a) \
-  CR (\
-a,\
-PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT, \
-RegisterContext,  \
-PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_SIGNATURE\
-)
-
 /**
  Macro that returns a pointer to a PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT 
  structure based on a pointer to a Link field.
@@ -280,26 +267,31 @@ LookupPeriodicSmiLibraryHandler (
 
 /**
   Internal worker function that sets that active periodic SMI handler based on 
-  the Context used when the periodic SMI handler was registered with the 
-  SMM Periodic Timer Dispatch 2 Protocol.  If Context is NULL, then the 
+  the DispatchHandle that was returned when the periodic SMI handler was 
enabled
+  with PeriodicSmiEnable(). If DispatchHandle is NULL, then the 
   state is updated to show that there is not active periodic SMI handler.
   A pointer to the active PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure 
   is returned.
-  
-  @retval  NULL   Context is NULL.
+
+  @param [in] DispatchHandle DispatchHandle that was returned when the periodic
+ SMI handler was enabled with PeriodicSmiEnable().
+ This is an optional parameter that may be NULL.
+ If this parameter is NULL, then the state is 
updated
+ to show that there is not active periodic SMI 
handler.
+  @retval  NULL   DispatchHandle is NULL.
   @retval  other  Pointer to the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
-  associated with Context.
+  associated with DispatchHandle.
   
 **/
 PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT *
 SetActivePeriodicSmiLibraryHandler (
-  IN CONST VOID  *Context  OPTIONAL
+  IN EFI_HANDLE DispatchHandleOPTIONAL
   )
 {
-  if (Context == NULL) {
+  if (DispatchHandle == NULL) {
 gActivePeriodicSmiLibraryHandler = NULL;
   } else {
-gActivePeriodicSmiLibraryHandler = 
PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT_FROM_REGISTER_CONTEXT (Context);
+gActivePeriodicSmiLibraryHandler = LookupPeriodicSmiLibraryHandler 
(DispatchHandle);
   }
   return gActivePeriodicSmiLibraryHandler;
 }
@@ -798,7 +790,7 @@ PeriodicSmiDispatchFunction (
   //
   // Set 

Re: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib LibraryClass.

2018-05-09 Thread Zeng, Star
Marvin,

It is good direction to reuse more code.
What am I concerning about are
1. There are comments "Sample ACPI Platform Driver" in AcpiPlatformDxe.inf and 
AcpiPlatformDxe.c, the current position of AcpiPlatformDxe seems just for 
reference.
2. Almost all the platforms have their own AcpiPlatformDxe, for example
https://github.com/tianocore/edk2/tree/master/OvmfPkg/AcpiPlatformDxe
https://github.com/tianocore/edk2/tree/master/QuarkPlatformPkg/Acpi/Dxe/AcpiPlatform
https://github.com/tianocore/edk2/tree/master/Vlv2TbltDevicePkg/AcpiPlatform
...

Should more evaluation be done on them to see whether we can do more or we just 
suggest platform should implement its own AcpiPlatformDxe?

Including more experts.


Thanks,
Star
-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Marvin 
H?user
Sent: Wednesday, May 9, 2018 7:26 AM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu ; Dong, Eric ; Zeng, 
Star 
Subject: [edk2] [PATCH 1/2] MdeModulePkg: Add PlatformAcpiLib LibraryClass.

PlatformAcpiLib can be consumed by the generic ACPI Platform driver
to allow platform specific updates to the ACPI tables loaded from the
configured Firmware Volume. This allows for more platforms to
incorporate the generic ACPI Platform driver.

This commit also provides a NULL implementation of PlatformAcpiLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser 
---
 MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c   | 36 

 MdeModulePkg/Include/Library/PlatformAcpiLib.h   | 36 

 MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.inf | 35 
+++
 MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.uni | 18 
++
 MdeModulePkg/MdeModulePkg.dec|  4 
+++
 MdeModulePkg/MdeModulePkg.dsc|  2 
++
 6 files changed, 131 insertions(+)

diff --git 
a/MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c 
b/MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c
new file mode 100644
index ..5d5d0d051e1b
--- /dev/null
+++ b/MdeModulePkg/Library/BasePlatformAcpiLibNull/BasePlatformAcpiLibNull.c
@@ -0,0 +1,36 @@
+/** @file
+  Null Platform ACPI Library instance.
+
+Copyright (c) 2018, Intel Corporation. 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.
+
+**/
+
+#include 
+
+#include 
+
+/**
+  Performs platform specific updates to CurrentTable.
+
+  @param[in,out] CurrentTable  The table to perform updates on.
+
+  @retval RETURN_SUCCESS  The platform specific ACPI table updates were applied
+  successfully.
+  @retval other   The platform specific ACPI table updates could not be
+  applied.
+  
+**/
+RETURN_STATUS
+PlatformAcpiUpdateTable (
+  IN OUT EFI_ACPI_COMMON_HEADER  *CurrentTable
+  )
+{
+  return RETURN_SUCCESS;
+}
diff --git a/MdeModulePkg/Include/Library/PlatformAcpiLib.h 
b/MdeModulePkg/Include/Library/PlatformAcpiLib.h
new file mode 100644
index ..a3e367f3ab61
--- /dev/null
+++ b/MdeModulePkg/Include/Library/PlatformAcpiLib.h
@@ -0,0 +1,36 @@
+/** @file
+  Platform ACPI library. Platform can provide an implementation of this
+  library class to provide an ACPI table update routine that may be required
+  for some type of platform initialization.
+
+Copyright (c) 2018, Intel Corporation. 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.
+
+**/
+
+#ifndef __PLATFORM_ACPI_LIB__
+#define __PLATFORM_ACPI_LIB__
+
+/**
+  Performs platform specific updates to CurrentTable.
+
+  @param[in,out] CurrentTable  The table to perform updates on.
+
+  @retval RETURN_SUCCESS  The platform specific ACPI table updates were applied
+  successfully.
+  @retval other   The platform specific ACPI table updates could not be
+

Re: [edk2] [PATCH] BaseTools: Fix --hash Package and Module hash value.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
Hi Yonghong,

Thanks for notify about this.
I resend the patch.

Thanks,
Derek


-Original Message-
From: Zhu, Yonghong [mailto:yonghong@intel.com] 
Sent: Wednesday, May 9, 2018 4:35 PM
To: Lin, Derek (HPS UEFI Dev) ; edk2-devel@lists.01.org
Cc: Zhu, Yonghong 
Subject: RE: [PATCH] BaseTools: Fix --hash Package and Module hash value.

Hi Derek,

Please refer below link to add Contributed-under and Signed-off-by info.
We can use BaseTools\Scripts\PatchCheck.py  to check the patch format. Thanks.
https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format 

Best Regards,
Zhu Yonghong


-Original Message-
From: Lin, Derek (HPS UEFI Dev) [mailto:derek.l...@hpe.com] 
Sent: Wednesday, May 09, 2018 3:49 PM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong ; Lin, Derek (HPS UEFI Dev) 

Subject: [PATCH] BaseTools: Fix --hash Package and Module hash value.

From: Lin, Derek (HPS UEFI Dev) 
Sent: Wednesday, May 9, 2018 3:39 PM
To: Lin, Derek (HPS UEFI Dev) 
Subject: [PATCH] BaseTools: Fix --hash Package and Module hash value.

The order of List enumeration is arbitrary.
Need to be sorted while calculating Package/Module hash, otherwise it generate 
different hash value even nothing changes.
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 54f6b1f173..90704dcae4 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2,6 +2,7 @@
 # Generate AutoGen.h, AutoGen.c and *.depex files  #  # Copyright (c) 2007 - 
2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 # 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 @@ 
-670,6 +671,9 @@ class WorkspaceAutoGen(AutoGen):
 return True
 
 def _GenPkgLevelHash(self, Pkg):
+if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]:
+return
+
 PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)
 CreateDirectory(PkgDir)
 HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash') @@ -681,17 
+685,16 @@ class WorkspaceAutoGen(AutoGen):
 m.update(Content)
 # Get include files hash value
 if Pkg.Includes:
-for inc in Pkg.Includes:
+for inc in sorted(Pkg.Includes, key=lambda x: str(x)):
 for Root, Dirs, Files in os.walk(str(inc)):
-for File in Files:
+for File in sorted(Files):
 File_Path = os.path.join(Root, File)
 f = open(File_Path, 'r')
 Content = f.read()
 f.close()
 m.update(Content)
 SaveFileOnChange(HashFile, m.hexdigest(), True)
-if Pkg.PackageName not in GlobalData.gPackageHash[Pkg.Arch]:
-GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()
+GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = 
+ m.hexdigest()
 
 def _GetMetaFiles(self, Target, Toolchain, Arch):
 AllWorkSpaceMetaFiles = set()
@@ -4432,13 +4435,13 @@ class ModuleAutoGen(AutoGen):
 m.update(GlobalData.gPlatformHash)
 # Add Package level hash
 if self.DependentPackageList:
-for Pkg in self.DependentPackageList:
+for Pkg in sorted(self.DependentPackageList, key=lambda x: 
x.PackageName):
 if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:
 
m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])
 
 # Add Library hash
 if self.LibraryAutoGenList:
-for Lib in self.LibraryAutoGenList:
+for Lib in sorted(self.LibraryAutoGenList, key=lambda x: x.Name):
 if Lib.Name not in GlobalData.gModuleHash[self.Arch]:
 Lib.GenModuleHash()
 m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])
@@ -4450,7 +4453,7 @@ class ModuleAutoGen(AutoGen):
 m.update(Content)
 # Add Module's source files
 if self.SourceFileList:
-for File in self.SourceFileList:
+for File in sorted(self.SourceFileList, key=lambda x: str(x)):
 f = open(str(File), 'r')
 Content = f.read()
 f.close()
--
2.15.1.windows.2


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


[edk2] [PATCH] BaseTools: Fix python error with --genfds-multi-thread.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
When self.Alignment is None, it ran into python error since there is no
strip() in None.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Derek Lin 
---
 BaseTools/Source/Python/GenFds/GuidSection.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py 
b/BaseTools/Source/Python/GenFds/GuidSection.py
index 1105689e0d..6cadff0bd2 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -2,7 +2,7 @@
 # process GUIDed section generation
 #
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. -#
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 #  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 @@ 
-273,7 +273,7 @@ class GuidSection(GuidSectionClassObject) :
 self.Alignment = None
 self.IncludeFvSection = False
 self.ProcessRequired = "TRUE"
-if IsMakefile and self.Alignment.strip() == '0':
+if IsMakefile and self.Alignment is not None and 
self.Alignment.strip() == '0':
 self.Alignment = '1'
 return OutputFileList, self.Alignment
 
--
2.15.1.windows.2

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


[edk2] [PATCH] BaseTools: Remove dsc nested include checking.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
The dsc nested include checking make unexpected build error when building 
project A and switch to project B.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Derek Lin 
---
 BaseTools/Source/Python/Workspace/MetaFileParser.py | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 36843643ed..e1f4ea995d 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -2,7 +2,7 @@
 # This file is used to parse meta files  #  # Copyright (c) 2008 - 2018, Intel 
Corporation. All rights reserved. -# (C) Copyright 2015-2016 Hewlett 
Packard Enterprise Development LP
+# (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
 # 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 @@ 
-1551,10 +1551,21 @@ class DscParser(MetaFileParser):
 
 self.IncludedFiles.add (IncludedFile1)
 
+# todo: rework the nested include checking logic
+# Current nested include checking rely on dsc file order inside 
build.db.
+# It is not reliable and will lead to build fail in some case.
+#
+# When project A and B include a common dsc file C.
+# Build project A. It give dsc file A = ID 1 in build.db, and C ID 
= 2.
+# Build project B. It give dsc file B ID = 3, and C ID still = 2.
+# Then, we build project B fail, unless we clean build.db.
+# In oldder BaseTools, the project B ID will still be 1,
+# that's why it work before.
+
 # Does not allow lower level included file to include upper level 
included file
-if Parser._From != Owner and int(Owner) > int (Parser._From):
-EdkLogger.error('parser', FILE_ALREADY_EXIST, 
File=self._FileWithError,
-Line=self._LineIndex + 1, ExtraData="{0} is already 
included at a higher level.".format(IncludedFile1))
+#if Parser._From != Owner and int(Owner) > int (Parser._From):
+#EdkLogger.error('parser', FILE_ALREADY_EXIST, 
File=self._FileWithError,
+#Line=self._LineIndex + 1, ExtraData="{0} is already 
included at a higher level.".format(IncludedFile1))
 
 
 # set the parser status with current status
--
2.15.1.windows.2

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


[edk2] [PATCH] BaseTools: Fix --hash Package and Module hash value.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
The order of List enumeration is arbitrary.
Need to be sorted while calculating Package/Module hash, otherwise it generate 
different hash value even nothing changes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Derek Lin 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 54f6b1f173..90704dcae4 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2,6 +2,7 @@
 # Generate AutoGen.h, AutoGen.c and *.depex files  #  # Copyright (c) 2007 - 
2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 # 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 @@ 
-670,6 +671,9 @@ class WorkspaceAutoGen(AutoGen):
 return True
 
 def _GenPkgLevelHash(self, Pkg):
+if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]:
+return
+
 PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)
 CreateDirectory(PkgDir)
 HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash') @@ -681,17 
+685,16 @@ class WorkspaceAutoGen(AutoGen):
 m.update(Content)
 # Get include files hash value
 if Pkg.Includes:
-for inc in Pkg.Includes:
+for inc in sorted(Pkg.Includes, key=lambda x: str(x)):
 for Root, Dirs, Files in os.walk(str(inc)):
-for File in Files:
+for File in sorted(Files):
 File_Path = os.path.join(Root, File)
 f = open(File_Path, 'r')
 Content = f.read()
 f.close()
 m.update(Content)
 SaveFileOnChange(HashFile, m.hexdigest(), True)
-if Pkg.PackageName not in GlobalData.gPackageHash[Pkg.Arch]:
-GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()
+GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = 
+ m.hexdigest()
 
 def _GetMetaFiles(self, Target, Toolchain, Arch):
 AllWorkSpaceMetaFiles = set()
@@ -4432,13 +4435,13 @@ class ModuleAutoGen(AutoGen):
 m.update(GlobalData.gPlatformHash)
 # Add Package level hash
 if self.DependentPackageList:
-for Pkg in self.DependentPackageList:
+for Pkg in sorted(self.DependentPackageList, key=lambda x: 
x.PackageName):
 if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:
 
m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])
 
 # Add Library hash
 if self.LibraryAutoGenList:
-for Lib in self.LibraryAutoGenList:
+for Lib in sorted(self.LibraryAutoGenList, key=lambda x: x.Name):
 if Lib.Name not in GlobalData.gModuleHash[self.Arch]:
 Lib.GenModuleHash()
 m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])
@@ -4450,7 +4453,7 @@ class ModuleAutoGen(AutoGen):
 m.update(Content)
 # Add Module's source files
 if self.SourceFileList:
-for File in self.SourceFileList:
+for File in sorted(self.SourceFileList, key=lambda x: str(x)):
 f = open(str(File), 'r')
 Content = f.read()
 f.close()
--
2.15.1.windows.2

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


Re: [edk2] [PATCH edk2-platforms v2 6/6] Platform/ARM/Sgi: add initial support for ARM SGI platform

2018-05-09 Thread Thomas Abraham
Hi Ard,

On Mon, Apr 16, 2018 at 4:14 PM, Ard Biesheuvel
 wrote:
> On 12 April 2018 at 20:47, Thomas Abraham  wrote:
>> From: Vishwanatha HG 
>>
>> Add the initial support for ARM's System Guidance for Infrastructure
>> (SGI) platforms. SGI-575 is the supported platform in this initial
>> implementation and can be extented to include support for upcoming
>> SGI platforms as well.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by:  Vishwanatha HG 
>> Signed-off-by: Thomas Abraham 
>> ---
>>  Platform/ARM/SgiPkg/SgiPlatform.dec |  36 
>>  Platform/ARM/SgiPkg/SgiPlatform.dsc | 243 +++
>>  Platform/ARM/SgiPkg/SgiPlatform.fdf | 320 
>> 
>>  3 files changed, 599 insertions(+)
>>  create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.dec
>>  create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.dsc
>>  create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.fdf
>>



>> +
>> +#
>> +# Components Section - list of all EDK II Modules needed by this Platform
>> +#
>> +
>> +[Components.common]
>> +  #
>> +  # PEI Phase modules
>> +  #
>> +  ArmPlatformPkg/PrePi/PeiMPCore.inf {
>
> Apologies for missing this before: please use PrePeiCore not PrePi.
> PrePi is a misguided optimization that skips the entire PEI phase,
> making ARM platforms deviate from other UEFI systems in ways that make
> it more difficult later on to reuse generic modules for things like
> capsule update etc.

Thank you for your comments. All the changes you have suggested has
been included in the v3 version of this patchset. As you have
suggested, the use of PrePi has been dropped and switched to using
PrePeiCore. Apologies for taking a lot of time to revert back on your
comments.

Thanks,
Thomas.


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


[edk2] [PATCH edk2-platforms v3 0/6] Platform/ARM/Sgi: Add Arm's SGI platform support

2018-05-09 Thread Thomas Abraham
Changes since v2:
- addressed all the comments from Ard.
- PrePeiCore is used instead of PrePi.

Changes since v1:
- minor update to commit messages

Arm CoreLink System Guidance for Infrastructure is a collection of
resources to provide a representative view of typical compute subsystems
that can be designed and implemented using specific generations of Arm IP.
These compute subsystems address the expected requirements of a specific
segment of the infrastructure market which includes servers, storage and
networking.

This patch series adds initial platform port support for Arm'S SGI-575
platform. This platform has 8x Cortex-A75 CPUs, supports DynamIQ
with L3 cache options, supports 2x DDR4-3200 (DMC-620) memory controller
and is SBSAv3 compliant. This series includes support for GIC, Serial,
smsc91x and virtio block device.

Daniil Egranov (3):
  Platform/ARM/Sgi: add initial platform dxe driver implementation
  Platform/ARM/Sgi: add support for virtio block device
  Platform/ARM/Sgi: add the initial set of acpi tables

Thomas Abraham (1):
  Platform/ARM/Sgi: Add Platform library implementation

Vishwanatha HG (2):
  Platform/ARM/Sgi: add NOR flash platform library implementation
  Platform/ARM/Sgi: add initial support for ARM SGI platform

 .../ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf|  54 
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc|  90 ++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl |  99 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc|  87 ++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc| 123 +
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc| 173 
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc|  77 ++
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c   |  48 
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf |  74 +
 .../ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c |  76 +
 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h|  41 +++
 Platform/ARM/SgiPkg/Include/SgiPlatform.h  |  73 +
 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c |  66 +
 .../ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf |  34 +++
 .../SgiPkg/Library/PlatformLib/AArch64/Helper.S|  65 +
 Platform/ARM/SgiPkg/Library/PlatformLib/Mem.c  | 110 
 Platform/ARM/SgiPkg/Library/PlatformLib/Platform.c |  73 +
 .../ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf |  59 
 Platform/ARM/SgiPkg/SgiPlatform.dec|  37 +++
 Platform/ARM/SgiPkg/SgiPlatform.dsc| 251 +
 Platform/ARM/SgiPkg/SgiPlatform.fdf| 306 +
 21 files changed, 2016 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc
 create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
 create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
 create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
 create mode 100644 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h
 create mode 100644 Platform/ARM/SgiPkg/Include/SgiPlatform.h
 create mode 100644 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c
 create mode 100644 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/AArch64/Helper.S
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/Mem.c
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/Platform.c
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
 create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.dec
 create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.dsc
 create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.fdf

-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v3 1/6] Platform/ARM/Sgi: Add Platform library implementation

2018-05-09 Thread Thomas Abraham
Add initial SGI platform library support. This includes the virtual
memory map and helper functions for platform intialization.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Thomas Abraham 
---
 Platform/ARM/SgiPkg/Include/SgiPlatform.h  |  73 ++
 .../SgiPkg/Library/PlatformLib/AArch64/Helper.S|  65 
 Platform/ARM/SgiPkg/Library/PlatformLib/Mem.c  | 110 +
 Platform/ARM/SgiPkg/Library/PlatformLib/Platform.c |  73 ++
 .../ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf |  59 +++
 5 files changed, 380 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/Include/SgiPlatform.h
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/AArch64/Helper.S
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/Mem.c
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/Platform.c
 create mode 100644 Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf

diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h 
b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
new file mode 100644
index 000..c08e011
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h
@@ -0,0 +1,73 @@
+/** @file
+*
+*  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.
+*
+**/
+
+#ifndef __SGI_PLATFORM_H__
+#define __SGI_PLATFORM_H__
+
+/***
+// Platform Memory Map
+/
+
+// Expansion AXI - SMC Chip Select 0
+#define SGI_EXP_SMC_CS0_BASE  0x0800
+#define SGI_EXP_SMC_CS0_SZSIZE_64MB
+
+// Expansion AXI - SMC Chip Select 1
+#define SGI_EXP_SMC_CS1_BASE  0x0C00
+#define SGI_EXP_SMC_CS1_SZSIZE_64MB
+
+// Expansion AXI - SMSC 91C111 (Ethernet)
+#define SGI_EXP_SMSC91X_BASE  0x1800
+#define SGI_EXP_SMSC91X_SZSIZE_64MB
+
+// Expansion AXI - System peripherals
+#define SGI_EXP_SYS_PERIPH_BASE   0x1C00
+#define SGI_EXP_SYS_PERIPH_SZ SIZE_2MB
+
+// Base address of system peripherals
+#define SGI_EXP_SYSPH_SYSTEM_REGISTERS0x1C01
+#define SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE   0x1C13
+
+// Sub System Peripherals - UART0
+#define SGI_SUBSYS_UART0_BASE 0x2A40
+#define SGI_SUBSYS_UART0_SZ   0x0001
+
+// Sub System Peripherals - UART1
+#define SGI_SUBSYS_UART1_BASE 0x2A41
+#define SGI_SUBSYS_UART1_SZ   0x0001
+
+// Sub System Peripherals - Generic Watchdog
+#define SGI_SUBSYS_GENERIC_WDOG_BASE  0x2A44
+#define SGI_SUBSYS_GENERIC_WDOG_SZSIZE_128KB
+
+// Sub System Peripherals - GIC
+#define SGI_SUBSYS_GENERIC_GIC_BASE   0x3000
+#define SGI_SUBSYS_GENERIC_GICR_BASE  0x300C
+#define SGI_SUBSYS_GENERIC_GIC_SZ SIZE_1MB
+
+// Expansion AXI - Platform Peripherals - UART0
+#define SGI_EXP_PLAT_PERIPH_UART0_BASE0x7FF7
+#define SGI_EXP_PLAT_PERIPH_UART0_SZ  SIZE_64KB
+
+// Expansion AXI - Platform Peripherals - UART1
+#define SGI_EXP_PLAT_PERIPH_UART1_BASE0x7FF8
+#define SGI_EXP_PLAT_PERIPH_UART1_SZ  SIZE_64KB
+
+#define ARM_PLATFORM_WATCHDOG_COUNT  2
+
+// Register offsets into the System Registers Block
+#define SGI_SYSPH_SYS_REG_FLASH   0x4C
+#define SGI_SYSPH_SYS_REG_FLASH_RWEN  0x1
+
+#endif // __SGI_PLATFORM_H__
diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/AArch64/Helper.S 
b/Platform/ARM/SgiPkg/Library/PlatformLib/AArch64/Helper.S
new file mode 100644
index 000..dab6c77
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Library/PlatformLib/AArch64/Helper.S
@@ -0,0 +1,65 @@
+/** @file
+*
+*  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 
+
+.text
+.align 3
+
+GCC_ASM_EXPORT(ArmPlatformPeiBootAction)

[edk2] [PATCH edk2-platforms v3 4/6] Platform/ARM/Sgi: add support for virtio block device

2018-05-09 Thread Thomas Abraham
From: Daniil Egranov 

Add the registration of the virtio block device.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov 
Signed-off-by: Thomas Abraham 
---
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c   | 18 -
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf |  1 +
 .../ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c | 76 ++
 3 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c

diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c 
b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
index eb26fde..fb1e390 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
@@ -15,11 +15,27 @@
 #include 
 
 EFI_STATUS
+InitVirtioBlockIo (
+  IN EFI_HANDLE ImageHandle
+);
+
+EFI_STATUS
 EFIAPI
 ArmSgiPkgEntryPoint (
   IN EFI_HANDLE ImageHandle,
   IN EFI_SYSTEM_TABLE   *SystemTable
   )
 {
-  return EFI_SUCCESS;
+  EFI_STATUS  Status;
+
+  // Install Virtio Block IO.
+  if (FeaturePcdGet (PcdVirtioSupported) == TRUE) {
+Status = InitVirtioBlockIo (ImageHandle);
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio Block 
IO\n"));
+  return Status;
+}
+  }
+
+  return Status;
 }
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf 
b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
index dbe04c5..995f80d 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
@@ -20,6 +20,7 @@
 
 [Sources.common]
   PlatformDxe.c
+  VirtioBlockIo.c
 
 [Packages]
   ArmPkg/ArmPkg.dec
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c 
b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
new file mode 100644
index 000..58dfd22
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
@@ -0,0 +1,76 @@
+/** @file
+
+  Copyright (c) 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 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 
+
+#pragma pack (1)
+typedef struct {
+  VENDOR_DEVICE_PATH  Vendor;
+  EFI_DEVICE_PATH_PROTOCOLEnd;
+} VIRTIO_BLK_DEVICE_PATH;
+#pragma pack ()
+
+STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
+{
+  {
+{
+  HARDWARE_DEVICE_PATH,
+  HW_VENDOR_DP,
+  {
+(UINT8)( sizeof (VENDOR_DEVICE_PATH) ),
+(UINT8)( (sizeof (VENDOR_DEVICE_PATH) ) >> 8)
+  }
+},
+EFI_CALLER_ID_GUID,
+  },
+  {
+END_DEVICE_PATH_TYPE,
+END_ENTIRE_DEVICE_PATH_SUBTYPE,
+{
+  sizeof (EFI_DEVICE_PATH_PROTOCOL),
+  0
+}
+  }
+};
+
+/**
+ * Entrypoint for 'VirtioBlockIo' driver
+ */
+EFI_STATUS
+InitVirtioBlockIo (
+   IN EFI_HANDLE ImageHandle
+  )
+{
+  EFI_STATUS Status = 0;
+
+  Status = gBS->InstallProtocolInterface (,
+   , EFI_NATIVE_INTERFACE,
+   );
+
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  // Declare the Virtio BlockIo device
+  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, 
ImageHandle);
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio block 
device\n"));
+  }
+
+  return Status;
+}
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v3 3/6] Platform/ARM/Sgi: add initial platform dxe driver implementation

2018-05-09 Thread Thomas Abraham
From: Daniil Egranov 

Add a initial platform dxe driver which starts of being almost
an empty implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov 
Signed-off-by: Thomas Abraham 
---
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c   | 25 
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 73 ++
 2 files changed, 98 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
 create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf

diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c 
b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
new file mode 100644
index 000..eb26fde
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
@@ -0,0 +1,25 @@
+/** @file
+*
+*  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 
+
+EFI_STATUS
+EFIAPI
+ArmSgiPkgEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  return EFI_SUCCESS;
+}
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf 
b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
new file mode 100644
index 000..dbe04c5
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
@@ -0,0 +1,73 @@
+#
+#  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= 0x0001001A
+  BASE_NAME  = PlatformDxe
+  FILE_GUID  = 54cee352-c4cd-4d80-8524-54325c3a528e
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= ArmSgiPkgEntryPoint
+
+[Sources.common]
+  PlatformDxe.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+  Platform/ARM/SgiPkg/SgiPlatform.dec
+
+[LibraryClasses]
+  AcpiLib
+  BaseMemoryLib
+  DebugLib
+  DxeServicesTableLib
+  FdtLib
+  HobLib
+  IoLib
+  PcdLib
+  PrintLib
+  SerialPortLib
+  UefiBootServicesTableLib
+  UefiRuntimeServicesTableLib
+  UefiLib
+  UefiDriverEntryPoint
+  VirtioMmioDeviceLib
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+  gEfiFileInfoGuid
+  gEfiHobListGuid
+  gFdtTableGuid
+  gEfiAcpi10TableGuid
+  gEfiAcpiTableGuid
+  gSgi575AcpiTablesiFileGuid
+
+[Protocols]
+  gEfiBlockIoProtocolGuid
+  gEfiDevicePathFromTextProtocolGuid
+  gEfiSimpleFileSystemProtocolGuid
+
+[FeaturePcd]
+  gArmSgiTokenSpaceGuid.PcdVirtioSupported
+
+[FixedPcd]
+  gArmTokenSpaceGuid.PcdSystemMemoryBase
+  gArmTokenSpaceGuid.PcdSystemMemorySize
+  gArmTokenSpaceGuid.PcdHypFvBaseAddress
+  gArmTokenSpaceGuid.PcdHypFvSize
+
+[Depex]
+  TRUE
-- 
2.7.4

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


[edk2] [PATCH edk2-platforms v3 6/6] Platform/ARM/Sgi: add initial support for ARM SGI platform

2018-05-09 Thread Thomas Abraham
From: Vishwanatha HG 

Add the initial support for ARM's System Guidance for Infrastructure
(SGI) platforms. SGI-575 is the supported platform in this initial
implementation and can be extented to include support for upcoming
SGI platforms as well.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vishwanatha HG 
Signed-off-by: Thomas Abraham 
---
 Platform/ARM/SgiPkg/SgiPlatform.dec |  37 +
 Platform/ARM/SgiPkg/SgiPlatform.dsc | 251 +
 Platform/ARM/SgiPkg/SgiPlatform.fdf | 306 
 3 files changed, 594 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.dec
 create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.dsc
 create mode 100644 Platform/ARM/SgiPkg/SgiPlatform.fdf

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec 
b/Platform/ARM/SgiPkg/SgiPlatform.dec
new file mode 100644
index 000..d995937
--- /dev/null
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
@@ -0,0 +1,37 @@
+#
+#  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]
+  DEC_SPECIFICATION  = 0x0001001A
+  PACKAGE_NAME   = SgiPkg
+  PACKAGE_GUID   = e6e0f26c-0df9-4f6c-a382-37ded896c6e9
+  PACKAGE_VERSION= 0.1
+
+
+#
+# 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
+
+[Guids.common]
+  gArmSgiTokenSpaceGuid  = { 0x577d6941, 0xaea1, 0x40b4, { 0x90, 0x93, 
0x2a, 0x86, 0x61, 0x72, 0x5a, 0x57 } }
+  gSgi575AcpiTablesiFileGuid = { 0xc712719a, 0x0aaf, 0x438c, { 0x9c, 0xdd, 
0x35, 0xab, 0x4d, 0x60, 0x20, 0x7d } }
+
+[PcdsFeatureFlag.common]
+  # Set this PCD to TRUE to enable virtio support.
+  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x0001
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc 
b/Platform/ARM/SgiPkg/SgiPlatform.dsc
new file mode 100644
index 000..c5f220e
--- /dev/null
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -0,0 +1,251 @@
+#
+#  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 Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME  = ArmSgi
+  PLATFORM_GUID  = 3a6b2eae-0275-4b6e-a5d1-bd2ba1ce1fae
+  PLATFORM_VERSION   = 0.1
+  DSC_SPECIFICATION  = 0x0001001B
+  OUTPUT_DIRECTORY   = Build/$(PLATFORM_NAME)
+  SUPPORTED_ARCHITECTURES= AARCH64|ARM
+  BUILD_TARGETS  = NOOPT|DEBUG|RELEASE
+  SKUID_IDENTIFIER   = DEFAULT
+  FLASH_DEFINITION   = Platform/ARM/SgiPkg/SgiPlatform.fdf
+  BUILD_NUMBER   = 1
+
+!include Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc
+
+[LibraryClasses.common]
+  ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+  ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+  ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+  
ArmPlatformSysConfigLib|Platform/ARM/VExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf
+  ArmPlatformLib|Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.inf
+  BasePathLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
+  
EfiResetSystemLib|ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
+  NorFlashPlatformLib|Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
+
+  # Virtio 

[edk2] [PATCH edk2-platforms v3 5/6] Platform/ARM/Sgi: add the initial set of acpi tables

2018-05-09 Thread Thomas Abraham
From: Daniil Egranov 

Add the initial version of Acpi tables for the SGI-575 platform which
is required to boot the linux kernel up to a busybox prompt.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov 
Signed-off-by: Thomas Abraham 
---
 .../ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf|  54 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc|  90 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl |  99 
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc|  87 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc| 123 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc| 173 +
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc|  77 +
 .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c   |   7 +
 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h|  41 +
 9 files changed, 751 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Fadt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Gtdt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Madt.aslc
 create mode 100644 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Spcr.aslc
 create mode 100644 Platform/ARM/SgiPkg/Include/SgiAcpiHeader.h

diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf 
b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
new file mode 100644
index 000..14d49d4
--- /dev/null
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/AcpiTables.inf
@@ -0,0 +1,54 @@
+## @file
+#
+#  ACPI table data and ASL sources required to boot the platform.
+#
+#  Copyright (c) 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 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  = Sgi575AcpiTables
+  FILE_GUID  = c712719a-0aaf-438c-9cdd-35ab4d60207d  # 
gSgi575AcpiTablesiFileGuid
+  MODULE_TYPE= USER_DEFINED
+  VERSION_STRING = 1.0
+
+[Sources]
+  Dbg2.aslc
+  Dsdt.asl
+  Fadt.aslc
+  Gtdt.aslc
+  Madt.aslc
+  Spcr.aslc
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/SgiPkg/SgiPlatform.dec
+  Platform/ARM/VExpressPkg/ArmVExpressPkg.dec
+
+[FixedPcd]
+  gArmPlatformTokenSpaceGuid.PcdCoreCount
+  gArmPlatformTokenSpaceGuid.PcdClusterCount
+  gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
+  gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
+
+  gArmTokenSpaceGuid.PcdGenericWatchdogControlBase
+  gArmTokenSpaceGuid.PcdGenericWatchdogRefreshBase
+  gArmPlatformTokenSpaceGuid.PcdSerialDbgRegisterBase
+  gArmPlatformTokenSpaceGuid.PL011UartInterrupt
diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc 
b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
new file mode 100644
index 000..ed671f3
--- /dev/null
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dbg2.aslc
@@ -0,0 +1,90 @@
+/** @file
+*  Debug Port Table 2 (DBG2)
+*
+*  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 "SgiAcpiHeader.h"
+#include 
+#include 
+#include 
+
+#define SGI_DBG2_NUM_DEBUG_PORTS   1
+#define SGI_DBG2_NUM_GAS   1
+#define SGI_DBG2_NS_STR_LENGTH 8
+#define SGI_PL011_REGISTER_SPACE   0x1000
+
+#define NAME_STR_UART1 {'C', 'O', 'M', '1', '\0', '\0', '\0', '\0'}
+
+#pragma pack(1)
+
+typedef struct {
+  EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device;
+  EFI_ACPI_6_1_GENERIC_ADDRESS_STRUCTUREBaseAddressRegister;
+  UINT32AddressSize;
+  UINT8

[edk2] [PATCH edk2-platforms v3 2/6] Platform/ARM/Sgi: add NOR flash platform library implementation

2018-05-09 Thread Thomas Abraham
From: Vishwanatha HG 

Add a initial NOR flash driver platform wrapper as part of the platform
library. Access to NOR flash devices connected to CS0 and CS1 is enabled
in this initial implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vishwanatha HG 
Signed-off-by: Thomas Abraham 
---
 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c | 66 ++
 .../ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf | 34 +++
 2 files changed, 100 insertions(+)
 create mode 100644 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c
 create mode 100644 Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf

diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c 
b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c
new file mode 100644
index 000..9b4981f
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlash.c
@@ -0,0 +1,66 @@
+/** @file
+
+  Copyright (c) 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 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 
+
+STATIC NOR_FLASH_DESCRIPTION mNorFlashDevices[] = {
+  {
+SGI_EXP_SMC_CS0_BASE,
+SGI_EXP_SMC_CS0_BASE,
+SIZE_256KB * 256,
+SIZE_256KB,
+{0xEBF0B9DF, 0x17d0, 0x4812, { 0xA9, 0x59, 0xCF, 0xD7, 0x92, 0xEE, 0x31, 
0x13} }
+  },
+  {
+SGI_EXP_SMC_CS1_BASE,
+SGI_EXP_SMC_CS1_BASE,
+SIZE_256KB * 256,
+SIZE_256KB,
+{ 0x1F15DA3C, 0x37FF, 0x4070, { 0xB4, 0x71, 0xBB, 0x4A, 0xF1, 0x2A, 0x72, 
0x4A } }
+  },
+};
+
+EFI_STATUS
+NorFlashPlatformInitialization (
+  VOID
+  )
+{
+  UINT64 SysRegFlash;
+
+  SysRegFlash = SGI_EXP_SYSPH_SYSTEM_REGISTERS + SGI_SYSPH_SYS_REG_FLASH;
+  if ((MmioRead32 (SysRegFlash) & SGI_SYSPH_SYS_REG_FLASH_RWEN) == 0) {
+MmioWrite32 (SysRegFlash, 1);
+  }
+
+  return EFI_SUCCESS;
+}
+
+EFI_STATUS
+NorFlashPlatformGetDevices (
+  OUT NOR_FLASH_DESCRIPTION   **NorFlashDevices,
+  OUT UINT32  *Count
+  )
+{
+  if ((NorFlashDevices == NULL) || (Count == NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  *NorFlashDevices = mNorFlashDevices;
+  *Count = ARRAY_SIZE (mNorFlashDevices);
+  return EFI_SUCCESS;
+}
diff --git a/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf 
b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
new file mode 100644
index 000..4db2fd8
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Library/NorFlashLib/NorFlashLib.inf
@@ -0,0 +1,34 @@
+#/** @file
+#
+#  Copyright (c) 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 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  = NorFlashSgiLib
+  FILE_GUID  = 3f021755-6d74-4065-9ee4-98225267b36e
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = NorFlashPlatformLib
+
+[Sources.common]
+  NorFlash.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/SgiPkg/SgiPlatform.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  IoLib
-- 
2.7.4

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


Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c

2018-05-09 Thread Marvin Häuser
Hey Tim,

The compiler has no information regarding the size of the stack and hence 
cannot determine an overflow.
This is basically a warning that stack of a single function is big enough to 
reach past the Guard Page and ensures it will be accessed.

Yao,

I just realized there already is Stack protection code in edk2, I was only 
aware of Heap protection.
Wouldn't a proper implementation make sense now to maybe not expand the stack, 
but at least runtime-error?

Regards,
Marvin

> -Original Message-
> From: Tim Lewis 
> Sent: Wednesday, May 9, 2018 3:28 AM
> To: 'Yao, Jiewen' ; marvin.haeu...@outlook.com;
> edk2-devel@lists.01.org
> Subject: RE: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> 
> I think that this is a fatal error in EDK2. It basically says, "we are out of 
> stack
> space." The alternative is: the system hangs in an unexpected way since the
> stack overflows into other pages.
> 
> Tim
> 
> -Original Message-
> From: edk2-devel  On Behalf Of Yao,
> Jiewen
> Sent: Tuesday, May 8, 2018 5:25 PM
> To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> 
> We discussed internally in Intel.
> 
> The quick workaround is: use /Gs65536. :-)
> 
> At the same time, our recommendation is to revisit the code which triggers
> this error. Why this function need such a big stack? And try to reduce the
> local stack usage.
> 
> What is why we still use /Gs32768 as default, instead of /Gs65536.
> 
> Thank you
> Yao Jiewen
> 
> 
> > -Original Message-
> > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> > Marvin H?user
> > Sent: Tuesday, May 8, 2018 5:21 PM
> > To: edk2-devel@lists.01.org
> > Cc: Yao, Jiewen 
> > Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> >
> > Oh, if you are prefering a good implementation, I will be all for
> > that. This was just a 'quick workaround', same as currently done for GCC.
> > I'm actually unsure whether a good implementation is possible with a
> > flat memory model. It will likely be mere luck whether there is enough
> > space free below the stack, except for maybe when it's located very
> > high (preferably past the 32-bit space).
> > Has there been any prior discussion on this topic? Would be interested
> > to follow up if there was.
> >
> > Thanks,
> > Marvin
> >
> > > -Original Message-
> > > From: Yao, Jiewen 
> > > Sent: Wednesday, May 9, 2018 2:13 AM
> > > To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> > > Cc: Gao, Liming 
> > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> > >
> > > There are some open source implementation:
> > > MSVC: https://github.com/ispc/ispc/issues/542
> > > GCC:
> > >
> https://android.googlesource.com/toolchain/gcc/+/b094d6c4bf572654a03
> > > 1e cc4afe675154c886dc5/gcc-4.4.3/gcc/config/i386/chkstk.asm
> > >
> > > The compiler generated code assumes the stack is enlarged after we
> > > can chkstk.
> > >
> > > I agree empty function can make build pass.
> > > But more important, we need make it work if there is a need to
> > > increase the stack.
> > > The potential issue is that the later code (after chkstk) assumes
> > > the stack is increased, but actually it is not.
> > >
> > > That is why I ask how this is validated.
> > >
> > > Thank you
> > > Yao Jiewen
> > >
> > >
> > > > -Original Message-
> > > > From: Marvin Häuser [mailto:marvin.haeu...@outlook.com]
> > > > Sent: Tuesday, May 8, 2018 4:58 PM
> > > > To: edk2-devel@lists.01.org
> > > > Cc: Yao, Jiewen ; Gao, Liming
> > > > 
> > > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> > > >
> > > > Hey Yao,
> > > >
> > > > As far as I am aware, all __chkstk does is access the stack in 4
> > > > KB intervals from the current location to the maximum requested
> > > > location to eventually hit the Windows Guard Page, which then
> > > > triggers the stack
> > > increase.
> > > > Because I do not know of any equivalent concept in edk2 and the
> > > > intrinsic was already disabled for GCC, I supposed it was a good
> > > > idea to do so globally. Are the potential issues I am not aware of?
> > > >
> > > > Thanks,
> > > > Marvin.
> > > >
> > > > > -Original Message-
> > > > > From: Yao, Jiewen 
> > > > > Sent: Wednesday, May 9, 2018 1:52 AM
> > > > > To: marvin.haeu...@outlook.com; edk2-devel@lists.01.org
> > > > > Cc: Gao, Liming 
> > > > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c
> > > > >
> > > > > HI Marvin
> > > > > Would you mind to share the information on how you test this
> update?
> > > > >
> > > > >
> > > > > Per my experience, chkstk not only does the check but also does
> > > > > the real work to allocate 

Re: [edk2] [PATCH] BaseTools: Fix --hash Package and Module hash value.

2018-05-09 Thread Zhu, Yonghong
Hi Derek,

Please refer below link to add Contributed-under and Signed-off-by info.
We can use BaseTools\Scripts\PatchCheck.py  to check the patch format. Thanks.
https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format 

Best Regards,
Zhu Yonghong


-Original Message-
From: Lin, Derek (HPS UEFI Dev) [mailto:derek.l...@hpe.com] 
Sent: Wednesday, May 09, 2018 3:49 PM
To: edk2-devel@lists.01.org
Cc: Zhu, Yonghong ; Lin, Derek (HPS UEFI Dev) 

Subject: [PATCH] BaseTools: Fix --hash Package and Module hash value.

From: Lin, Derek (HPS UEFI Dev) 
Sent: Wednesday, May 9, 2018 3:39 PM
To: Lin, Derek (HPS UEFI Dev) 
Subject: [PATCH] BaseTools: Fix --hash Package and Module hash value.

The order of List enumeration is arbitrary.
Need to be sorted while calculating Package/Module hash, otherwise it generate 
different hash value even nothing changes.
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 54f6b1f173..90704dcae4 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2,6 +2,7 @@
 # Generate AutoGen.h, AutoGen.c and *.depex files  #  # Copyright (c) 2007 - 
2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 # 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 @@ 
-670,6 +671,9 @@ class WorkspaceAutoGen(AutoGen):
 return True
 
 def _GenPkgLevelHash(self, Pkg):
+if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]:
+return
+
 PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)
 CreateDirectory(PkgDir)
 HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash') @@ -681,17 
+685,16 @@ class WorkspaceAutoGen(AutoGen):
 m.update(Content)
 # Get include files hash value
 if Pkg.Includes:
-for inc in Pkg.Includes:
+for inc in sorted(Pkg.Includes, key=lambda x: str(x)):
 for Root, Dirs, Files in os.walk(str(inc)):
-for File in Files:
+for File in sorted(Files):
 File_Path = os.path.join(Root, File)
 f = open(File_Path, 'r')
 Content = f.read()
 f.close()
 m.update(Content)
 SaveFileOnChange(HashFile, m.hexdigest(), True)
-if Pkg.PackageName not in GlobalData.gPackageHash[Pkg.Arch]:
-GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()
+GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = 
+ m.hexdigest()
 
 def _GetMetaFiles(self, Target, Toolchain, Arch):
 AllWorkSpaceMetaFiles = set()
@@ -4432,13 +4435,13 @@ class ModuleAutoGen(AutoGen):
 m.update(GlobalData.gPlatformHash)
 # Add Package level hash
 if self.DependentPackageList:
-for Pkg in self.DependentPackageList:
+for Pkg in sorted(self.DependentPackageList, key=lambda x: 
x.PackageName):
 if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:
 
m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])
 
 # Add Library hash
 if self.LibraryAutoGenList:
-for Lib in self.LibraryAutoGenList:
+for Lib in sorted(self.LibraryAutoGenList, key=lambda x: x.Name):
 if Lib.Name not in GlobalData.gModuleHash[self.Arch]:
 Lib.GenModuleHash()
 m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])
@@ -4450,7 +4453,7 @@ class ModuleAutoGen(AutoGen):
 m.update(Content)
 # Add Module's source files
 if self.SourceFileList:
-for File in self.SourceFileList:
+for File in sorted(self.SourceFileList, key=lambda x: str(x)):
 f = open(str(File), 'r')
 Content = f.read()
 f.close()
--
2.15.1.windows.2


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


Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer

2018-05-09 Thread Dong, Eric
Reviewed-by: Eric Dong 

-Original Message-
From: Bi, Dandan 
Sent: Wednesday, May 9, 2018 1:02 PM
To: edk2-devel@lists.01.org
Cc: Dong, Eric ; Gao, Liming ; Gary 
Lin 
Subject: [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer

V2:
Add function _INIT_OPHDR_COND () for variable initialization.
Make code logic more clean.

Previously _CLEAR_SAVED_OPHDR () is used for variable initialization, and we 
updated it to clean memory.
But _CLEAR_SAVED_OPHDR () is still called for variable initialization. This 
will cause uninitialized pointer will be checked to free and cause unexpected 
issue.

This patch is to add new function for variable initialization and keep 
_CLEAR_SAVED_OPHDR () to clean memory which is aligned with its function name.

Cc: Eric Dong 
Cc: Liming Gao 
Cc: Gary Lin 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g 
b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index 4b0a43606ea..84dd2c3ed3f 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults :
 
 //
 // Root expression extension function called by other function.
 //
 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
-  << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= 
MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth 
of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >>
+   <<
+  if ($RootLevel == 0) 
{
+mCIfrOpHdrIndex ++;
+if 
(mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) {
+  _PCATCH 
(VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max 
supported level 8!");
+}
+_INIT_OPHDR_COND 
();
+  }
+   >>
   andTerm[$RootLevel, $ExpOpCount]
   (
 L:OR andTerm[$RootLevel, $ExpOpCount]  << $ExpOpCount++; 
CIfrOr OObj(L->getLine()); >>
   )*
<< @@ -4988,10 +4996,11 
@@ private:
   CIfrOpHeader *  mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];
   UINT32  mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];
   UINT8   mCIfrOpHdrIndex;
   VOID_SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 
LineNo = 0);
   VOID_CLEAR_SAVED_OPHDR (VOID);
+  VOID_INIT_OPHDR_COND (VOID);
   BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID);
 
 
   EFI_VARSTORE_INFO   mCurrQestVarInfo;
   EFI_GUID*mOverrideClassGuid;
@@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND (
 mCIfrOpHdr[mCIfrOpHdrIndex]   = new CIfrOpHeader(OpHdr);
 mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;
   }
 }
 
+VOID
+EfiVfrParser::_INIT_OPHDR_COND (
+  VOID
+  )
+{
+  mCIfrOpHdr[mCIfrOpHdrIndex]   = NULL;
+  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; }
+
 VOID
 EfiVfrParser::_CLEAR_SAVED_OPHDR (
   VOID
   )
 {
   if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
 delete mCIfrOpHdr[mCIfrOpHdrIndex];
-mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
+mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
   }
-  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;  }
 
 BOOLEAN
 EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
   VOID
--
2.14.3.windows.1

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


Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer

2018-05-09 Thread Gary Lin
On Wed, May 09, 2018 at 01:02:11PM +0800, Dandan Bi wrote:
> V2:
> Add function _INIT_OPHDR_COND () for variable initialization.
> Make code logic more clean.
> 
> Previously _CLEAR_SAVED_OPHDR () is used for variable
> initialization, and we updated it to clean memory.
> But _CLEAR_SAVED_OPHDR () is still called for variable
> initialization. This will cause uninitialized pointer
> will be checked to free and cause unexpected issue.
> 
> This patch is to add new function for variable initialization
> and keep _CLEAR_SAVED_OPHDR () to clean memory which is
> aligned with its function name.
> 
This patch fixes the build errors I had :)

Tested-by: Gary Lin 

> Cc: Eric Dong 
> Cc: Liming Gao 
> Cc: Gary Lin 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi 
> ---
>  BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23 ---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g 
> b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> index 4b0a43606ea..84dd2c3ed3f 100644
> --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
> @@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults :
>  
>  //
>  // Root expression extension function called by other function.
>  //
>  vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
> -  << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= 
> MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The 
> depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR 
> ();} >>
> +   <<
> +  if ($RootLevel == 
> 0) {
> +mCIfrOpHdrIndex 
> ++;
> +if 
> (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) {
> +  _PCATCH 
> (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max 
> supported level 8!");
> +}
> +_INIT_OPHDR_COND 
> ();
> +  }
> +   >>
>andTerm[$RootLevel, $ExpOpCount]
>(
>  L:OR andTerm[$RootLevel, $ExpOpCount]  << $ExpOpCount++; 
> CIfrOr OObj(L->getLine()); >>
>)*
> <<
> @@ -4988,10 +4996,11 @@ private:
>CIfrOpHeader *  mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH];
>UINT32  mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH];
>UINT8   mCIfrOpHdrIndex;
>VOID_SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, 
> UINT32 LineNo = 0);
>VOID_CLEAR_SAVED_OPHDR (VOID);
> +  VOID_INIT_OPHDR_COND (VOID);
>BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID);
>  
>  
>EFI_VARSTORE_INFO   mCurrQestVarInfo;
>EFI_GUID*mOverrideClassGuid;
> @@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND (
>  mCIfrOpHdr[mCIfrOpHdrIndex]   = new CIfrOpHeader(OpHdr);
>  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo;
>}
>  }
>  
> +VOID
> +EfiVfrParser::_INIT_OPHDR_COND (
> +  VOID
> +  )
> +{
> +  mCIfrOpHdr[mCIfrOpHdrIndex]   = NULL;
> +  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;
> +}
> +
>  VOID
>  EfiVfrParser::_CLEAR_SAVED_OPHDR (
>VOID
>)
>  {
>if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {
>  delete mCIfrOpHdr[mCIfrOpHdrIndex];
> -mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
> +mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;
>}
> -  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;
>  }
>  
>  BOOLEAN
>  EfiVfrParser::_SET_SAVED_OPHDR_SCOPE (
>VOID
> -- 
> 2.14.3.windows.1
> 
> ___
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH] BaseTools: Remove dsc nested include checking.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
From: Lin, Derek (HPS UEFI Dev) 
Sent: Wednesday, May 9, 2018 3:39 PM
To: Lin, Derek (HPS UEFI Dev) 
Subject: [PATCH] BaseTools: Remove dsc nested include checking.

The dsc nested include checking make unexpected build error when building 
project A and switch to project B.
---
 BaseTools/Source/Python/Workspace/MetaFileParser.py | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 36843643ed..092253530f 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -2,7 +2,7 @@
 # This file is used to parse meta files  #  # Copyright (c) 2008 - 2018, Intel 
Corporation. All rights reserved. -# (C) Copyright 2015-2016 Hewlett 
Packard Enterprise Development LP
+# (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
 # 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 @@ 
-1551,10 +1551,21 @@ class DscParser(MetaFileParser):
 
 self.IncludedFiles.add (IncludedFile1)
 
+# todo: rework the nested include checking logic
+# Current nested include checking rely on dsc file order inside 
build.db.
+# It is not reliable and will lead to build fail in some case.
+#
+# When project A and B include a common dsc file C.
+# Build project A. It give dsc file A = ID 1 in build.db, and C ID 
= 2.
+# Build project B. It give dsc file B ID = 3, and C ID still = 2.
+# Then, we build project B fail, unless we clean build.db.
+# In oldder BaseTools, the project B ID will still be 1, 
+# that's why it work before.
+
 # Does not allow lower level included file to include upper level 
included file
-if Parser._From != Owner and int(Owner) > int (Parser._From):
-EdkLogger.error('parser', FILE_ALREADY_EXIST, 
File=self._FileWithError,
-Line=self._LineIndex + 1, ExtraData="{0} is already 
included at a higher level.".format(IncludedFile1))
+#if Parser._From != Owner and int(Owner) > int (Parser._From):
+#EdkLogger.error('parser', FILE_ALREADY_EXIST, 
File=self._FileWithError,
+#Line=self._LineIndex + 1, ExtraData="{0} is already 
included at a higher level.".format(IncludedFile1))
 
 
 # set the parser status with current status
--
2.15.1.windows.2

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


[edk2] [PATCH] BaseTools: Fix --hash Package and Module hash value.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
From: Lin, Derek (HPS UEFI Dev) 
Sent: Wednesday, May 9, 2018 3:39 PM
To: Lin, Derek (HPS UEFI Dev) 
Subject: [PATCH] BaseTools: Fix --hash Package and Module hash value.

The order of List enumeration is arbitrary.
Need to be sorted while calculating Package/Module hash, otherwise it generate 
different hash value even nothing changes.
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 54f6b1f173..90704dcae4 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2,6 +2,7 @@
 # Generate AutoGen.h, AutoGen.c and *.depex files  #  # Copyright (c) 2007 - 
2018, Intel Corporation. All rights reserved.
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 # 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 @@ 
-670,6 +671,9 @@ class WorkspaceAutoGen(AutoGen):
 return True
 
 def _GenPkgLevelHash(self, Pkg):
+if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]:
+return
+
 PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)
 CreateDirectory(PkgDir)
 HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash') @@ -681,17 
+685,16 @@ class WorkspaceAutoGen(AutoGen):
 m.update(Content)
 # Get include files hash value
 if Pkg.Includes:
-for inc in Pkg.Includes:
+for inc in sorted(Pkg.Includes, key=lambda x: str(x)):
 for Root, Dirs, Files in os.walk(str(inc)):
-for File in Files:
+for File in sorted(Files):
 File_Path = os.path.join(Root, File)
 f = open(File_Path, 'r')
 Content = f.read()
 f.close()
 m.update(Content)
 SaveFileOnChange(HashFile, m.hexdigest(), True)
-if Pkg.PackageName not in GlobalData.gPackageHash[Pkg.Arch]:
-GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()
+GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = 
+ m.hexdigest()
 
 def _GetMetaFiles(self, Target, Toolchain, Arch):
 AllWorkSpaceMetaFiles = set()
@@ -4432,13 +4435,13 @@ class ModuleAutoGen(AutoGen):
 m.update(GlobalData.gPlatformHash)
 # Add Package level hash
 if self.DependentPackageList:
-for Pkg in self.DependentPackageList:
+for Pkg in sorted(self.DependentPackageList, key=lambda x: 
x.PackageName):
 if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:
 
m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])
 
 # Add Library hash
 if self.LibraryAutoGenList:
-for Lib in self.LibraryAutoGenList:
+for Lib in sorted(self.LibraryAutoGenList, key=lambda x: x.Name):
 if Lib.Name not in GlobalData.gModuleHash[self.Arch]:
 Lib.GenModuleHash()
 m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])
@@ -4450,7 +4453,7 @@ class ModuleAutoGen(AutoGen):
 m.update(Content)
 # Add Module's source files
 if self.SourceFileList:
-for File in self.SourceFileList:
+for File in sorted(self.SourceFileList, key=lambda x: str(x)):
 f = open(str(File), 'r')
 Content = f.read()
 f.close()
--
2.15.1.windows.2

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


[edk2] [PATCH] BaseTools: Fix python error with --genfds-multi-thread.

2018-05-09 Thread Lin, Derek (HPS UEFI Dev)
From: Lin, Derek (HPS UEFI Dev) 
Sent: Wednesday, May 9, 2018 3:39 PM
To: Lin, Derek (HPS UEFI Dev) 
Subject: [PATCH] BaseTools: Fix python error with --genfds-multi-thread.

When self.Alignment is None, it ran into python error since there is no strip() 
in None.
---
 BaseTools/Source/Python/GenFds/GuidSection.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py 
b/BaseTools/Source/Python/GenFds/GuidSection.py
index 1105689e0d..6cadff0bd2 100644
--- a/BaseTools/Source/Python/GenFds/GuidSection.py
+++ b/BaseTools/Source/Python/GenFds/GuidSection.py
@@ -2,7 +2,7 @@
 # process GUIDed section generation
 #
 #  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. -#
+#  Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.
 #  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 @@ 
-273,7 +273,7 @@ class GuidSection(GuidSectionClassObject) :
 self.Alignment = None
 self.IncludeFvSection = False
 self.ProcessRequired = "TRUE"
-if IsMakefile and self.Alignment.strip() == '0':
+if IsMakefile and self.Alignment is not None and 
self.Alignment.strip() == '0':
 self.Alignment = '1'
 return OutputFileList, self.Alignment
 
--
2.15.1.windows.2

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


[edk2] [Patch] BaseTools: Fix generating array's size is incorrect in AutoGen.c

2018-05-09 Thread Yonghong Zhu
From: Yunhua Feng 

case example:
DSC:
 [PcdsFixedAtBuild]
  PcdToken.PcdName | "A"
 [Components]
 TestPkg/TestDriver.inf {
  PcdToken.PcdName | {0x41,0x42,0x43,0x44}
 }

Generating the size of array is incorrect in AutoGen.c
 GLOBAL_REMOVE_IF_UNREFERENCED const UINT8
 _gPcd_FixedAtBuild_PcdName[2] = {0x41,0x42,0x43,0x44};

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=950
Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
---
 BaseTools/Source/Python/AutoGen/GenC.py | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index d062588..35ebd60 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1055,42 +1055,43 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
 "Too large PCD value for datum type [%s] 
of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName),
 ExtraData="[%s]" % str(Info))
 if not Value.endswith('U'):
 Value += 'U'
 if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES:
-if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':
+if not Pcd.MaxDatumSize:
 EdkLogger.error("build", AUTOGEN_ERROR,
 "Unknown [MaxDatumSize] of PCD [%s.%s]" % 
(Pcd.TokenSpaceGuidCName, TokenCName),
 ExtraData="[%s]" % str(Info))
 
 ArraySize = int(Pcd.MaxDatumSize, 0)
 if Value[0] == '{':
 Type = '(VOID *)'
+ValueSize = len(Value.split(','))
 else:
 if Value[0] == 'L':
 Unicode = True
 Value = Value.lstrip('L')   #.strip('"')
 Value = eval(Value) # translate escape character
+ValueSize = len(Value) + 1
 NewValue = '{'
 for Index in range(0,len(Value)):
 if Unicode:
 NewValue = NewValue + str(ord(Value[Index]) % 0x1) 
+ ', '
 else:
 NewValue = NewValue + str(ord(Value[Index]) % 0x100) + 
', '
 if Unicode:
-ArraySize = ArraySize / 2;
-
-if ArraySize < (len(Value) + 1):
-if Pcd.MaxSizeUserSet:
-EdkLogger.error("build", AUTOGEN_ERROR,
-"The maximum size of VOID* type PCD 
'%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, 
TokenCName),
-ExtraData="[%s]" % str(Info))
-else:
-ArraySize = Pcd.GetPcdSize()
-if Unicode:
-ArraySize = ArraySize / 2
+ArraySize = ArraySize / 2
 Value = NewValue + '0 }'
+if ArraySize < ValueSize:
+if Pcd.MaxSizeUserSet:
+EdkLogger.error("build", AUTOGEN_ERROR,
+"The maximum size of VOID* type PCD '%s.%s' is 
less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName),
+ExtraData="[%s]" % str(Info))
+else:
+ArraySize = Pcd.GetPcdSize()
+if Unicode:
+ArraySize = ArraySize / 2
 Array = '[%d]' % ArraySize
 #
 # skip casting for fixed at build since it breaks ARM assembly.
 # Long term we need PCD macros that work in assembly
 #
-- 
2.6.1.windows.1

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