Re: [edk2] [edk2-announce] Community Meeting Minutes

2019-02-19 Thread Rebecca Cran via edk2-devel
On Tuesday, 19 February 2019 23:23:59 MST stephano wrote:

> Github Pull Requests
> -
> We are still considering Github as a possible platform for patch review.

One thing I've not seen mentioned here is that there's an official command line 
tool for GitHub, named 'hub': https://hub.github.com/

>From the output of 'hub --help':

These GitHub commands are provided by hub:

   browse Open a GitHub page in the default browser
   ci-status  Show the status of GitHub checks for a commit
   compareOpen a compare page on GitHub
   create Create this repository on GitHub and add GitHub as origin
   delete Delete a repository on GitHub
   fork   Make a fork of a remote repository on GitHub and add as 
remote
   issue  List or create GitHub issues
   pr List or checkout GitHub pull requests
   pull-request   Open a pull request on GitHub
   releaseList or create GitHub releases
   sync   Fetch git objects from upstream and update branches


-- 
Rebecca Cran


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


Re: [edk2] Issues with EDK-II-Debugging wiki page, and how to submit a pull request for wiki pages

2019-02-19 Thread Rebecca Cran via edk2-devel
On Thursday, 14 February 2019 12:23:05 MST Laszlo Ersek wrote:

> The wikis on github are non-intuitive, if you intend to edit them in a
> normal text editor, locally. I struggled a lot until I came up with the
> list on top. (It's possible I relied on others' advice in that; I no
> longer remember.) I hope it helps.

Yeah, thanks but no thanks. I'm not _that_ keen on making my changes if it's 
going to involve all that work!

-- 
Rebecca Cran


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


Re: [edk2] [PATCH 1/1] EmbeddedPkg/Library: Add VirtualRealTimeClockLib

2019-02-19 Thread Ard Biesheuvel
On Fri, 15 Feb 2019 at 15:57, Pete Batard  wrote:
>
> On 2019-02-15 14:39, Ard Biesheuvel wrote:
> > On Fri, 15 Feb 2019 at 11:07, Ard Biesheuvel  
> > wrote:
> >>
> >> On Tue, 12 Feb 2019 at 19:14, Leif Lindholm  
> >> wrote:
> >>>
> >>> On Mon, Feb 04, 2019 at 12:47:36PM +, Pete Batard wrote:
>  This is designed to be used on platforms where a a real RTC is not
>  available and relies on an RtcEpochSeconds variable having been set or,
>  if that is not the case, falls back to using the epoch embedded at
>  compilation time.
> 
>  Note that, in order to keep things simple for the setting of the
>  compilation time variable, only GCC environments with UNIX-like shells
>  and where a 'date' command is available are meant to be supported for
>  now.
> 
>  Contributed-under: TianoCore Contribution Agreement 1.1
>  Signed-off-by: Pete Batard 
> >>>
> >>> On the whole, this looks good to me.
> >>> One addition we'll need, so that we can build this library standalone
> >>> is an entry in EmbeddedPkg.dsc:
> >>>
> >>> diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
> >>> index 4d9e6399d5..dc5040e611 100644
> >>> --- a/EmbeddedPkg/EmbeddedPkg.dsc
> >>> +++ b/EmbeddedPkg/EmbeddedPkg.dsc
> >>> @@ -218,6 +218,7 @@ [Components.common]
> >>> EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf
> >>> EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
> >>> 
> >>> EmbeddedPkg/Library/DxeDtPlatformDtbLoaderLibDefault/DxeDtPlatformDtbLoaderLibDefault.inf
> >>> +  EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
> >>> EmbeddedPkg/EmbeddedMonotonicCounter/EmbeddedMonotonicCounter.inf
> >>> EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
> >>>
> >>> I don't have any strong opinions on either of Phil's suggestions, but
> >>> if you could give some feedback on those and fold the above in, this
> >>> could go in.
> >>>
> >>
> >> WIth this addition
> >>
> >> Reviewed-by: Ard Biesheuvel 
> >>
> >> Pushed as 1b261a705f94..64a17fadcb79
> >
> > OK, there is a problem with this code:
> >
> > +EFI_STATUS
> > +EFIAPI
> > +LibGetTime (
> > +  OUT EFI_TIME   *Time,
> > +  OUT EFI_TIME_CAPABILITIES  *Capabilities
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  UINT32  EpochSeconds;
> >
> > EpochSeconds is declared here, and updated depending on time zone and
> > DST settings. However, the resulting value is never used anywhere.
>
> You're right.
>
> Looks like I forgot to merge all the use of EpochSeconds into
> ElapsedSeconds, from the code I copy/pasted.
>
> I'm very sorry about this, as it's something I should have picked up
> before sending this patch for review.
> > It is not clear to me what the correct fix is, so Pete, could you
> > please look into this?
>
> I'll send a fix for this as soon as I have a chance. Thanks for pointing
> the mistake.
>

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


[edk2] [PATCH edk2-platforms v2 16/18] Hisilicon/D0x: Remove and tidy some codes about SerdesLib

2019-02-19 Thread Ming Huang
As some definitions are about OemMiscLib, so move them from
SerdesLib.h to OemMiscLib.h and drop some useless function
definitions. After doing this, some unnecessary references
can be removed for D03/D05.

SerdesLib is useless for SmbiosMiscDxe and D06, so remove it and
delete SerdesLib.h for D06.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/D06.dsc 
   |   2 -
 Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf   
   |   2 +-
 Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h   
   | 109 
 Silicon/Hisilicon/Hi1616/Include/Library/SerdesLib.h   
   |  64 
 Silicon/Hisilicon/Hi1620/Include/Library/SerdesLib.h   
   |  85 ---
 Silicon/Hisilicon/Include/Library/OemMiscLib.h 
   |  63 +++
 Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c 
   |   1 -
 Platform/Hisilicon/D05/Library/OemMiscLibD05/BoardFeatureD05.c 
   |   1 -
 Platform/Hisilicon/D06/Library/OemMiscLibD06/BoardFeatureD06.c 
   |   1 -
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c   
   |   1 -
 
Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/Type09/MiscSystemSlotDesignationFunction.c
 |   2 +-
 11 files changed, 65 insertions(+), 266 deletions(-)

diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc
index d762230768e9..a3a01bfb1e23 100644
--- a/Platform/Hisilicon/D06/D06.dsc
+++ b/Platform/Hisilicon/D06/D06.dsc
@@ -63,8 +63,6 @@ [LibraryClasses.common]
 
   CpldIoLib|Silicon/Hisilicon/Library/CpldIoLib/CpldIoLib.inf
 
-  SerdesLib|Silicon/Hisilicon/Hi1620/Library/Hi1620Serdes/Hi1620SerdesLib.inf
-
   TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
   
RealTimeClockLib|Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf
   OemMiscLib|Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf
diff --git a/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf 
b/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
index 61cead7779b9..669e6a2d52cc 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
+++ b/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
@@ -69,6 +69,7 @@ [LibraryClasses]
   BaseMemoryLib
   BaseLib
   DebugLib
+  OemMiscLib
   UefiBootServicesTableLib
   UefiRuntimeServicesTableLib
   UefiDriverEntryPoint
@@ -77,7 +78,6 @@ [LibraryClasses]
 
   IpmiCmdLib
 
-  SerdesLib
 
 [Protocols]
   gEfiSmbiosProtocolGuid   # PROTOCOL ALWAYS_CONSUMED
diff --git a/Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h 
b/Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h
index 077dd5edc847..b493dd9ac090 100755
--- a/Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h
+++ b/Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h
@@ -16,116 +16,7 @@
 #ifndef _SERDES_LIB_H_
 #define _SERDES_LIB_H_
 
-typedef enum {
-  EmHilink0Hccs1X8 = 0,
-  EmHilink0Pcie1X8 = 2,
-  EmHilink0Pcie1X4Pcie2X4 = 3,
-  EmHilink0Sas2X8 = 4,
-  EmHilink0Hccs1X8Width16,
-  EmHilink0Hccs1X8Width32,
-} HILINK0_MODE_TYPE;
-
-typedef enum {
-  EmHilink1Sas2X1 = 0,
-  EmHilink1Hccs0X8 = 1,
-  EmHilink1Pcie0X8 = 2,
-  EmHilink1Hccs0X8Width16,
-  EmHilink1Hccs0X8Width32,
-} HILINK1_MODE_TYPE;
-
-typedef enum {
-  EmHilink2Pcie2X8 = 0,
-  EmHilink2Sas0X8 = 2,
-} HILINK2_MODE_TYPE;
-
-typedef enum {
-  EmHilink5Pcie3X4 = 0,
-  EmHilink5Pcie2X2Pcie3X2 = 1,
-  EmHilink5Sas1X4 = 2,
-} HILINK5_MODE_TYPE;
-
-typedef enum {
-  Em32coreEvbBoard = 0,
-  Em16coreEvbBoard = 1,
-  EmV2R1CO5Borad = 2,
-  EmOtherBorad
-} BOARD_TYPE;
-
-
-typedef struct {
-  HILINK0_MODE_TYPE Hilink0Mode;
-  HILINK1_MODE_TYPE Hilink1Mode;
-  HILINK2_MODE_TYPE Hilink2Mode;
-  UINT32 Hilink3Mode;
-  UINT32 Hilink4Mode;
-  HILINK5_MODE_TYPE Hilink5Mode;
-  UINT32 Hilink6Mode;
-  UINT32 UseSsc;
-} SERDES_PARAM;
-
-
-#define SERDES_INVALID_MACRO_ID  0x
-#define SERDES_INVALID_LANE_NUM  0x
-#define SERDES_INVALID_RATE_MODE  0x
-
-typedef struct {
-  UINT32 MacroId;
-  UINT32 DsNum;
-  UINT32 DsCfg;
-} SERDES_POLARITY_INVERT;
-
-EFI_STATUS OemGetSerdesParam (SERDES_PARAM *ParamA, SERDES_PARAM *ParamB, 
UINT32 SocketId);
-extern SERDES_POLARITY_INVERT gSerdesPolarityTxDesc[];
-extern SERDES_POLARITY_INVERT gSerdesPolarityRxDesc[];
-UINT32 GetEthType(UINT8 EthChannel);
-
 EFI_STATUS
 EfiSerdesInitWrap (VOID);
 
-void SRE_SerdesEnableCTLEDFE(UINT32 macro, UINT32 lane, UINT32 ulDsCfg);
-
-//EYE test
-UINT32 serdes_eye_test(UINT32 uwMacroId, UINT32 uwDsNum, UINT32 eyemode, 
UINT32 scanwindowvalue, UINT32 uwRateData);
-
-UINT32 Serdes_ReadBert(UINT32   ulMacroId , UINT32   ulDsNum);
-

[edk2] [PATCH edk2-platforms v2 10/18] Hisilicon/D06: Modify for IMP self-Adapte support

2019-02-19 Thread Ming Huang
As new IMP(Cortex-M7) firmware support self-adapte, so do not
need BIOS to implement some function, remove useless funtions
and report CPU0/CPU1 Nic NCL offset to IMP.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/Library/OemNicLib/OemNicLib.c | 281 
 1 file changed, 54 insertions(+), 227 deletions(-)

diff --git a/Platform/Hisilicon/D06/Library/OemNicLib/OemNicLib.c 
b/Platform/Hisilicon/D06/Library/OemNicLib/OemNicLib.c
index aaf990216982..678c2107bdd3 100644
--- a/Platform/Hisilicon/D06/Library/OemNicLib/OemNicLib.c
+++ b/Platform/Hisilicon/D06/Library/OemNicLib/OemNicLib.c
@@ -21,44 +21,21 @@
 #include 
 
 #define CPU2_SFP2_100G_CARD_OFFSET   0x25
-#define CPU1_SFP1_LOCATE_OFFSET  0x16
-#define CPU1_SFP0_LOCATE_OFFSET  0x12
-#define CPU2_SFP1_LOCATE_OFFSET  0x21
-#define CPU2_SFP0_LOCATE_OFFSET  0x19
-#define CPU2_SFP2_10G_GE_CARD_OFFSET 0x25
 
-#define SFP_10G_SPEED   10
-#define SFP_25G_SPEED   25
-#define SFP_100G_SPEED  100
-#define SFP_GE_SPEED1
-
-#define SFP_GE_SPEED_VAL_VENDOR_FINISAR 0x0C
-#define SFP_GE_SPEED_VAL0x0D
-#define SFP_10G_SPEED_VAL   0x67
-#define SFP_25G_SPEED_VAL   0xFF
+#define SOCKET1_NET_PORT_100G 1
+#define SOCKET0_NET_PORT_NUM  4
+#define SOCKET1_NET_PORT_NUM  2
 
 #define CARD_PRESENT_100G   (BIT7)
-#define CARD_PRESENT_10G(BIT0)
-#define SELECT_SFP_BY_INDEX(index)  (1 << (index - 1))
-#define SPF_SPEED_OFFSET12
-
-#define SFP_DEVICE_ADDRESS 0x50
-#define CPU1_9545_I2C_ADDR 0x70
-#define CPU2_9545_I2C_ADDR 0x71
-
-#define FIBER_PRESENT 0
-#define CARD_PRESENT  1
-#define I2C_PORT_SFP  4
-#define CPU2_I2C_PORT_SFP 5
-
-#define SOCKET_0 0
-#define SOCKET_1 1
 #define EEPROM_I2C_PORT  4
 #define EEPROM_PAGE_SIZE 0x40
 #define MAC_ADDR_LEN 6
 #define I2C_OFFSET_EEPROM_ETH0   (0xc00)
 #define I2C_SLAVEADDR_EEPROM (0x52)
 
+#define SRAM_NIC_NCL1_OFFSET_ADDRESS   0xA0E87FE0
+#define SRAM_NIC_NCL2_OFFSET_ADDRESS   0xA0E87FE4
+
 #pragma pack(1)
 typedef struct {
   UINT16 Crc16;
@@ -114,204 +91,6 @@ UINT16 CrcTable16[256] = {
   0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0,
 };
 
-EFI_STATUS
-GetSfpSpeed (
-  UINT16 Socket,
-  UINT16 SfpNum,
-  UINT8* FiberSpeed
-  )
-{
-  EFI_STATUS  Status;
-  I2C_DEVICE  SpdDev;
-  UINT8   SfpSelect;
-  UINT8   SfpSpeed;
-  UINT32  RegAddr;
-  UINT16  I2cAddr;
-  UINT32  SfpPort;
-
-  SfpSpeed = 0x0;
-  if (Socket == SOCKET_1) {
-I2cAddr = CPU2_9545_I2C_ADDR;
-SfpPort = CPU2_I2C_PORT_SFP;
-  } else {
-I2cAddr = CPU1_9545_I2C_ADDR;
-SfpPort = I2C_PORT_SFP;
-  }
-
-  Status = I2CInit (Socket, SfpPort, Normal);
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Socket%d Call I2CInit failed! p1=0x%x.\n",
-__FUNCTION__, __LINE__, Socket, Status));
-return Status;
-  }
-
-  SpdDev.Socket = Socket;
-  SpdDev.DeviceType = DEVICE_TYPE_SPD;
-  SpdDev.Port = SfpPort;
-  SpdDev.SlaveDeviceAddress = I2cAddr;
-  RegAddr = 0x0;
-  SfpSelect = SELECT_SFP_BY_INDEX (SfpNum);
-
-  Status = I2CWrite (, RegAddr, 1, );
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "I2CWrite Error =%r.\n", Status));
-return Status;
-  }
-
-  SpdDev.Socket = Socket;
-  SpdDev.DeviceType = DEVICE_TYPE_SPD;
-  SpdDev.Port = SfpPort;
-  SpdDev.SlaveDeviceAddress = SFP_DEVICE_ADDRESS;
-
-  RegAddr = SPF_SPEED_OFFSET;
-  Status = I2CRead (, RegAddr, 1, );
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "I2CRead Error =%r.\n", Status));
-return Status;
-  }
-
-  DEBUG ((DEBUG_INFO, "BR, Nominal, Nominal signalling rate, SfpSpeed:
0x%x\n",
- SfpSpeed));
-
-  if (SfpSpeed == SFP_10G_SPEED_VAL) {
-*FiberSpeed = SFP_10G_SPEED;
-  } else if (SfpSpeed == SFP_25G_SPEED_VAL) {
-*FiberSpeed = SFP_25G_SPEED;
-  } else if ((SfpSpeed == SFP_GE_SPEED_VAL) ||
- (SfpSpeed == SFP_GE_SPEED_VAL_VENDOR_FINISAR)) {
-*FiberSpeed = SFP_GE_SPEED;
-  }
-
-  return EFI_SUCCESS;
-}
-
-//Fiber1Type/Fiber2Type/Fiber3Type return: SFP_10G_SPEED, SFP_100G_SPEED, 
SFP_GE_SPEED
-UINT32
-GetCpu2FiberType (
-  UINT8* Fiber1Type,
-  UINT8* Fiber2Type,
-  UINT8* Fiber100Ge
-  )
-{
-  EFI_STATUS  Status;
-  UINT16  SfpNum1;
-  UINT8   SfpSpeed1;
-  UINT16  SfpNum2;
-  UINT8   SfpSpeed2;
-
-  SfpNum1 = 0x1;
-  SfpSpeed1 = SFP_10G_SPEED;
-  SfpNum2 = 0x2;
-  SfpSpeed2 = SFP_10G_SPEED;
-  *Fiber100Ge = 0x0;
-  *Fiber1Type = SFP_10G_SPEED;
-  *Fiber2Type = SFP_10G_SPEED;
-
-  if ((ReadCpldReg (CPU2_SFP2_100G_CARD_OFFSET) & CARD_PRESENT_100G) != 0) {
-// 100 Ge card
-*Fiber1Type = SFP_10G_SPEED;
-*Fiber2Type = SFP_10G_SPEED;
-*Fiber100Ge = SFP_100G_SPEED;
-DEBUG ((DEBUG_ERROR,"Detect Fiber SFP_100G is Present, Set 100Ge\n"));
-  } else if ((ReadCpldReg 

[edk2] [PATCH edk2-platforms v2 12/18] Hisilicon/D06: Use new flash layout

2019-02-19 Thread Ming Huang
In new flash layout, BIOS fd change from offset 1M to 8M in 16M
spi flash.

Use the new CustomData.Fv which indicate the offset of fd and
which flash area can be updated for BMC.

This patch is relative with patch "Use new flash layout" in
edk2-non-osi.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/D06.fdf | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D06/D06.fdf b/Platform/Hisilicon/D06/D06.fdf
index d495ad7f264c..f72b513352fb 100644
--- a/Platform/Hisilicon/D06/D06.fdf
+++ b/Platform/Hisilicon/D06/D06.fdf
@@ -29,7 +29,7 @@ [DEFINES]
 

 [FD.D06]
 
-BaseAddress   = 0x20410|gArmTokenSpaceGuid.PcdFdBaseAddress  # The base 
address of the Firmware in NOR Flash.
+BaseAddress   = 0x20480|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
@@ -124,7 +124,7 @@ [FD.D06]
 0x003E|0x0001
 
 0x003F|0x0001
-FILE = Platform/Hisilicon/D0x-CustomData.Fv
+FILE = Platform/Hisilicon/D06/CustomData.Fv
 
 

 #
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 17/18] Hisilicon/D0x: Delete some header files

2019-02-19 Thread Ming Huang
As some interfaces exposed only by implementations in edk2-non-osi,
so delete corresponding header files and modify code to make build.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf  
|   1 +
 Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf 
|   2 +-
 Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf  
|   1 +
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf 
|   1 +
 Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf  
|   1 +
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf 
|   1 +
 Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClassDxe.inf   
|   1 +
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf 
|   1 +
 Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf   
|   2 +-
 Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.inf
|   1 +
 Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.inf   
|   1 +
 Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.inf
|   1 +
 Silicon/Hisilicon/Library/I2CLib/I2CLib.inf
|   1 +
 Silicon/Hisilicon/Library/I2CLib/I2CLibRuntime.inf 
|   1 +
 Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h   
|  22 
 Silicon/Hisilicon/Hi1616/Include/Library/SerdesLib.h   
|  22 
 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h 
| 110 ---
 Silicon/Hisilicon/Include/Library/LpcLib.h 
| 113 
 Silicon/Hisilicon/Include/Library/OemAddressMapLib.h   
|  45 
 Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h 
| 112 ---
 20 files changed, 14 insertions(+), 426 deletions(-)

diff --git a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf 
b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf
index c65cf7b6dd9f..90e40ae2b393 100644
--- a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf
+++ b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf
@@ -30,6 +30,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
 
   ArmPkg/ArmPkg.dec
+  Silicon/Hisilicon/HisiliconNonOsi.dec
   Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
diff --git a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf 
b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf
index 0fa7fdf80fa8..c0195b2fa9cf 100644
--- a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf
+++ b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf
@@ -30,7 +30,7 @@ [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   ArmPkg/ArmPkg.dec
-
+  Silicon/Hisilicon/HisiliconNonOsi.dec
   Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
diff --git a/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf 
b/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf
index 0f6b68d4c88d..e82c9204d5d6 100644
--- a/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf
+++ b/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf
@@ -29,6 +29,7 @@ [Packages]
   ArmPkg/ArmPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
+  Silicon/Hisilicon/HisiliconNonOsi.dec
   Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
diff --git a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf 
b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf
index 022c3e940a31..7ec577530610 100644
--- a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf
+++ b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf
@@ -30,6 +30,7 @@ [Packages]
   ArmPkg/ArmPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
+  Silicon/Hisilicon/HisiliconNonOsi.dec
   Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
diff --git a/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf 
b/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf
index 8296ee02de4e..715a4efadde8 100644
--- a/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf
+++ b/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf
@@ -29,6 +29,7 @@ [Packages]
   ArmPkg/ArmPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
+  Silicon/Hisilicon/HisiliconNonOsi.dec
   Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf 
b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf
index 75c5054bbfd1..9bc6eb549c41 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf
+++ 

[edk2] [PATCH edk2-platforms v2 18/18] Hisilicon/D0x: Modify version to 19.02

2019-02-19 Thread Ming Huang
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D03/D03.dsc | 4 ++--
 Platform/Hisilicon/D05/D05.dsc | 4 ++--
 Platform/Hisilicon/D06/D06.dsc | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 35b54f8c83be..07ff461277df 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -171,12 +171,12 @@ [PcdsFixedAtBuild.common]
   !ifdef $(FIRMWARE_VER)
 gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
   !else
-gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 18.08 for Hisilicon D03"
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 19.02 for Hisilicon D03"
   !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
 
-  gHisiTokenSpaceGuid.PcdBiosVersionForBmc|L"1.12"
+  gHisiTokenSpaceGuid.PcdBiosVersionForBmc|L"19.02"
 
   gHisiTokenSpaceGuid.PcdSystemProductName|L"D03"
   gHisiTokenSpaceGuid.PcdSystemVersion|L"Estuary"
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 49bd5b37ea34..70b044c7e33a 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -187,12 +187,12 @@ [PcdsFixedAtBuild.common]
   !ifdef $(FIRMWARE_VER)
 gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
   !else
-gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 18.08 for Hisilicon D05"
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 19.02 for Hisilicon D05"
   !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
 
-  gHisiTokenSpaceGuid.PcdBiosVersionForBmc|L"1.12"
+  gHisiTokenSpaceGuid.PcdBiosVersionForBmc|L"19.02"
 
   gHisiTokenSpaceGuid.PcdSystemProductName|L"D05"
   gHisiTokenSpaceGuid.PcdSystemVersion|L"Estuary"
diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc
index a3a01bfb1e23..73bea728b0f6 100644
--- a/Platform/Hisilicon/D06/D06.dsc
+++ b/Platform/Hisilicon/D06/D06.dsc
@@ -156,12 +156,12 @@ [PcdsFixedAtBuild.common]
   !ifdef $(FIRMWARE_VER)
 gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
   !else
-gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 18.08 for Hisilicon D06"
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 19.02 for Hisilicon D06"
   !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
 
-  gHisiTokenSpaceGuid.PcdBiosVersionForBmc|L"0.42"
+  gHisiTokenSpaceGuid.PcdBiosVersionForBmc|L"19.02"
 
   gHisiTokenSpaceGuid.PcdSystemProductName|L"D06"
   gHisiTokenSpaceGuid.PcdSystemVersion|L"VER.A"
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 13/18] Hisilicon/D06: Remove SECURE_BOOT_ENABLE definition

2019-02-19 Thread Ming Huang
As secure boot is not ready, remove SECURE_BOOT_ENABLE and
relative code.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D06/D06.dsc | 12 
 Platform/Hisilicon/D06/D06.fdf | 11 ---
 2 files changed, 23 deletions(-)

diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc
index 3856578e74be..d762230768e9 100644
--- a/Platform/Hisilicon/D06/D06.dsc
+++ b/Platform/Hisilicon/D06/D06.dsc
@@ -30,7 +30,6 @@ [Defines]
   FLASH_DEFINITION   = 
Platform/Hisilicon/$(PLATFORM_NAME)/$(PLATFORM_NAME).fdf
   DEFINE NETWORK_IP6_ENABLE  = FALSE
   DEFINE HTTP_BOOT_ENABLE= FALSE
-  DEFINE SECURE_BOOT_ENABLE  = FALSE
 
 !include Silicon/Hisilicon/Hisilicon.dsc.inc
 
@@ -89,9 +88,6 @@ [LibraryClasses.common]
   LpcLib|Silicon/Hisilicon/Hi1620/Library/LpcLibHi1620/LpcLib.inf
   
SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortLib.inf
   OemNicLib|Platform/Hisilicon/D06/Library/OemNicLib/OemNicLib.inf
-!if $(SECURE_BOOT_ENABLE) == TRUE
-  FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
-!endif
   PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
   
PciPlatformLib|Silicon/Hisilicon/Hi1620/Library/Hi1620PciPlatformLib/Hi1620PciPlatformLib.inf
 
@@ -292,15 +288,7 @@ [Components.common]
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   Platform/Hisilicon/D06/Drivers/OemNicConfig2PHi1620/OemNicConfig2P.inf
 
-!if $(SECURE_BOOT_ENABLE) == TRUE
-  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
-
-  
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
-  }
-  SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
-!else
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
-!endif
   Silicon/Hisilicon/Drivers/FlashFvbDxe/FlashFvbDxe.inf
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
 
diff --git a/Platform/Hisilicon/D06/D06.fdf b/Platform/Hisilicon/D06/D06.fdf
index f72b513352fb..e402628a1b35 100644
--- a/Platform/Hisilicon/D06/D06.fdf
+++ b/Platform/Hisilicon/D06/D06.fdf
@@ -88,17 +88,10 @@ [FD.D06]
   #Blockmap[1]: End
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   ## This is the VARIABLE_STORE_HEADER
-!if $(SECURE_BOOT_ENABLE) == TRUE
-  #Signature: gEfiAuthenticatedVariableGuid =
-  #  { 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 
0x92 }}
-  0x78, 0x2c, 0xf3, 0xaa, 0x7b, 0x94, 0x9a, 0x43,
-  0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92,
-!else
   #Signature: gEfiVariableGuid =
   #  { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 
0x7d }}
   0x16, 0x36, 0xcf, 0xdd, 0x75, 0x32, 0x64, 0x41,
   0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d,
-!endif
   #Size: 0xe000 (gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize) 
- 0x48 (size of EFI_FIRMWARE_VOLUME_HEADER) = 0xdFB8
   0xB8, 0xdF, 0x00, 0x00,
   #FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32
@@ -183,10 +176,6 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
   INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
 
-!if $(SECURE_BOOT_ENABLE) == TRUE
-  INF 
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
-!endif
-
   INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
   INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
   INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 15/18] Hisilicon/D06: Fix USB crash issue(4079)

2019-02-19 Thread Ming Huang
Last patch "Modify IORT" change revision id of node type 2 to 1,
and 4.19 later kernel will judge the revision id to get root pci
bridge DMA informations from IORT. As Hi1620 USB 2.0 don't support
64 bit DMA, but the DMA attribute get from IORT node type 2 is 64
bit. So add _DMA method in USB pci bridge 3 and pci bridge 8 to
fix usb crash when usb device is present issue.

https://bugs.linaro.org/show_bug.cgi?id=4079

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl | 46 

 1 file changed, 46 insertions(+)

diff --git a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl 
b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
index 6dc380f27fa2..c1083dc16a2a 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
+++ b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
@@ -375,6 +375,29 @@ Device (PCI2)
 
   PCI_OSC_SUPPORT ()
 
+  Method(_DMA, 0, Serialized)
+  {
+Return (ResourceTemplate()
+{
+  QWORDMemory(
+  ResourceConsumer,
+  PosDecode,  // _DEC
+  MinFixed,   // _MIF
+  MaxFixed,   // _MAF
+  Prefetchable,   // _MEM
+  ReadWrite,  // _RW
+  0,  // _GRA
+  0x, // _MIN
+  0x, // _MAX
+  0x,// _TRA
+  0x1, // _LEN
+  ,
+  ,
+  ,
+  )
+})
+  }
+
   Method (_STA, 0x0, NotSerialized)
   {
 Return (0xf)
@@ -1077,6 +1100,29 @@ Device (PCI8)
 Return (0xf)
   }
 
+  Method(_DMA, 0, Serialized)
+  {
+Return (ResourceTemplate()
+{
+  QWORDMemory(
+  ResourceConsumer,
+  PosDecode,  // _DEC
+  MinFixed,   // _MIF
+  MaxFixed,   // _MAF
+  Prefetchable,   // _MEM
+  ReadWrite,  // _RW
+  0,  // _GRA
+  0x, // _MIN
+  0x, // _MAX
+  0x,// _TRA
+  0x1, // _LEN
+  ,
+  ,
+  ,
+  )
+})
+  }
+
   Method (_PXM, 0, NotSerialized)
   {
 Return(0x02)
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 14/18] Hisilicon/D0x: Remove SP805 watchdog pcd

2019-02-19 Thread Ming Huang
SP805 watchdog is no used for D0x, so remove it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D03/D03.dsc   | 3 ---
 Platform/Hisilicon/D05/D05.dsc   | 3 ---
 Silicon/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf | 1 -
 3 files changed, 7 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index fe443dd929ad..35b54f8c83be 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -149,9 +149,6 @@ [PcdsFixedAtBuild.common]
 
   gHisiTokenSpaceGuid.PcdPcieRootBridgeMask|0x7 # 
bit0:HB0RB0,bit1:HB0RB1,bit2:HB0RB2,bit3:HB0RB3,bit4:HB1RB0,bit5:HB1RB1,bit6:HB1RB2,bit7:HB1RB3
 
-  ## SP805 Watchdog - Motherboard Watchdog
-  gArmPlatformTokenSpaceGuid.PcdSP805WatchdogBase|0x601e
-
   ## Serial Terminal
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x2F8
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 0c4f21fbe056..49bd5b37ea34 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -163,9 +163,6 @@ [PcdsFixedAtBuild.common]
   gHisiTokenSpaceGuid.PcdPcieRootBridgeMask2P|0x34F4 # 
bit0:HB0RB0,bit1:HB0RB1,bit2:HB0RB2,bit3:HB0RB3,bit4:HB0RB4,bit5:HB0RB5,bit6:HB0RB6,bit7:HB0RB7
 # 
bit8:HB1RB0,bit9:HB1RB1,bit10:HB1RB2,bit11:HB1RB3,bit12:HB1RB4,bit13:HB1RB5,bit14:HB1RB6,bit14:HB1RB15
 
-  ## SP805 Watchdog - Motherboard Watchdog
-  gArmPlatformTokenSpaceGuid.PcdSP805WatchdogBase|0x601e
-
   ## Serial Terminal
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x602B
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
diff --git 
a/Silicon/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf 
b/Silicon/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
index 3563df6e10d1..4ce5f5fea1f3 100644
--- a/Silicon/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
+++ b/Silicon/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf
@@ -61,5 +61,4 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
   gHisiTokenSpaceGuid.PcdSysControlBaseAddress
   gHisiTokenSpaceGuid.PcdPeriSubctrlAddress
-  gArmPlatformTokenSpaceGuid.PcdSP805WatchdogBase
 
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 06/18] Hisilicon/D06: Add OemGetCpuFreq to encapsulate difference

2019-02-19 Thread Ming Huang
From: xingjiang tang 

Implementation OemGetCpuFreq() to get cpu frequency from cpld to
encapsulate project difference, for some projects don't support
get cpu frequency by this way.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/Include/Library/CpldD06.h |  4 
 Silicon/Hisilicon/Include/Library/OemMiscLib.h   |  2 ++
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c | 16 

 3 files changed, 22 insertions(+)

diff --git a/Platform/Hisilicon/D06/Include/Library/CpldD06.h 
b/Platform/Hisilicon/D06/Include/Library/CpldD06.h
index ec9b49f4e70d..8eb333de529c 100644
--- a/Platform/Hisilicon/D06/Include/Library/CpldD06.h
+++ b/Platform/Hisilicon/D06/Include/Library/CpldD06.h
@@ -36,4 +36,8 @@
 #define CPLD_X8_X8_X8_BOARD_ID0x92
 #define CPLD_X16_X8_BOARD_ID  0x93
 
+#define CPLD_CLOCK_FLAG  0xFD
+#define CPLD_BOM_VER_FLAG0x0B
+#define CPLD_BOARD_REVISION_4TH   0x4
+
 #endif /* __CPLDD06_H__ */
diff --git a/Silicon/Hisilicon/Include/Library/OemMiscLib.h 
b/Silicon/Hisilicon/Include/Library/OemMiscLib.h
index 86ea6a1b3deb..dfac87d635d9 100644
--- a/Silicon/Hisilicon/Include/Library/OemMiscLib.h
+++ b/Silicon/Hisilicon/Include/Library/OemMiscLib.h
@@ -53,4 +53,6 @@ BOOLEAN OemIsNeedDisableExpanderBuffer(VOID);
 
 extern EFI_STRING_ID gDimmToDevLocator[MAX_SOCKET][MAX_CHANNEL][MAX_DIMM];
 EFI_HII_HANDLE EFIAPI OemGetPackages ();
+UINTN OemGetCpuFreq (UINT8 Socket);
+
 #endif
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c 
b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
index 2a9db46d1ff9..624fa33d2e14 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
+++ b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
@@ -207,3 +207,19 @@ OemIsNeedDisableExpanderBuffer (
 {
   return TRUE;
 }
+
+UINTN OemGetCpuFreq (UINT8 Socket)
+{
+  UINT8 BoardRevision;
+
+  BoardRevision = MmioRead8 (CPLD_BASE_ADDRESS + CPLD_BOM_VER_FLAG);
+
+  // Board revision 4 and higher run at 2.5GHz
+  // Earlier revisions run at 2GHz
+  if (BoardRevision >= CPLD_BOARD_REVISION_4TH) {
+return 25;
+  } else {
+return 20;
+  }
+}
+
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 11/18] Hisilicon/D06: Add Setup Item "Support DPC" and delete some PCIe menus

2019-02-19 Thread Ming Huang
Add setup item "Support DPC" to enable or disable PCIe DPC
(Downstream Port Containment).

The pcie menu is suppressed for original code as these menus
are not ready. This patch remove the suppression for pcie menu,
so delete these menus for now.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Include/Library/OemConfigData.h   |   1 +
 Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfigVfr.vfr  |   2 -
 Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfig.c   |   4 +
 Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/PcieConfig.hfr| 197 
+---
 Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/PcieConfigStrings.uni |   3 +-
 5 files changed, 10 insertions(+), 197 deletions(-)

diff --git a/Silicon/Hisilicon/Include/Library/OemConfigData.h 
b/Silicon/Hisilicon/Include/Library/OemConfigData.h
index f120e3123c83..c0097d0829f0 100644
--- a/Silicon/Hisilicon/Include/Library/OemConfigData.h
+++ b/Silicon/Hisilicon/Include/Library/OemConfigData.h
@@ -49,6 +49,7 @@ typedef struct {
   UINT8 OSWdtAction;
   /*PCIe Config*/
   UINT8 PcieSRIOVSupport;
+  UINT8 PcieDPCSupport;
   UINT8 PciePort[PCIE_MAX_TOTAL_PORTS];
   UINT8 PcieLinkSpeedPort[PCIE_MAX_TOTAL_PORTS];
   UINT8 PcieLinkDeEmphasisPort[PCIE_MAX_TOTAL_PORTS];
diff --git a/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfigVfr.vfr 
b/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfigVfr.vfr
index 08236704fbfe..93ccb99bdc67 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfigVfr.vfr
+++ b/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfigVfr.vfr
@@ -62,11 +62,9 @@ formset
   prompt = STRING_TOKEN(STR_IBMC_CONFIG_FORM_TITLE),
   help   = STRING_TOKEN(STR_IBMC_CONFIG_FORM_HELP);
 
-suppressif TRUE;
 goto PCIE_CONFIG_FORM_ID,
   prompt  = STRING_TOKEN(STR_PCIE_CONFIG_FORM_TITLE),
   help= STRING_TOKEN(STR_PCIE_CONFIG_FORM_HELP);
-endif;
 
 goto MISC_CONFIG_FORM_ID,
   prompt  = STRING_TOKEN(STR_MISC_CONFIG_FORM_TITLE),
diff --git a/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfig.c 
b/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfig.c
index 6668103af027..be4ce8820f73 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfig.c
+++ b/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfig.c
@@ -290,6 +290,10 @@ OemConfigUiLibConstructor (
   Configuration.OSWdtTimeout = 5;
   Configuration.OSWdtAction = 1;
   //
+  //Set the default value of the PCIe option
+  //
+  Configuration.PcieDPCSupport = 0;
+  //
   //Set the default value of the Misc option
   //
   Configuration.EnableSmmu = 1;
diff --git a/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/PcieConfig.hfr 
b/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/PcieConfig.hfr
index 7cf7cdd29ba2..c65907fe846e 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/PcieConfig.hfr
+++ b/Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/PcieConfig.hfr
@@ -17,203 +17,12 @@
 form formid = PCIE_CONFIG_FORM_ID,
   title   = STRING_TOKEN (STR_PCIE_CONFIG_FORM_TITLE);
 
-  goto VFR_FORMID_PCIE_SOCKET0,
-prompt  = STRING_TOKEN (STR_PCIE_CPU_0_PROMPT),
-help= STRING_TOKEN (STR_PCIE_CPU_PROMPT_HELP);
-
-  goto VFR_FORMID_PCIE_SOCKET1,
-prompt  = STRING_TOKEN (STR_PCIE_CPU_1_PROMPT),
-help= STRING_TOKEN (STR_PCIE_CPU_PROMPT_HELP);
-
-  oneof varid  = OEM_CONFIG_DATA.PcieSRIOVSupport,
-prompt   = STRING_TOKEN (STR_SRIOV_SUPPORT_PROMPT),
-help = STRING_TOKEN (STR_SRIOV_SUPPORT_HELP),
+  oneof varid  = OEM_CONFIG_DATA.PcieDPCSupport,
+prompt   = STRING_TOKEN (STR_DPC_SUPPORT_PROMPT),
+help = STRING_TOKEN (STR_DPC_SUPPORT_HELP),
 option text = STRING_TOKEN (STR_DISABLE), value = 0, flags = 
MANUFACTURING | DEFAULT | RESET_REQUIRED;
 option text = STRING_TOKEN (STR_ENABLE),  value = 1, flags = 
RESET_REQUIRED;
   endoneof;
 
 endform;
 
-form formid = VFR_FORMID_PCIE_SOCKET0,
-  title = STRING_TOKEN(STR_PCIE_CPU_0_PROMPT);
-
-  goto VFR_FORMID_PCIE_PORT2,
-prompt  = STRING_TOKEN(STR_PCIE_PORT_2_PROMPT),
-help= STRING_TOKEN(STR_PCIE_PORT_PROMPT_HELP);
-
-  goto VFR_FORMID_PCIE_PORT4,
-prompt  = STRING_TOKEN(STR_PCIE_PORT_4_PROMPT),
-help= STRING_TOKEN(STR_PCIE_PORT_PROMPT_HELP);
-
-  goto VFR_FORMID_PCIE_PORT5,
-prompt  = STRING_TOKEN(STR_PCIE_PORT_5_PROMPT),
-help= STRING_TOKEN(STR_PCIE_PORT_PROMPT_HELP);
-
-  goto VFR_FORMID_PCIE_PORT6,
-prompt  = STRING_TOKEN(STR_PCIE_PORT_6_PROMPT),
-help= STRING_TOKEN(STR_PCIE_PORT_PROMPT_HELP);
-
-  goto VFR_FORMID_PCIE_PORT7,
-prompt  = STRING_TOKEN(STR_PCIE_PORT_7_PROMPT),
-help= STRING_TOKEN(STR_PCIE_PORT_PROMPT_HELP);
-
-endform;
-
-form formid = VFR_FORMID_PCIE_SOCKET1,
-  title = STRING_TOKEN(STR_PCIE_CPU_1_PROMPT);
-  goto VFR_FORMID_PCIE_PORT10,
-prompt  = 

[edk2] [PATCH edk2-platforms v2 09/18] Hisilicon/D06: Add PCI_OSC_SUPPORT

2019-02-19 Thread Ming Huang
Add PCI_OSC_SUPPORT for remaining host bridges to remove fail
output in kernel:
[  103.478893] acpi PNP0A08:01: _OSC failed (AE_NOT_FOUND);

Add PCI_OSC_SUPPORT_HOTPLUG to rewrite _OSC of PCI0 and PCI6.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl | 200 
+++-
 1 file changed, 106 insertions(+), 94 deletions(-)

diff --git a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl 
b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
index 4d9d9d95be68..6dc380f27fa2 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
+++ b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
@@ -17,6 +17,90 @@
 **/
 
 //#include "ArmPlatform.h"
+
+/*
+  See ACPI 6.1 Spec, 6.2.11, PCI Firmware Spec 3.0, 4.5
+*/
+#define PCI_OSC_SUPPORT() \
+  Name(SUPP, Zero) /* PCI _OSC Support Field value */ \
+  Name(CTRL, Zero) /* PCI _OSC Control Field value */ \
+  Method(_OSC,4) { \
+If(LEqual(Arg0,ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))) { \
+  /* Create DWord-adressable fields from the Capabilities Buffer */ \
+  CreateDWordField(Arg3,0,CDW1) \
+  CreateDWordField(Arg3,4,CDW2) \
+  CreateDWordField(Arg3,8,CDW3) \
+  /* Save Capabilities DWord2 & 3 */ \
+  Store(CDW2,SUPP) \
+  Store(CDW3,CTRL) \
+  /* Only allow native hot plug control if OS supports: */ \
+  /* ASPM */ \
+  /* Clock PM */ \
+  /* MSI/MSI-X */ \
+  If(LNotEqual(And(SUPP, 0x16), 0x16)) { \
+And(CTRL,0x1E,CTRL) \
+  }\
+  \
+  /* Do not allow native PME, AER */ \
+  /* Never allow SHPC (no SHPC controller in this system)*/ \
+  And(CTRL,0x10,CTRL) \
+  If(LNotEqual(Arg1,One)) { /* Unknown revision */ \
+Or(CDW1,0x08,CDW1) \
+  } \
+  \
+  If(LNotEqual(CDW3,CTRL)) { /* Capabilities bits were masked */ \
+Or(CDW1,0x10,CDW1) \
+  } \
+  \
+  /* Update DWORD3 in the buffer */ \
+  Store(CTRL,CDW3) \
+  Return(Arg3) \
+} Else { \
+  Or(CDW1,4,CDW1) /* Unrecognized UUID */ \
+  Return(Arg3) \
+} \
+  } // End _OSC
+
+#define PCI_OSC_SUPPORT_HOTPLUG() \
+  Name(SUPP, Zero) /* PCI _OSC Support Field value */ \
+  Name(CTRL, Zero) /* PCI _OSC Control Field value */ \
+  Method(_OSC,4) { \
+If(LEqual(Arg0,ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))) { \
+  /* Create DWord-adressable fields from the Capabilities Buffer */ \
+  CreateDWordField(Arg3,0,CDW1) \
+  CreateDWordField(Arg3,4,CDW2) \
+  CreateDWordField(Arg3,8,CDW3) \
+  /* Save Capabilities DWord2 & 3 */ \
+  Store(CDW2,SUPP) \
+  Store(CDW3,CTRL) \
+  /* Only allow native hot plug control if OS supports: */ \
+  /* ASPM */ \
+  /* Clock PM */ \
+  /* MSI/MSI-X */ \
+  If(LNotEqual(And(SUPP, 0x16), 0x16)) { \
+And(CTRL,0x1E,CTRL) \
+  }\
+  \
+  /* Always allow native PME, AER (no dependencies) */ \
+  /* Never allow SHPC (no SHPC controller in this system)*/ \
+  And(CTRL,0x1D,CTRL) \
+  If(LNotEqual(Arg1,One)) { /* Unknown revision */ \
+Or(CDW1,0x08,CDW1) \
+  } \
+  \
+  If(LNotEqual(CDW3,CTRL)) { /* Capabilities bits were masked */ \
+Or(CDW1,0x10,CDW1) \
+  } \
+  \
+  /* Update DWORD3 in the buffer */ \
+  Store(CTRL,CDW3) \
+  Return(Arg3) \
+} Else { \
+  Or(CDW1,4,CDW1) /* Unrecognized UUID */ \
+  Return(Arg3) \
+} \
+  } // End _OSC
+
 Scope(_SB)
 {
   Device (PCI0)
@@ -139,53 +223,7 @@ Scope(_SB)
   Return (RBUF)
 }// Method(_CRS), this method 
return RBUF!
 
-  //
-  // OS Control Handoff
-  //
-  Name(SUPP, Zero) // PCI _OSC Support Field value
-  Name(CTRL, Zero) // PCI _OSC Control Field value
-
-  Method(_OSC,4) {
-// Check for proper UUID
-If(LEqual(Arg0,ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))) {
-  // Create DWord-adressable fields from the Capabilities Buffer
-  CreateDWordField(Arg3,0,CDW1)
-  CreateDWordField(Arg3,4,CDW2)
-  CreateDWordField(Arg3,8,CDW3)
-
-  // Save Capabilities DWord2 & 3
-  Store(CDW2,SUPP)
-  Store(CDW3,CTRL)
-
-  // Only allow native hot plug control if OS supports:
-  //  ASPM
-  //  Clock PM
-  //  MSI/MSI-X
-  If(LNotEqual(And(SUPP, 0x16), 0x16)) {
-And(CTRL,0x1E,CTRL) // Mask bit 0 (and undefined bits)
-  }
-
-  // Always allow native PME, AER (no dependencies)
-
-  // Never allow SHPC (no SHPC controller in this system)
-  And(CTRL,0x1D,CTRL)
-
-  If(LNotEqual(Arg1,One)) {  // Unknown revision
-Or(CDW1,0x08,CDW1)
-  }
-
-  If(LNotEqual(CDW3,CTRL)) {  // Capabilities bits were masked
-Or(CDW1,0x10,CDW1)
-  }
-
-  // Update DWORD3 in the buffer
-  Store(CTRL,CDW3)
-  Return(Arg3)
-} Else {
-  Or(CDW1,4,CDW1) // 

[edk2] [PATCH edk2-platforms v2 07/18] Hisilicon/D0x: Rename StartupAp() function

2019-02-19 Thread Ming Huang
As suggestion of community, 'AP' is a bit unfortunate to use in EDK2
context. PI specifies 'BSP' for Boot-strap Processor, as the one
executing all of the EDK2 code. It then uses 'AP' to refer to
Additional Processors, which can be assigned tasks using the
EFI_MP_SERVICES_PROTOCOL. In a TianoCore context, this should be 'BSP'.
So, Rename StartupAp() to StartUpBSP.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h   | 2 +-
 Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c  | 2 +-
 Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c | 2 +-
 Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c  | 2 +-
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c | 3 ++-
 Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c  | 2 +-
 6 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h 
b/Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h
index a232e52ed719..712b77c44fc8 100644
--- a/Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h
+++ b/Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h
@@ -76,7 +76,7 @@ VOID MN_CONFIG (VOID);
 VOID SmmuConfigForOS (VOID);
 VOID SmmuConfigForBios (VOID);
 
-VOID StartupAp (VOID);
+VOID StartUpBSP (VOID);
 
 VOID LlcCleanInvalidate (VOID);
 
diff --git a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c 
b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
index 97cf6b8d8757..dacd9e871faf 100644
--- a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
+++ b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
@@ -83,7 +83,7 @@ void QResetAp(VOID)
 //SCCL A
 if (!PcdGet64 (PcdTrustedFirmwareEnable))
 {
-StartupAp();
+StartUpBSP ();
 }
 }
 
diff --git a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c 
b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c
index b57fdfa68e45..c8a9da73bbca 100644
--- a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c
+++ b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c
@@ -133,7 +133,7 @@ VOID CoreSelectBoot(VOID)
 {
 if (!PcdGet64 (PcdTrustedFirmwareEnable))
 {
-StartupAp ();
+StartUpBSP ();
 }
 
 return;
diff --git a/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c 
b/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
index 76a055cbe980..b374347e5c4d 100644
--- a/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
+++ b/Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
@@ -35,7 +35,7 @@ QResetAp (
   (VOID)WriteBackInvalidateDataCacheRange((VOID *) 
FixedPcdGet64(PcdMailBoxAddress), 8);
 
   if (!PcdGet64 (PcdTrustedFirmwareEnable)) {
-StartupAp();
+StartUpBSP ();
   }
 }
 
diff --git a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c 
b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c
index 4c4c944dbead..a1458da7f0a3 100644
--- a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c
+++ b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.c
@@ -96,7 +96,7 @@ UINTN OemGetDimmSlot(UINTN Socket, UINTN Channel)
 VOID CoreSelectBoot(VOID)
 {
   if (!PcdGet64 (PcdTrustedFirmwareEnable)) {
-  StartupAp ();
+  StartUpBSP ();
   }
 
   return;
@@ -128,3 +128,4 @@ BOOLEAN OemIsNeedDisableExpanderBuffer(VOID)
 {
   return TRUE;
 }
+
diff --git a/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c 
b/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c
index 0790f7941ae7..a8261d370626 100644
--- a/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c
+++ b/Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.c
@@ -78,7 +78,7 @@ QResetAp (
 
   //SCCL A
   if (!PcdGet64 (PcdTrustedFirmwareEnable)) {
-StartupAp ();
+StartUpBSP ();
   }
 }
 
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 05/18] Hisilicon/D06: Add more PCIe port INT-x support

2019-02-19 Thread Ming Huang
Since NVMe riser width is 6*X4, need add the related
port's INT-x support to match OS driver.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl | 37 
+++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl 
b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
index 0f2d11bb952b..4d9d9d95be68 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
+++ b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
@@ -41,11 +41,21 @@ Scope(_SB)
   // adding RPx INTx configure deponds on hardware board topology,
   // if UEFI enables RPx, RPy, RPz... related INTx configure
   // should be added
+  Package () {0x2,0,0,640}, // INT_A
+  Package () {0x2,1,0,641}, // INT_B
+  Package () {0x2,2,0,642}, // INT_C
+  Package () {0x2,3,0,643}, // INT_D
+
   Package () {0x4,0,0,640}, // INT_A
   Package () {0x4,1,0,641}, // INT_B
   Package () {0x4,2,0,642}, // INT_C
   Package () {0x4,3,0,643}, // INT_D
 
+  Package () {0x6,0,0,640}, // INT_A
+  Package () {0x6,1,0,641}, // INT_B
+  Package () {0x6,2,0,642}, // INT_C
+  Package () {0x6,3,0,643}, // INT_D
+
   Package () {0x8,0,0,640}, // INT_A
   Package () {0x8,1,0,641}, // INT_B
   Package () {0x8,2,0,642}, // INT_C
@@ -56,6 +66,11 @@ Scope(_SB)
   Package () {0xC,2,0,642}, // INT_C
   Package () {0xC,3,0,643}, // INT_D
 
+  Package () {0xE,0,0,640}, // INT_A
+  Package () {0xE,1,0,641}, // INT_B
+  Package () {0xE,2,0,642}, // INT_C
+  Package () {0xE,3,0,643}, // INT_D
+
   Package () {0x10,0,0,640}, // INT_A
   Package () {0x10,1,0,641}, // INT_B
   Package () {0x10,2,0,642}, // INT_C
@@ -759,11 +774,21 @@ Device (PCI6)
 // adding RPx INTx configure deponds on hardware board topology,
 // if UEFI enables RPx, RPy, RPz... related INTx configure
 // should be added
+Package () {0x2,0,0,640}, // INT_A
+Package () {0x2,1,0,641}, // INT_B
+Package () {0x2,2,0,642}, // INT_C
+Package () {0x2,3,0,643}, // INT_D
+
 Package () {0x4,0,0,640}, // INT_A
 Package () {0x4,1,0,641}, // INT_B
 Package () {0x4,2,0,642}, // INT_C
 Package () {0x4,3,0,643}, // INT_D
 
+Package () {0x6,0,0,640}, // INT_A
+Package () {0x6,1,0,641}, // INT_B
+Package () {0x6,2,0,642}, // INT_C
+Package () {0x6,3,0,643}, // INT_D
+
 Package () {0x8,0,0,640}, // INT_A
 Package () {0x8,1,0,641}, // INT_B
 Package () {0x8,2,0,642}, // INT_C
@@ -774,11 +799,21 @@ Device (PCI6)
 Package () {0xC,2,0,642}, // INT_C
 Package () {0xC,3,0,643}, // INT_D
 
+Package () {0xE,0,0,640}, // INT_A
+Package () {0xE,1,0,641}, // INT_B
+Package () {0xE,2,0,642}, // INT_C
+Package () {0xE,3,0,643}, // INT_D
+
 Package () {0x10,0,0,640}, // INT_A
 Package () {0x10,1,0,641}, // INT_B
 Package () {0x10,2,0,642}, // INT_C
 Package () {0x10,3,0,643}, // INT_D
-  })
+
+Package () {0x12,0,0,640}, // INT_A
+Package () {0x12,1,0,641}, // INT_B
+Package () {0x12,2,0,642}, // INT_C
+Package () {0x12,3,0,643}, // INT_D
+})
 
   Method (_CRS, 0, Serialized) {   // Root complex resources, _CRS: 
current resource setting
 Name (RBUF, ResourceTemplate () {  // Name: 19.6.87, ResourceTemplate: 
19.6.111,
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 04/18] Hisilicon/D06: Drop the leading 0 (0x0 -> 0x)

2019-02-19 Thread Ming Huang
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl | 24 
++--
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl 
b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
index 27fde2e09bfe..0f2d11bb952b 100644
--- a/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
+++ b/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Dsdt/Hi1620Pci.asl
@@ -759,20 +759,20 @@ Device (PCI6)
 // adding RPx INTx configure deponds on hardware board topology,
 // if UEFI enables RPx, RPy, RPz... related INTx configure
 // should be added
-Package () {0x04,0,0,640}, // INT_A
-Package () {0x04,1,0,641}, // INT_B
-Package () {0x04,2,0,642}, // INT_C
-Package () {0x04,3,0,643}, // INT_D
+Package () {0x4,0,0,640}, // INT_A
+Package () {0x4,1,0,641}, // INT_B
+Package () {0x4,2,0,642}, // INT_C
+Package () {0x4,3,0,643}, // INT_D
 
-Package () {0x08,0,0,640}, // INT_A
-Package () {0x08,1,0,641}, // INT_B
-Package () {0x08,2,0,642}, // INT_C
-Package () {0x08,3,0,643}, // INT_D
+Package () {0x8,0,0,640}, // INT_A
+Package () {0x8,1,0,641}, // INT_B
+Package () {0x8,2,0,642}, // INT_C
+Package () {0x8,3,0,643}, // INT_D
 
-Package () {0x0C,0,0,640}, // INT_A
-Package () {0x0C,1,0,641}, // INT_B
-Package () {0x0C,2,0,642}, // INT_C
-Package () {0x0C,3,0,643}, // INT_D
+Package () {0xC,0,0,640}, // INT_A
+Package () {0xC,1,0,641}, // INT_B
+Package () {0xC,2,0,642}, // INT_C
+Package () {0xC,3,0,643}, // INT_D
 
 Package () {0x10,0,0,640}, // INT_A
 Package () {0x10,1,0,641}, // INT_B
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 08/18] Hisilicon/D06: Use HCCS speed with 2.6G

2019-02-19 Thread Ming Huang
Follow chip team suggestion, HCCS(Huawei Cache-Coherent System)
may be unstable while speed is 3.0G, so use 2.6G to avoid some
unstable stress issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Include/Library/OemMiscLib.h   | 10 ++
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c |  8 
 2 files changed, 18 insertions(+)

diff --git a/Silicon/Hisilicon/Include/Library/OemMiscLib.h 
b/Silicon/Hisilicon/Include/Library/OemMiscLib.h
index dfac87d635d9..ea95fe38d75c 100644
--- a/Silicon/Hisilicon/Include/Library/OemMiscLib.h
+++ b/Silicon/Hisilicon/Include/Library/OemMiscLib.h
@@ -22,6 +22,11 @@
 #include 
 #include 
 
+#define HCCS_PLL_VALUE_2600  0x52240681
+#define HCCS_PLL_VALUE_2800  0x52240701
+#define HCCS_PLL_VALUE_3000  0x52240781
+
+
 #define PCIEDEVICE_REPORT_MAX  8
 #define MAX_PROCESSOR_SOCKETS  MAX_SOCKET
 #define MAX_MEMORY_CHANNELSMAX_CHANNEL
@@ -55,4 +60,9 @@ extern EFI_STRING_ID 
gDimmToDevLocator[MAX_SOCKET][MAX_CHANNEL][MAX_DIMM];
 EFI_HII_HANDLE EFIAPI OemGetPackages ();
 UINTN OemGetCpuFreq (UINT8 Socket);
 
+UINTN
+OemGetHccsFreq (
+  VOID
+  );
+
 #endif
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c 
b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
index 624fa33d2e14..914387de7d63 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
+++ b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.c
@@ -223,3 +223,11 @@ UINTN OemGetCpuFreq (UINT8 Socket)
   }
 }
 
+UINTN
+OemGetHccsFreq (
+  VOID
+  )
+{
+  return HCCS_PLL_VALUE_2600;
+}
+
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 02/18] Hisilicon/D06: Optimize SAS driver for reducing boot time

2019-02-19 Thread Ming Huang
SAS controller is always existed, so accessing SAS register don't
depend on PciBusDxe (pci enumeration).
Move the SAS module early in D06.fdf for dispatching SAS driver
early. This can avoid wait in BDS normally and reduce boot time.

This change is only valid after the update to SasDriverDxe in
edk2-non-osi has been applied.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/D06.fdf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/Hisilicon/D06/D06.fdf b/Platform/Hisilicon/D06/D06.fdf
index a937660a09e2..d495ad7f264c 100644
--- a/Platform/Hisilicon/D06/D06.fdf
+++ b/Platform/Hisilicon/D06/D06.fdf
@@ -165,6 +165,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
 
   INF Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.inf
+  INF Platform/Hisilicon/D06/Drivers/Sas/SasDxeDriver.inf
   #
   # PI DXE Drivers producing Architectural Protocols (EFI Services)
   #
@@ -296,7 +297,6 @@ [FV.FvMain]
   #
   INF Platform/Hisilicon/D06/Drivers/Sm750Dxe/UefiSmi.inf
   INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
-  INF Platform/Hisilicon/D06/Drivers/Sas/SasDxeDriver.inf
   INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
   INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
   INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
-- 
2.9.5

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


[edk2] [PATCH edk2-platforms v2 00/18] Fix issues and improve D0x

2019-02-19 Thread Ming Huang
Main Changes since v1 :
1 Submit separate patch to drop the leading 0 for Hi1620Pci.asl;
2 Add Fix USB crash issue patch;
3 Modify some code style issues;
4 Drop "Use CalculateCrc16 in BaseLib" patch;
5 Refactor "Remove SerdesLib" patch;
6 Add patch for move some header files to edk2-non-osi/;

Code can also be found in github:
https://github.com/hisilicon/OpenPlatformPkg.git
branch: 1902-platforms-v2


Jason Zhang (1):
  Hisilicon/D06: Fix access variable fail issue

Ming Huang (16):
  Hisilicon/D0x: Add DriverHealthManagerDxe
  Hisilicon/D06: Optimize SAS driver for reducing boot time
  Hisilicon/D06: Drop the leading 0 (0x0 -> 0x)
  Hisilicon/D06: Add more PCIe port INT-x support
  Hisilicon/D0x: Rename StartupAp() function
  Hisilicon/D06: Use HCCS speed with 2.6G
  Hisilicon/D06: Add PCI_OSC_SUPPORT
  Hisilicon/D06: Modify for IMP self-Adapte support
  Hisilicon/D06: Add Setup Item "Support DPC" and delete some PCIe menus
  Hisilicon/D06: Use new flash layout
  Hisilicon/D06: Remove SECURE_BOOT_ENABLE definition
  Hisilicon/D0x: Remove SP805 watchdog pcd
  Hisilicon/D06: Fix USB crash issue(4079)
  Hisilicon/D0x: Remove and tidy some codes about SerdesLib
  Hisilicon/D0x: Delete some header files
  Hisilicon/D0x: Modify version to 19.02

xingjiang tang (1):
  Hisilicon/D06: Add OemGetCpuFreq to encapsulate difference

 Platform/Hisilicon/D03/D03.dsc 
   |   8 +-
 Platform/Hisilicon/D05/D05.dsc 
   |   8 +-
 Platform/Hisilicon/D06/D06.dsc 
   |  19 +-
 Platform/Hisilicon/D03/D03.fdf 
   |   1 +
 Platform/Hisilicon/D05/D05.fdf 
   |   1 +
 Platform/Hisilicon/D06/D06.fdf 
   |  18 +-
 Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf  
   |   1 +
 Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf 
   |   2 +-
 Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.inf  
   |   1 +
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf 
   |   1 +
 Platform/Hisilicon/D06/EarlyConfigPeim/EarlyConfigPeimD06.inf  
   |   1 +
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf 
   |   1 +
 Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClassDxe.inf   
   |   1 +
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf 
   |   1 +
 Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf   
   |   4 +-
 Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.inf
   |   1 +
 Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.inf   
   |   1 +
 Silicon/Hisilicon/Library/ArmPlatformLibHisilicon/ArmPlatformLib.inf   
   |   1 -
 Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.inf
   |   1 +
 Silicon/Hisilicon/Library/I2CLib/I2CLib.inf
   |   1 +
 Silicon/Hisilicon/Library/I2CLib/I2CLibRuntime.inf 
   |   1 +
 Platform/Hisilicon/D06/Include/Library/CpldD06.h   
   |   4 +
 Silicon/Hisilicon/Hi1610/Include/Library/SerdesLib.h   
   | 131 -
 Silicon/Hisilicon/Hi1616/Include/Library/SerdesLib.h   
   |  86 --
 Silicon/Hisilicon/Hi1620/Include/Library/SerdesLib.h   
   |  85 --
 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h 
   | 110 ---
 Silicon/Hisilicon/Include/Library/LpcLib.h 
   | 113 ---
 Silicon/Hisilicon/Include/Library/OemAddressMapLib.h   
   |  45 ---
 Silicon/Hisilicon/Include/Library/OemConfigData.h  
   |   1 +
 Silicon/Hisilicon/Include/Library/OemMiscLib.h 
   |  75 +
 Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h 
   | 112 ---
 Silicon/Hisilicon/Hi1620/Hi1620OemConfigUiLib/OemConfigVfr.vfr 
   |   4 +-
 Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.c
   |   2 +-
 Platform/Hisilicon/D03/Library/OemMiscLib2P/BoardFeature2PHi1610.c 
   |   1 -
 Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.c   
   |   2 +-
 Platform/Hisilicon/D05/EarlyConfigPeim/EarlyConfigPeimD05.c
   |   2 +-
 

[edk2] [PATCH edk2-platforms v2 01/18] Hisilicon/D0x: Add DriverHealthManagerDxe

2019-02-19 Thread Ming Huang
DriverHealthManagerDxe Collect driver health form of third party
drivers to repair no healthy card.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D03/D03.dsc | 1 +
 Platform/Hisilicon/D05/D05.dsc | 1 +
 Platform/Hisilicon/D06/D06.dsc | 1 +
 Platform/Hisilicon/D03/D03.fdf | 1 +
 Platform/Hisilicon/D05/D05.fdf | 1 +
 Platform/Hisilicon/D06/D06.fdf | 1 +
 6 files changed, 6 insertions(+)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 3f59be22ec8e..fe443dd929ad 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -492,6 +492,7 @@ [Components.common]
 
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf {
 
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 25db1c38d287..0c4f21fbe056 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -638,6 +638,7 @@ [Components.common]
   MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
   SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf {
diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc
index 396bd03c9d24..3856578e74be 100644
--- a/Platform/Hisilicon/D06/D06.dsc
+++ b/Platform/Hisilicon/D06/D06.dsc
@@ -437,6 +437,7 @@ [Components.common]
   
Silicon/Hisilicon/Hi1620/Drivers/Pl011DebugSerialPortInitDxe/Pl011DebugSerialPortInitDxe.inf
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
   SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.inf {
 
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index f453f9e46321..3f07b2e57778 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -295,6 +295,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
   INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
 [FV.FVMAIN_COMPACT]
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index 85dd791564a4..9632aea4b00e 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -314,6 +314,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
   INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
 [FV.FVMAIN_COMPACT]
diff --git a/Platform/Hisilicon/D06/D06.fdf b/Platform/Hisilicon/D06/D06.fdf
index fda29ab322e9..a937660a09e2 100644
--- a/Platform/Hisilicon/D06/D06.fdf
+++ b/Platform/Hisilicon/D06/D06.fdf
@@ -319,6 +319,7 @@ [FV.FvMain]
   INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
   INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
+  INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
   INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
 [FV.FVMAIN_COMPACT]
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 7/8] Hisilicon/D06: Add Setup Item "Support DPC"

2019-02-19 Thread Ming Huang
Add setup item "Support DPC" to enable or disable PCIe DPC
(Downstream Port Containment).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.efi | Bin 232832 -> 226784 
bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.efi 
b/Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.efi
index e32c056..4511f6b 100644
Binary files a/Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.efi and 
b/Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.efi differ
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 8/8] Hisilicon/D0x: Add some header files

2019-02-19 Thread Ming Huang
As interfaces exposed only by implementations in edk2-non-osi,
so move some header files from edk2-platforms to edk2-non-osi.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h | 110 
+++
 Silicon/Hisilicon/Include/Library/LpcLib.h | 113 

 Silicon/Hisilicon/Include/Library/OemAddressMapLib.h   |  45 
 Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h | 112 
+++
 Silicon/Hisilicon/Include/Library/SerdesLib.h  |  21 
 5 files changed, 401 insertions(+)

diff --git a/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h 
b/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
new file mode 100644
index 000..b956ee6
--- /dev/null
+++ b/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
@@ -0,0 +1,110 @@
+/** @file
+*
+*  Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2017, Linaro 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 _IPMI_CMD_LIB_H_
+#define _IPMI_CMD_LIB_H_
+
+#define BOOT_OPTION_BOOT_FLAG_VALID 1
+#define BOOT_OPTION_BOOT_FLAG_INVALID   0
+
+typedef enum {
+  EfiReserved,
+  EfiBiosFrb2,
+  EfiBiosPost,
+  EfiOsLoad,
+  EfiSmsOs,
+  EfiOem,
+  EfiFrbReserved1,
+  EfiFrbReserved2
+} EFI_WDT_USER_TYPE;
+
+typedef enum {
+  NoOverride = 0x0,
+  ForcePxe,
+  ForceDefaultHardDisk,
+  ForceDefaultHardDiskSafeMode,
+  ForceDefaultDiagnosticPartition,
+  ForceDefaultCD,
+  ForceSetupUtility,
+  ForceRemoteRemovableMedia,
+  ForceRemoteCD,
+  ForcePrimaryRemoteMedia,
+  ForceRemoteHardDisk = 0xB,
+  ForcePrimaryRemovableMedia = 0xF
+} BOOT_DEVICE_SELECTOR;
+
+//
+// Get System Boot Option data structure
+//
+typedef struct {
+  UINT8 ParameterVersion   :4;
+  UINT8 Reserved1  :4;
+  UINT8 ParameterSelector  :7;
+  UINT8 ParameterValid :1;
+  //
+  // Boot Flags Data 1
+  //
+  UINT8 Reserved2  :5;
+  UINT8 BiosBootType   :1;
+  UINT8 Persistent :1;
+  UINT8 BootFlagsValid :1;
+  //
+  // Boot Flags Data 2
+  //
+  UINT8 LockResetBtn   :1;
+  UINT8 ScreenBlank:1;
+  UINT8 BootDeviceSelector :4;
+  UINT8 LockKeyboard   :1;
+  UINT8 ClearCmos  :1;
+  //
+  // Boot Flags Data 3
+  //
+  UINT8 ConsoleRedirectionControl  :2;
+  UINT8 LockSleepBtn   :1;
+  UINT8 UserPasswordByPass :1;
+  UINT8 Reserved3  :1;
+  UINT8 FirmwareVerbosity  :2;
+  UINT8 LockPowerBtn   :1;
+  //
+  // Boot Flags Data 4
+  //
+  UINT8 MuxControlOverride :3;
+  UINT8 ShareModeOverride  :1;
+  UINT8 Reserved4  :4;
+  //
+  // Boot Flags Data 5
+  //
+  UINT8 DeviceInstanceSelector :5;
+  UINT8 Reserved5  :3;
+} IPMI_GET_BOOT_OPTION;
+
+EFI_STATUS
+EFIAPI
+IpmiCmdSetSysBootOptions (
+  OUT IPMI_GET_BOOT_OPTION  *BootOption
+  );
+
+EFI_STATUS
+EFIAPI
+IpmiCmdGetSysBootOptions (
+  IN IPMI_GET_BOOT_OPTION   *BootOption
+  );
+
+EFI_STATUS
+IpmiCmdStopWatchdogTimer (
+  IN EFI_WDT_USER_TYPE  UserType
+  );
+
+#endif
diff --git a/Silicon/Hisilicon/Include/Library/LpcLib.h 
b/Silicon/Hisilicon/Include/Library/LpcLib.h
new file mode 100755
index 000..236a52b
--- /dev/null
+++ b/Silicon/Hisilicon/Include/Library/LpcLib.h
@@ -0,0 +1,113 @@
+/** @file
+*
+*  Copyright (c) 2016, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2016, Linaro 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 _LPC_LIB_H_
+#define _LPC_LIB_H_
+
+#include 
+
+#define PCIE_SUBSYS_IO_MUX  0xA017
+#define PCIE_SUBSYS_IOMG033 (PCIE_SUBSYS_IO_MUX + 0x84)
+#define PCIE_SUBSYS_IOMG035 (PCIE_SUBSYS_IO_MUX + 0x8C)
+#define PCIE_SUBSYS_IOMG036 (PCIE_SUBSYS_IO_MUX + 0x90)
+#define PCIE_SUBSYS_IOMG045 (PCIE_SUBSYS_IO_MUX + 0xB4)
+#define PCIE_SUBSYS_IOMG046 (PCIE_SUBSYS_IO_MUX + 0xB8)
+#define PCIE_SUBSYS_IOMG047 (PCIE_SUBSYS_IO_MUX + 0xBC)
+#define PCIE_SUBSYS_IOMG048 (PCIE_SUBSYS_IO_MUX + 0xC0)

[edk2] [PATCH edk2-non-osi v2 6/8] Hisilicon/D06: Fix numa node wrong issue

2019-02-19 Thread Ming Huang
Numa informations are acquired from HOB that build from memory
initialization module. Correct numa informations to match booting
from TA(Totem A or super cpu cluster A).

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/MemoryInitPei/MemoryInit.efi | Bin 297696 -> 358656 
bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D06/MemoryInitPei/MemoryInit.efi 
b/Platform/Hisilicon/D06/MemoryInitPei/MemoryInit.efi
index 5fba353..fea1475 100644
Binary files a/Platform/Hisilicon/D06/MemoryInitPei/MemoryInit.efi and 
b/Platform/Hisilicon/D06/MemoryInitPei/MemoryInit.efi differ
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 0/8] Upload D0x binary modules

2019-02-19 Thread Ming Huang
Main Changes since v1 :
1 Add some header files to edk2-non-osi;

Code can also be found in github:
https://github.com/hisilicon/OpenPlatformPkg.git
branch: 1902-non-osi-v2


Ming Huang (8):
  Hisilicon/D06: Remove PCI enumeration dependency from SAS driver
  Hisilicon/D0x: Update PlatformSysCtrlLib binary
  Hisilicon/D06: Update Mbigen and gic RAS register
  Hisilicon/D06: Support PCIe local RAS
  Hisilicon/D06: Use new flash layout
  Hisilicon/D06: Fix numa node wrong issue
  Hisilicon/D06: Add Setup Item "Support DPC"
  Hisilicon/D0x: Add some header files

 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h 
| 110 +++
 Silicon/Hisilicon/Include/Library/LpcLib.h 
| 113 
 Silicon/Hisilicon/Include/Library/OemAddressMapLib.h   
|  45 
 Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h 
| 112 +++
 Silicon/Hisilicon/Include/Library/SerdesLib.h  
|  21 
 Platform/Hisilicon/D06/CustomData.Fv   
| Bin 0 -> 65536 bytes
 Platform/Hisilicon/D06/Drivers/IoInitDxe/IoInitDxe.efi 
| Bin 232832 -> 226784 bytes
 Platform/Hisilicon/D06/Drivers/PcieRasInitDxe/PcieRasInitDxe.efi   
| Bin 21248 -> 22048 bytes
 Platform/Hisilicon/D06/Drivers/RasInitDxe/RasInitDxe.efi   
| Bin 17984 -> 18720 bytes
 Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.depex  
| Bin 216 -> 36 bytes
 Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.efi
| Bin 221312 -> 220640 bytes
 Platform/Hisilicon/D06/Library/OemAddressMapD06/OemAddressMapD06.lib   
| Bin 61892 -> 31696 bytes
 Platform/Hisilicon/D06/MemoryInitPei/MemoryInit.efi
| Bin 297696 -> 358656 bytes
 Platform/Hisilicon/D06/Sec/FVMAIN_SEC.Fv   
| Bin 1048576 -> 1048576 bytes
 Platform/Hisilicon/D06/bl1.bin 
| Bin 12432 -> 12432 bytes
 Platform/Hisilicon/D06/fip.bin 
| Bin 113450 -> 121866 bytes
 
Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
 | Bin 297590 -> 229128 bytes
 
Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
 | Bin 344310 -> 275312 bytes
 
Silicon/Hisilicon/Hi1620/Library/PlatformSysCtrlLibHi1620/PlatformSysCtrlLibHi1620.lib
 | Bin 356032 -> 375916 bytes
 19 files changed, 401 insertions(+)
 create mode 100644 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
 create mode 100755 Silicon/Hisilicon/Include/Library/LpcLib.h
 create mode 100644 Silicon/Hisilicon/Include/Library/OemAddressMapLib.h
 create mode 100644 Silicon/Hisilicon/Include/Library/PlatformSysCtrlLib.h
 create mode 100644 Silicon/Hisilicon/Include/Library/SerdesLib.h
 create mode 100644 Platform/Hisilicon/D06/CustomData.Fv

-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 3/8] Hisilicon/D06: Update Mbigen and gic RAS register

2019-02-19 Thread Ming Huang
As chip group suggestions, update Mbigen and gic RAS configuration
flow.
Add below flow:
1 Reset Mbigen;
2 Disable Mbigen clock;
3 Deassert reset Mbigen;
4 Enable Mbigen clock;

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/Drivers/RasInitDxe/RasInitDxe.efi | Bin 17984 -> 18720 
bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D06/Drivers/RasInitDxe/RasInitDxe.efi 
b/Platform/Hisilicon/D06/Drivers/RasInitDxe/RasInitDxe.efi
index 19adbc9..9ea21e9 100644
Binary files a/Platform/Hisilicon/D06/Drivers/RasInitDxe/RasInitDxe.efi and 
b/Platform/Hisilicon/D06/Drivers/RasInitDxe/RasInitDxe.efi differ
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 5/8] Hisilicon/D06: Use new flash layout

2019-02-19 Thread Ming Huang
In new flash layout, BIOS fd change from offset 1M to 8M in 16M
spi flash.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/CustomData.Fv | Bin 0 
-> 65536 bytes
 Platform/Hisilicon/D06/Library/OemAddressMapD06/OemAddressMapD06.lib | Bin 
61892 -> 31696 bytes
 Platform/Hisilicon/D06/Sec/FVMAIN_SEC.Fv | Bin 
1048576 -> 1048576 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D06/CustomData.Fv 
b/Platform/Hisilicon/D06/CustomData.Fv
new file mode 100644
index 000..22ef62b
Binary files /dev/null and b/Platform/Hisilicon/D06/CustomData.Fv differ
diff --git 
a/Platform/Hisilicon/D06/Library/OemAddressMapD06/OemAddressMapD06.lib 
b/Platform/Hisilicon/D06/Library/OemAddressMapD06/OemAddressMapD06.lib
index 7e1f6b2..851c2c3 100644
Binary files 
a/Platform/Hisilicon/D06/Library/OemAddressMapD06/OemAddressMapD06.lib and 
b/Platform/Hisilicon/D06/Library/OemAddressMapD06/OemAddressMapD06.lib differ
diff --git a/Platform/Hisilicon/D06/Sec/FVMAIN_SEC.Fv 
b/Platform/Hisilicon/D06/Sec/FVMAIN_SEC.Fv
index 247e44e..7f75bc6 100644
Binary files a/Platform/Hisilicon/D06/Sec/FVMAIN_SEC.Fv and 
b/Platform/Hisilicon/D06/Sec/FVMAIN_SEC.Fv differ
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 4/8] Hisilicon/D06: Support PCIe local RAS

2019-02-19 Thread Ming Huang
Add some registers configuration in PcieRasInitDxe and add PCIe
local RAS interrupt handle in trusted firmware to support PCIe
local RAS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Reviewed-by: Leif Lindholm 
---
 Platform/Hisilicon/D06/Drivers/PcieRasInitDxe/PcieRasInitDxe.efi | Bin 21248 
-> 22048 bytes
 Platform/Hisilicon/D06/bl1.bin   | Bin 12432 
-> 12432 bytes
 Platform/Hisilicon/D06/fip.bin   | Bin 113450 
-> 121866 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D06/Drivers/PcieRasInitDxe/PcieRasInitDxe.efi 
b/Platform/Hisilicon/D06/Drivers/PcieRasInitDxe/PcieRasInitDxe.efi
index 0e22237..f9ceff2 100644
Binary files a/Platform/Hisilicon/D06/Drivers/PcieRasInitDxe/PcieRasInitDxe.efi 
and b/Platform/Hisilicon/D06/Drivers/PcieRasInitDxe/PcieRasInitDxe.efi differ
diff --git a/Platform/Hisilicon/D06/bl1.bin b/Platform/Hisilicon/D06/bl1.bin
index 416535f..d0970e5 100644
Binary files a/Platform/Hisilicon/D06/bl1.bin and 
b/Platform/Hisilicon/D06/bl1.bin differ
diff --git a/Platform/Hisilicon/D06/fip.bin b/Platform/Hisilicon/D06/fip.bin
index c9b7ca0..795cfb5 100644
Binary files a/Platform/Hisilicon/D06/fip.bin and 
b/Platform/Hisilicon/D06/fip.bin differ
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 2/8] Hisilicon/D0x: Update PlatformSysCtrlLib binary

2019-02-19 Thread Ming Huang
As suggestion of community, 'AP' is a bit unfortunate to use in EDK2
context. PI specifies 'BSP' for Boot-strap Processor, as the one
executing all of the EDK2 code. It then uses 'AP' to refer to
Additional Processors, which can be assigned tasks using the
EFI_MP_SERVICES_PROTOCOL. In a TianoCore context, this should be
'BSP'. So, Rename StartupAp() to StartUpBSP.

This patch applies to D0x PlatformSysCtrlLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 
Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
 | Bin 297590 -> 229128 bytes
 
Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
 | Bin 344310 -> 275312 bytes
 
Silicon/Hisilicon/Hi1620/Library/PlatformSysCtrlLibHi1620/PlatformSysCtrlLibHi1620.lib
 | Bin 356032 -> 375916 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git 
a/Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
 
b/Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
index 68be770..4c63a26 100644
Binary files 
a/Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
 and 
b/Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.lib
 differ
diff --git 
a/Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
 
b/Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
index b3cc88e..cb2c652 100644
Binary files 
a/Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
 and 
b/Silicon/Hisilicon/Hi1616/Library/PlatformSysCtrlLibHi1616/PlatformSysCtrlLibHi1616.lib
 differ
diff --git 
a/Silicon/Hisilicon/Hi1620/Library/PlatformSysCtrlLibHi1620/PlatformSysCtrlLibHi1620.lib
 
b/Silicon/Hisilicon/Hi1620/Library/PlatformSysCtrlLibHi1620/PlatformSysCtrlLibHi1620.lib
index 50d453a..d643f7b 100644
Binary files 
a/Silicon/Hisilicon/Hi1620/Library/PlatformSysCtrlLibHi1620/PlatformSysCtrlLibHi1620.lib
 and 
b/Silicon/Hisilicon/Hi1620/Library/PlatformSysCtrlLibHi1620/PlatformSysCtrlLibHi1620.lib
 differ
-- 
2.9.5

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


[edk2] [PATCH edk2-non-osi v2 1/8] Hisilicon/D06: Remove PCI enumeration dependency from SAS driver

2019-02-19 Thread Ming Huang
SAS controller is always existed, so accessing SAS register don't
depend on PciBusDxe (pci enumeration). Modify SAS driver remove the
dependence on pci enumeration.
This patch is done to improve boot times.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.depex | Bin 216 -> 36 bytes
 Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.efi   | Bin 221312 -> 220640 
bytes
 2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.depex 
b/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.depex
index 1a5bc1e..e076777 100644
Binary files a/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.depex and 
b/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.depex differ
diff --git a/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.efi 
b/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.efi
index ac6bae7..4a29e8c 100644
Binary files a/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.efi and 
b/Platform/Hisilicon/D06/Drivers/Sas/SasDriverDxe.efi differ
-- 
2.9.5

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


[edk2] [PATCH v2] UefiCpuPkg/Microcode: Fix incorrect checksum issue for extended table

2019-02-19 Thread Chen A Chen
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1020

The following Microcode payload format is define in SDM spec.
Payload: |MicrocodeHeader|MicrocodeBinary|ExtendedHeader|ExtendedTable|.
When we verify the CheckSum32 with ExtendedTable, we should use the fields
of ExtendedTable to replace corresponding fields in MicrocodeHeader,
and then calculate the CheckSum32 with MicrocodeHeader+MicrocodeBinary.
This patch already verified on ICL platform.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chen A Chen 
Cc: Ray Ni 
Cc: Eric Dong 
Cc: Zhang Chao B 
---
 UefiCpuPkg/Library/MpInitLib/Microcode.c | 82 
 1 file changed, 73 insertions(+), 9 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/Microcode.c 
b/UefiCpuPkg/Library/MpInitLib/Microcode.c
index d84344c6f5..e1f661d6b1 100644
--- a/UefiCpuPkg/Library/MpInitLib/Microcode.c
+++ b/UefiCpuPkg/Library/MpInitLib/Microcode.c
@@ -35,6 +35,42 @@ GetCurrentMicrocodeSignature (
 /**
   Detect whether specified processor can find matching microcode patch and 
load it.
 
+  Microcode Payload as the following format:
+  ++--+
+  |  CPU_MICROCODE_HEADER  |  |
+  ++  CheckSum Part1  |
+  |Microcode Binary|  |
+  ++--+
+  |  CPU_MICROCODE_EXTENDED_TABLE_HEADER   |  |
+  ++  CheckSum Part2  |
+  |  CPU_MICROCODE_EXTENDED_TABLE  |  |
+  |   ...  |  |
+  ++--+
+
+  There may by multiple CPU_MICROCODE_EXTENDED_TABLE in this format.
+  The count of CPU_MICROCODE_EXTENDED_TABLE is indicated by 
ExtendedSignatureCount
+  of CPU_MICROCODE_EXTENDED_TABLE_HEADER structure.
+
+  When we are trying to verify the CheckSum32 with extended table.
+  We should use the fields of exnteded table to replace the corresponding
+  fields in CPU_MICROCODE_HEADER structure, and recalculate the
+  CheckSum32 with CPU_MICROCODE_HEADER + Microcode Binary. We named
+  it as CheckSum Part3.
+
+  The CheckSum Part2 is used to verify the CPU_MICROCODE_EXTENDED_TABLE_HEADER
+  and CPU_MICROCODE_EXTENDED_TABLE parts. We should make sure CheckSum Part2
+  is correct before we are going to verify each CPU_MICROCODE_EXTENDED_TABLE.
+
+  Only ProcessorSignature, ProcessorFlag and CheckSum are different between
+  CheckSum Part1 and CheckSum Part3. To avoid multiple computing CheckSum 
Part3.
+  Save an in-complete CheckSum32 from CheckSum Part1 for common parts.
+  When we are going to calculate CheckSum32, just should use the corresponding 
part
+  of the ProcessorSignature, ProcessorFlag and CheckSum with in-complete 
CheckSum32.
+
+  Notes: CheckSum32 is not a strong verification.
+ It does not guarantee that the data has not been modified.
+ CPU has its own mechanism to verify Microcode Binary part.
+
   @param[in]  CpuMpDataThe pointer to CPU MP Data structure.
   @param[in]  IsBspCallIn  Indicate whether the caller is BSP or not.
 **/
@@ -57,6 +93,7 @@ MicrocodeDetect (
   UINT32  LatestRevision;
   UINTN   TotalSize;
   UINT32  CheckSum32;
+  UINT32  InCompleteCheckSum32;
   BOOLEAN CorrectMicrocode;
   VOID*MicrocodeData;
   MSR_IA32_PLATFORM_ID_REGISTER   PlatformIdMsr;
@@ -121,6 +158,25 @@ MicrocodeDetect (
   MicrocodeData  = NULL;
   MicrocodeEnd = (UINTN) (CpuMpData->MicrocodePatchAddress + 
CpuMpData->MicrocodePatchRegionSize);
   MicrocodeEntryPoint = (CPU_MICROCODE_HEADER *) (UINTN) 
CpuMpData->MicrocodePatchAddress;
+
+  //
+  // Save an in-complete CheckSum32 from CheckSum Part1 for common parts.
+  //
+  if (MicrocodeEntryPoint->DataSize == 0) {
+InCompleteCheckSum32 = CalculateSum32 (
+ (UINT32 *) MicrocodeEntryPoint,
+ sizeof (CPU_MICROCODE_HEADER) + 2000
+ );
+  } else {
+InCompleteCheckSum32 = CalculateSum32 (
+ (UINT32 *) MicrocodeEntryPoint,
+ sizeof (CPU_MICROCODE_HEADER) + 
MicrocodeEntryPoint->DataSize
+ );
+  }
+  InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorSignature.Uint32;
+  InCompleteCheckSum32 -= MicrocodeEntryPoint->ProcessorFlags;
+  InCompleteCheckSum32 -= MicrocodeEntryPoint->Checksum;
+
   do {
 //
 // Check if the microcode is for the Cpu and the version is newer
@@ -137,14 +193,13 @@ MicrocodeDetect (
   MicrocodeEntryPoint->UpdateRevision > LatestRevision &&
   

Re: [edk2] [edk2-announce] Community Meeting Minutes

2019-02-19 Thread stephano

On 2/19/2019 10:23 PM, stephano wrote:


Groups.io
-
Laszlo and I will evaluate Groups.io, however initial impressions is 
that this will work as a communication platform going forward. We'd like 
to use this for design discussions and as a replacement for our current 
mailing list as 01.org does not allow attachments or whistling.


I have double checked, and indeed, 01.org does not allow whistling of 
any kind. Thank you autocorrect for that insightful suggestion.


I would like to note that 01.org also does not allow white-listing, 
something perhaps more valuable to our community.


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


[edk2] [edk2-announce] Community Meeting Minutes

2019-02-19 Thread stephano

An HTML version is available here:
https://www.tianocore.org/minutes/Community-2019-02.html

Github Pull Requests
-
We are still considering Github as a possible platform for patch review. 
There are two issues we'd like to overcome:


1. comprehensive email notifications or backup/archival functionality
2. workflow for users that do not have a consistent internet connection

The notification issue degrades our current ability to archive the 
history of a patch review. Github notifications do not provide:


1. the subject line of the patch
2. trailing code context of comments (code that comes AFTER the comment)
3. the commit message

In this way, it is hard to avoid losing the meaning of the pull request 
conversation if we were to move to a different system some day. The 
longevity of PR branches is also a concern, and a workaround would need 
to be found and maintained. We need to be sure that PR branches can be 
easily archived so that if a Github user deletes their account, even if 
their PR was rejected, the code would be available.


Jeremiah and I are both looking for work around to these issues, 
hopefully without having to maintain more code. See here for details on 
Laszlo's thorough Github evaluation:


https://lists.01.org/pipermail/edk2-devel/2018-December/033509.html

To be clear, these hurtles do not *have to be* overcome. They were 
brought up by several maintainers and community members. They are simply 
barriers that we want to discuss fully before committing to a 
transition. It is impossible to "change our mind" on this transition 
without some loss of data, so best we be sure before we switch.


Working in a community means providing consistent messaging, clear 
expectations, and the understanding that each member is valuable. 
Working in the open means moderating, evaluating, and distilling input 
from community members and companies without bias or prejudice. I take 
this transition seriously and do not plan to rush it.


Gerrit Code Review
-
Gerrit code review is viable platform, but Intel's implementation of the 
'repo' tool is still working on being open sourced. Also, there would be 
a lot of work that would go into implementing a proper Gerrit solution. 
If someone would like to volunteer to carry this out, please feel free 
to contact me, but I'm going to postpone this for the moment as my 
schedule is rather full.


Groups.io
-
Laszlo and I will evaluate Groups.io, however initial impressions is 
that this will work as a communication platform going forward. We'd like 
to use this for design discussions and as a replacement for our current 
mailing list as 01.org does not allow attachments or whistling. Also, 
Groups.io allows for online search of the list, chats, and uploads which 
is much easier for some than searching through emails. Assuming this is 
successful, I will work with 01.org to archive all (if possible) of the 
edk2-devel mailing list into groups.io for a (mostly) seamless 
transition. I will see how long 01.org is willing to store archives, and 
will notify the community of how long that archive will be available.


Community Bug Triage
-
Community bug triage meetings will occur every two weeks, and we will 
have 2 meetings to accommodate both sets of timezones. See here for details:


https://www.tianocore.org/bug-triage/

I will be working to develop bugzilla reports and researching possible 
platforms that we could add to a community CI. Maintaining these 
platforms would be a great way to add to the list of community bugs and 
encourage open development.


Community Design
-
We will be starting the community design meetings in March and holding 
them every 2 weeks. If we find that there are enough submissions we can 
meet every week. I will hold two meetings, much like the community 
meetings. Any submission will be discussed in both meeting and notes 
sent out in the meeting minutes. Discussion can then continue on the 
mailing list. I will send out an RFC for folks to submit possible topics 
the day before each meeting.


Rust in EDK II Exploration Notes
--
I have been working with the Rust community, as well as members of 
Intel's Firmware Security teams, to explore the benefits of using Rust 
in EDK II. For those of you who have never heard of Rust, please take 
some time to look into it:


https://en.wikipedia.org/wiki/Rust_(programming_language)

Here is a brief overview of the pros/cons:

Benefits of Rust
Rust is a modern language with features like counted buffers and 
strings. It can call C code and be called by C code. It requires no 
calls to "free", and does so without garbage collection by statically 
inserting calls to "free" for you. Rust types keep track of which 
structs own which memory chunks so that developers do not have to keep 
track of ownership of struct memory. Rust includes a lot of 

Re: [edk2] [PATCH] MdeModulePkg/VariableSmmRuntimeDxe: Refactor locating Variable Arch Protocol

2019-02-19 Thread Jagadeesh Ujja
hi Ard,
On Tue, Feb 19, 2019 at 6:55 PM Ard Biesheuvel
 wrote:
>
> Hello Jagadeesh,
>
> On Tue, 19 Feb 2019 at 11:47, Jagadeesh Ujja  wrote:
> >
> > In preparation for providing a standalone MM based non-secure variable
> > runtime driver, factor out some portions that are specific to the
> > traditional driver, mainly related to locating variable arch protocol
> > and variable write arch protocol, which are not required to be located
> > when using standalone MM based secure variable implementation.
> >
>
> While i think this change is correct from a technical perspective, I
> don't think this is the right approach.
>
these changes are mandatory, this is one of the possible solution.

> It was a deliberate decision to expose the MM services in a way that
> only the producer of the communication protocol is aware of the
> implementation details, i.e., whether it is backed by tradtional MM or
> standalone MM.
>
can you please provide more details on how "exposing the MM services"
will help to resolve the issue here. if this helps, definitely i will use that.

> By creating separate runtime DXE drivers that can work either with the
> traditional MM or the standalone MM, you are defeating that, and so we
> should discuss this at a more fundamental level, and also take into
> account the other issue we ran into, where the communicate protocol
> needs either the physical address of the comm buffer (in the
> traditional MM case) or the virtual address (in the standalone MM
> case).
>
> Both issues suggest that perhaps the 'abstract' MM communicate
> protocol is not feasible in practice, in which case this patch would
> probably be an appropriate course of action.
>
> If not, we should discuss how in general DXE runtime drivers that
> DEPEX on protocols produced by SMM drivers should be implemented based
> on this abstract MM model. One potential approach could be to
> introduce a library that encapsulates this dependency, and leave it up
> to the platform to make it depend on whichever dependencies it
> defines.
>
>
>
>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Jagadeesh Ujja 
> > ---
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h  
> >| 18 
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 
> >|  9 +-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf   
> >|  1 +
> >  
> > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.c 
> >   | 42 +
> >  
> > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.inf
> >  | 95 
> >  
> > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMmRuntimeDxe.c
> >   | 45 ++
> >  6 files changed, 203 insertions(+), 7 deletions(-)
> >
> > diff --git 
> > a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h 
> > b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> > index 9b294e6..c50 100644
> > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> > @@ -160,4 +160,22 @@ VariableHaveTcgProtocols (
> >VOID
> >);
> >
> > +/**
> > +  Check whether the protocol is installed or not.
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +VariableLocateSmmReady (
> > +  VOID
> > +  );
> > +
> > +/**
> > +  Check whether the protocol is installed or not.
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +VariableLocateSmmWriteReady (
> > +  VOID
> > +  );
> > +
> >  #endif
> > diff --git 
> > a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 
> > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> > index 85d655d..2976f04 100644
> > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> > @@ -47,7 +47,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
> > EXPRESS OR IMPLIED.
> >  #include "PrivilegePolymorphic.h"
> >
> >  EFI_HANDLE   mHandle= NULL;
> > -EFI_SMM_VARIABLE_PROTOCOL   *mSmmVariable   = NULL;
> >  EFI_EVENTmVirtualAddressChangeEvent = NULL;
> >  EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication  = NULL;
> >  UINT8   *mVariableBuffer= NULL;
> > @@ -991,7 +990,7 @@ SmmVariableReady (
> >  {
> >EFI_STATUSStatus;
> >
> > -  Status = gBS->LocateProtocol (, NULL, (VOID 
> > **));
> > +  Status = VariableLocateSmmReady ();
> >if (EFI_ERROR (Status)) {
> >  return;
> >}
> > @@ -1068,12 +1067,8 @@ SmmVariableWriteReady (
> >)
> >  {
> >EFI_STATUSStatus;
> > -  VOID  *ProtocolOps;
> >
> > -  //
> > -  // Check whether the protocol is installed or not.
> 

Re: [edk2] [PATCH 2/2] ArmPlatformPkg/NorFlash: Allow reusability as a MM driver

2019-02-19 Thread Jagadeesh Ujja
On Tue, Feb 19, 2019 at 10:14 PM Ard Biesheuvel
 wrote:
>
> Hello Jagadeesh,
>
Hi Ard,

Thank you for your valuable comments. Will do the appropriate changes
based on your comments and publish in the next patchset

Regards,
Jagadeesh
> On Tue, 19 Feb 2019 at 11:32, Jagadeesh Ujja  wrote:
> >
> > Adapt the NorFlash driver to be used as a MM_STANDALONE driver to
> > allow access to NOR flash for code executing in MM_STANDALONE mode.
> > This allows storing of EFI variables on NOR flash which is accessible
> > only via the MM STANDALONE mode software.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Jagadeesh Ujja 
> > ---
> >  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c   | 267 
> > 
> >  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  77 ++
> >  2 files changed, 344 insertions(+)
> >
> > diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c 
> > b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
> > new file mode 100644
> > index 000..1e3603c
> > --- /dev/null
> > +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
> > @@ -0,0 +1,267 @@
> > +/*++ @file  NorFlashStandaloneMm.c
> > +
> > + Copyright (c) 2019, 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 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
>
> Please sort alphabetically - I know this originates in existing code,
> but it is a brand new file so let's make it clean from the start.
>
> > +
> > +#include 
> > +#include 
> > +#include 
>
> I don't think we need this - please see below.
>
> > +#include "NorFlash.h"
> > +
> > +//
> > +// Global variable declarations
> > +//
> > +NOR_FLASH_INSTANCE **mNorFlashInstances;
> > +UINT32   mNorFlashDeviceCount;
> > +
>
> These are definitions, not declarations. Could they be moved to a
> shared .c file instead?
>
> > +extern NOR_FLASH_INSTANCE  mNorFlashInstanceTemplate;
>
> Move this to a header?
>
> > +
> > +EFI_STATUS
> > +EFIAPI
> > +NorFlashFvbInitialize (
> > +  IN NOR_FLASH_INSTANCE* Instance
> > +  )
> > +{
> > +  EFI_STATUS  Status;
> > +  UINT32  FvbNumLba;
> > +  EFI_BOOT_MODE BootMode;
> > +
> > +  DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
> > +  ASSERT((Instance != NULL));
> > +
> > +  mFlashNvStorageVariableBase = FixedPcdGet32 
> > (PcdFlashNvStorageVariableBase);
> > +
> > +  // Set the index of the first LBA for the FVB
> > +  Instance->StartLba = (PcdGet32 (PcdFlashNvStorageVariableBase) - 
> > Instance->RegionBaseAddress) / Instance->Media.BlockSize;
> > +
>
> Please wrap to 80 columns
>
> > +  BootMode = GetBootModeHob ();
>
> Where does the boot mode HOB come from in standalone MM?
>
> > +  if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
> > +Status = EFI_INVALID_PARAMETER;
> > +  } else {
> > +// Determine if there is a valid header at the beginning of the 
> > NorFlash
> > +Status = ValidateFvHeader (Instance);
> > +  }
> > +
>
>
> > +  // Install the Default FVB header if required
> > +  if (EFI_ERROR(Status)) {
> > +// There is no valid header, so time to install one.
> > +DEBUG ((EFI_D_INFO, "%a: The FVB Header is not valid.\n", 
> > __FUNCTION__));
> > +DEBUG ((EFI_D_INFO, "%a: Installing a correct one for this volume.\n",
> > +  __FUNCTION__));
> > +
>
> Please use DEBUG_INFO not EFI_D_INFO (the latter form is deprecated)
>
> > +// Erase all the NorFlash that is reserved for variable storage
> > +FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + 
> > PcdGet32(PcdFlashNvStorageFtwWorkingSize) + 
> > PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
> > +
>
> Please wrap to 80 columns
>
> > +Status = FvbEraseBlocks (>FvbProtocol, (EFI_LBA)0, 
> > FvbNumLba, EFI_LBA_LIST_TERMINATOR);
> > +if (EFI_ERROR(Status)) {
> > +  return Status;
> > +}
> > +
> > +// Install all appropriate headers
> > +Status = InitializeFvAndVariableStoreHeaders (Instance);
> > +if (EFI_ERROR(Status)) {
> > +  return Status;
> > +}
>
> This if {} is redundant since we will be returning Status anyway.
>
> > +  }
> > +
> > +  return Status;
> > +}
> > +
> > +VOID
> > +EFIAPI
> > +NorFlashLock (
> > +  NOR_FLASH_LOCK_CONTEXT*Context
> > +  )
> > +{
> > +}
> > +
> > +VOID
> > +EFIAPI
> > +NorFlashUnlock (
> > +  NOR_FLASH_LOCK_CONTEXT*Context
> > +  )
> > +{
> > +}
> > +
> > +EFI_STATUS
> > 

[edk2] [PATCH v2 5/6] MdeModulePkg: Add a runtime library instance of ResetSystemLib

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1461

Implement a runtime library instance of ResetSystemLib. It would
use a internal point instead of gRT and convert it depend on
gEfiEventVirtualAddressChangeGuid.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 
---
 .../RuntimeResetSystemLib/RuntimeResetSystemLib.c  | 216 +
 .../RuntimeResetSystemLib.inf  |  50 +
 .../RuntimeResetSystemLib.uni  |  21 ++
 3 files changed, 287 insertions(+)
 create mode 100644 
MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c
 create mode 100644 
MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf
 create mode 100644 
MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.uni

diff --git a/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c 
b/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c
new file mode 100644
index 00..17826cd6a9
--- /dev/null
+++ b/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c
@@ -0,0 +1,216 @@
+/** @file
+  DXE Reset System Library instance that calls gRT->ResetSystem().
+
+  Copyright (c) 2017 - 2019, 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
+  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 
+
+EFI_EVENT mRuntimeResetSystemLibVirtualAddressChangeEvent;
+EFI_RUNTIME_SERVICES  *mInternalRT;
+
+/**
+  This function causes a system-wide reset (cold reset), in which
+  all circuitry within the system returns to its initial state. This type of 
reset
+  is asynchronous to system operation and operates without regard to
+  cycle boundaries.
+
+  If this function returns, it means that the system does not support cold 
reset.
+**/
+VOID
+EFIAPI
+ResetCold (
+  VOID
+  )
+{
+  mInternalRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+  This function causes a system-wide initialization (warm reset), in which all 
processors
+  are set to their initial state. Pending cycles are not corrupted.
+
+  If this function returns, it means that the system does not support warm 
reset.
+**/
+VOID
+EFIAPI
+ResetWarm (
+  VOID
+  )
+{
+  mInternalRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+  This function causes the system to enter a power state equivalent
+  to the ACPI G2/S5 or G3 states.
+
+  If this function returns, it means that the system does not support shut 
down reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+  VOID
+  )
+{
+  mInternalRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+}
+
+/**
+  This function causes the system to enter S3 and then wake up immediately.
+
+  If this function returns, it means that the system does not support S3 
feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+  VOID
+  )
+{
+}
+
+/**
+  This function causes a systemwide reset. The exact type of the reset is
+  defined by the EFI_GUID that follows the Null-terminated Unicode string 
passed
+  into ResetData. If the platform does not recognize the EFI_GUID in ResetData
+  the platform must pick a supported reset type to perform.The platform may
+  optionally log the parameters from any non-normal reset that occurs.
+
+  @param[in]  DataSize   The size, in bytes, of ResetData.
+  @param[in]  ResetData  The data buffer starts with a Null-terminated string,
+ followed by the EFI_GUID.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+  IN UINTN   DataSize,
+  IN VOID*ResetData
+  )
+{
+  mInternalRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, 
ResetData);
+}
+
+/**
+  The ResetSystem function resets the entire platform.
+
+  @param[in] ResetType  The type of reset to perform.
+  @param[in] ResetStatusThe status code for the reset.
+  @param[in] DataSize   The size, in bytes, of ResetData.
+  @param[in] ResetData  For a ResetType of EfiResetCold, EfiResetWarm, or 
EfiResetShutdown
+the data buffer starts with a Null-terminated 
string, optionally
+followed by additional binary data. The string is 
a description
+that the caller may use to further indicate the 
reason for the
+system reset. ResetData is only valid if 
ResetStatus is something
+other than EFI_SUCCESS unless the ResetType is 
EfiResetPlatformSpecific
+where a minimum amount of ResetData is always 
required.

[edk2] [PATCH v2 4/6] MdeModulePkg: Add the new API ResetSystem in the head file

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1460

Add the new API ResetSystem in the related head file so that
the consumer can use it through the combination of library
instance and head file.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 
---
 MdeModulePkg/Include/Library/ResetSystemLib.h | 28 ++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Library/ResetSystemLib.h 
b/MdeModulePkg/Include/Library/ResetSystemLib.h
index 55d1923ae1..05e3e7d30f 100644
--- a/MdeModulePkg/Include/Library/ResetSystemLib.h
+++ b/MdeModulePkg/Include/Library/ResetSystemLib.h
@@ -2,7 +2,7 @@
   System reset Library Services.  This library class defines a set of
   methods that reset the whole system.
 
-Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2019, 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
@@ -16,6 +16,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #ifndef __RESET_SYSTEM_LIB_H__
 #define __RESET_SYSTEM_LIB_H__
 
+#include 
+#include 
+
 /**
   This function causes a system-wide reset (cold reset), in which
   all circuitry within the system returns to its initial state. This type of 
reset
@@ -83,4 +86,27 @@ ResetPlatformSpecific (
   IN VOID*ResetData
   );
 
+/**
+  The ResetSystem function resets the entire platform.
+
+  @param[in] ResetType  The type of reset to perform.
+  @param[in] ResetStatusThe status code for the reset.
+  @param[in] DataSize   The size, in bytes, of ResetData.
+  @param[in] ResetData  For a ResetType of EfiResetCold, EfiResetWarm, or 
EfiResetShutdown
+the data buffer starts with a Null-terminated 
string, optionally
+followed by additional binary data. The string is 
a description
+that the caller may use to further indicate the 
reason for the
+system reset. ResetData is only valid if 
ResetStatus is something
+other than EFI_SUCCESS unless the ResetType is 
EfiResetPlatformSpecific
+where a minimum amount of ResetData is always 
required.
+**/
+VOID
+EFIAPI
+ResetSystem (
+  IN EFI_RESET_TYPE   ResetType,
+  IN EFI_STATUS   ResetStatus,
+  IN UINTNDataSize,
+  IN VOID *ResetData OPTIONAL
+  );
+
 #endif
-- 
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 6/6] MdeModulePkg: Add the runtime ResetSystemLib in MdeModulePkg.dsc

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1461

Add the runtime library instance of ResetSystemLib in
MdeModulePkg.dsc to make sure it can build pass.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 
---
 MdeModulePkg/MdeModulePkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 3b315fca5a..790a5fa05d 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -286,6 +286,7 @@
   MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
   MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   
MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
+  MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf
   MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
   MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
   
MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.inf
-- 
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 2/6] MdeModulePkg: Add a new API ResetSystem for DXE ResetSystemLib

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1460

Add a new API ResetSystem for DXE ResetSystemLib. So the consumer of
ResetSystemLib can use this API to reset system with additional reset
data.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 
---
 .../Library/DxeResetSystemLib/DxeResetSystemLib.c  | 28 +-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c 
b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
index ea4878cab1..f5c7386c9a 100644
--- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
+++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
@@ -1,7 +1,7 @@
 /** @file
   DXE Reset System Library instance that calls gRT->ResetSystem().
 
-  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2019, 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
@@ -96,3 +96,29 @@ ResetPlatformSpecific (
 {
   gRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, 
ResetData);
 }
+
+/**
+  The ResetSystem function resets the entire platform.
+
+  @param[in] ResetType  The type of reset to perform.
+  @param[in] ResetStatusThe status code for the reset.
+  @param[in] DataSize   The size, in bytes, of ResetData.
+  @param[in] ResetData  For a ResetType of EfiResetCold, EfiResetWarm, or 
EfiResetShutdown
+the data buffer starts with a Null-terminated 
string, optionally
+followed by additional binary data. The string is 
a description
+that the caller may use to further indicate the 
reason for the
+system reset. ResetData is only valid if 
ResetStatus is something
+other than EFI_SUCCESS unless the ResetType is 
EfiResetPlatformSpecific
+where a minimum amount of ResetData is always 
required.
+**/
+VOID
+EFIAPI
+ResetSystem (
+  IN EFI_RESET_TYPE   ResetType,
+  IN EFI_STATUS   ResetStatus,
+  IN UINTNDataSize,
+  IN VOID *ResetData OPTIONAL
+  )
+{
+  gRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
+}
-- 
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 1/6] MdeModulePkg: change the function name ResetSystem

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1460

Change the function name form ResetSystem to EfiRuntimeResetSystem.
Because ResetSystem and EfiResetSystem would be used in ResetSystemLib
and RuntimeLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 
---
 MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c | 8 
 MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c 
b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
index afc35587fc..e16b0cda7b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
@@ -1,7 +1,7 @@
 /** @file
   Reset Architectural and Reset Notification protocols implementation.
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, 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
@@ -187,7 +187,7 @@ InitializeResetSystem (
   //
   // Hook the runtime service table
   //
-  gRT->ResetSystem = ResetSystem;
+  gRT->ResetSystem = EfiRuntimeResetSystem;
 
   //
   // Now install the Reset RT AP on a new handle
@@ -242,7 +242,7 @@ DoS3 (
 **/
 VOID
 EFIAPI
-ResetSystem (
+EfiRuntimeResetSystem (
   IN EFI_RESET_TYPE   ResetType,
   IN EFI_STATUS   ResetStatus,
   IN UINTNDataSize,
@@ -256,7 +256,7 @@ ResetSystem (
   RESET_NOTIFY_ENTRY  *Entry;
 
   //
-  // Only do REPORT_STATUS_CODE() on first call to ResetSystem()
+  // Only do REPORT_STATUS_CODE() on first call to EfiRuntimeResetSystem()
   //
   if (mResetNotifyDepth == 0) {
 //
diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h 
b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
index 8529de675c..448e30f079 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2019, 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
@@ -97,7 +97,7 @@ InitializeResetSystem (
 **/
 VOID
 EFIAPI
-ResetSystem (
+EfiRuntimeResetSystem (
   IN EFI_RESET_TYPE   ResetType,
   IN EFI_STATUS   ResetStatus,
   IN UINTNDataSize,
-- 
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 0/6] ResetSystemLib changings

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1460
Add a new API ResetSystem in ResetSystemLib.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1461
Implement a runtime library instance of ResetSystemLib
base on the new changing.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 

Zhichao Gao (6):
  MdeModulePkg: change the function name ResetSystem
  MdeModulePkg: Add a new API ResetSystem for DXE ResetSystemLib
  MdeModulePkg: Add a new API ResetSystem for Null version
  MdeModulePkg: Add the new API ResetSystem in the head file
  MdeModulePkg: Add a runtime library instance of ResetSystemLib
  MdeModulePkg: Add the runtime ResetSystemLib in MdeModulePkg.dsc

 MdeModulePkg/Include/Library/ResetSystemLib.h  |  28 ++-
 .../BaseResetSystemLibNull.c   |  27 +++
 .../Library/DxeResetSystemLib/DxeResetSystemLib.c  |  28 ++-
 .../RuntimeResetSystemLib/RuntimeResetSystemLib.c  | 216 +
 .../RuntimeResetSystemLib.inf  |  50 +
 .../RuntimeResetSystemLib.uni  |  21 ++
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 .../Universal/ResetSystemRuntimeDxe/ResetSystem.c  |   8 +-
 .../Universal/ResetSystemRuntimeDxe/ResetSystem.h  |   4 +-
 9 files changed, 375 insertions(+), 8 deletions(-)
 create mode 100644 
MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c
 create mode 100644 
MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf
 create mode 100644 
MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.uni

-- 
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 3/6] MdeModulePkg: Add a new API ResetSystem for Null version

2019-02-19 Thread Zhichao Gao
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1460

Add a new API ResetSystem for BaseResetSystemLibNull to be
in accord with other instances.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao 
Cc: Ray Ni 
Cc: Liming Gao 
---
 .../BaseResetSystemLibNull.c   | 27 ++
 1 file changed, 27 insertions(+)

diff --git 
a/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c 
b/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c
index 59d720895b..875f839175 100644
--- a/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c
+++ b/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c
@@ -98,3 +98,30 @@ ResetPlatformSpecific (
 {
   ResetCold ();
 }
+
+/**
+  The ResetSystem function resets the entire platform.
+
+  @param[in] ResetType  The type of reset to perform.
+  @param[in] ResetStatusThe status code for the reset.
+  @param[in] DataSize   The size, in bytes, of ResetData.
+  @param[in] ResetData  For a ResetType of EfiResetCold, EfiResetWarm, or 
EfiResetShutdown
+the data buffer starts with a Null-terminated 
string, optionally
+followed by additional binary data. The string is 
a description
+that the caller may use to further indicate the 
reason for the
+system reset. ResetData is only valid if 
ResetStatus is something
+other than EFI_SUCCESS unless the ResetType is 
EfiResetPlatformSpecific
+where a minimum amount of ResetData is always 
required.
+**/
+VOID
+EFIAPI
+ResetSystem (
+  IN EFI_RESET_TYPE   ResetType,
+  IN EFI_STATUS   ResetStatus,
+  IN UINTNDataSize,
+  IN VOID *ResetData OPTIONAL
+  )
+{
+  ASSERT (FALSE);
+}
+
-- 
2.16.2.windows.1

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


[edk2] [PATCH] BaseTools:Build fail if define [DEPEX] in library inf

2019-02-19 Thread Fan, ZhijuX
When define [DEPEX] in lib inf to build, it will fail and report"
gUefiOvmfPkgTokenSpaceGuid.test1 used in [Depex] section should be
used as FixedAtBuild type and VOID* datum type in the module."
But we define this PCD to FixedAtBuild type and VOID* datum type indeed.

DEC:
[PcdsFixedAtBuild]
gUefiOvmfPkgTokenSpaceGuid.test1 | 
{GUID("4096267b-da0a-42eb-b5eb-fef31d207cb4")}|VOID*|0x3c

DSC:
add pcd under lib inf as below:

NULL|TestPkg/TestLib/TestLib.inf
 
gUefiOvmfPkgTokenSpaceGuid.test1 | {GUID(gUefiOvmfPkgTokenSpaceGuid)}

Lib inf:(TestPkg/TestLib/TestLib.inf)
[Depex]
gUefiOvmfPkgTokenSpaceGuid.test1
[FixedPcd]
gUefiOvmfPkgTokenSpaceGuid.test1

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2452ecbcba..e64be656e8 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2892,10 +2892,16 @@ class ModuleAutoGen(AutoGen):
 if '.' not in item:
 NewList.append(item)
 else:
-if item not in self.FixedVoidTypePcds:
+FixedVoidTypePcds = {}
+if M in self.PlatformInfo.LibraryAutoGenList:
+Index = 
self.PlatformInfo.LibraryAutoGenList.index(M)
+FixedVoidTypePcds = 
self.PlatformInfo.LibraryAutoGenList[Index].FixedVoidTypePcds
+if item in self.FixedVoidTypePcds:
+FixedVoidTypePcds = self.FixedVoidTypePcds
+if item not in FixedVoidTypePcds:
 EdkLogger.error("build", FORMAT_INVALID, "{} used 
in [Depex] section should be used as FixedAtBuild type and VOID* datum type in 
the module.".format(item))
 else:
-Value = self.FixedVoidTypePcds[item]
+Value = FixedVoidTypePcds[item]
 if len(Value.split(',')) != 16:
 EdkLogger.error("build", FORMAT_INVALID,
 "{} used in [Depex] section 
should be used as FixedAtBuild type and VOID* datum type and 16 bytes in the 
module.".format(item))
-- 
2.14.1.windows.1

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


Re: [edk2] [PATCH] SecurityPkg/TcgConfigDxe: Allow enabling TPM 1.2 device from disabled state.

2019-02-19 Thread Yao, Jiewen
Thanks for the enhancement.

Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Gonzalez Del Cueto, Rodrigo
> Sent: Monday, February 4, 2019 2:07 PM
> To: edk2-devel@lists.01.org
> Cc: Gonzalez Del Cueto, Rodrigo ;
> Zhang, Chao B ; Yao, Jiewen
> 
> Subject: [PATCH] SecurityPkg/TcgConfigDxe: Allow enabling TPM 1.2 device
> from disabled state.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1511
> 
> Currently the TCG config setup form defaults the physical presence action to
> PHYSICAL_PRESENCE_ENABLE, this prevents the action from being called.
> When a TPM
> 1.2 device is in Disabled and Activated state it is not possible to issue the
> PHYSICAL_PRESENCE_ENABLE using the menu action.
> 
> By having the form default to PHYSICAL_PRESENCE_NO_ACTION, the user is
> now able
> to select PHYSICAL_PRESENCE_ENABLE and toggle the TPM 1.2 device
> enable state.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> 
> Signed-off-by: Rodrigo Gonzalez del Cueto
> 
> Cc: Chao Zhang 
> Cc: Jiewen Yao 
> ---
>  SecurityPkg/Tcg/TcgConfigDxe/TcgConfig.vfr| 8 ++--
>  SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c  | 4 ++--
>  SecurityPkg/Tcg/TcgConfigDxe/TcgConfigStrings.uni | 3 ++-
>  3 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfig.vfr
> b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfig.vfr
> index b0a7bf6f47..1047475cef 100644
> --- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfig.vfr
> +++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfig.vfr
> @@ -1,7 +1,7 @@
>  /** @file
>VFR file used by the TCG configuration component.
> 
> -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2011 - 2019, 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
> @@ -43,6 +43,10 @@ formset
>help   = STRING_TOKEN(STR_TPM_OPERATION_HELP),
>flags  = INTERACTIVE | RESET_REQUIRED,
>//
> +  // Default the form to NO ACTION to allow toggling other
> options
> +  //
> +  option text = STRING_TOKEN(STR_NO_ACTION), value =
> PHYSICAL_PRESENCE_NO_ACTION, flags = DEFAULT;
> +  //
>// Disable (TPM_ORD_PhysicalDisable) command is not
> available when disabled.
>// Activate/deactivate (TPM_ORD_physicalSetDeactivated)
> command is not available when disabled.
>//
> @@ -61,7 +65,7 @@ formset
>  option text =
> STRING_TOKEN(STR_TPM_CLEAR_ENABLE_ACTIVATE), value =
> PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE, flags = 0;
>endif
> 
> -  option text = STRING_TOKEN(STR_ENABLE), value =
> PHYSICAL_PRESENCE_ENABLE, flags = DEFAULT;
> +  option text = STRING_TOKEN(STR_ENABLE), value =
> PHYSICAL_PRESENCE_ENABLE, flags = 0;
>option text = STRING_TOKEN(STR_TPM_ENABLE_ACTIVATE),
> value = PHYSICAL_PRESENCE_ENABLE_ACTIVATE, flags = 0;
>option text =
> STRING_TOKEN(STR_TPM_ENABLE_ACTIVATE_CLEAR), value =
> PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR, flags = 0;
>option text =
> STRING_TOKEN(STR_TPM_ENABLE_ACTIVATE_CLEAR_E_A), value =
> PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE, flags
> = 0;
> diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
> b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
> index a3065c..4455fd2b48 100644
> --- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
> +++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
> @@ -1,7 +1,7 @@
>  /** @file
>HII Config Access protocol implementation of TCG configuration module.
> 
> -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2011 - 2019, 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
> @@ -176,7 +176,7 @@ TcgExtractConfig (
>//
>// Convert buffer data to  by helper function
> BlockToConfig()
>//
> -  PrivateData->Configuration->TpmOperation =
> PHYSICAL_PRESENCE_ENABLE;
> +  PrivateData->Configuration->TpmOperation =
> PHYSICAL_PRESENCE_NO_ACTION;
> 
>//
>// Get current TPM state.
> diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigStrings.uni
> b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigStrings.uni
> index 7a84462a6e..3c3f0f7ddb 100644
> --- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigStrings.uni
> +++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigStrings.uni
> @@ -1,7 +1,7 @@
>  /** @file
>String definitions for TCG configuration form.
> 
> -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
> +Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved.
>  This program and the accompanying materials
>  

Re: [edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when fail to load/start boot option

2019-02-19 Thread Bi, Dandan
Hi Laszlo,

Thanks for catching this issue.
I am sorry that I didn't consider the alignment issue when working on this 
patch.


Thanks,
Dandan

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Laszlo Ersek
> Sent: Wednesday, February 20, 2019 9:19 AM
> To: Bi, Dandan 
> Cc: Wu, Hao A ; Ni, Ray ; edk2-
> de...@lists.01.org
> Subject: Re: [edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when
> fail to load/start boot option
> 
> Hi Dandan,
> 
> On 02/15/19 09:51, Dandan Bi wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398
> >
> > According to PI1.7 Spec, report extended data describing an EFI_STATUS
> > return value along with EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR
> and
> > EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED status code when fail to load
> or
> > start boot option image.
> >
> > Cc: Jian J Wang 
> > Cc: Hao Wu 
> > Cc: Ruiyu Ni 
> > Cc: Laszlo Ersek 
> > Cc: Sean Brogan 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Dandan Bi 
> > ---
> >  .../Library/UefiBootManagerLib/BmBoot.c   | 22 ++-
> >  1 file changed, 16 insertions(+), 6 deletions(-)
> >
> > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > index 6444fb43eb..9be1633b74 100644
> > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > @@ -1818,15 +1818,20 @@ EfiBootManagerBoot (
> >FreePool (FilePath);
> >  }
> >
> >  if (EFI_ERROR (Status)) {
> >//
> > -  // Report Status Code to indicate that the failure to load boot 
> > option
> > +  // Report Status Code with the failure status to indicate that
> > + the failure to load boot option
> >//
> > -  REPORT_STATUS_CODE (
> > +  REPORT_STATUS_CODE_EX (
> >  EFI_ERROR_CODE | EFI_ERROR_MINOR,
> > -(EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)
> > +(EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR),
> > +0,
> > +NULL,
> > +NULL,
> > +,
> > +sizeof (EFI_STATUS)
> >  );
> >BootOption->Status = Status;
> >//
> >// Destroy the RAM disk
> >//
> > @@ -1902,15 +1907,20 @@ EfiBootManagerBoot (
> >Status = gBS->StartImage (ImageHandle, >ExitDataSize,
> >ExitData);
> >DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n",
> Status));
> >BootOption->Status = Status;
> >if (EFI_ERROR (Status)) {
> >  //
> > -// Report Status Code to indicate that boot failure
> > +// Report Status Code with the failure status to indicate that
> > + boot failure
> >  //
> > -REPORT_STATUS_CODE (
> > +REPORT_STATUS_CODE_EX (
> >EFI_ERROR_CODE | EFI_ERROR_MINOR,
> > -  (EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)
> > +  (EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED),
> > +  0,
> > +  NULL,
> > +  NULL,
> > +  ,
> > +  sizeof (EFI_STATUS)
> >);
> >}
> >PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32)
> > OptionNumber);
> >
> >//
> >
> 
> Unfortunately, this patch is not good; we made a mistake here.
> 
> Consider the EFI_RETURN_STATUS_EXTENDED_DATA structure, added in
> patch
> #1:
> 
> > typedef struct {
> >   ///
> >   /// The data header identifying the data:
> >   /// DataHeader.HeaderSize should be sizeof(EFI_STATUS_CODE_DATA),
> >   /// DataHeader.Size should be
> sizeof(EFI_RETURN_STATUS_EXTENDED_DATA) - HeaderSize,
> >   /// DataHeader.Type should be EFI_STATUS_CODE_SPECIFIC_DATA_GUID.
> >   ///
> >   EFI_STATUS_CODE_DATA DataHeader;
> >   ///
> >   /// The EFI_STATUS return value of the service or function whose failure
> triggered the
> >   /// reporting of the status code (generally an error code or a debug 
> > code).
> >   ///
> >   EFI_STATUS   ReturnStatus;
> > } EFI_RETURN_STATUS_EXTENDED_DATA;
> 
> According to the UEFI spec, unless specified otherwise, structure members
> are aligned naturally.
> 
> And, the PI spec references the UEFI spec with regard to data types.
> 
> Accordingly, when this structure is built for X64, the size of this structure 
> is 32
> bytes, and the offset of ReturnStatus is 24. There is a 4-byte padding
> between DataHeader (which is 20 bytes in size) and the ReturnStatus field.
> DataHeader has type
> 
> > typedef struct {
> >   ///
> >   /// The size of the structure. This is specified to enable future 
> > expansion.
> >   ///
> >   UINT16HeaderSize;
> >   ///
> >   /// The size of the data in bytes. This does not include the size of the
> header structure.
> >   ///
> >   UINT16Size;
> >   ///
> >   /// The GUID defining the type of the data.
> >   ///
> >   EFI_GUID  Type;
> > } EFI_STATUS_CODE_DATA;
> 
> which extends to 20 bytes.
> 
> I'm working on 

Re: [edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when fail to load/start boot option

2019-02-19 Thread Ni, Ray
Laszlo,
Thanks for catching this.

GenPerformMemoryTest() in
MdeModulePkg\Universal\MemoryTest\GenericMemoryTestDxe\LightMemoryTest.c
uses the same technics as you suggested.

I give up to propose another option: having pack(1) for the new status 
structure.


> -Original Message-
> From: Laszlo Ersek 
> Sent: Wednesday, February 20, 2019 9:19 AM
> To: Bi, Dandan 
> Cc: edk2-devel@lists.01.org; Wu, Hao A ; Ni, Ray
> 
> Subject: Re: [edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when
> fail to load/start boot option
> 
> Hi Dandan,
> 
> On 02/15/19 09:51, Dandan Bi wrote:
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398
> >
> > According to PI1.7 Spec, report extended data describing an EFI_STATUS
> > return value along with EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR
> and
> > EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED status code when fail to load
> or
> > start boot option image.
> >
> > Cc: Jian J Wang 
> > Cc: Hao Wu 
> > Cc: Ruiyu Ni 
> > Cc: Laszlo Ersek 
> > Cc: Sean Brogan 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Dandan Bi 
> > ---
> >  .../Library/UefiBootManagerLib/BmBoot.c   | 22 ++-
> >  1 file changed, 16 insertions(+), 6 deletions(-)
> >
> > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > index 6444fb43eb..9be1633b74 100644
> > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> > @@ -1818,15 +1818,20 @@ EfiBootManagerBoot (
> >FreePool (FilePath);
> >  }
> >
> >  if (EFI_ERROR (Status)) {
> >//
> > -  // Report Status Code to indicate that the failure to load boot 
> > option
> > +  // Report Status Code with the failure status to indicate that
> > + the failure to load boot option
> >//
> > -  REPORT_STATUS_CODE (
> > +  REPORT_STATUS_CODE_EX (
> >  EFI_ERROR_CODE | EFI_ERROR_MINOR,
> > -(EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)
> > +(EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR),
> > +0,
> > +NULL,
> > +NULL,
> > +,
> > +sizeof (EFI_STATUS)
> >  );
> >BootOption->Status = Status;
> >//
> >// Destroy the RAM disk
> >//
> > @@ -1902,15 +1907,20 @@ EfiBootManagerBoot (
> >Status = gBS->StartImage (ImageHandle, >ExitDataSize,
> >ExitData);
> >DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n",
> Status));
> >BootOption->Status = Status;
> >if (EFI_ERROR (Status)) {
> >  //
> > -// Report Status Code to indicate that boot failure
> > +// Report Status Code with the failure status to indicate that
> > + boot failure
> >  //
> > -REPORT_STATUS_CODE (
> > +REPORT_STATUS_CODE_EX (
> >EFI_ERROR_CODE | EFI_ERROR_MINOR,
> > -  (EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)
> > +  (EFI_SOFTWARE_DXE_BS_DRIVER |
> EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED),
> > +  0,
> > +  NULL,
> > +  NULL,
> > +  ,
> > +  sizeof (EFI_STATUS)
> >);
> >}
> >PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32)
> > OptionNumber);
> >
> >//
> >
> 
> Unfortunately, this patch is not good; we made a mistake here.
> 
> Consider the EFI_RETURN_STATUS_EXTENDED_DATA structure, added in
> patch
> #1:
> 
> > typedef struct {
> >   ///
> >   /// The data header identifying the data:
> >   /// DataHeader.HeaderSize should be sizeof(EFI_STATUS_CODE_DATA),
> >   /// DataHeader.Size should be
> sizeof(EFI_RETURN_STATUS_EXTENDED_DATA) - HeaderSize,
> >   /// DataHeader.Type should be EFI_STATUS_CODE_SPECIFIC_DATA_GUID.
> >   ///
> >   EFI_STATUS_CODE_DATA DataHeader;
> >   ///
> >   /// The EFI_STATUS return value of the service or function whose failure
> triggered the
> >   /// reporting of the status code (generally an error code or a debug 
> > code).
> >   ///
> >   EFI_STATUS   ReturnStatus;
> > } EFI_RETURN_STATUS_EXTENDED_DATA;
> 
> According to the UEFI spec, unless specified otherwise, structure members
> are aligned naturally.
> 
> And, the PI spec references the UEFI spec with regard to data types.
> 
> Accordingly, when this structure is built for X64, the size of this structure 
> is 32
> bytes, and the offset of ReturnStatus is 24. There is a 4-byte padding
> between DataHeader (which is 20 bytes in size) and the ReturnStatus field.
> DataHeader has type
> 
> > typedef struct {
> >   ///
> >   /// The size of the structure. This is specified to enable future 
> > expansion.
> >   ///
> >   UINT16HeaderSize;
> >   ///
> >   /// The size of the data in bytes. This does not include the size of the
> header structure.
> >   ///
> >   UINT16Size;
> >   ///
> >   /// The GUID defining the type of the data.
> >   ///
> >   EFI_GUID  Type;
> > } EFI_STATUS_CODE_DATA;
> 
> 

Re: [edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when fail to load/start boot option

2019-02-19 Thread Laszlo Ersek
On 02/20/19 02:19, Laszlo Ersek wrote:
> Hi Dandan,
> 
> On 02/15/19 09:51, Dandan Bi wrote:
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398
>>
>> According to PI1.7 Spec, report extended data describing an
>> EFI_STATUS return value along with
>> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR and
>> EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED status code
>> when fail to load or start boot option image.

> Unfortunately, this patch is not good; we made a mistake here.

> I'll report the same in a TianoCore BZ, and will try to submit a patch
> as well.

https://bugzilla.tianocore.org/show_bug.cgi?id=1539

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


[edk2] Intel Platforms in Bugzilla

2019-02-19 Thread Kubacki, Michael A
Hi Mike,

The devel-MinPlatform branch in the edk2-platforms repo is being used to 
develop Intel platform code. We plan to move this work to the master branch in 
edk2-platforms after a refactor in the MinPlatformPkg.

There's a need to submit feature requests and bugs against this code now. Do 
you think we could add the AdvancedFeaturePkg, ClevoOpenBoardPkg, 
KabylakeOpenBoardPkg, MinPlatformPkg, and PurleyOpenBoardPkg to the EDK2 
Platforms product on Bugzilla?

Regards,
Michael

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


Re: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths

2019-02-19 Thread Wu, Hao A
> -Original Message-
> From: Ard Biesheuvel [mailto:ard.biesheu...@linaro.org]
> Sent: Sunday, February 03, 2019 8:39 PM
> To: Wu, Hao A
> Cc: Jeff Brasen; edk2-devel@lists.01.org; Edgar Handal; Marcin Wojtas
> Subject: Re: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit
> IO widths
> 
> On Fri, 1 Feb 2019 at 06:55, Wu, Hao A  wrote:
> >
> > > -Original Message-
> > > From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Jeff
> > > Brasen
> > > Sent: Thursday, January 31, 2019 7:59 AM
> > > To: edk2-devel@lists.01.org
> > > Cc: Edgar Handal; Jeff Brasen
> > > Subject: [edk2] [PATCH] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit
> IO
> > > widths
> > >
> > > From: Edgar Handal 
> > >
> > > Use 16-bit and 32-bit IO widths for SDMMC MMIO to prevent all register
> > > accesses from being split up into 8-bit accesses.
> > >
> > > The SDHCI specification states that the registers shall be accessable in
> > > byte, word, and double word accesses.
> >
> 
> Acked-by: Ard Biesheuvel 

Ard,

Really sorry for missing your 'Acked-by' tag.
It came to me after I pushed the commit.

Sorry again for this.

Best Regards,
Hao Wu

> 
> I think we should always prefer accessing MMIO registers using their
> native size, unless there are pressing reasons not to.
> 
> 
> > Hi,
> >
> > Thanks for the contribution. The change seems good to me.
> >
> > Just curious, if the accesses are always slit into byte(8-bit), is there any
> > issue or performance impact is encountered during your usage?
> >
> > It will be helpful to get more information on the purpose of the patch.
> > Thanks.
> >
> > Best Regards,
> > Hao Wu
> >
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Jeff Brasen 
> > > ---
> > >  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 25
> > > 
> > >  1 file changed, 21 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> > > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> > > index 5aec8c6..82f4493 100644
> > > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> > > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> > > @@ -152,19 +152,36 @@ SdMmcHcRwMmio (
> > >)
> > >  {
> > >EFI_STATUS   Status;
> > > +  EFI_PCI_IO_PROTOCOL_WIDTHWidth;
> > >
> > >if ((PciIo == NULL) || (Data == NULL))  {
> > >  return EFI_INVALID_PARAMETER;
> > >}
> > >
> > > -  if ((Count != 1) && (Count != 2) && (Count != 4) && (Count != 8)) {
> > > -return EFI_INVALID_PARAMETER;
> > > +  switch (Count) {
> > > +case 1:
> > > +  Width = EfiPciIoWidthUint8;
> > > +  break;
> > > +case 2:
> > > +  Width = EfiPciIoWidthUint16;
> > > +  Count = 1;
> > > +  break;
> > > +case 4:
> > > +  Width = EfiPciIoWidthUint32;
> > > +  Count = 1;
> > > +  break;
> > > +case 8:
> > > +  Width = EfiPciIoWidthUint32;
> > > +  Count = 2;
> > > +  break;
> > > +default:
> > > +  return EFI_INVALID_PARAMETER;
> > >}
> > >
> > >if (Read) {
> > >  Status = PciIo->Mem.Read (
> > >PciIo,
> > > -  EfiPciIoWidthUint8,
> > > +  Width,
> > >BarIndex,
> > >(UINT64) Offset,
> > >Count,
> > > @@ -173,7 +190,7 @@ SdMmcHcRwMmio (
> > >} else {
> > >  Status = PciIo->Mem.Write (
> > >PciIo,
> > > -  EfiPciIoWidthUint8,
> > > +  Width,
> > >BarIndex,
> > >(UINT64) Offset,
> > >Count,
> > > --
> > > 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-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [patch 2/2] MdeModulePkg/BmBoot: Report status when fail to load/start boot option

2019-02-19 Thread Laszlo Ersek
Hi Dandan,

On 02/15/19 09:51, Dandan Bi wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1398
>
> According to PI1.7 Spec, report extended data describing an
> EFI_STATUS return value along with
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR and
> EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED status code
> when fail to load or start boot option image.
>
> Cc: Jian J Wang 
> Cc: Hao Wu 
> Cc: Ruiyu Ni 
> Cc: Laszlo Ersek 
> Cc: Sean Brogan 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi 
> ---
>  .../Library/UefiBootManagerLib/BmBoot.c   | 22 ++-
>  1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
> b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> index 6444fb43eb..9be1633b74 100644
> --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
> @@ -1818,15 +1818,20 @@ EfiBootManagerBoot (
>FreePool (FilePath);
>  }
>
>  if (EFI_ERROR (Status)) {
>//
> -  // Report Status Code to indicate that the failure to load boot option
> +  // Report Status Code with the failure status to indicate that the 
> failure to load boot option
>//
> -  REPORT_STATUS_CODE (
> +  REPORT_STATUS_CODE_EX (
>  EFI_ERROR_CODE | EFI_ERROR_MINOR,
> -(EFI_SOFTWARE_DXE_BS_DRIVER | 
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR)
> +(EFI_SOFTWARE_DXE_BS_DRIVER | 
> EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR),
> +0,
> +NULL,
> +NULL,
> +,
> +sizeof (EFI_STATUS)
>  );
>BootOption->Status = Status;
>//
>// Destroy the RAM disk
>//
> @@ -1902,15 +1907,20 @@ EfiBootManagerBoot (
>Status = gBS->StartImage (ImageHandle, >ExitDataSize, 
> >ExitData);
>DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Image Return Status = %r\n", Status));
>BootOption->Status = Status;
>if (EFI_ERROR (Status)) {
>  //
> -// Report Status Code to indicate that boot failure
> +// Report Status Code with the failure status to indicate that boot 
> failure
>  //
> -REPORT_STATUS_CODE (
> +REPORT_STATUS_CODE_EX (
>EFI_ERROR_CODE | EFI_ERROR_MINOR,
> -  (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED)
> +  (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED),
> +  0,
> +  NULL,
> +  NULL,
> +  ,
> +  sizeof (EFI_STATUS)
>);
>}
>PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
>
>//
>

Unfortunately, this patch is not good; we made a mistake here.

Consider the EFI_RETURN_STATUS_EXTENDED_DATA structure, added in patch
#1:

> typedef struct {
>   ///
>   /// The data header identifying the data:
>   /// DataHeader.HeaderSize should be sizeof(EFI_STATUS_CODE_DATA),
>   /// DataHeader.Size should be sizeof(EFI_RETURN_STATUS_EXTENDED_DATA) - 
> HeaderSize,
>   /// DataHeader.Type should be EFI_STATUS_CODE_SPECIFIC_DATA_GUID.
>   ///
>   EFI_STATUS_CODE_DATA DataHeader;
>   ///
>   /// The EFI_STATUS return value of the service or function whose failure 
> triggered the
>   /// reporting of the status code (generally an error code or a debug code).
>   ///
>   EFI_STATUS   ReturnStatus;
> } EFI_RETURN_STATUS_EXTENDED_DATA;

According to the UEFI spec, unless specified otherwise, structure
members are aligned naturally.

And, the PI spec references the UEFI spec with regard to data types.

Accordingly, when this structure is built for X64, the size of this
structure is 32 bytes, and the offset of ReturnStatus is 24. There is a
4-byte padding between DataHeader (which is 20 bytes in size) and the
ReturnStatus field. DataHeader has type

> typedef struct {
>   ///
>   /// The size of the structure. This is specified to enable future expansion.
>   ///
>   UINT16HeaderSize;
>   ///
>   /// The size of the data in bytes. This does not include the size of the 
> header structure.
>   ///
>   UINT16Size;
>   ///
>   /// The GUID defining the type of the data.
>   ///
>   EFI_GUID  Type;
> } EFI_STATUS_CODE_DATA;

which extends to 20 bytes.

I'm working on patches that capture / process
EFI_RETURN_STATUS_EXTENDED_DATA. The fields I'm seeing in DataHeader are
(on X64):
- HeaderSize = 0x14 (20 decimal)
- Size = 0x8,
- Type = {
Data1 = 0x335984bd,
Data2 = 0xe805,
Data3 = 0x409a,
Data4 = {0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 0xa6}
  }

The "DataHeader.Size" field is incorrect. It should be 12 (that is,
32-20), according to the documentation:

>   /// DataHeader.Size should be sizeof(EFI_RETURN_STATUS_EXTENDED_DATA) - 
> HeaderSize,

I think in the code above, we should use a temporary
EFI_RETURN_STATUS_EXTENDED_DATA structure, zero it out, then set the
ReturnStatus field in it. Finally, call the REPORT_STATUS_CODE_EX ()
macro with the trailing portion of this temporary object.

I'll report the 

Re: [edk2] [PATCH] BaseTools:PCD value error in structure pcd sku case.

2019-02-19 Thread Feng, Bob C
Reviewed-by: Bob Feng 

-Original Message-
From: Fan, ZhijuX 
Sent: Monday, February 18, 2019 5:53 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Feng, Bob C 
Subject: [PATCH] BaseTools:PCD value error in structure pcd sku case.

Defined 2 PCDs(Test4 & Test401) and 2 SKUs(DEFAULT & _), then set 
"SKUID_Defines" to ALL, for FixedAtBuild gEfiStructuredPcdPkgTokenSpaceGuid. 
Test401 in this case, its value should get from "Default" SKU, not from "_" 
SKU, but we does not set value in SKU "_" in dsc, so Test401 should only 
display the value get from dec.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/Common/GlobalData.py  | 2 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py | 3 +++
 BaseTools/Source/Python/build/BuildReport.py  | 5 -
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/Common/GlobalData.py 
b/BaseTools/Source/Python/Common/GlobalData.py
index 5eaee06694..f117998b0b 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -103,7 +103,7 @@ MixedPcd = {}
 
 # Structure Pcd dict
 gStructurePcd = {}
-
+gPcdSkuOverrides={}
 # Pcd name for the Pcd which used in the Conditional directives  
gConditionalPcds = []
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 1fd1639ab6..5daefe835e 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1537,6 +1537,9 @@ class DscBuildData(PlatformBuildClassObject):
 stru_pcd.SkuOverrideValues[skuid] = 
copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else 
copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in 
DefaultStores} if DefaultStores else {}) 
#{TAB_DEFAULT_STORES_DEFAULT:stru_pcd.DefaultValues})
 if not NoDefault:
 stru_pcd.ValueChain.add((skuid, ''))
+if 'DEFAULT' in stru_pcd.SkuOverrideValues and not 
GlobalData.gPcdSkuOverrides.get((stru_pcd.TokenCName, 
stru_pcd.TokenSpaceGuidCName)):
+GlobalData.gPcdSkuOverrides.update(
+{(stru_pcd.TokenCName, 
+ stru_pcd.TokenSpaceGuidCName): 
+ {'DEFAULT':stru_pcd.SkuOverrideValues['DEFAULT']}})
 if stru_pcd.Type in 
[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], 
self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
 for skuid in SkuIds:
 nextskuid = skuid
diff --git a/BaseTools/Source/Python/build/BuildReport.py 
b/BaseTools/Source/Python/build/BuildReport.py
index 0b98d62cb6..358fdd82d6 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -1295,7 +1295,10 @@ class PcdReport(object):
 FileWrite(File, ' %-*s   : %6s %10s = %s' % (self.MaxLen, Flag 
+ ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', Value))
 if IsStructure:
 FiledOverrideFlag = False
-OverrideValues = Pcd.SkuOverrideValues
+if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in 
GlobalData.gPcdSkuOverrides:
+OverrideValues = 
GlobalData.gPcdSkuOverrides[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)]
+else:
+OverrideValues = Pcd.SkuOverrideValues
 if OverrideValues:
 for Data in OverrideValues.values():
 Struct = list(Data.values())
--
2.14.1.windows.1

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


Re: [edk2] [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths

2019-02-19 Thread Wu, Hao A
Thanks Jeff.

Reviewed-by: Hao Wu 
And pushed via commit f168816c49e388dcd097dd62d766d63f73aaabb3.

Best Regards,
Hao Wu


> -Original Message-
> From: Jeff Brasen [mailto:jbra...@nvidia.com]
> Sent: Wednesday, February 20, 2019 1:07 AM
> To: edk2-devel@lists.01.org
> Cc: Edgar Handal; Jeff Brasen; Wu, Hao A
> Subject: [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO
> widths
> 
> From: Edgar Handal 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1537
> 
> Use 16-bit and 32-bit IO widths for SDMMC MMIO to prevent all register
> accesses from being split up into 8-bit accesses.
> 
> The SDHCI specification states that the registers shall be accessible in
> byte, word, and double word accesses. (SD Host Controller Simplified
> Specification 4.20 Section 1.2)
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jeff Brasen 
> Cc: Hao A Wu 
> ---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 25
> 
>  1 file changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> index 4c64da3..d73fa10 100644
> --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
> @@ -154,19 +154,36 @@ SdMmcHcRwMmio (
>)
>  {
>EFI_STATUS   Status;
> +  EFI_PCI_IO_PROTOCOL_WIDTHWidth;
> 
>if ((PciIo == NULL) || (Data == NULL))  {
>  return EFI_INVALID_PARAMETER;
>}
> 
> -  if ((Count != 1) && (Count != 2) && (Count != 4) && (Count != 8)) {
> -return EFI_INVALID_PARAMETER;
> +  switch (Count) {
> +case 1:
> +  Width = EfiPciIoWidthUint8;
> +  break;
> +case 2:
> +  Width = EfiPciIoWidthUint16;
> +  Count = 1;
> +  break;
> +case 4:
> +  Width = EfiPciIoWidthUint32;
> +  Count = 1;
> +  break;
> +case 8:
> +  Width = EfiPciIoWidthUint32;
> +  Count = 2;
> +  break;
> +default:
> +  return EFI_INVALID_PARAMETER;
>}
> 
>if (Read) {
>  Status = PciIo->Mem.Read (
>PciIo,
> -  EfiPciIoWidthUint8,
> +  Width,
>BarIndex,
>(UINT64) Offset,
>Count,
> @@ -175,7 +192,7 @@ SdMmcHcRwMmio (
>} else {
>  Status = PciIo->Mem.Write (
>PciIo,
> -  EfiPciIoWidthUint8,
> +  Width,
>BarIndex,
>(UINT64) Offset,
>Count,
> --
> 2.7.4

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


Re: [edk2] [PATCHv2 1/1] MdeModulePkg/SdMmcPciHcDxe Fix eMMC HS400 switch sequence

2019-02-19 Thread Wu, Hao A
Thanks Mateusz,

Reviewed-by: Hao Wu 
And pushed via commit 68c67d3a2a33261e41ff0123129b4e9759617f71.

Best Regards,
Hao Wu


> -Original Message-
> From: Albecki, Mateusz
> Sent: Monday, February 18, 2019 7:12 PM
> To: edk2-devel@lists.01.org
> Cc: Albecki, Mateusz; Wu, Hao A
> Subject: [PATCHv2 1/1] MdeModulePkg/SdMmcPciHcDxe Fix eMMC HS400
> switch sequence
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1140
> 
> In eMMC HS400 switch sequence flow eMMC driver attempted
> to execute SEND_STATUS just after switching bus timing to high
> speed and before downgrading clock frequency to 52MHz. Since link
> was at that time in incorrect state SEND_STATUS was failing which
> made driver think switch to HS400 failed.
> This change makes driver always change clock frequency after
> switching bus timing and before executing SEND_STATUS.
> 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Albecki Mateusz 
> ---
>  MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 39
> +
>  1 file changed, 20 insertions(+), 19 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
> b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
> index 4ef849fd0962..15db8a87a5c4 100644
> --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
> +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c
> @@ -642,7 +642,7 @@ EmmcSwitchBusWidth (
>  }
> 
>  /**
> -  Switch the clock frequency to the specified value.
> +  Switch the bus timing and clock frequency.
> 
>Refer to EMMC Electrical Standard Spec 5.1 Section 6.6 and SD Host
> Controller
>Simplified Spec 3.0 Figure 3-3 for details.
> @@ -660,7 +660,7 @@ EmmcSwitchBusWidth (
> 
>  **/
>  EFI_STATUS
> -EmmcSwitchClockFreq (
> +EmmcSwitchBusTiming (
>IN EFI_PCI_IO_PROTOCOL*PciIo,
>IN EFI_SD_MMC_PASS_THRU_PROTOCOL  *PassThru,
>IN UINT8  Slot,
> @@ -689,22 +689,10 @@ EmmcSwitchClockFreq (
> 
>Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);
>if (EFI_ERROR (Status)) {
> -DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d
> fails with %r\n", HsTiming, Status));
> +DEBUG ((DEBUG_ERROR, "EmmcSwitchBusTiming: Switch to hstiming %d
> fails with %r\n", HsTiming, Status));
>  return Status;
>}
> 
> -  Status = EmmcSendStatus (PassThru, Slot, Rca, );
> -  if (EFI_ERROR (Status)) {
> -DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails
> with %r\n", Status));
> -return Status;
> -  }
> -  //
> -  // Check the switch operation is really successful or not.
> -  //
> -  if ((DevStatus & BIT7) != 0) {
> -DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation
> fails as DevStatus is 0x%08x\n", DevStatus));
> -return EFI_DEVICE_ERROR;
> -  }
>//
>// Convert the clock freq unit from MHz to KHz.
>//
> @@ -713,6 +701,19 @@ EmmcSwitchClockFreq (
>  return Status;
>}
> 
> +  Status = EmmcSendStatus (PassThru, Slot, Rca, );
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "EmmcSwitchBusTiming: Send status fails
> with %r\n", Status));
> +return Status;
> +  }
> +  //
> +  // Check the switch operation is really successful or not.
> +  //
> +  if ((DevStatus & BIT7) != 0) {
> +DEBUG ((DEBUG_ERROR, "EmmcSwitchBusTiming: The switch operation
> fails as DevStatus is 0x%08x\n", DevStatus));
> +return EFI_DEVICE_ERROR;
> +  }
> +
>if (mOverride != NULL && mOverride->NotifyPhase != NULL) {
>  Status = mOverride->NotifyPhase (
>Private->ControllerHandle,
> @@ -799,7 +800,7 @@ EmmcSwitchToHighSpeed (
>}
> 
>HsTiming = 1;
> -  Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing,
> ClockFreq);
> +  Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, HsTiming,
> Timing, ClockFreq);
> 
>return Status;
>  }
> @@ -887,7 +888,7 @@ EmmcSwitchToHS200 (
>Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL, sizeof
> (ClockCtrl), );
> 
>HsTiming = 2;
> -  Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing,
> ClockFreq);
> +  Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, HsTiming,
> Timing, ClockFreq);
>if (EFI_ERROR (Status)) {
>  return Status;
>}
> @@ -937,7 +938,7 @@ EmmcSwitchToHS400 (
>// Set to Hight Speed timing and set the clock frequency to a value less 
> than
> 52MHz.
>//
>HsTiming = 1;
> -  Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming,
> SdMmcMmcHsSdr, 52);
> +  Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, HsTiming,
> SdMmcMmcHsSdr, 52);
>if (EFI_ERROR (Status)) {
>  return Status;
>}
> @@ -957,7 +958,7 @@ EmmcSwitchToHS400 (
>}
> 
>HsTiming = 3;
> -  Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, Timing,
> ClockFreq);
> +  Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, HsTiming,
> Timing, 

Re: [edk2] [PATCH 06/10] OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration

2019-02-19 Thread Jordan Justen
On 2019-02-19 14:50:13, Brian J. Johnson wrote:
> On 2/18/19 3:32 AM, Ard Biesheuvel wrote:
> > On Mon, 18 Feb 2019 at 10:08, Jordan Justen  
> > wrote:
> >>
> >> On 2019-02-17 23:53:01, Ard Biesheuvel wrote:
> >>> On Mon, 18 Feb 2019 at 05:12, Jordan Justen  
> >>> wrote:
> 
> >>>
> >>> This needs an explanation why optimization needs to be disabled.
> >>
> >> I'm not sure this is required. The reason I added these patches is to
> >> hopefully prevent the compiler from removing the frame pointer. We
> >> adjust the frame pointer in the code, and that is a little sketchy if
> >> the frame pointer isn't being used.
> >>
> >> Unfortunately, it can reasonably be argued that the
> >> TemporaryRamSupport PPI definition ultimately makes it unsafe to write
> >> the migration code in C.
> >>
> >> I tried reverting both the EmulatorPkg and OvmfPkg patches for
> >> disabling the optimizations, and with my setup there was no impact. I
> >> think there is a good change that we'd be pretty safe to just drop
> >> these two patches to wait and see if someone encounters a situation
> >> that requires it.
> >>
> >> Ok, so based on this explanation, do you think I should add info to
> >> the commit message and keep the patches, or just drop them?
> >>
> > 
> > I think 'little sketchy' is an understatement here (as is
> > setjmp/longjmp in general), but it is the reality we have to deal with
> > when writing startup code in C. Looking at the code, I agree that the
> > fact that [re]bp is assigned directly implies that we should not
> > permit it to be used as a general purpose register, especially when
> > you throw LTO into the mix, which could produce all kinds of
> > surprising results when it decides to inline functions being called
> > from here.
> > 
> > For GCC/Clang, I don't think it is correct to assume that changing the
> > optimization level will result in -fno-omit-frame-pointer to be set,
> > so I'd prefer setting that option directly, either via the pragma, or
> > for the whole file.
> > 
> > For MSVC, I have no idea how to tweak the compiler to force it to emit
> > frame pointers.
> > 
> 
> https://docs.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=vs-2017

Hmm, and based on:

https://docs.microsoft.com/en-us/cpp/preprocessor/optimize?view=vs-2017

#pragma optimize ("", off)

...includes the "y" option.

This 2nd page seems a little confused, as it documents "y" as
"Generate frame pointers on the program stack", while the 1st page
says "Suppresses creation of frame pointers on the call stack".

I think the "suppress" is more accurate as it makes more sense that
suppressing the frame pointer gives better optimization opportunities.

Anyway, I think that means that `#pragma optimize ("", off)` does what
we want on MSVC to force frame pointers to be used.

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


Re: [edk2] [PATCH 06/10] OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration

2019-02-19 Thread Brian J. Johnson

On 2/18/19 3:32 AM, Ard Biesheuvel wrote:

On Mon, 18 Feb 2019 at 10:08, Jordan Justen  wrote:


On 2019-02-17 23:53:01, Ard Biesheuvel wrote:

On Mon, 18 Feb 2019 at 05:12, Jordan Justen  wrote:




This needs an explanation why optimization needs to be disabled.


I'm not sure this is required. The reason I added these patches is to
hopefully prevent the compiler from removing the frame pointer. We
adjust the frame pointer in the code, and that is a little sketchy if
the frame pointer isn't being used.

Unfortunately, it can reasonably be argued that the
TemporaryRamSupport PPI definition ultimately makes it unsafe to write
the migration code in C.

I tried reverting both the EmulatorPkg and OvmfPkg patches for
disabling the optimizations, and with my setup there was no impact. I
think there is a good change that we'd be pretty safe to just drop
these two patches to wait and see if someone encounters a situation
that requires it.

Ok, so based on this explanation, do you think I should add info to
the commit message and keep the patches, or just drop them?



I think 'little sketchy' is an understatement here (as is
setjmp/longjmp in general), but it is the reality we have to deal with
when writing startup code in C. Looking at the code, I agree that the
fact that [re]bp is assigned directly implies that we should not
permit it to be used as a general purpose register, especially when
you throw LTO into the mix, which could produce all kinds of
surprising results when it decides to inline functions being called
from here.

For GCC/Clang, I don't think it is correct to assume that changing the
optimization level will result in -fno-omit-frame-pointer to be set,
so I'd prefer setting that option directly, either via the pragma, or
for the whole file.

For MSVC, I have no idea how to tweak the compiler to force it to emit
frame pointers.



https://docs.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission?view=vs-2017

Brian






Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
---
  OvmfPkg/Sec/SecMain.c | 12 
  1 file changed, 12 insertions(+)

diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 46ac739862..86c22a2ac9 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -873,6 +873,13 @@ SecStartupPhase2(
CpuDeadLoop ();
  }

+#ifdef __GNUC__
+#pragma GCC push_options
+#pragma GCC optimize ("O0")
+#else
+#pragma optimize ("", off)
+#endif
+
  EFI_STATUS
  EFIAPI
  TemporaryRamMigration (
@@ -946,3 +953,8 @@ TemporaryRamMigration (
return EFI_SUCCESS;
  }

+#ifdef __GNUC__
+#pragma GCC pop_options
+#else
+#pragma optimize ("", on)
+#endif


I can't tell from the context if this is the end of the file, but if
it is not, aren't you turning on optimization here for non-GCC even if
it was not enabled on the command line to begin with?

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




--
Brian J. Johnson
Enterprise X86 Lab

Hewlett Packard Enterprise

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


Re: [edk2] [PATCH] OvmfPkg/Sec: Clear the Cache Disable flag in the CR0 register

2019-02-19 Thread Jordan Justen
On 2019-02-18 05:23:28, Laszlo Ersek wrote:
> generic comment (applies to all NASM usage I guess):
> 
> On 02/18/19 11:10, Jordan Justen wrote:
> 
> > +mov eax, cr0
> > +and eax, ~(1 << 30)
> > +mov cr0, eax
> 
> > +mov rax, cr0
> > +and eax, ~(1 << 30)
> > +mov cr0, rax
> 
> I've read up on the << and ~ operators in the NASM documentation, and I
> think the above build-time calculations of the masks are well-defined
> and correct.
> 
> - bit shifts are always unsigned
> - given bit position 30, ~(1 << 30) will be a value with 32 bits
> - bit-neg simply flips bits (one's complement)
> 
> On the other hand, I find these NASM specifics counter-intuitive. The
> expression ~(1 << 30) looks like valid C, but in C, it means a quite
> different thing.

Can you elaborate? I guess there might be something subtly different,
but for the most part it means the same thing, right?

> I think calculating the mask with "strict dword" somehow (not exactly
> sure how) would make this more readable;

Oh, are you saying that (1 << 30) doesn't necessarily mean we are
operating on a 32-bit value?

> or else the BTR instruction would.

Yeah, I guess this works.

> Opinions? (Again, pertaining to all NASM usage in edk2.)

As always, my opinion is to avoid writing assembly code. :)

We actually had a version that set this just before the decompress in
SecMain.c. Then I noted that we were initializing temp-ram here, so I
moved it, even though the memory init doesn't take a significant
amount of time compared to the decompress. Maybe we should just do
that instead?

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


Re: [edk2] [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction

2019-02-19 Thread Kinney, Michael D
Ashish,

Thanks for looking at simplifying this logic again.

I have not had a chance to run the size analysis yet.

I will get back to you in a couple of days.

Thanks,

Mike

> -Original Message-
> From: Ashish Singhal [mailto:ashishsin...@nvidia.com]
> Sent: Tuesday, February 19, 2019 8:19 AM
> To: edk2-devel@lists.01.org
> Cc: Kinney, Michael D ;
> Gao, Liming 
> Subject: RE: [PATCH] MdePkg/UefiLib: Simplify protocol
> un/installation abstraction
> 
> Hello Mike/Lao,
> 
> Were you able to have a look at this?
> 
> Thanks
> Ashish
> 
> -Original Message-
> From: Ashish Singhal 
> Sent: Monday, February 4, 2019 1:16 PM
> To: edk2-devel@lists.01.org
> Cc: michael.d.kin...@intel.com; liming@intel.com;
> Ashish Singhal 
> Subject: [PATCH] MdePkg/UefiLib: Simplify protocol
> un/installation abstraction
> 
> Add helper functions to operate upon protocol
> installation and
> uninstallation instead of every function doing it by
> itself.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ashish Singhal 
> ---
>  MdePkg/Library/UefiLib/UefiDriverModel.c | 2040 +-
> 
>  1 file changed, 342 insertions(+), 1698 deletions(-)
> 
> diff --git a/MdePkg/Library/UefiLib/UefiDriverModel.c
> b/MdePkg/Library/UefiLib/UefiDriverModel.c
> index 262d8bc..268edf7 100644
> --- a/MdePkg/Library/UefiLib/UefiDriverModel.c
> +++ b/MdePkg/Library/UefiLib/UefiDriverModel.c
> @@ -17,6 +17,290 @@
> 
>  #include "UefiLibInternal.h"
> 
> +
> +#define MAX_SUPPORTED_PROTOCOLS 7
> +typedef struct {
> +  EFI_GUID *Guid;
> +  VOID *Interface;
> +} EFI_PROCESS_PROTOCOL;
> +
> +
> +static
> +EFI_STATUS
> +EFIAPI
> +EfiLibProcessProtocols (
> +  IN CONST EFI_HANDLE
> ImageHandle,
> +  IN EFI_DRIVER_BINDING_PROTOCOL
> *DriverBinding,
> +  IN EFI_HANDLE
> DriverBindingHandle,
> +  IN BOOLEAN  Install,
> +  IN CONST EFI_PROCESS_PROTOCOL
> *ProtocolArray
> +  )
> +{
> +  ASSERT (DriverBinding != NULL);
> +  ASSERT (ProtocolArray != NULL);
> +
> +  if (Install) {
> +//
> +// Update the ImageHandle and DriverBindingHandle
> fields of the Driver Binding Protocol
> +//
> +DriverBinding->ImageHandle = ImageHandle;
> +DriverBinding->DriverBindingHandle =
> DriverBindingHandle;
> +
> +return gBS->InstallMultipleProtocolInterfaces (
> +  >DriverBindingHandle,
> +  ProtocolArray[0].Guid,
> ProtocolArray[0].Interface,
> +  ProtocolArray[1].Guid,
> ProtocolArray[1].Interface,
> +  ProtocolArray[2].Guid,
> ProtocolArray[2].Interface,
> +  ProtocolArray[3].Guid,
> ProtocolArray[3].Interface,
> +  ProtocolArray[4].Guid,
> ProtocolArray[4].Interface,
> +  ProtocolArray[5].Guid,
> ProtocolArray[5].Interface,
> +  ProtocolArray[6].Guid,
> ProtocolArray[6].Interface,
> +  NULL
> +  );
> +  } else {
> +return gBS->UninstallMultipleProtocolInterfaces (
> +  DriverBinding->DriverBindingHandle,
> +  ProtocolArray[0].Guid,
> ProtocolArray[0].Interface,
> +  ProtocolArray[1].Guid,
> ProtocolArray[1].Interface,
> +  ProtocolArray[2].Guid,
> ProtocolArray[2].Interface,
> +  ProtocolArray[3].Guid,
> ProtocolArray[3].Interface,
> +  ProtocolArray[4].Guid,
> ProtocolArray[4].Interface,
> +  ProtocolArray[5].Guid,
> ProtocolArray[5].Interface,
> +  ProtocolArray[6].Guid,
> ProtocolArray[6].Interface,
> +  NULL
> +  );
> +  }
> +}
> +
> +
> +
> +static
> +EFI_STATUS
> +EFIAPI
> +EfiLibProcessAllDriverProtocols (
> +  IN CONST EFI_HANDLE
> ImageHandle,
> +  IN EFI_DRIVER_BINDING_PROTOCOL
> *DriverBinding,
> +  IN EFI_HANDLE
> DriverBindingHandle,
> +  IN BOOLEAN  Install,
> +  IN CONST EFI_COMPONENT_NAME_PROTOCOL
> *ComponentName,
> +  IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL
> *DriverConfiguration,
> +  IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL
> *DriverDiagnostics
> +  )
> +{
> +  EFI_STATUS   Status;
> +  EFI_PROCESS_PROTOCOL
> ProtocolArray[MAX_SUPPORTED_PROTOCOLS];
> +  UINT8ProtocolCount;
> +
> +  ASSERT (DriverBinding != NULL);
> +
> +  //
> +  // ZI the ProtocolArray structure. Both
> InstallMultipleProtocolInterfaces
> +  // and UninstallMultipleProtocolInterfaces would
> stop processing ProtocolArray
> +  // elements as soon as they encounter a NULL.
> +  //
> +  ZeroMem(ProtocolArray, sizeof(ProtocolArray));
> +  ProtocolCount = 0;
> +
> +  //
> +  // Populate ProtocolArray with valid protocol
> interfaces.
> +  //
> +  ProtocolArray[ProtocolCount].Guid =
> 
> +  ProtocolArray[ProtocolCount].Interface =
> DriverBinding;
> +  ProtocolCount++;
> +
> +  if (ComponentName != NULL &&
> !FeaturePcdGet(PcdComponentNameDisable)) {
> +

Re: [edk2] [PATCH] OvmfPkg/Sec: Clear the Cache Disable flag in the CR0 register

2019-02-19 Thread Andrew Fish via edk2-devel



> On Feb 18, 2019, at 5:23 AM, Laszlo Ersek  wrote:
> 
> generic comment (applies to all NASM usage I guess):
> 
> On 02/18/19 11:10, Jordan Justen wrote:
> 
>> +mov eax, cr0
>> +and eax, ~(1 << 30)
>> +mov cr0, eax
> 
>> +mov rax, cr0
>> +and eax, ~(1 << 30)
>> +mov cr0, rax
> 
> I've read up on the << and ~ operators in the NASM documentation, and I
> think the above build-time calculations of the masks are well-defined
> and correct.
> 
> - bit shifts are always unsigned
> - given bit position 30, ~(1 << 30) will be a value with 32 bits
> - bit-neg simply flips bits (one's complement)
> 
> On the other hand, I find these NASM specifics counter-intuitive. The
> expression ~(1 << 30) looks like valid C, but in C, it means a quite
> different thing.
> 
> I think calculating the mask with "strict dword" somehow (not exactly
> sure how) would make this more readable; or else the BTR instruction would.
> 
> Opinions? (Again, pertaining to all NASM usage in edk2.)
> 

Lazlo,

I guess comments, or #defines, are other options?

Thanks,

Andrew Fish

> Thanks
> Laszlo
> ___
> 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] OvmfPkg/Sec: Clear the Cache Disable flag in the CR0 register

2019-02-19 Thread Jordan Justen
On 2019-02-18 04:17:26, Laszlo Ersek wrote:
> On 02/18/19 11:10, Jordan Justen wrote:
> > Clear the CD (Cache Disable) flag in the CR0 register. When the VM
> > implements the CD flag, this can substantially decrease the time it
> > takes to decompress the firmware volumes.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Jordan Justen 
> > Tested-by: Peter Fang 
> > Cc: Peter Fang 
> > Cc: Maurice Ma 
> > Cc: Laszlo Ersek 
> > Cc: Ard Biesheuvel 
> > Cc: Anthony Perard 
> > Cc: Julien Grall 
> > ---
> >  OvmfPkg/Sec/Ia32/SecEntry.nasm | 8 +++-
> >  OvmfPkg/Sec/X64/SecEntry.nasm  | 8 +++-
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/OvmfPkg/Sec/Ia32/SecEntry.nasm b/OvmfPkg/Sec/Ia32/SecEntry.nasm
> > index 03501969eb..fc7f47385a 100644
> > --- a/OvmfPkg/Sec/Ia32/SecEntry.nasm
> > +++ b/OvmfPkg/Sec/Ia32/SecEntry.nasm
> > @@ -40,6 +40,13 @@ extern ASM_PFX(SecCoreStartupWithStack)
> >  global ASM_PFX(_ModuleEntryPoint)
> >  ASM_PFX(_ModuleEntryPoint):
> >  
> > +;
> > +; Clear the CD (Cache Disable) flag in the CR0 register.
> > +;
> > +mov eax, cr0
> > +and eax, ~(1 << 30)
> > +mov cr0, eax
> > +
> >  ;
> >  ; Fill the temporary RAM with the initial stack value.
> >  ; The loop below will seed the heap as well, but that's harmless.
> > @@ -71,4 +78,3 @@ ASM_PFX(_ModuleEntryPoint):
> >  pusheax
> >  pushebp
> >  callASM_PFX(SecCoreStartupWithStack)
> > -
> > diff --git a/OvmfPkg/Sec/X64/SecEntry.nasm b/OvmfPkg/Sec/X64/SecEntry.nasm
> > index d76adcffd8..7471b3a3e3 100644
> > --- a/OvmfPkg/Sec/X64/SecEntry.nasm
> > +++ b/OvmfPkg/Sec/X64/SecEntry.nasm
> > @@ -41,6 +41,13 @@ extern ASM_PFX(SecCoreStartupWithStack)
> >  global ASM_PFX(_ModuleEntryPoint)
> >  ASM_PFX(_ModuleEntryPoint):
> >  
> > +;
> > +; Clear the CD (Cache Disable) flag in the CR0 register.
> > +;
> > +mov rax, cr0
> > +and eax, ~(1 << 30)
> > +mov cr0, rax
> > +
> >  ;
> >  ; Fill the temporary RAM with the initial stack value.
> >  ; The loop below will seed the heap as well, but that's harmless.
> > @@ -72,4 +79,3 @@ ASM_PFX(_ModuleEntryPoint):
> >  mov rdx, rsp
> >  sub rsp, 0x20
> >  callASM_PFX(SecCoreStartupWithStack)
> > -
> > 
> 
> In commit 98f378a7be12 ("OvmfPkg/ResetVector: enable caching in initial
> page tables", 2013-09-24), we said
> 
> In UEFI X64 we use other mechanisms to disable caching.
> (CD/NW in CR0 and MTRRs.)
> 
> That suggests that having caching disabled in SEC is a good thing.

I think there can be good reasons to disable caching on a platform,
such as during memory initialization, but I'm not sure any apply to
OVMF.

As far as I know, kvm still doesn't attempt to disable caching via the
CR0.CD bit or the MTRRs. This kind of backs up the previous statement
about there not being a reason to disable caching in OVMF.

> What has changed? I assume Peter reported a problem.
> 
> ... Is this by any chance related to Linux commit 879ae1880449 ("KVM:
> x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()", 2015-11-04) --
> or CR0.CD virtualization in KVM, in general?
> 
> (The commit message says "When the VM implements the CD flag", and not
> "When the *VMM* implements the CD flag", so I'm unsure.)

Yeah, I guess we probably want VMM, and I don't think the observed
issue applies to kvm.

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


Re: [edk2] [PATCH 00/10] Fix PEI Core issue during TemporaryRamMigration

2019-02-19 Thread Jordan Justen
On 2019-02-18 18:46:24, Ni, Ray wrote:
> Jordan,
> I find many real platforms do not implement the temporary ram migration
> PPI and rely on the PeiCore migration  logic.
> So perhaps TemporaryRamMigration PPI was added to help platform to
> destroy the temporary RAM (CAR in x86 platform).

I guess since it is in the PI spec, we can't be sure it is only used
for this case, or that it might not be used in the future.

> But with the introduction of TemporaryRamDone PPI, maybe the
> TemporaryRamMigration PPI can be retired.
> The logic in PeiCore to call TemporaryRamMigration is just for backward
> compatibility.
> If that's true, do you still need to enhance PeiCore?

I checked the PI 1.4 spec, and I didn't see anything indicating that
TemporaryRamSupport PPI is deprecated.

Since it is not deprecated, should we ignore the known issue?

> For the Emulator case, I already found without TemporaryRamMigration
> the platform can still boot.
> 
> Does OVMF hard-depend on TemporaryRamMigration? Or it can reply on
> the PeiCore migration logic + TemporaryDone PPI?

This is a good question. If it is true that TemporaryRamSupport is
rarely used, then maybe it is better to have the sample platforms use
the more commonly used path.

Personally, I think we should still address the issue with
TemporaryRamSupport, and leave the question of whether to test
TemporaryRamSupport code paths in the sample platforms as a separate
task.

At the least, I think we should still continue to use TemporaryRamDone
to reset the temp-ram contents to help make sure nothing accidentally
depends on a temp-ram pointer. Unfortunately, this would mean that the
TemporaryRamSupport path is not really being tested, but it might be
the better choise if TemporaryRamSupport is never used in real
platforms.

-Jordan

> 
> > -Original Message-
> > From: Justen, Jordan L 
> > Sent: Monday, February 18, 2019 12:12 PM
> > To: edk2-devel@lists.01.org
> > Cc: Justen, Jordan L ; Liu Yu
> > ; Andrew Fish ; Anthony
> > Perard ; Ard Biesheuvel
> > ; Wu, Hao A ; Wang, Jian
> > J ; Julien Grall ; Laszlo 
> > Ersek
> > ; Ni, Ray ; Zeng, Star
> > 
> > Subject: [PATCH 00/10] Fix PEI Core issue during TemporaryRamMigration
> > 
> > https://github.com/jljusten/edk2.git temp-ram-support
> > 
> > This series fixes an issue that, while rare, is possible based on the way 
> > the
> > TemporaryRamSupport PPI is defined along with how it is used by the PEI
> > Core.
> > 
> > Liu Yu reported a boot issue with EmulatorPkg, which I believe was caused by
> > this issue.
> > 
> > The details of the issue are described in the commit message of the
> > "MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram
> > migration" patch.
> > 
> > Along with this, I added a few Temporary RAM patches for EmulatorPkg and
> > OvmfPkg.
> > 
> > Cc: Liu Yu 
> > Cc: Andrew Fish 
> > Cc: Anthony Perard 
> > Cc: Ard Biesheuvel 
> > Cc: Hao Wu 
> > Cc: Jian J Wang 
> > Cc: Julien Grall 
> > Cc: Laszlo Ersek 
> > Cc: Ray Ni 
> > Cc: Star Zeng 
> > 
> > Jordan Justen (10):
> >   EmulatorPkg/build.sh: Fix missing usage of -b BUILDTARGET parameter
> >   EmulatorPkg/Unix/Host: Use PcdInitValueInTempStack to init temp-ram
> >   EmulatorPkg/Sec: Replace assembly temp-ram support with C code
> >   EmulatorPkg/Sec: Disable optimizations for TemporaryRamMigration
> > function
> >   OvmfPkg/Sec: Swap TemporaryRam Stack and Heap locations
> >   OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration
> >   MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram
> > migration
> >   MdeModulePkg/Core/Pei: Use assembly for X64 TemporaryRamMigration
> >   MdeModulePkg/Core/Pei: Use assembly for IA32 TemporaryRamMigration
> >   OvmfPkg/Sec: Fill Temp Ram after TemporaryRamMigration
> > 
> >  EmulatorPkg/Sec/Ia32/SwitchRam.S  | 95 ---
> >  EmulatorPkg/Sec/Ia32/SwitchRam.asm| 94 --
> >  EmulatorPkg/Sec/Ia32/TempRam.c| 65 -
> >  EmulatorPkg/Sec/Sec.c | 76 ++-
> >  EmulatorPkg/Sec/Sec.inf   | 13 +--
> >  EmulatorPkg/Sec/X64/SwitchRam.S   | 72 --
> >  EmulatorPkg/Sec/X64/SwitchRam.asm | 76 ---
> >  EmulatorPkg/Unix/Host/Host.c  |  2 +-
> >  EmulatorPkg/Unix/Host/Host.inf|  1 +
> >  EmulatorPkg/build.sh  | 10 +-
> >  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 59 
> >  .../Dispatcher/Ia32/TemporaryRamMigration.S   | 72 ++
> >  .../Ia32/TemporaryRamMigration.nasm   | 78 +++
> >  .../Pei/Dispatcher/TemporaryRamMigration.c| 52 ++
> >  .../Dispatcher/X64/TemporaryRamMigration.S| 69 ++
> >  .../Dispatcher/X64/TemporaryRamMigration.nasm | 75 +++
> >  MdeModulePkg/Core/Pei/PeiMain.h   | 52 ++
> >  MdeModulePkg/Core/Pei/PeiMain.inf | 14 

[edk2] [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: Use 16/32-bit IO widths

2019-02-19 Thread Jeff Brasen
From: Edgar Handal 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1537

Use 16-bit and 32-bit IO widths for SDMMC MMIO to prevent all register
accesses from being split up into 8-bit accesses.

The SDHCI specification states that the registers shall be accessible in
byte, word, and double word accesses. (SD Host Controller Simplified
Specification 4.20 Section 1.2)

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jeff Brasen 
Cc: Hao A Wu 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 25 
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
index 4c64da3..d73fa10 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
@@ -154,19 +154,36 @@ SdMmcHcRwMmio (
   )
 {
   EFI_STATUS   Status;
+  EFI_PCI_IO_PROTOCOL_WIDTHWidth;
 
   if ((PciIo == NULL) || (Data == NULL))  {
 return EFI_INVALID_PARAMETER;
   }
 
-  if ((Count != 1) && (Count != 2) && (Count != 4) && (Count != 8)) {
-return EFI_INVALID_PARAMETER;
+  switch (Count) {
+case 1:
+  Width = EfiPciIoWidthUint8;
+  break;
+case 2:
+  Width = EfiPciIoWidthUint16;
+  Count = 1;
+  break;
+case 4:
+  Width = EfiPciIoWidthUint32;
+  Count = 1;
+  break;
+case 8:
+  Width = EfiPciIoWidthUint32;
+  Count = 2;
+  break;
+default:
+  return EFI_INVALID_PARAMETER;
   }
 
   if (Read) {
 Status = PciIo->Mem.Read (
   PciIo,
-  EfiPciIoWidthUint8,
+  Width,
   BarIndex,
   (UINT64) Offset,
   Count,
@@ -175,7 +192,7 @@ SdMmcHcRwMmio (
   } else {
 Status = PciIo->Mem.Write (
   PciIo,
-  EfiPciIoWidthUint8,
+  Width,
   BarIndex,
   (UINT64) Offset,
   Count,
-- 
2.7.4

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


Re: [edk2] [PATCH 2/2] ArmPlatformPkg/NorFlash: Allow reusability as a MM driver

2019-02-19 Thread Ard Biesheuvel
Hello Jagadeesh,

On Tue, 19 Feb 2019 at 11:32, Jagadeesh Ujja  wrote:
>
> Adapt the NorFlash driver to be used as a MM_STANDALONE driver to
> allow access to NOR flash for code executing in MM_STANDALONE mode.
> This allows storing of EFI variables on NOR flash which is accessible
> only via the MM STANDALONE mode software.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c   | 267 
> 
>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  77 ++
>  2 files changed, 344 insertions(+)
>
> diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c 
> b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
> new file mode 100644
> index 000..1e3603c
> --- /dev/null
> +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
> @@ -0,0 +1,267 @@
> +/*++ @file  NorFlashStandaloneMm.c
> +
> + Copyright (c) 2019, 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 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 

Please sort alphabetically - I know this originates in existing code,
but it is a brand new file so let's make it clean from the start.

> +
> +#include 
> +#include 
> +#include 

I don't think we need this - please see below.

> +#include "NorFlash.h"
> +
> +//
> +// Global variable declarations
> +//
> +NOR_FLASH_INSTANCE **mNorFlashInstances;
> +UINT32   mNorFlashDeviceCount;
> +

These are definitions, not declarations. Could they be moved to a
shared .c file instead?

> +extern NOR_FLASH_INSTANCE  mNorFlashInstanceTemplate;

Move this to a header?

> +
> +EFI_STATUS
> +EFIAPI
> +NorFlashFvbInitialize (
> +  IN NOR_FLASH_INSTANCE* Instance
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINT32  FvbNumLba;
> +  EFI_BOOT_MODE BootMode;
> +
> +  DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
> +  ASSERT((Instance != NULL));
> +
> +  mFlashNvStorageVariableBase = FixedPcdGet32 
> (PcdFlashNvStorageVariableBase);
> +
> +  // Set the index of the first LBA for the FVB
> +  Instance->StartLba = (PcdGet32 (PcdFlashNvStorageVariableBase) - 
> Instance->RegionBaseAddress) / Instance->Media.BlockSize;
> +

Please wrap to 80 columns

> +  BootMode = GetBootModeHob ();

Where does the boot mode HOB come from in standalone MM?

> +  if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
> +Status = EFI_INVALID_PARAMETER;
> +  } else {
> +// Determine if there is a valid header at the beginning of the NorFlash
> +Status = ValidateFvHeader (Instance);
> +  }
> +


> +  // Install the Default FVB header if required
> +  if (EFI_ERROR(Status)) {
> +// There is no valid header, so time to install one.
> +DEBUG ((EFI_D_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__));
> +DEBUG ((EFI_D_INFO, "%a: Installing a correct one for this volume.\n",
> +  __FUNCTION__));
> +

Please use DEBUG_INFO not EFI_D_INFO (the latter form is deprecated)

> +// Erase all the NorFlash that is reserved for variable storage
> +FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + 
> PcdGet32(PcdFlashNvStorageFtwWorkingSize) + 
> PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
> +

Please wrap to 80 columns

> +Status = FvbEraseBlocks (>FvbProtocol, (EFI_LBA)0, FvbNumLba, 
> EFI_LBA_LIST_TERMINATOR);
> +if (EFI_ERROR(Status)) {
> +  return Status;
> +}
> +
> +// Install all appropriate headers
> +Status = InitializeFvAndVariableStoreHeaders (Instance);
> +if (EFI_ERROR(Status)) {
> +  return Status;
> +}

This if {} is redundant since we will be returning Status anyway.

> +  }
> +
> +  return Status;
> +}
> +
> +VOID
> +EFIAPI
> +NorFlashLock (
> +  NOR_FLASH_LOCK_CONTEXT*Context
> +  )
> +{
> +}
> +
> +VOID
> +EFIAPI
> +NorFlashUnlock (
> +  NOR_FLASH_LOCK_CONTEXT*Context
> +  )
> +{
> +}
> +
> +EFI_STATUS
> +NorFlashCreateInstance (
> +  IN UINTN  NorFlashDeviceBase,
> +  IN UINTN  NorFlashRegionBase,
> +  IN UINTN  NorFlashSize,
> +  IN UINT32 Index,
> +  IN UINT32 BlockSize,
> +  IN BOOLEANSupportFvb,
> +  OUT NOR_FLASH_INSTANCE**  NorFlashInstance
> +  )
> +{
> +  EFI_STATUS Status;
> +  NOR_FLASH_INSTANCE* Instance;
> +
> +  ASSERT(NorFlashInstance != NULL);
> +
> +  Instance = AllocateRuntimeCopyPool 
> (sizeof(NOR_FLASH_INSTANCE),);

Why runtime?

Re: [edk2] [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction

2019-02-19 Thread Ashish Singhal
Hello Mike/Lao,

Were you able to have a look at this?

Thanks
Ashish

-Original Message-
From: Ashish Singhal  
Sent: Monday, February 4, 2019 1:16 PM
To: edk2-devel@lists.01.org
Cc: michael.d.kin...@intel.com; liming@intel.com; Ashish Singhal 

Subject: [PATCH] MdePkg/UefiLib: Simplify protocol un/installation abstraction

Add helper functions to operate upon protocol installation and
uninstallation instead of every function doing it by itself.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ashish Singhal 
---
 MdePkg/Library/UefiLib/UefiDriverModel.c | 2040 +-
 1 file changed, 342 insertions(+), 1698 deletions(-)

diff --git a/MdePkg/Library/UefiLib/UefiDriverModel.c 
b/MdePkg/Library/UefiLib/UefiDriverModel.c
index 262d8bc..268edf7 100644
--- a/MdePkg/Library/UefiLib/UefiDriverModel.c
+++ b/MdePkg/Library/UefiLib/UefiDriverModel.c
@@ -17,6 +17,290 @@
 
 #include "UefiLibInternal.h"
 
+
+#define MAX_SUPPORTED_PROTOCOLS 7
+typedef struct {
+  EFI_GUID *Guid;
+  VOID *Interface;
+} EFI_PROCESS_PROTOCOL;
+
+
+static
+EFI_STATUS
+EFIAPI
+EfiLibProcessProtocols (
+  IN CONST EFI_HANDLE ImageHandle,
+  IN EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding,
+  IN EFI_HANDLE   DriverBindingHandle,
+  IN BOOLEAN  Install,
+  IN CONST EFI_PROCESS_PROTOCOL   *ProtocolArray
+  )
+{
+  ASSERT (DriverBinding != NULL);
+  ASSERT (ProtocolArray != NULL);
+
+  if (Install) {
+//
+// Update the ImageHandle and DriverBindingHandle fields of the Driver 
Binding Protocol
+//
+DriverBinding->ImageHandle = ImageHandle;
+DriverBinding->DriverBindingHandle = DriverBindingHandle;
+
+return gBS->InstallMultipleProtocolInterfaces (
+  >DriverBindingHandle,
+  ProtocolArray[0].Guid, ProtocolArray[0].Interface,
+  ProtocolArray[1].Guid, ProtocolArray[1].Interface,
+  ProtocolArray[2].Guid, ProtocolArray[2].Interface,
+  ProtocolArray[3].Guid, ProtocolArray[3].Interface,
+  ProtocolArray[4].Guid, ProtocolArray[4].Interface,
+  ProtocolArray[5].Guid, ProtocolArray[5].Interface,
+  ProtocolArray[6].Guid, ProtocolArray[6].Interface,
+  NULL
+  );
+  } else {
+return gBS->UninstallMultipleProtocolInterfaces (
+  DriverBinding->DriverBindingHandle,
+  ProtocolArray[0].Guid, ProtocolArray[0].Interface,
+  ProtocolArray[1].Guid, ProtocolArray[1].Interface,
+  ProtocolArray[2].Guid, ProtocolArray[2].Interface,
+  ProtocolArray[3].Guid, ProtocolArray[3].Interface,
+  ProtocolArray[4].Guid, ProtocolArray[4].Interface,
+  ProtocolArray[5].Guid, ProtocolArray[5].Interface,
+  ProtocolArray[6].Guid, ProtocolArray[6].Interface,
+  NULL
+  );
+  }
+}
+
+
+
+static
+EFI_STATUS
+EFIAPI
+EfiLibProcessAllDriverProtocols (
+  IN CONST EFI_HANDLE ImageHandle,
+  IN EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding,
+  IN EFI_HANDLE   DriverBindingHandle,
+  IN BOOLEAN  Install,
+  IN CONST EFI_COMPONENT_NAME_PROTOCOL*ComponentName,
+  IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL  *DriverConfiguration,
+  IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL*DriverDiagnostics
+  )
+{
+  EFI_STATUS   Status;
+  EFI_PROCESS_PROTOCOL ProtocolArray[MAX_SUPPORTED_PROTOCOLS];
+  UINT8ProtocolCount;
+
+  ASSERT (DriverBinding != NULL);
+
+  //
+  // ZI the ProtocolArray structure. Both InstallMultipleProtocolInterfaces
+  // and UninstallMultipleProtocolInterfaces would stop processing 
ProtocolArray
+  // elements as soon as they encounter a NULL.
+  //
+  ZeroMem(ProtocolArray, sizeof(ProtocolArray));
+  ProtocolCount = 0;
+
+  //
+  // Populate ProtocolArray with valid protocol interfaces.
+  //
+  ProtocolArray[ProtocolCount].Guid = 
+  ProtocolArray[ProtocolCount].Interface = DriverBinding;
+  ProtocolCount++;
+
+  if (ComponentName != NULL && !FeaturePcdGet(PcdComponentNameDisable)) {
+ProtocolArray[ProtocolCount].Guid = 
+ProtocolArray[ProtocolCount].Interface = (VOID *)ComponentName;
+ProtocolCount++;
+  }
+
+  if (DriverConfiguration != NULL) {
+ProtocolArray[ProtocolCount].Guid = 
+ProtocolArray[ProtocolCount].Interface = (VOID *)DriverConfiguration;
+ProtocolCount++;
+  }
+
+  if (DriverDiagnostics != NULL && 
!FeaturePcdGet(PcdDriverDiagnosticsDisable)) {
+ProtocolArray[ProtocolCount].Guid = 
+ProtocolArray[ProtocolCount].Interface = (VOID *)DriverDiagnostics;
+ProtocolCount++;
+  }
+
+  Status = EfiLibProcessProtocols (
+ ImageHandle,
+ DriverBinding,
+ 

Re: [edk2] [Patch V2] BaseTools: replace Sdict with OrderedDict in UPT

2019-02-19 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Feng, Bob C
> Sent: Tuesday, February 19, 2019 7:44 AM
> To: edk2-devel@lists.01.org
> Cc: Feng, Bob C ; Gao, Liming
> ; Carsey, Jaben 
> Subject: [Patch V2] BaseTools: replace Sdict with OrderedDict in UPT
> Importance: High
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1504
> 
> V2: import OrderredDict as Sdict in Misc.py instead
> updating all the py files.
> 
> Sdict class is removed on the commit
> 174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec
> but there are still some py files import it.
> 
> This patch is to use collections.OrderedDict to replace Sdict.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng 
> Cc: Liming Gao 
> Cc: Jaben Carsey 
> ---
>  BaseTools/Source/Python/UPT/Library/Misc.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py
> b/BaseTools/Source/Python/UPT/Library/Misc.py
> index e7ee27cc53..0967ea53d1 100644
> --- a/BaseTools/Source/Python/UPT/Library/Misc.py
> +++ b/BaseTools/Source/Python/UPT/Library/Misc.py
> @@ -1,9 +1,9 @@
>  ## @file
>  # Common routines used by all tools
>  #
> -# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
> +# Copyright (c) 2011 - 2019, 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
>  # http://opensource.org/licenses/bsd-license.php
> @@ -30,11 +30,11 @@ from os import remove
>  from os import rmdir
>  from os import linesep
>  from os import walk
>  from os import environ
>  import re
> -from collections import OrderedDict
> +from collections import OrderedDict as Sdict
> 
>  import Logger.Log as Logger
>  from Logger import StringTable as ST
>  from Logger import ToolError
>  from Library import GlobalData
> --
> 2.18.0.windows.1

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


[edk2] [Patch V2] BaseTools: replace Sdict with OrderedDict in UPT

2019-02-19 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1504

V2: import OrderredDict as Sdict in Misc.py instead 
updating all the py files.

Sdict class is removed on the commit
174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec
but there are still some py files import it.

This patch is to use collections.OrderedDict to replace Sdict.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
Cc: Jaben Carsey 
---
 BaseTools/Source/Python/UPT/Library/Misc.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/UPT/Library/Misc.py 
b/BaseTools/Source/Python/UPT/Library/Misc.py
index e7ee27cc53..0967ea53d1 100644
--- a/BaseTools/Source/Python/UPT/Library/Misc.py
+++ b/BaseTools/Source/Python/UPT/Library/Misc.py
@@ -1,9 +1,9 @@
 ## @file
 # Common routines used by all tools
 #
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2019, 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
 # http://opensource.org/licenses/bsd-license.php
@@ -30,11 +30,11 @@ from os import remove
 from os import rmdir
 from os import linesep
 from os import walk
 from os import environ
 import re
-from collections import OrderedDict
+from collections import OrderedDict as Sdict
 
 import Logger.Log as Logger
 from Logger import StringTable as ST
 from Logger import ToolError
 from Library import GlobalData
-- 
2.18.0.windows.1

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


Re: [edk2] [PATCH] ShellPkg: add array index check for shell delay option

2019-02-19 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Zhichao Gao
> Sent: Monday, February 18, 2019 12:28 AM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2] [PATCH] ShellPkg: add array index check for shell delay
> option
> Importance: High
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1528
> 
> Shell delay option without parameters do not check the
> index of shell parameter argv. Add index check to avoid
> invalid pointer references.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhichao Gao 
> 
> Cc: Liming Gao 
> Cc: Ray Ni 
> ---
>  ShellPkg/Application/Shell/Shell.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/Shell.c
> b/ShellPkg/Application/Shell/Shell.c
> index 104f4c8961..ec344137d3 100644
> --- a/ShellPkg/Application/Shell/Shell.c
> +++ b/ShellPkg/Application/Shell/Shell.c
> @@ -1,7 +1,7 @@
>  /** @file
>This is THE shell (application)
> 
> -  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> +  Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
>(C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.
>Copyright 2015-2018 Dell Technologies.
>This program and the accompanying materials
> @@ -1002,7 +1002,11 @@ ProcessCommandLine(
>   ) == 0) {
>ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay= TRUE;
>// Check for optional delay value following "-delay"
> -  DelayValueStr = gEfiShellParametersProtocol->Argv[LoopVar + 1];
> +  if ((LoopVar + 1) >= gEfiShellParametersProtocol->Argc) {
> +DelayValueStr = NULL;
> +  } else {
> +DelayValueStr = gEfiShellParametersProtocol->Argv[LoopVar + 1];
> +  }
>if (DelayValueStr != NULL){
>  if (*DelayValueStr == L':') {
>DelayValueStr++;
> --
> 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] BaseTools: replace Sdict with OrderedDict in UPT

2019-02-19 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1504
Sdict class is removed on the commit
174a9d3cc8f74f7a731ac5f16ce6864c8eb359ec
but there are still some py files import it.

This patch is to use collections.OrderedDict to replace Sdict.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py  | 4 ++--
 BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py | 4 ++--
 BaseTools/Source/Python/UPT/InstallPkg.py | 4 ++--
 BaseTools/Source/Python/UPT/Object/POM/PackageObject.py   | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/DecObject.py| 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfBinaryObject.py  | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfDefineObject.py  | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfGuidObject.py| 4 ++--
 .../Python/UPT/Object/Parser/InfLibraryClassesObject.py   | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfMisc.py  | 4 ++--
 .../Source/Python/UPT/Object/Parser/InfPackagesObject.py  | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfPcdObject.py | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfPpiObject.py | 4 ++--
 .../Source/Python/UPT/Object/Parser/InfProtocolObject.py  | 4 ++--
 BaseTools/Source/Python/UPT/Object/Parser/InfSoucesObject.py  | 4 ++--
 .../Source/Python/UPT/Object/Parser/InfUserExtensionObject.py | 4 ++--
 BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py | 4 ++--
 BaseTools/Source/Python/UPT/Xml/XmlParser.py  | 4 ++--
 18 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py 
b/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
index 873e2b4de4..13f5cd951b 100644
--- a/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
+++ b/BaseTools/Source/Python/UPT/Core/DistributionPackageClass.py
@@ -1,9 +1,9 @@
 ## @file
 # This file is used to define a class object to describe a distribution package
 #
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2019, 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
 # http://opensource.org/licenses/bsd-license.php
@@ -18,11 +18,11 @@ DistributionPackageClass
 ##
 # Import Modules
 #
 import os.path
 
-from Library.Misc import Sdict
+from collections import OrderedDict as Sdict
 from Library.Misc import GetNonMetaDataFiles
 from PomAdapter.InfPomAlignment import InfPomAlignment
 from PomAdapter.DecPomAlignment import DecPomAlignment
 import Logger.Log as Logger
 from Logger import StringTable as ST
diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py 
b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
index 40346b0b3a..1ef2714c5e 100644
--- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
+++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
@@ -1,10 +1,10 @@
 ## @file GenInfFile.py
 #
 # This file contained the logical of transfer package object to INF files.
 #
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2019, 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
 # http://opensource.org/licenses/bsd-license.php
@@ -24,11 +24,11 @@ from Library.StringUtils import GetSplitValueList
 from Library.Parsing import GenSection
 from Library.Parsing import GetWorkspacePackage
 from Library.Parsing import ConvertArchForInstall
 from Library.Misc import SaveFileOnChange
 from Library.Misc import IsAllModuleList
-from Library.Misc import Sdict
+from collections import OrderedDict as Sdict
 from Library.Misc import ConvertPath
 from Library.Misc import ConvertSpec
 from Library.Misc import GetRelativePath
 from Library.Misc import GetLocalValue
 from Library.CommentGenerating import GenHeaderCommentSection
diff --git a/BaseTools/Source/Python/UPT/InstallPkg.py 
b/BaseTools/Source/Python/UPT/InstallPkg.py
index cbc54f9407..91c7f040b1 100644
--- a/BaseTools/Source/Python/UPT/InstallPkg.py
+++ b/BaseTools/Source/Python/UPT/InstallPkg.py
@@ -1,9 +1,9 @@
 ## @file
 # Install distribution package.
 #
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2019, 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
 # 

Re: [edk2] [PATCH edk2-platforms 0/2] Platform/RaspberryPi3: add RNG support

2019-02-19 Thread Ard Biesheuvel
On Tue, 19 Feb 2019 at 15:44, Leif Lindholm  wrote:
>
> On Sat, Feb 16, 2019 at 11:34:20AM +0100, Ard Biesheuvel wrote:
> > Add a RNG driver for the BCM283x and wire it up for the Raspberry Pi 3
> > platform so that the random number generator is accessible to the OS
> > loader via the EFI_RNG_PROTOCOL. This is used by the KASLR implementation
> > in the arm64 Linux kernel to randomize the placement of various parts of
> > the kernel.
> >
> > Changes since v2:
> > - move the RNG specific SoC definitions into the Bcm2836.h common header
> > - add patch that wires up the driver into the RPi3 platform
> >
> > Cc: Pete Batard 
> > Cc: Jeremy Linton 
> > Cc: Leif Lindholm 
>
> For the series:
> Reviewed-by: Leif Lindholm 
>

Thanks

Pushed as 94d6843f1a90..76d9e9a5da9e

> > Ard Biesheuvel (2):
> >   Silicon/Bcm2836: add random number generator driver
> >   Platform/RaspberryPi3: add RNG driver
> >
> >  Platform/RaspberryPi/RPi3/RPi3.dsc  |   5 +
> >  Platform/RaspberryPi/RPi3/RPi3.fdf  |   5 +
> >  Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c| 203 
> > 
> >  Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.inf  |  45 +
> >  Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h |   9 +
> >  5 files changed, 267 insertions(+)
> >  create mode 100644 Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c
> >  create mode 100644 Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.inf
> >
> > --
> > 2.20.1
> >
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V3] BaseTools:BaseTools supports to the driver combination.

2019-02-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

> -Original Message-
> From: Fan, ZhijuX
> Sent: Tuesday, February 19, 2019 6:47 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming 
> Subject: [edk2][PATCH V3] BaseTools:BaseTools supports to the driver 
> combination.
> 
> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1520
> 
> To save the image size without the compression, more than
> one drivers can be combined into single one. When more than
> one drivers are combined, their depex will be AND together.
> Below is the example to combine BootManagerPolicyDxe into
> DriverHealthManagerDxe.
> 
> Besides this patch, BaseTools also needs to check the module
> type and make sure all module type are same. Otherwise,
> BaseTools will report the error.
> DRIVER INF has the parameter ENTRY_POINT
> LIBRARY INF has the parameter LIBRARY_CLASS
> 
> Cc: Liming Gao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhiju.Fan 
> ---
>  BaseTools/Source/Python/AutoGen/GenC.py| 32 
> ++
>  .../Source/Python/Workspace/WorkspaceCommon.py |  8 ++
>  2 files changed, 35 insertions(+), 5 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
> b/BaseTools/Source/Python/AutoGen/GenC.py
> index 9700bf8527..e6fc5cda3c 100644
> --- a/BaseTools/Source/Python/AutoGen/GenC.py
> +++ b/BaseTools/Source/Python/AutoGen/GenC.py
> @@ -1455,10 +1455,25 @@ def CreateLibraryDestructorCode(Info, AutoGenC, 
> AutoGenH):
>  def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
>  if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, 
> SUP_MODULE_SEC]:
>  return
> +ModuleEntryPointList = []
> +for Lib in Info.DependentLibraryList:
> +if len(Lib.ModuleEntryPointList) > 0:
> +if Lib.ModuleType == Info.ModuleType:
> +ModuleEntryPointList = ModuleEntryPointList + 
> Lib.ModuleEntryPointList
> +else:
> +EdkLogger.error(
> +"build",
> +PREBUILD_ERROR,
> +"Driver's ModuleType must be consistent [%s]"%(str(Lib)),
> +File=str(Info.PlatformInfo),
> +ExtraData="consumed by [%s]" % str(Info.MetaFile)
> +)
> +ModuleEntryPointList = ModuleEntryPointList + 
> Info.Module.ModuleEntryPointList
> +
>  #
>  # Module Entry Points
>  #
> -NumEntryPoints = len(Info.Module.ModuleEntryPointList)
> +NumEntryPoints = len(ModuleEntryPointList)
>  if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification:
>  PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION']
>  else:
> @@ -1468,7 +1483,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, 
> AutoGenH):
>  else:
>  UefiSpecVersion = '0x'
>  Dict = {
> -'Function'   :   Info.Module.ModuleEntryPointList,
> +'Function'   :   ModuleEntryPointList,
>  'PiSpecVersion'  :   PiSpecVersion + 'U',
>  'UefiSpecVersion':   UefiSpecVersion + 'U'
>  }
> @@ -1481,7 +1496,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, 
> AutoGenH):
>AUTOGEN_ERROR,
>'%s must have exactly one entry point' % Info.ModuleType,
>File=str(Info),
> -  ExtraData= ", ".join(Info.Module.ModuleEntryPointList)
> +  ExtraData= ", ".join(ModuleEntryPointList)
>)
>  if Info.ModuleType == SUP_MODULE_PEI_CORE:
>  AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
> @@ -1535,11 +1550,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, 
> AutoGenH):
>  def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
>  if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, 
> SUP_MODULE_SEC]:
>  return
> +
> +ModuleUnloadImageList = []
> +for Lib in Info.DependentLibraryList:
> +if len(Lib.ModuleUnloadImageList) > 0:
> +ModuleUnloadImageList = ModuleUnloadImageList + 
> Lib.ModuleUnloadImageList
> +ModuleUnloadImageList = ModuleUnloadImageList + 
> Info.Module.ModuleUnloadImageList
> +
>  #
>  # Unload Image Handlers
>  #
> -NumUnloadImage = len(Info.Module.ModuleUnloadImageList)
> -Dict = {'Count':str(NumUnloadImage) + 'U', 
> 'Function':Info.Module.ModuleUnloadImageList}
> +NumUnloadImage = len(ModuleUnloadImageList)
> +Dict = {'Count':str(NumUnloadImage) + 'U', 
> 'Function':ModuleUnloadImageList}
>  if NumUnloadImage < 2:
>  AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict))
>  else:
> diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py 
> b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
> index b79280bc2e..22abda8743 100644
> --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
> +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
> @@ -20,6 +20,8 @@ from Workspace.BuildClassObject import 

Re: [edk2] [PATCH edk2-platforms 0/2] Platform/RaspberryPi3: add RNG support

2019-02-19 Thread Leif Lindholm
On Sat, Feb 16, 2019 at 11:34:20AM +0100, Ard Biesheuvel wrote:
> Add a RNG driver for the BCM283x and wire it up for the Raspberry Pi 3
> platform so that the random number generator is accessible to the OS
> loader via the EFI_RNG_PROTOCOL. This is used by the KASLR implementation
> in the arm64 Linux kernel to randomize the placement of various parts of
> the kernel.
> 
> Changes since v2:
> - move the RNG specific SoC definitions into the Bcm2836.h common header
> - add patch that wires up the driver into the RPi3 platform
> 
> Cc: Pete Batard 
> Cc: Jeremy Linton 
> Cc: Leif Lindholm 

For the series:
Reviewed-by: Leif Lindholm 

> Ard Biesheuvel (2):
>   Silicon/Bcm2836: add random number generator driver
>   Platform/RaspberryPi3: add RNG driver
> 
>  Platform/RaspberryPi/RPi3/RPi3.dsc  |   5 +
>  Platform/RaspberryPi/RPi3/RPi3.fdf  |   5 +
>  Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c| 203 
> 
>  Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.inf  |  45 +
>  Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h |   9 +
>  5 files changed, 267 insertions(+)
>  create mode 100644 Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.c
>  create mode 100644 Silicon/Broadcom/Bcm283x/Drivers/RngDxe/RngDxe.inf
> 
> -- 
> 2.20.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH] BaseTools:Fixed build failure when specifying multiple BUILDTARGET

2019-02-19 Thread Feng, Bob C
Reviewed-by: Bob Feng 

-Original Message-
From: Fan, ZhijuX 
Sent: Tuesday, February 19, 2019 6:56 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Feng, Bob C 
Subject: [edk2][PATCH] BaseTools:Fixed build failure when specifying multiple 
BUILDTARGET

With Python3, the dict.value() method returns an iterator.
If a dictionary is updated while an iterator on its keys is used, a 
RuntimeError is generated.
Converting the iterator to a list() forces a copy of the mutable keys in an 
immutable list which can be safely iterated.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2452ecbcba..7969e46d87 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -580,7 +580,7 @@ class WorkspaceAutoGen(AutoGen):
 if NewPcd2 not in GlobalData.MixedPcd[item]:
 GlobalData.MixedPcd[item].append(NewPcd2)
 
-for BuildData in PGen.BuildDatabase._CACHE_.values():
+for BuildData in list(PGen.BuildDatabase._CACHE_.values()):
 if BuildData.Arch != Arch:
 continue
 for key in BuildData.Pcds:
--
2.14.1.windows.1

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


Re: [edk2] [Patch] BaseTools: Remove unused txt files

2019-02-19 Thread Feng, Bob C
Reviewed-by: Bob Feng 

-Original Message-
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Liming 
Gao
Sent: Friday, February 15, 2019 10:32 PM
To: edk2-devel@lists.01.org
Subject: [edk2] [Patch] BaseTools: Remove unused txt files

externals.txt is to refer to the binary Win32. It is not used any longer.
BuildNotes.txt is to freeze BaseTools python. It is not used any longer.
BinaryFiles.txt is to list the file in Bin directory. But, Bin dir is empty.
building-gcc.txt and gcc is for mingw-gcc. It is not used any longer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 BaseTools/Bin/externals.txt  |   1 -
 BaseTools/BuildNotes.txt |  83 --
 BaseTools/Source/BinaryFiles.txt |  79 --
 BaseTools/building-gcc.txt   |  15 --
 BaseTools/gcc/README.txt |  71 -
 BaseTools/gcc/mingw-gcc-build.py | 565 ---
 6 files changed, 814 deletions(-)
 delete mode 100644 BaseTools/Bin/externals.txt  delete mode 100644 
BaseTools/BuildNotes.txt  delete mode 100644 BaseTools/Source/BinaryFiles.txt  
delete mode 100644 BaseTools/building-gcc.txt  delete mode 100644 
BaseTools/gcc/README.txt  delete mode 100755 BaseTools/gcc/mingw-gcc-build.py

diff --git a/BaseTools/Bin/externals.txt b/BaseTools/Bin/externals.txt deleted 
file mode 100644 index c2c4ab7297..00
--- a/BaseTools/Bin/externals.txt
+++ /dev/null
@@ -1 +0,0 @@
-Win32  https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32
diff --git a/BaseTools/BuildNotes.txt b/BaseTools/BuildNotes.txt deleted file 
mode 100644 index e2b10fddc3..00
--- a/BaseTools/BuildNotes.txt
+++ /dev/null
@@ -1,83 +0,0 @@
-Intel(R) Platform Innovation Framework for EFI -BuildTools Project, BaseTools 
Sub-Project -Root Package 1.00
-2007-08-31
-
-Intel is a trademark or registered trademark of Intel Corporation or its 
-subsidiaries in the United States and other countries.
-* Other names and brands may be claimed as the property of others.
-Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
-

-Quick Start

-
-Windows:
-  a) Go to the /BaseTools and run "toolsetup" script
-
-Unix-like:
-  a) make -C /BaseTools
-  b) Look over 
https://github.com/tianocore/tianocore.github.io/wiki/Getting%20Started%20with%20EDK%20II
- for a helpful step-by-step guide for building 'Hello World' on
- various operating systems with edk2.
-
-Supported build targets (toolsetup)

-
-build(or none)  - Incremental Build of all C based tools. This is the default 
target
-rebuild - Clean all generated files and directories during build, and 
rebuild all tools
-

-Tools in Python

-* Convert Python source to exe file
-
-  The tools written in Python can be converted into executable program which 
can
-  be executed without installing a Python interpreter. (Generally it is easier
-  to run the scripts from their source on operating systems other than 
Windows.)
-
-  For Windows and Linux, the conversion tool package is called cx_Freeze, its
-  home page is:
-
-http://sourceforge.net/projects/cx-freeze/
-
-  If you have installed cx_Freeze at c:\cx_Freeze-3.0.3. Use following command
-  lines to convert MyBuild.py to MyBuild.exe (note this is an example, there is
-  no MyBuild Python project in the BaseTools\Python tree.
-
-set PYTHONPATH=\Source\Python
-c:\cx_Freeze-3.0.3\FreezePython.exe 
--include-modules=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_16_le,encodings.utf_8
 --install-dir=.\mybuild MyBuild.py
-
-  The generated .exe (and .dll) files are put in "mybuild" subdirectory.
-
-  The following is a real example with the BuildTools/trunk/BaseTools project
-  installed in: C:\Work\BaseTools
-
-
-  C:\Work\BaseTools\Source\Python> set 
PYTHONPATH=C:\Work\BaseTools\Source\Python
-  C:\Work\BaseTools\Source\Python> c:\cx_Freeze-3.0.3\FreezePython.exe 
--include-modules=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_16_le,encodings.utf_8
 --install-dir=C:\Work\BaseTools\Bin\Win32 build\build.py
-

-* Execute tools written in Python without conversion
-
-Unix-like systems:
-
-The edk2/edksetup.sh script will setup everything which is needed to -run the 
scripts from their source.
-
-Windows:
-
-  The tools written in Python can be executed directly from its source 
directory -as long as the Python interpreter (Python 2.5) has been installed. 
Before the execution, -please make sure the environment variable PYTHONPATH is 
set to
-
-/BaseTools/Source/Python
-
-  There're five tools written in Python. The entrance file of each tool is 
listed -below.
-
-  build   
/BaseTools/Source/Python/build/build.py
-  GenFds  

[edk2] [Patch] BaseTools: Fix a bug about Structure PCD

2019-02-19 Thread Feng, Bob C
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1535
If there is Hii Structure Pcd, build will fail, root cause is that
there is an incorrect variable access method used in code.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng 
Cc: Liming Gao 
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index e45beb3924..2e6eb16b08 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -2392,11 +2392,11 @@ class DscBuildData(PlatformBuildClassObject):
 skuinfo = Pcd.SkuInfoList[skuname]
 if skuinfo.VariableName:
 for defaultstore in skuinfo.DefaultStoreDict:
 pcddscrawdefaultvalue = 
self.GetPcdDscRawDefaultValue(Pcd, skuname, defaultstore)
 if pcddscrawdefaultvalue:
-Value = skuinfo[defaultstore]
+Value = skuinfo.DefaultStoreDict[defaultstore]
 if "{CODE(" in Value:
 realvalue = Value.strip()[6:-2] # 
"{CODE(").rstrip(")}"
 CApp += "static %s %s_%s_%s_%s_Value%s = 
%s;\n" % 
(Pcd.BaseDatumType,Pcd.TokenSpaceGuidCName,Pcd.TokenCName,skuname,defaultstore,Demesion,realvalue)
 else:
 pcddscrawdefaultvalue = self.GetPcdDscRawDefaultValue(Pcd, 
skuname, TAB_DEFAULT_STORES_DEFAULT)
-- 
2.20.1.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg/VariableSmmRuntimeDxe: Refactor locating Variable Arch Protocol

2019-02-19 Thread Ard Biesheuvel
Hello Jagadeesh,

On Tue, 19 Feb 2019 at 11:47, Jagadeesh Ujja  wrote:
>
> In preparation for providing a standalone MM based non-secure variable
> runtime driver, factor out some portions that are specific to the
> traditional driver, mainly related to locating variable arch protocol
> and variable write arch protocol, which are not required to be located
> when using standalone MM based secure variable implementation.
>

While i think this change is correct from a technical perspective, I
don't think this is the right approach.

It was a deliberate decision to expose the MM services in a way that
only the producer of the communication protocol is aware of the
implementation details, i.e., whether it is backed by tradtional MM or
standalone MM.

By creating separate runtime DXE drivers that can work either with the
traditional MM or the standalone MM, you are defeating that, and so we
should discuss this at a more fundamental level, and also take into
account the other issue we ran into, where the communicate protocol
needs either the physical address of the comm buffer (in the
traditional MM case) or the virtual address (in the standalone MM
case).

Both issues suggest that perhaps the 'abstract' MM communicate
protocol is not feasible in practice, in which case this patch would
probably be an appropriate course of action.

If not, we should discuss how in general DXE runtime drivers that
DEPEX on protocols produced by SMM drivers should be implemented based
on this abstract MM model. One potential approach could be to
introduce a library that encapsulates this dependency, and leave it up
to the platform to make it depend on whichever dependencies it
defines.




> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jagadeesh Ujja 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
>  | 18 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c   
>  |  9 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf 
>  |  1 +
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.c  
>  | 42 +
>  
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.inf 
> | 95 
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMmRuntimeDxe.c 
>  | 45 ++
>  6 files changed, 203 insertions(+), 7 deletions(-)
>
> diff --git 
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> index 9b294e6..c50 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> @@ -160,4 +160,22 @@ VariableHaveTcgProtocols (
>VOID
>);
>
> +/**
> +  Check whether the protocol is installed or not.
> +**/
> +EFI_STATUS
> +EFIAPI
> +VariableLocateSmmReady (
> +  VOID
> +  );
> +
> +/**
> +  Check whether the protocol is installed or not.
> +**/
> +EFI_STATUS
> +EFIAPI
> +VariableLocateSmmWriteReady (
> +  VOID
> +  );
> +
>  #endif
> diff --git 
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> index 85d655d..2976f04 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
> @@ -47,7 +47,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
> EXPRESS OR IMPLIED.
>  #include "PrivilegePolymorphic.h"
>
>  EFI_HANDLE   mHandle= NULL;
> -EFI_SMM_VARIABLE_PROTOCOL   *mSmmVariable   = NULL;
>  EFI_EVENTmVirtualAddressChangeEvent = NULL;
>  EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication  = NULL;
>  UINT8   *mVariableBuffer= NULL;
> @@ -991,7 +990,7 @@ SmmVariableReady (
>  {
>EFI_STATUSStatus;
>
> -  Status = gBS->LocateProtocol (, NULL, (VOID 
> **));
> +  Status = VariableLocateSmmReady ();
>if (EFI_ERROR (Status)) {
>  return;
>}
> @@ -1068,12 +1067,8 @@ SmmVariableWriteReady (
>)
>  {
>EFI_STATUSStatus;
> -  VOID  *ProtocolOps;
>
> -  //
> -  // Check whether the protocol is installed or not.
> -  //
> -  Status = gBS->LocateProtocol (, NULL, (VOID **) 
> );
> +  Status = VariableLocateSmmWriteReady ();
>if (EFI_ERROR (Status)) {
>  return;
>}
> diff --git 
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf 
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
> index bd73f7a..103acfa 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
> @@ -41,6 

Re: [edk2] [PATCH 00/10] Fix PEI Core issue during TemporaryRamMigration

2019-02-19 Thread Gao, Liming
Ray:
In PI spec, TEMPORARY_RAM_SUPPORT_PPI is described as an optional PPI 
that is only required for platforms that may have side effects when both 
Temporary RAM and Permanent RAM are enabled. If a platform does not have any 
side effects when both Temporary RAM and Permanent RAM are enabled, and the 
platform is required to disable the use of Temporary RAM, then 
EFI_PEI_TEMPORARY_RAM_DONE should be produced. If a platform does not have any 
side effects when both Temporary RAM and Permanent RAM are enabled, and the 
platform is not required to disable the use of Temporary RAM, then neither 
EFI_PEI_TEMPORARY_RAM_DONE nor EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI should be 
produced.

Now, real platform has no side effect. So, only TempRamDone PPI is 
produced. For emulator platform, is there any side effect when both Temporary 
RAM and Permanent RAM are enabled? 

Thanks
Liming
> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ni, Ray
> Sent: Tuesday, February 19, 2019 10:46 AM
> To: Justen, Jordan L ; edk2-devel@lists.01.org
> Cc: Wu, Hao A ; Anthony Perard 
> ; Laszlo Ersek ; Zeng, Star
> 
> Subject: Re: [edk2] [PATCH 00/10] Fix PEI Core issue during 
> TemporaryRamMigration
> 
> Jordan,
> I find many real platforms do not implement the temporary ram migration
> PPI and rely on the PeiCore migration  logic.
> So perhaps TemporaryRamMigration PPI was added to help platform to
> destroy the temporary RAM (CAR in x86 platform).
> But with the introduction of TemporaryRamDone PPI, maybe the
> TemporaryRamMigration PPI can be retired.
> The logic in PeiCore to call TemporaryRamMigration is just for backward
> compatibility.
> If that's true, do you still need to enhance PeiCore?
> 
> For the Emulator case, I already found without TemporaryRamMigration
> the platform can still boot.
> 
> Does OVMF hard-depend on TemporaryRamMigration? Or it can reply on
> the PeiCore migration logic + TemporaryDone PPI?
> 
> Thanks,
> Ray
> 
> > -Original Message-
> > From: Justen, Jordan L 
> > Sent: Monday, February 18, 2019 12:12 PM
> > To: edk2-devel@lists.01.org
> > Cc: Justen, Jordan L ; Liu Yu
> > ; Andrew Fish ; Anthony
> > Perard ; Ard Biesheuvel
> > ; Wu, Hao A ; Wang, Jian
> > J ; Julien Grall ; Laszlo 
> > Ersek
> > ; Ni, Ray ; Zeng, Star
> > 
> > Subject: [PATCH 00/10] Fix PEI Core issue during TemporaryRamMigration
> >
> > https://github.com/jljusten/edk2.git temp-ram-support
> >
> > This series fixes an issue that, while rare, is possible based on the way 
> > the
> > TemporaryRamSupport PPI is defined along with how it is used by the PEI
> > Core.
> >
> > Liu Yu reported a boot issue with EmulatorPkg, which I believe was caused by
> > this issue.
> >
> > The details of the issue are described in the commit message of the
> > "MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram
> > migration" patch.
> >
> > Along with this, I added a few Temporary RAM patches for EmulatorPkg and
> > OvmfPkg.
> >
> > Cc: Liu Yu 
> > Cc: Andrew Fish 
> > Cc: Anthony Perard 
> > Cc: Ard Biesheuvel 
> > Cc: Hao Wu 
> > Cc: Jian J Wang 
> > Cc: Julien Grall 
> > Cc: Laszlo Ersek 
> > Cc: Ray Ni 
> > Cc: Star Zeng 
> >
> > Jordan Justen (10):
> >   EmulatorPkg/build.sh: Fix missing usage of -b BUILDTARGET parameter
> >   EmulatorPkg/Unix/Host: Use PcdInitValueInTempStack to init temp-ram
> >   EmulatorPkg/Sec: Replace assembly temp-ram support with C code
> >   EmulatorPkg/Sec: Disable optimizations for TemporaryRamMigration
> > function
> >   OvmfPkg/Sec: Swap TemporaryRam Stack and Heap locations
> >   OvmfPkg/Sec: Disable optimizations for TemporaryRamMigration
> >   MdeModePkg/Core/Pei: Add code path to allow assembly temp-ram
> > migration
> >   MdeModulePkg/Core/Pei: Use assembly for X64 TemporaryRamMigration
> >   MdeModulePkg/Core/Pei: Use assembly for IA32 TemporaryRamMigration
> >   OvmfPkg/Sec: Fill Temp Ram after TemporaryRamMigration
> >
> >  EmulatorPkg/Sec/Ia32/SwitchRam.S  | 95 ---
> >  EmulatorPkg/Sec/Ia32/SwitchRam.asm| 94 --
> >  EmulatorPkg/Sec/Ia32/TempRam.c| 65 -
> >  EmulatorPkg/Sec/Sec.c | 76 ++-
> >  EmulatorPkg/Sec/Sec.inf   | 13 +--
> >  EmulatorPkg/Sec/X64/SwitchRam.S   | 72 --
> >  EmulatorPkg/Sec/X64/SwitchRam.asm | 76 ---
> >  EmulatorPkg/Unix/Host/Host.c  |  2 +-
> >  EmulatorPkg/Unix/Host/Host.inf|  1 +
> >  EmulatorPkg/build.sh  | 10 +-
> >  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 59 
> >  .../Dispatcher/Ia32/TemporaryRamMigration.S   | 72 ++
> >  .../Ia32/TemporaryRamMigration.nasm   | 78 +++
> >  .../Pei/Dispatcher/TemporaryRamMigration.c| 52 ++
> >  .../Dispatcher/X64/TemporaryRamMigration.S| 69 

Re: [edk2] [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path

2019-02-19 Thread Ni, Ray



> -Original Message-
> From: Wang, Jian J 
> Sent: Tuesday, February 19, 2019 6:12 PM
> To: Ni, Ray ; edk2-devel@lists.01.org
> Cc: Gao, Liming ; Kinney, Michael D
> 
> Subject: RE: [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for
> FilePath device path
> 
> Hi Ray,
> 
> > -Original Message-
> > From: Ni, Ray
> > Sent: Tuesday, February 19, 2019 5:34 PM
> > To: Wang, Jian J ; edk2-devel@lists.01.org
> > Cc: Gao, Liming ; Kinney, Michael D
> > 
> > Subject: RE: [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check
> > for FilePath device path
> >
> >
> >
> > > -Original Message-
> > > From: Wang, Jian J 
> > > Sent: Tuesday, February 19, 2019 5:22 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Gao, Liming ; Ni, Ray ;
> > > Kinney, Michael D 
> > > Subject: [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check
> > > for FilePath device path
> > >
> > > > v2: fix wrong detection of FilePath device path
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497
> > >
> > > Current implementation of IsDevicePathValid() is not enough for type
> > > of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device
> path.
> > > This patch add a simple NULL character check at Length position.
> > >
> > > Cc: Liming Gao 
> > > Cc: Ray Ni 
> > > Cc: Michael D Kinney 
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Jian J Wang 
> > > ---
> > >  MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c | 9
> > > +
> > >  1 file changed, 9 insertions(+)
> > >
> > > diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > > b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > > index 5d7635fe3e..dd1bddc1c2 100644
> > > --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > > +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > > @@ -95,6 +95,15 @@ IsDevicePathValid (
> > >  return FALSE;
> > >}
> > >  }
> > > +
> > > +//
> > > +// FilePath must be a NULL-terminated string.
> > > +//
> > > +if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
> > > +DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&
> > > +*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
> > Can we assume the device path node buffer contains exact the null
> > terminated string?
> > What if the buffer contains some padding bytes after null terminated string?
> >
> > To handle this case, can we convert the DevicePath to
> > FILEPATH_DEVICE_PATH and use logic similar as below?
> >
> > FILEPATH_DEVICE_PATH *FilePath;
> > FilePath = (FILEPATH_DEVICE_PATH *) DevicePath; MaxSize = (NodeLength
> > - sizeof (EFI_DEVICE_PATH_PROTOCOL)) / sizeof (CHAR16); If (StrnLenS
> > (FilePath->PathName, MaxSize) == MaxSize) {
> >   Return FALSE;
> > }
> >
> 
> I did think about your implementation and I agree it might be the best way 
> from
> compatibility perspective. But I have three considerations:
> 
> 1. It's not a good programming habit to pass unwanted data around and should
> not
>  be encouraged to do so.
> 2. It might leave potential security hole (maybe I'm a little too cautious) 
> 3. The
> UEFI spec has following statement on this type of device path (ch10.3.6.4).
> 
> " A NULL-terminated Path string including directory and file names. The length
> of this string n can be determined by subtracting 4 from the Length entry."
> 

With such statement, I am ok to your changes.

Reviewed-by: Ray Ni 

> But I'm still open to your suggestion, if all agree that compatibility is more
> important.
> 
> Regards,
> Jian
> 
> >
> >
> > > +  return FALSE;
> > > +}
> > >}
> > >
> > >//
> > > --
> > > 2.17.1.windows.2

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


[edk2] [PATCH] MdeModulePkg/VariableSmmRuntimeDxe: Refactor locating Variable Arch Protocol

2019-02-19 Thread Jagadeesh Ujja
In preparation for providing a standalone MM based non-secure variable
runtime driver, factor out some portions that are specific to the
traditional driver, mainly related to locating variable arch protocol
and variable write arch protocol, which are not required to be located
when using standalone MM based secure variable implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jagadeesh Ujja 
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h 
| 18 
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
|  9 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf  
|  1 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.c   
| 42 +
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.inf 
| 95 
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMmRuntimeDxe.c  
| 45 ++
 6 files changed, 203 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
index 9b294e6..c50 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
@@ -160,4 +160,22 @@ VariableHaveTcgProtocols (
   VOID
   );
 
+/**
+  Check whether the protocol is installed or not.
+**/
+EFI_STATUS
+EFIAPI
+VariableLocateSmmReady (
+  VOID
+  );
+
+/**
+  Check whether the protocol is installed or not.
+**/
+EFI_STATUS
+EFIAPI
+VariableLocateSmmWriteReady (
+  VOID
+  );
+
 #endif
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
index 85d655d..2976f04 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -47,7 +47,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 #include "PrivilegePolymorphic.h"
 
 EFI_HANDLE   mHandle= NULL;
-EFI_SMM_VARIABLE_PROTOCOL   *mSmmVariable   = NULL;
 EFI_EVENTmVirtualAddressChangeEvent = NULL;
 EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication  = NULL;
 UINT8   *mVariableBuffer= NULL;
@@ -991,7 +990,7 @@ SmmVariableReady (
 {
   EFI_STATUSStatus;
 
-  Status = gBS->LocateProtocol (, NULL, (VOID 
**));
+  Status = VariableLocateSmmReady ();
   if (EFI_ERROR (Status)) {
 return;
   }
@@ -1068,12 +1067,8 @@ SmmVariableWriteReady (
   )
 {
   EFI_STATUSStatus;
-  VOID  *ProtocolOps;
 
-  //
-  // Check whether the protocol is installed or not.
-  //
-  Status = gBS->LocateProtocol (, NULL, (VOID **) 
);
+  Status = VariableLocateSmmWriteReady ();
   if (EFI_ERROR (Status)) {
 return;
   }
diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
index bd73f7a..103acfa 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf
@@ -41,6 +41,7 @@
 #
 
 [Sources]
+  VariableTraditionalMmRuntimeDxe.c
   VariableSmmRuntimeDxe.c
   PrivilegePolymorphic.h
   Measurement.c
diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.c
new file mode 100644
index 000..0c039f1
--- /dev/null
+++ 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.c
@@ -0,0 +1,42 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2019, 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 "Variable.h"
+
+
+/**
+  Check whether the protocol is installed or not.
+**/
+EFI_STATUS
+EFIAPI
+VariableLocateSmmReady (
+  VOID
+  )
+{
+  return TRUE;
+}
+
+/**
+  Check whether the protocol is installed or not.
+**/
+EFI_STATUS
+EFIAPI
+VariableLocateSmmWriteReady (
+  VOID
+  )
+{
+  return TRUE;
+}
diff --git 
a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.inf 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMmRuntimeDxe.inf
new file mode 100644

[edk2] [PATCH] BaseTools:Fixed build failure when specifying multiple BUILDTARGET

2019-02-19 Thread Fan, ZhijuX
With Python3, the dict.value() method returns an iterator.
If a dictionary is updated while an iterator on its keys is used,
a RuntimeError is generated.
Converting the iterator to a list() forces a copy of the mutable
keys in an immutable list which can be safely iterated.

Cc: Bob Feng 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 2452ecbcba..7969e46d87 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -580,7 +580,7 @@ class WorkspaceAutoGen(AutoGen):
 if NewPcd2 not in GlobalData.MixedPcd[item]:
 GlobalData.MixedPcd[item].append(NewPcd2)
 
-for BuildData in PGen.BuildDatabase._CACHE_.values():
+for BuildData in list(PGen.BuildDatabase._CACHE_.values()):
 if BuildData.Arch != Arch:
 continue
 for key in BuildData.Pcds:
-- 
2.14.1.windows.1

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


[edk2] [PATCH 1/2] ArmPlatformPkg/NorFlash: Refactor Nor Flash DXE driver

2019-02-19 Thread Jagadeesh Ujja
To allow the ArmPlatformPkg NOR flash driver to be reusable with
StandaloneMM, refactor the DXE specfic portions into a separate file.
This will then allow the common portions to be reused in StandaloneMM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jagadeesh Ujja 
---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c  
| 1136 +
 ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashDxe.h => NorFlash.h}   
|   62 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashBlockIoDxe.c => NorFlashBlockIo.c} 
|6 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c   
| 1690 
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf 
|7 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashFvbDxe.c => NorFlashFvb.c} 
|  131 +-
 6 files changed, 1552 insertions(+), 1480 deletions(-)

diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c 
b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c
new file mode 100644
index 000..725b783
--- /dev/null
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c
@@ -0,0 +1,1136 @@
+/** @file  NorFlash.c
+
+  Copyright (c) 2011 - 2019, 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 "NorFlash.h"
+
+
+NOR_FLASH_INSTANCE  mNorFlashInstanceTemplate = {
+  NOR_FLASH_SIGNATURE, // Signature
+  NULL, // Handle ... NEED TO BE FILLED
+
+  0, // DeviceBaseAddress ... NEED TO BE FILLED
+  0, // RegionBaseAddress ... NEED TO BE FILLED
+  0, // Size ... NEED TO BE FILLED
+  0, // StartLba
+
+  {
+EFI_BLOCK_IO_PROTOCOL_REVISION2, // Revision
+NULL, // Media ... NEED TO BE FILLED
+NorFlashBlockIoReset, // Reset;
+NorFlashBlockIoReadBlocks,  // ReadBlocks
+NorFlashBlockIoWriteBlocks, // WriteBlocks
+NorFlashBlockIoFlushBlocks  // FlushBlocks
+  }, // BlockIoProtocol
+
+  {
+0, // MediaId ... NEED TO BE FILLED
+FALSE, // RemovableMedia
+TRUE, // MediaPresent
+FALSE, // LogicalPartition
+FALSE, // ReadOnly
+FALSE, // WriteCaching;
+0, // BlockSize ... NEED TO BE FILLED
+4, //  IoAlign
+0, // LastBlock ... NEED TO BE FILLED
+0, // LowestAlignedLba
+1, // LogicalBlocksPerPhysicalBlock
+  }, //Media;
+
+  {
+EFI_DISK_IO_PROTOCOL_REVISION, // Revision
+NorFlashDiskIoReadDisk,// ReadDisk
+NorFlashDiskIoWriteDisk// WriteDisk
+  },
+
+  {
+FvbGetAttributes, // GetAttributes
+FvbSetAttributes, // SetAttributes
+FvbGetPhysicalAddress,  // GetPhysicalAddress
+FvbGetBlockSize,  // GetBlockSize
+FvbRead,  // Read
+FvbWrite, // Write
+FvbEraseBlocks, // EraseBlocks
+NULL, //ParentHandle
+  }, //  FvbProtoccol;
+  NULL, // ShadowBuffer
+  {
+{
+  {
+HARDWARE_DEVICE_PATH,
+HW_VENDOR_DP,
+{
+  (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End)),
+  (UINT8)(OFFSET_OF (NOR_FLASH_DEVICE_PATH, End) >> 8)
+}
+  },
+  { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }, // GUID 
... NEED TO BE FILLED
+},
+0, // Index
+{
+  END_DEVICE_PATH_TYPE,
+  END_ENTIRE_DEVICE_PATH_SUBTYPE,
+  { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
+}
+} // DevicePath
+};
+
+
+UINT32
+NorFlashReadStatusRegister (
+  IN NOR_FLASH_INSTANCE *Instance,
+  IN UINTN  SR_Address
+  )
+{
+  // Prepare to read the status register
+  SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, 
P30_CMD_READ_STATUS_REGISTER);
+  return MmioRead32 (Instance->DeviceBaseAddress);
+}
+
+STATIC
+BOOLEAN
+NorFlashBlockIsLocked (
+  IN NOR_FLASH_INSTANCE *Instance,
+  IN UINTN  BlockAddress
+  )
+{
+  UINT32LockStatus;
+
+  // Send command for reading device id
+  SEND_NOR_COMMAND (BlockAddress, 2, P30_CMD_READ_DEVICE_ID);
+
+  // Read block lock status
+  LockStatus = MmioRead32 (CREATE_NOR_ADDRESS(BlockAddress, 2));
+
+  // Decode block lock status
+  LockStatus = FOLD_32BIT_INTO_16BIT(LockStatus);
+
+  if ((LockStatus & 0x2) != 0) {
+DEBUG((EFI_D_ERROR, "NorFlashBlockIsLocked: WARNING: Block LOCKED 
DOWN\n"));
+  }
+
+  return ((LockStatus & 0x1) != 0);
+}
+
+STATIC
+EFI_STATUS
+NorFlashUnlockSingleBlock (
+  IN NOR_FLASH_INSTANCE *Instance,
+  IN UINTN  BlockAddress
+  )
+{
+  UINT32LockStatus;
+
+  // Raise the Task Priority Level to TPL_NOTIFY to serialise all its 
operations
+  // and to protect shared data 

[edk2] [PATCH V3] BaseTools:BaseTools supports to the driver combination.

2019-02-19 Thread Fan, ZhijuX
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1520

To save the image size without the compression, more than
one drivers can be combined into single one. When more than
one drivers are combined, their depex will be AND together.
Below is the example to combine BootManagerPolicyDxe into
DriverHealthManagerDxe.

Besides this patch, BaseTools also needs to check the module
type and make sure all module type are same. Otherwise,
BaseTools will report the error.
DRIVER INF has the parameter ENTRY_POINT
LIBRARY INF has the parameter LIBRARY_CLASS

Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan 
---
 BaseTools/Source/Python/AutoGen/GenC.py| 32 ++
 .../Source/Python/Workspace/WorkspaceCommon.py |  8 ++
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py 
b/BaseTools/Source/Python/AutoGen/GenC.py
index 9700bf8527..e6fc5cda3c 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1455,10 +1455,25 @@ def CreateLibraryDestructorCode(Info, AutoGenC, 
AutoGenH):
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, 
SUP_MODULE_SEC]:
 return
+ModuleEntryPointList = []
+for Lib in Info.DependentLibraryList:
+if len(Lib.ModuleEntryPointList) > 0:
+if Lib.ModuleType == Info.ModuleType:
+ModuleEntryPointList = ModuleEntryPointList + 
Lib.ModuleEntryPointList
+else:
+EdkLogger.error(
+"build",
+PREBUILD_ERROR,
+"Driver's ModuleType must be consistent [%s]"%(str(Lib)),
+File=str(Info.PlatformInfo),
+ExtraData="consumed by [%s]" % str(Info.MetaFile)
+)
+ModuleEntryPointList = ModuleEntryPointList + 
Info.Module.ModuleEntryPointList
+
 #
 # Module Entry Points
 #
-NumEntryPoints = len(Info.Module.ModuleEntryPointList)
+NumEntryPoints = len(ModuleEntryPointList)
 if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification:
 PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION']
 else:
@@ -1468,7 +1483,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 else:
 UefiSpecVersion = '0x'
 Dict = {
-'Function'   :   Info.Module.ModuleEntryPointList,
+'Function'   :   ModuleEntryPointList,
 'PiSpecVersion'  :   PiSpecVersion + 'U',
 'UefiSpecVersion':   UefiSpecVersion + 'U'
 }
@@ -1481,7 +1496,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
   AUTOGEN_ERROR,
   '%s must have exactly one entry point' % Info.ModuleType,
   File=str(Info),
-  ExtraData= ", ".join(Info.Module.ModuleEntryPointList)
+  ExtraData= ", ".join(ModuleEntryPointList)
   )
 if Info.ModuleType == SUP_MODULE_PEI_CORE:
 AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
@@ -1535,11 +1550,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, 
AutoGenH):
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
 if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, 
SUP_MODULE_SEC]:
 return
+
+ModuleUnloadImageList = []
+for Lib in Info.DependentLibraryList:
+if len(Lib.ModuleUnloadImageList) > 0:
+ModuleUnloadImageList = ModuleUnloadImageList + 
Lib.ModuleUnloadImageList
+ModuleUnloadImageList = ModuleUnloadImageList + 
Info.Module.ModuleUnloadImageList
+
 #
 # Unload Image Handlers
 #
-NumUnloadImage = len(Info.Module.ModuleUnloadImageList)
-Dict = {'Count':str(NumUnloadImage) + 'U', 
'Function':Info.Module.ModuleUnloadImageList}
+NumUnloadImage = len(ModuleUnloadImageList)
+Dict = {'Count':str(NumUnloadImage) + 'U', 
'Function':ModuleUnloadImageList}
 if NumUnloadImage < 2:
 AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict))
 else:
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py 
b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
index b79280bc2e..22abda8743 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
@@ -20,6 +20,8 @@ from Workspace.BuildClassObject import StructurePcd
 from Common.BuildToolError import RESOURCE_NOT_AVAILABLE
 from Common.BuildToolError import OPTION_MISSING
 from Common.BuildToolError import BUILD_ERROR
+from Common.BuildToolError import PREBUILD_ERROR
+import Common.EdkLogger as EdkLogError
 
 class OrderedListDict(OrderedDict):
 def __init__(self, *args, **kwargs):
@@ -138,6 +140,12 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, 
Arch, Target, Toolcha
 return []
 
  

[edk2] [PATCH 2/2] ArmPlatformPkg/NorFlash: Allow reusability as a MM driver

2019-02-19 Thread Jagadeesh Ujja
Adapt the NorFlash driver to be used as a MM_STANDALONE driver to
allow access to NOR flash for code executing in MM_STANDALONE mode.
This allows storing of EFI variables on NOR flash which is accessible
only via the MM STANDALONE mode software.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jagadeesh Ujja 
---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c   | 267 

 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf |  77 ++
 2 files changed, 344 insertions(+)

diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c 
b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
new file mode 100644
index 000..1e3603c
--- /dev/null
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
@@ -0,0 +1,267 @@
+/*++ @file  NorFlashStandaloneMm.c
+
+ Copyright (c) 2019, 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include "NorFlash.h"
+
+//
+// Global variable declarations
+//
+NOR_FLASH_INSTANCE **mNorFlashInstances;
+UINT32   mNorFlashDeviceCount;
+
+extern NOR_FLASH_INSTANCE  mNorFlashInstanceTemplate;
+
+EFI_STATUS
+EFIAPI
+NorFlashFvbInitialize (
+  IN NOR_FLASH_INSTANCE* Instance
+  )
+{
+  EFI_STATUS  Status;
+  UINT32  FvbNumLba;
+  EFI_BOOT_MODE BootMode;
+
+  DEBUG((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
+  ASSERT((Instance != NULL));
+
+  mFlashNvStorageVariableBase = FixedPcdGet32 (PcdFlashNvStorageVariableBase);
+
+  // Set the index of the first LBA for the FVB
+  Instance->StartLba = (PcdGet32 (PcdFlashNvStorageVariableBase) - 
Instance->RegionBaseAddress) / Instance->Media.BlockSize;
+
+  BootMode = GetBootModeHob ();
+  if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
+Status = EFI_INVALID_PARAMETER;
+  } else {
+// Determine if there is a valid header at the beginning of the NorFlash
+Status = ValidateFvHeader (Instance);
+  }
+
+  // Install the Default FVB header if required
+  if (EFI_ERROR(Status)) {
+// There is no valid header, so time to install one.
+DEBUG ((EFI_D_INFO, "%a: The FVB Header is not valid.\n", __FUNCTION__));
+DEBUG ((EFI_D_INFO, "%a: Installing a correct one for this volume.\n",
+  __FUNCTION__));
+
+// Erase all the NorFlash that is reserved for variable storage
+FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) + 
PcdGet32(PcdFlashNvStorageFtwWorkingSize) + 
PcdGet32(PcdFlashNvStorageFtwSpareSize)) / Instance->Media.BlockSize;
+
+Status = FvbEraseBlocks (>FvbProtocol, (EFI_LBA)0, FvbNumLba, 
EFI_LBA_LIST_TERMINATOR);
+if (EFI_ERROR(Status)) {
+  return Status;
+}
+
+// Install all appropriate headers
+Status = InitializeFvAndVariableStoreHeaders (Instance);
+if (EFI_ERROR(Status)) {
+  return Status;
+}
+  }
+
+  return Status;
+}
+
+VOID
+EFIAPI
+NorFlashLock (
+  NOR_FLASH_LOCK_CONTEXT*Context
+  )
+{
+}
+
+VOID
+EFIAPI
+NorFlashUnlock (
+  NOR_FLASH_LOCK_CONTEXT*Context
+  )
+{
+}
+
+EFI_STATUS
+NorFlashCreateInstance (
+  IN UINTN  NorFlashDeviceBase,
+  IN UINTN  NorFlashRegionBase,
+  IN UINTN  NorFlashSize,
+  IN UINT32 Index,
+  IN UINT32 BlockSize,
+  IN BOOLEANSupportFvb,
+  OUT NOR_FLASH_INSTANCE**  NorFlashInstance
+  )
+{
+  EFI_STATUS Status;
+  NOR_FLASH_INSTANCE* Instance;
+
+  ASSERT(NorFlashInstance != NULL);
+
+  Instance = AllocateRuntimeCopyPool 
(sizeof(NOR_FLASH_INSTANCE),);
+  if (Instance == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  Instance->DeviceBaseAddress = NorFlashDeviceBase;
+  Instance->RegionBaseAddress = NorFlashRegionBase;
+  Instance->Size = NorFlashSize;
+
+  Instance->BlockIoProtocol.Media = >Media;
+  Instance->Media.MediaId = Index;
+  Instance->Media.BlockSize = BlockSize;
+  Instance->Media.LastBlock = (NorFlashSize / BlockSize)-1;
+
+  CopyGuid (>DevicePath.Vendor.Guid, );
+  Instance->DevicePath.Index = (UINT8)Index;
+
+  Instance->ShadowBuffer = AllocateRuntimePool (BlockSize);;
+  if (Instance->ShadowBuffer == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  if (SupportFvb) {
+NorFlashFvbInitialize (Instance);
+
+//Install DevicePath Protocol
+Status = gMmst->MmInstallProtocolInterface (
+  >Handle,
+  ,
+  EFI_NATIVE_INTERFACE,
+  >DevicePath
+  );
+if 

[edk2] [PATCH 0/2] Allow use of ArmPlatformPkg NOR flash driver in StandaloneMM

2019-02-19 Thread Jagadeesh Ujja
In-Reply-To: 

This patch series refactors Arm Platform NorFlashDxe driver and extends
it to be usable in StandaloneMM mode as well. This will be then useable
on platforms that use StandaloneMM to implement secure EFI variables 
with NOR flash as the non-volatile storage.


Jagadeesh Ujja (2):
  ArmPlatformPkg/NorFlash: Refactor Nor Flash DXE driver
  ArmPlatformPkg/NorFlash: Allow reusability as a MM driver

 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c  
| 1136 +
 ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashDxe.h => NorFlash.h}   
|   62 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashBlockIoDxe.c => NorFlashBlockIo.c} 
|6 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c   
| 1690 
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.inf 
|7 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashFvbDxe.c => NorFlashFvb.c} 
|  131 +-
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c  
|  267 
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf
|   77 +
 8 files changed, 1896 insertions(+), 1480 deletions(-)
 create mode 100644 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlash.c
 rename ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashDxe.h => NorFlash.h} (87%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashBlockIoDxe.c => 
NorFlashBlockIo.c} (93%)
 rename ArmPlatformPkg/Drivers/NorFlashDxe/{NorFlashFvbDxe.c => NorFlashFvb.c} 
(84%)
 create mode 100644 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.c
 create mode 100644 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashStandaloneMm.inf

-- 
2.7.4

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


Re: [edk2] [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path

2019-02-19 Thread Wang, Jian J
Hi Ray,

> -Original Message-
> From: Ni, Ray
> Sent: Tuesday, February 19, 2019 5:34 PM
> To: Wang, Jian J ; edk2-devel@lists.01.org
> Cc: Gao, Liming ; Kinney, Michael D
> 
> Subject: RE: [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for
> FilePath device path
> 
> 
> 
> > -Original Message-
> > From: Wang, Jian J 
> > Sent: Tuesday, February 19, 2019 5:22 PM
> > To: edk2-devel@lists.01.org
> > Cc: Gao, Liming ; Ni, Ray ; Kinney,
> > Michael D 
> > Subject: [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for
> > FilePath device path
> >
> > > v2: fix wrong detection of FilePath device path
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497
> >
> > Current implementation of IsDevicePathValid() is not enough for type of
> > MEDIA_FILEPATH_DP, which has NULL-terminated string in the device path.
> > This patch add a simple NULL character check at Length position.
> >
> > Cc: Liming Gao 
> > Cc: Ray Ni 
> > Cc: Michael D Kinney 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Jian J Wang 
> > ---
> >  MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c | 9 +
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > index 5d7635fe3e..dd1bddc1c2 100644
> > --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> > @@ -95,6 +95,15 @@ IsDevicePathValid (
> >  return FALSE;
> >}
> >  }
> > +
> > +//
> > +// FilePath must be a NULL-terminated string.
> > +//
> > +if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
> > +DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&
> > +*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
> Can we assume the device path node buffer contains exact the null terminated
> string?
> What if the buffer contains some padding bytes after null terminated string?
> 
> To handle this case, can we convert the DevicePath to FILEPATH_DEVICE_PATH
> and use logic similar as below?
> 
> FILEPATH_DEVICE_PATH *FilePath;
> FilePath = (FILEPATH_DEVICE_PATH *) DevicePath;
> MaxSize = (NodeLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) / sizeof
> (CHAR16);
> If (StrnLenS (FilePath->PathName, MaxSize) == MaxSize) {
>   Return FALSE;
> }
> 

I did think about your implementation and I agree it might be the best way
from compatibility perspective. But I have three considerations:

1. It's not a good programming habit to pass unwanted data around and should not
 be encouraged to do so.
2. It might leave potential security hole (maybe I'm a little too cautious)
3. The UEFI spec has following statement on this type of device path 
(ch10.3.6.4).

" A NULL-terminated Path string including directory and file names. The length 
of
this string n can be determined by subtracting 4 from the Length entry."

But I'm still open to your suggestion, if all agree that compatibility is more 
important.

Regards,
Jian

> 
> 
> > +  return FALSE;
> > +}
> >}
> >
> >//
> > --
> > 2.17.1.windows.2

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


Re: [edk2] [PATCH v2] IntelSiliconPkg/MicrocodeUpdateDxe: Error message enhancement

2019-02-19 Thread Ni, Ray
> -Original Message-
> From: Zhang, Shenglei 
> Sent: Tuesday, February 19, 2019 3:57 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ray ; Chaganty, Rangasai V
> 
> Subject: [PATCH v2] IntelSiliconPkg/MicrocodeUpdateDxe: Error message
> enhancement
> 
> The error message of ExtendedTableCount is not clear. Add the count
> number into the debug message.
> https://bugzilla.tianocore.org/show_bug.cgi?id=1500
> 
> v2: Change the judgment condition to return error message when
> ExtendedTableCount is not equal to target value.
> 
> Cc: Ray Ni 
> Cc: Rangasai V Chaganty 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Shenglei Zhang 
> ---
>  .../Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c  | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git
> a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate
> .c
> b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate
> .c
> index 9098712c2f..037b2433a6 100644
> ---
> a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate
> .c
> +++
> b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate
> +++ .c
> @@ -517,8 +517,8 @@ VerifyMicrocode (
>// Checksum correct
>//
>ExtendedTableCount = ExtendedTableHeader-
> >ExtendedSignatureCount;
> -  if (ExtendedTableCount > (ExtendedTableLength -
> sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) /
> sizeof(CPU_MICROCODE_EXTENDED_TABLE)) {
> -DEBUG((DEBUG_ERROR, "VerifyMicrocode - ExtendedTableCount too
> big\n"));
> +  if (ExtendedTableCount != (ExtendedTableLength -
> sizeof(CPU_MICROCODE_EXTENDED_TABLE_HEADER)) /
> sizeof(CPU_MICROCODE_EXTENDED_TABLE)) {
> +DEBUG((DEBUG_ERROR, "VerifyMicrocode - ExtendedTableCount
> + %d is incorrect\n", ExtendedTableCount));

I am not sure if changing ">" to "!=" is ok here.
Because the total size is multiple of 1024, ExtendedTableLength calculated from
the total length may contain padding bytes.
The original ">" is ok because it makes sure the extended table header doesn't
declare more entries than the ExtendedTableLength can cover.
But ExtendedTableLength may be bigger.

So I am wondering this change may cause some originally good uCode be denied.

>} else {
>  ExtendedTable = (CPU_MICROCODE_EXTENDED_TABLE
> *)(ExtendedTableHeader + 1);
>  for (Index = 0; Index < ExtendedTableCount; Index++) {
> --
> 2.18.0.windows.1

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


Re: [edk2] [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path

2019-02-19 Thread Ni, Ray



> -Original Message-
> From: Wang, Jian J 
> Sent: Tuesday, February 19, 2019 5:22 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming ; Ni, Ray ; Kinney,
> Michael D 
> Subject: [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for
> FilePath device path
> 
> > v2: fix wrong detection of FilePath device path
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497
> 
> Current implementation of IsDevicePathValid() is not enough for type of
> MEDIA_FILEPATH_DP, which has NULL-terminated string in the device path.
> This patch add a simple NULL character check at Length position.
> 
> Cc: Liming Gao 
> Cc: Ray Ni 
> Cc: Michael D Kinney 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> index 5d7635fe3e..dd1bddc1c2 100644
> --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
> @@ -95,6 +95,15 @@ IsDevicePathValid (
>  return FALSE;
>}
>  }
> +
> +//
> +// FilePath must be a NULL-terminated string.
> +//
> +if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
> +DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&
> +*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
Can we assume the device path node buffer contains exact the null terminated 
string?
What if the buffer contains some padding bytes after null terminated string?

To handle this case, can we convert the DevicePath to FILEPATH_DEVICE_PATH and 
use logic similar as below?

FILEPATH_DEVICE_PATH *FilePath;
FilePath = (FILEPATH_DEVICE_PATH *) DevicePath;
MaxSize = (NodeLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)) / sizeof (CHAR16);
If (StrnLenS (FilePath->PathName, MaxSize) == MaxSize) {
  Return FALSE;
}



> +  return FALSE;
> +}
>}
> 
>//
> --
> 2.17.1.windows.2

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


Re: [edk2] [PATCH v2 0/2] Add sanity check for FilePath device path

2019-02-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Jian
>J Wang
>Sent: Tuesday, February 19, 2019 5:22 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [PATCH v2 0/2] Add sanity check for FilePath device path
>
>> v2: fix wrong detection of FilePath device path
>
>REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497
>
>Tests
>- Pass specific DevicePathLib test cases
>- Boot shell
>- Boot to Fedora 26 (Qemu/x64)
>- Boot to Ubuntu 18.04 (Qemu/x64)
>- Boot to Windows 10 (Qemu/x64)
>- Boot to Windows 7 (Qemu/x64)
>
>Jian J Wang (2):
>  MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
>  MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for
>FilePath device path
>
> MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c   | 9 +
> .../UefiDevicePathLib.c  | 9 +
> 2 files changed, 18 insertions(+)
>
>--
>2.17.1.windows.2
>
>___
>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] UefiCpuPkg/SecCore: Wrong Debug Information for SecCore

2019-02-19 Thread Ni, Ray
Chasel,
Please change the two FindAndReportEntryPoints() calls in SecStartupPhase2() so 
that
their line length doesn't exceed 120.

With the modification, Reviewed-by: Ray Ni 

> -Original Message-
> From: Chiu, Chasel 
> Sent: Tuesday, February 19, 2019 3:44 PM
> To: edk2-devel@lists.01.org
> Cc: Dong, Eric ; Ni, Ray ; Laszlo
> Ersek ; Chiu, Chasel 
> Subject: [PATCH] UefiCpuPkg/SecCore: Wrong Debug Information for
> SecCore
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1533
> 
> When SecCore and PeiCore in different FV, current implementation still
> assuming SecCore and PeiCore are in the same FV.
> To fix this issue 2 FVs will be input parameters for FindAndReportEntryPoints
> () and SecCore and PeiCore will be found in each FV and correct debug
> information will be reported.
> 
> Test: Booted with internal platform successfully.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu 
> ---
>  UefiCpuPkg/SecCore/FindPeiCore.c | 60
> ++--
>  UefiCpuPkg/SecCore/SecMain.c | 10 --
>  UefiCpuPkg/SecCore/SecMain.h |  8 +---
>  3 files changed, 43 insertions(+), 35 deletions(-)
> 
> diff --git a/UefiCpuPkg/SecCore/FindPeiCore.c
> b/UefiCpuPkg/SecCore/FindPeiCore.c
> index bb9c434d1e..6f2046ad95 100644
> --- a/UefiCpuPkg/SecCore/FindPeiCore.c
> +++ b/UefiCpuPkg/SecCore/FindPeiCore.c
> @@ -1,7 +1,7 @@
>  /** @file
>Locate the entry point for the PEI Core
> 
> -  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.
> +  Copyright (c) 2008 - 2019, 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 @@ -19,17 +19,17 @@
>  /**
>Find core image base.
> 
> -  @param   BootFirmwareVolumePtrPoint to the boot firmware volume.
> -  @param   SecCoreImageBase The base address of the SEC core image.
> -  @param   PeiCoreImageBase The base address of the PEI core image.
> +  @param   FirmwareVolumePtrPoint to the firmware volume for finding
> core image.
> +  @param   FileType The FileType for searching, either 
> SecCore or
> PeiCore.
> +  @param   CoreImageBaseThe base address of the core image.
> 
>  **/
>  EFI_STATUS
>  EFIAPI
>  FindImageBase (
> -  IN  EFI_FIRMWARE_VOLUME_HEADER   *BootFirmwareVolumePtr,
> -  OUT EFI_PHYSICAL_ADDRESS *SecCoreImageBase,
> -  OUT EFI_PHYSICAL_ADDRESS *PeiCoreImageBase
> +  IN  EFI_FIRMWARE_VOLUME_HEADER   *FirmwareVolumePtr,
> +  IN  EFI_FV_FILETYPE  FileType,
> +  OUT EFI_PHYSICAL_ADDRESS *CoreImageBase
>)
>  {
>EFI_PHYSICAL_ADDRESSCurrentAddress;
> @@ -40,16 +40,15 @@ FindImageBase (
>EFI_COMMON_SECTION_HEADER   *Section;
>EFI_PHYSICAL_ADDRESSEndOfSection;
> 
> -  *SecCoreImageBase = 0;
> -  *PeiCoreImageBase = 0;
> +  *CoreImageBase = 0;
> 
> -  CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)
> BootFirmwareVolumePtr;
> -  EndOfFirmwareVolume = CurrentAddress + BootFirmwareVolumePtr-
> >FvLength;
> +  CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) FirmwareVolumePtr;
> + EndOfFirmwareVolume = CurrentAddress + FirmwareVolumePtr-
> >FvLength;
> 
>//
>// Loop through the FFS files in the Boot Firmware Volume
>//
> -  for (EndOfFile = CurrentAddress + BootFirmwareVolumePtr-
> >HeaderLength; ; ) {
> +  for (EndOfFile = CurrentAddress + FirmwareVolumePtr->HeaderLength; ;
> + ) {
> 
>  CurrentAddress = (EndOfFile + 7) & 0xfff8ULL;
>  if (CurrentAddress > EndOfFirmwareVolume) { @@ -75,10 +74,9 @@
> FindImageBase (
>  }
> 
>  //
> -// Look for SEC Core / PEI Core files
> +// Look for particular Core file (either SEC Core or PEI Core)
>  //
> -if (File->Type != EFI_FV_FILETYPE_SECURITY_CORE &&
> -File->Type != EFI_FV_FILETYPE_PEI_CORE) {
> +if (File->Type != FileType) {
>continue;
>  }
> 
> @@ -115,17 +113,11 @@ FindImageBase (
>// Look for executable sections
>//
>if (Section->Type == EFI_SECTION_PE32 || Section->Type ==
> EFI_SECTION_TE) {
> -if (File->Type == EFI_FV_FILETYPE_SECURITY_CORE) {
> +if (File->Type == FileType) {
>if (IS_SECTION2 (Section)) {
> -*SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *)
> Section + sizeof (EFI_COMMON_SECTION_HEADER2));
> +*CoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *)
> + Section + sizeof (EFI_COMMON_SECTION_HEADER2));
>} else {
> -*SecCoreImageBase = (PHYSICAL_ADDRESS) (UINTN) ((UINT8 *)
> Section + sizeof (EFI_COMMON_SECTION_HEADER));
> -  }
> -} else {
> -  if (IS_SECTION2 

[edk2] [PATCH v2 1/2] MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path

2019-02-19 Thread Jian J Wang
> v2: fix wrong detection of FilePath device path

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Current implementation of IsDevicePathValid() is not enough for type
of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device
path. This patch add a simple NULL character check at Length position.

Cc: Liming Gao 
Cc: Ray Ni 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c 
b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
index 5d7635fe3e..dd1bddc1c2 100644
--- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
+++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
@@ -95,6 +95,15 @@ IsDevicePathValid (
 return FALSE;
   }
 }
+
+//
+// FilePath must be a NULL-terminated string.
+//
+if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
+DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&
+*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
+  return FALSE;
+}
   }
 
   //
-- 
2.17.1.windows.2

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


[edk2] [PATCH v2 0/2] Add sanity check for FilePath device path

2019-02-19 Thread Jian J Wang
> v2: fix wrong detection of FilePath device path

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Tests
- Pass specific DevicePathLib test cases
- Boot shell
- Boot to Fedora 26 (Qemu/x64)
- Boot to Ubuntu 18.04 (Qemu/x64)
- Boot to Windows 10 (Qemu/x64)
- Boot to Windows 7 (Qemu/x64)

Jian J Wang (2):
  MdePkg/UefiDevicePathLib: Add sanity check for FilePath device path
  MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for
FilePath device path

 MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c   | 9 +
 .../UefiDevicePathLib.c  | 9 +
 2 files changed, 18 insertions(+)

-- 
2.17.1.windows.2

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


[edk2] [PATCH v2 2/2] MdePkg/UefiDevicePathLibDevicePathProtocol: Add sanity check for FilePath device path

2019-02-19 Thread Jian J Wang
> v2: fix wrong detection of FilePath device path

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1497

Current implementation of IsDevicePathValid() is not enough for type
of MEDIA_FILEPATH_DP, which has NULL-terminated string in the device
path. This patch add a simple NULL character check at Length position.

Cc: Liming Gao 
Cc: Ray Ni 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang 
---
 .../UefiDevicePathLib.c  | 9 +
 1 file changed, 9 insertions(+)

diff --git 
a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c 
b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
index 9a0ee42fd1..c8e78d2373 100644
--- a/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
+++ b/MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c
@@ -138,6 +138,15 @@ IsDevicePathValid (
 return FALSE;
   }
 }
+
+//
+// FilePath must be a NULL-terminated string.
+//
+if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&
+DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&
+*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {
+  return FALSE;
+}
   }
 
   //
-- 
2.17.1.windows.2

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


Re: [edk2] [Patch] BaseTools: Fixed a code bug for Pcd Array.

2019-02-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>Feng, Bob C
>Sent: Saturday, February 16, 2019 1:54 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming 
>Subject: [edk2] [Patch] BaseTools: Fixed a code bug for Pcd Array.
>
>For example, PCD gUefiOvmfPkgTokenSpaceGuid.Test001 datatype is Array:
>TEST1[2]
>and the filed TEST1UINT64ARRAY in TEST1 is also an array:
>UINT64 TEST1UINT64ARRAY[2];
>
>Then the following filed assignment in DSC will cause build failure.
>gUefiOvmfPkgTokenSpaceGuid.Test001[0].TEST1UINT64ARRAY|{'A','B'}
>
>The root cause is build tool generate incorrect PcdValueInit.c File.
>
>This patch is going to fix this issue.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/Workspace/DscBuildData.py | 12 +---
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 1fd1639ab6..e45beb3924 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -2015,14 +2015,13 @@ class DscBuildData(PlatformBuildClassObject):
> indicator = self.GetIndicator(index, FieldName,Pcd)
> if IsArray:
> #
> # Use memcpy() to copy value into field
> #
>-CApp = CApp + '  FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.DatumType, FieldName)
>+CApp = CApp + '  FieldSize = __FIELD_SIZE(%s, %s);\n' %
>(Pcd.BaseDatumType, FieldName)
> CApp = CApp + '  Value = %s; // From %s Line %d Value 
> %s\n' %
>(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
>-CApp = CApp + '  __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= 
>%d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize,
>Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
>-CApp = CApp + '  memcpy (>%s, Value, (FieldSize > 0 
>&&
>FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
>+CApp = CApp + '  __STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= 
>%d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.BaseDatumType, FieldName, ValueSize,
>Pcd.BaseDatumType, FieldName, FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
> CApp = CApp + '  memcpy (&%s, Value, (FieldSize > 0 && 
> FieldSize
>< %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize)
> elif isinstance(Value, str):
> CApp = CApp + '  %s = %s; // From %s Line %d Value %s\n' %
>(indicator, Value, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
> else:
> if '[' in FieldName and ']' in FieldName:
>@@ -2130,12 +2129,11 @@ class DscBuildData(PlatformBuildClassObject):
> #
> # Use memcpy() to copy value into field
> #
> CApp = CApp + '  FieldSize = __FIELD_SIZE(%s, %s);\n' 
> %
>(Pcd.BaseDatumType, FieldName)
> CApp = CApp + '  Value = %s; // From %s Line %d 
> Value %s\n' %
>(DscBuildData.IntToCString(Value, ValueSize), FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
>-CApp = CApp + '  __STATIC_ASSERT((__FIELD_SIZE(%s, 
>%s) >= %d)
>|| (__FIELD_SIZE(%s, %s) == 0), "Input buffer exceeds the buffer array"); //
>From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName, ValueSize,
>Pcd.DatumType, FieldName, FieldList[FieldName][1], FieldList[FieldName][2],
>FieldList[FieldName][0])
>-CApp = CApp + '  memcpy (>%s, Value, (FieldSize 
>> 0 &&
>FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)
>+CApp = CApp + '
>__STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d) || (__FIELD_SIZE(%s, %s)
>== 0), "Input buffer exceeds the buffer array"); // From %s Line %d
>Value %s\n' % (Pcd.BaseDatumType, FieldName, ValueSize,
>Pcd.BaseDatumType, FieldName, FieldList[FieldName][1],
>FieldList[FieldName][2], FieldList[FieldName][0])
> CApp = CApp + '  memcpy (&%s, Value, (FieldSize > 0 
> && FieldSize
>< %d) ? FieldSize : %d);\n' % (indicator, ValueSize, ValueSize)
> else:
> if '[' in FieldName and ']' in FieldName:
> Index = int(FieldName.split('[')[1].split(']')[0])
> CApp = CApp + '  __STATIC_ASSERT((%d < 
> 

Re: [edk2] [Patch] BaseTools: Add MaxSizeUserSet to Pcd deepcopy function

2019-02-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Feng, Bob C
>Sent: Saturday, February 16, 2019 10:55 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming 
>Subject: [Patch] BaseTools: Add MaxSizeUserSet to Pcd deepcopy function
>
>MaxSizeUserSet is missing in Pcd deepcopy function.
>This patch is to add it back to Pcd deepcopy function.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/Workspace/BuildClassObject.py | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>index 1df042f41c..d7ca9e8cf1 100644
>--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>@@ -220,10 +220,11 @@ class PcdClassObject(object):
> new_pcd.Type = self.Type
> new_pcd.DatumType = self.DatumType
> new_pcd.DefaultValue = self.DefaultValue
> new_pcd.TokenValue = self.TokenValue
> new_pcd.MaxDatumSize = self.MaxDatumSize
>+new_pcd.MaxSizeUserSet = self.MaxSizeUserSet
>
> new_pcd.Phase = self.Phase
> new_pcd.Pending = self.Pending
> new_pcd.IsOverrided = self.IsOverrided
> new_pcd.IsFromBinaryInf = self.IsFromBinaryInf
>--
>2.18.0.windows.1

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


Re: [edk2] [Patch] BaseTools: Fix a ParseDevPathValue function issue.

2019-02-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>Feng, Bob C
>Sent: Saturday, February 16, 2019 11:38 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming 
>Subject: [edk2] [Patch] BaseTools: Fix a ParseDevPathValue function issue.
>
>In ParseDevPathValue, the binary data need to convert to string
>for python3 and python2 compatiblity.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/Common/Misc.py | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/BaseTools/Source/Python/Common/Misc.py
>b/BaseTools/Source/Python/Common/Misc.py
>index 565a5ad40b..c7daf5417c 100644
>--- a/BaseTools/Source/Python/Common/Misc.py
>+++ b/BaseTools/Source/Python/Common/Misc.py
>@@ -1030,10 +1030,11 @@ def ParseFieldValue (Value):
> subprocess._cleanup()
> p.stdout.close()
> p.stderr.close()
> if err:
> raise BadExpression("DevicePath: %s" % str(err))
>+out = out.decode()
> Size = len(out.split())
> out = ','.join(out.split())
> return '{' + out + '}', Size
>
> if "{CODE(" in Value:
>--
>2.18.0.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] BaseTools: Fixed a bug in Vpd handling

2019-02-19 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Feng, Bob C
>Sent: Monday, February 18, 2019 5:50 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming 
>Subject: [Patch] BaseTools: Fixed a bug in Vpd handling
>
>If there are multiple sku used in a platform and
>gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer PCD
>is used, build will fail.
>
>This is a regression issue introduced by the commit:
>5695877ec8f636bd4ad873ef50eceb9da7a0f382 which only update the
>Vpd offset for default SKU but not other SKUs.
>
>This patch is going to fix this issue.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 2452ecbcba..8370ee0c93 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -1686,11 +1686,11 @@ class PlatformAutoGen(AutoGen):
> PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if
>item.TokenCName == "PcdNvStoreDefaultValueBuffer" and
>item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]
> if PcdNvStoreDfBuffer:
> PcdName,PcdGuid = PcdNvStoreDfBuffer[0].TokenCName,
>PcdNvStoreDfBuffer[0].TokenSpaceGuidCName
> if (PcdName,PcdGuid) in VpdSkuMap:
> DefaultSku =
>PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT)
>-VpdSkuMap[(PcdName,PcdGuid)] =
>{DefaultSku.DefaultValue:[DefaultSku]}
>+VpdSkuMap[(PcdName,PcdGuid)] =
>{DefaultSku.DefaultValue:[SkuObj for SkuObj in
>PcdNvStoreDfBuffer[0].SkuInfoList.values() ]}
>
> # Process VPD map file generated by third party BPDG tool
> if NeedProcessVpdMapFile:
> VpdMapFilePath = os.path.join(self.BuildDir, 
> TAB_FV_DIRECTORY,
>"%s.map" % self.Platform.VpdToolGuid)
> if os.path.exists(VpdMapFilePath):
>--
>2.20.1.windows.1

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


Re: [edk2] nonzero LUN on USB Bulk Only Transfer fails with QEMU+edk2

2019-02-19 Thread Laszlo Ersek
On 02/19/19 09:49, Gerd Hoffmann wrote:
>   Hi,
> 
>> (2) If I change the cmdline to "lun=5", then the exchange is:
> 
> Not supported (by the usb protocol).
> 
> The protocol has a control message to query the number of devices (grep
> for GetMaxLun in qemu).  LUNs are not allowed to be sparse.  So, with a
> single storage device the LUN must be zero.  With two devices the LUNs
> must be 0,1, with three 0,1,2 etc., you get the idea :)

Yes, Phil explained the same -- I originally missed this part of the
documentation (because the requirement is documented, so the fault is
clearly mine).

However, once I fixed the configuration (so that I'd have LUNs 0 and 1),
edk2 still tripped an assert. Please see my message elsewhere in this
thread; the fixed config case is marked as item (4).

Thanks!
Laszlo

> Maybe usb-bot should check for that and throw an error, I think right
> now we only have the generic scsi code check which will verify the lun
> isn't too big (<= 15) but will not check the non-sparse requirement.
> 
> cheers,
>   Gerd
> 

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


Re: [edk2] nonzero LUN on USB Bulk Only Transfer fails with QEMU+edk2

2019-02-19 Thread Gerd Hoffmann
  Hi,

> (2) If I change the cmdline to "lun=5", then the exchange is:

Not supported (by the usb protocol).

The protocol has a control message to query the number of devices (grep
for GetMaxLun in qemu).  LUNs are not allowed to be sparse.  So, with a
single storage device the LUN must be zero.  With two devices the LUNs
must be 0,1, with three 0,1,2 etc., you get the idea :)

Maybe usb-bot should check for that and throw an error, I think right
now we only have the generic scsi code check which will verify the lun
isn't too big (<= 15) but will not check the non-sparse requirement.

cheers,
  Gerd

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