Re: [edk2] [PATCH] SecurityPkg: Tcg2Smm: Fix type casting issue

2018-02-07 Thread Wu, Hao A
Hi Chao,

The change is good to me. How about changing the commit title and body
into:


SecurityPkg/Tcg2Smm: Refine type cast for pointer subtraction

Since the pointer subtraction here is not performed by pointers to
elements of the same array object. This might lead to potential issues,
such behavior is undefined according to C11 standard.

Refine the pointer subtraction expressions by casting each pointer to
UINTN first and then perform the subtraction.


With the commit message change:
Reviewed-by: Hao Wu 


Best Regards,
Hao Wu

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Zhang, Chao B
> Sent: Thursday, February 08, 2018 2:25 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A; Zhang, Chao B
> Subject: [edk2] [PATCH] SecurityPkg: Tcg2Smm: Fix type casting issue
> 
> Fix type casting issue when calculating pointers offset
> 
> Cc: Wu Hao 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chao Zhang 
> ---
>  SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> index 6eb62ae..c3cee83 100644
> --- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> +++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
> @@ -543,7 +543,7 @@ UpdatePossibleResource (
>//
>DataPtr += 2;
>if (DataPtr < DataEndPtr) {
> -SetMem(DataPtr, (UINTN)(DataEndPtr - DataPtr), AML_NOOP_OP);
> +SetMem(DataPtr, (UINTN)DataEndPtr - (UINTN)DataPtr, AML_NOOP_OP);
>}
> 
>return EFI_SUCCESS;
> --
> 1.9.5.msysgit.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 05/10] OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Ard Biesheuvel
On 8 February 2018 at 01:35, Laszlo Ersek  wrote:
> On 02/08/18 00:48, Kinney, Michael D wrote:
>> Laszlo,
>>
>> The BmpSupportLib content was from contributions from
>> a capsule related branch.  However, the BmpSupportLib
>> can be used for UX capsules as well as other places that
>> conversions between BMP and GOP BLT buffers are needed,
>> so it is a more generic feature.  The SafeIntLib was also
>> based on content from the same capsule related branch but
>> also has uses other than capsules.
>>
>> Yes.  I need to add Signed-off-by for Sean.

I will note once again that our signed off by deviates from other
usage in the industry.

Usually, a sign off is not an assertion of authorship. It means that
the submitter is able to submit the code under the license that covers
it.

In our case, it means authorship, which is why we as
reviewers/maintainers add 'reviewed-by' not 'signed-off-by' like we do
in the linux kernel.

So what if I want to merge code that is available under a suitable
license, but the author is not available to give his sign off, or
there are many (hundreds) of authors etc etc? The whole point of open
source licensing is that we don't *need* the explicit sign off of the
authors, because the license tells us what we can and cannot do with
the code.

I guess this is also related to the DCO vs contributed-under tags, but
in general, I think adding the sign off of people who are not involved
in the actual upstreaming of the code is wrong, and it is perfectly
fine for the author not to be in a s-o-b line.

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


[edk2] [Patch] BaseTools GenFv: Update error message to describe PE image alignment

2018-02-07 Thread Liming Gao
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 
---
 BaseTools/Source/C/GenFv/GenFvInternalLib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c 
b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index fc1a760..75cbd3a 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -1,7 +1,7 @@
 /** @file
 This file contains the internal functions required to generate a Firmware 
Volume.
 
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
 Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
 Portions Copyright (c) 2016 HP Development Company, L.P.
 This program and the accompanying materials  
@@ -3532,7 +3532,7 @@ Returns:
   //
   // Xip module has the same section alignment and file alignment.
   //
-  Error (NULL, 0, 3000, "Invalid", "Section-Alignment and 
File-Alignment do not match : %s.", FileName);
+  Error (NULL, 0, 3000, "Invalid", "PE image Section-Alignment and 
File-Alignment do not match : %s.", FileName);
   return EFI_ABORTED;
 }
 //
@@ -3610,7 +3610,7 @@ Returns:
   //
   // Xip module has the same section alignment and file alignment.
   //
-  Error (NULL, 0, 3000, "Invalid", "Section-Alignment and 
File-Alignment do not match : %s.", FileName);
+  Error (NULL, 0, 3000, "Invalid", "PE image Section-Alignment and 
File-Alignment do not match : %s.", FileName);
   return EFI_ABORTED;
 }
 NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section 
+ CurSecHdrSize - (UINTN)FfsFile;
-- 
2.8.0.windows.1

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


Re: [edk2] [PATCH] SourceLevelDebugPkg DebugUsb3: Support IOMMU

2018-02-07 Thread Ni, Ruiyu
Reviewed-by: Ruiyu Ni 

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
> Star Zeng
> Sent: Tuesday, February 6, 2018 8:23 PM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu ; Wu, Hao A ; Yao,
> Jiewen ; Zeng, Star 
> Subject: [edk2] [PATCH] SourceLevelDebugPkg DebugUsb3: Support IOMMU
> 
> For PEI, allocate granted DMA buffer from IOMMU PPI.
> For DXE, map DMA buffer by PciIo.
> 
> Cc: Jiewen Yao 
> Cc: Ruiyu Ni 
> Cc: Hao Wu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng 
> ---
>  .../DebugCommunicationLibUsb3Common.c  | 219 +--
>  .../DebugCommunicationLibUsb3Dxe.c | 433
> -
>  .../DebugCommunicationLibUsb3Dxe.inf   |  12 +-
>  .../DebugCommunicationLibUsb3Internal.h|  60 ++-
>  .../DebugCommunicationLibUsb3Pei.c | 233 ++-
>  .../DebugCommunicationLibUsb3Pei.inf   |   8 +-
>  6 files changed, 838 insertions(+), 127 deletions(-)
> 
> diff --git
> a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Common.c
> b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Common.c
> index 49bad6b5864d..80532e56acc5 100644
> ---
> a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> municationLibUsb3Common.c
> +++
> b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom
> muni
> +++ cationLibUsb3Common.c
> @@ -14,11 +14,6 @@
> 
>  #include "DebugCommunicationLibUsb3Internal.h"
> 
> -//
> -// The global variable which can be used after memory is ready.
> -//
> -USB3_DEBUG_PORT_HANDLE
> mDebugCommunicationLibUsb3DebugPortHandle;
> -
>  UINT16   mString0Desc[] = {
>//  String Descriptor Type + Length
>( USB_DESC_TYPE_STRING << 8 ) + STRING0_DESC_LEN, @@ -85,7 +80,7
> @@ XhcClearR32Bit(
>Write the data to the XHCI debug register.
> 
>@param  Handle   Debug port handle.
> -  @param  Offset   The offset of the runtime register.
> +  @param  Offset   The offset of the debug register.
>@param  Data The data to write.
> 
>  **/
> @@ -129,16 +124,16 @@ XhcReadDebugReg (
>  }
> 
>  /**
> -  Set one bit of the runtime register while keeping other bits.
> +  Set one bit of the debug register while keeping other bits.
> 
>@param  Handle   Debug port handle.
> -  @param  Offset   The offset of the runtime register.
> +  @param  Offset   The offset of the debug register.
>@param  Bit  The bit mask of the register to set.
> 
>  **/
>  VOID
>  XhcSetDebugRegBit (
> -  IN USB3_DEBUG_PORT_HANDLE *Handle,
> +  IN USB3_DEBUG_PORT_HANDLE   *Handle,
>IN UINT32   Offset,
>IN UINT32   Bit
>)
> @@ -151,6 +146,28 @@ XhcSetDebugRegBit (  }
> 
>  /**
> +  Clear one bit of the debug register while keeping other bits.
> +
> +  @param  Handle   Debug port handle.
> +  @param  Offset   The offset of the debug register.
> +  @param  Bit  The bit mask of the register to clear.
> +
> +**/
> +VOID
> +XhcClearDebugRegBit (
> +  IN USB3_DEBUG_PORT_HANDLE   *Handle,
> +  IN UINT32   Offset,
> +  IN UINT32   Bit
> +  )
> +{
> +  UINT32  Data;
> +
> +  Data  = XhcReadDebugReg (Handle, Offset);
> +  Data  &= ~Bit;
> +  XhcWriteDebugReg (Handle, Offset, Data); }
> +
> +/**
>Program and eanble XHCI MMIO base address.
> 
>@return XHCI MMIO base address.
> @@ -199,7 +216,7 @@ UpdateXhcResource (
>IN EFI_PHYSICAL_ADDRESS   XhciMmioBase
>)
>  {
> -  if ((Handle == NULL) || (Handle->XhciMmioBase == XhciMmioBase)) {
> +  if (Handle == NULL) {
>  return;
>}
> 
> @@ -216,7 +233,7 @@ UpdateXhcResource (
> 
>@param  Handle Debug port handle.
> 
> -  @retval RETURN_UNSUPPORTED The usb host controller does not
> supported usb debug port capability.
> +  @retval RETURN_UNSUPPORTED The usb host controller does not support
> usb debug port capability.
>@retval RETURN_SUCCESS Get bar and offset successfully.
> 
>  **/
> @@ -236,6 +253,14 @@ CalculateUsbDebugPortMmioBase (
>EFI_PHYSICAL_ADDRESSCapabilityPointer;
>UINT8   CapLength;
> 
> +  if (Handle->Initialized != USB3DBG_UNINITIALIZED) {
> +if (Handle->Initialized == USB3DBG_NO_DBG_CAB) {
> +  return RETURN_UNSUPPORTED;
> +} else {
> +  return RETURN_SUCCESS;
> +}
> +  }
> +
>VendorId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) +
> PCI_VENDOR_ID_OFFSET);
>DeviceId = PciRead16 (PcdGet32(PcdUsbXhciPciAddress) +
> PCI_DEVICE_ID_OFFSET);
> 
> @@ -288,6 +313,7 @@ CalculateUsbDebugPortMmioBase (
>Handle->DebugCapabilityBase   = CapabilityPointer;
>Handle->DebugCapabilityOffset = CapabilityPointer - Handle-
> >XhciMmioBase;
>Handle->XhciOpRegister= Handle->XhciMmioBase + CapLength;
> +  Handle->DebugSupport

Re: [edk2] [PATCH] SourceLevelDebugPkg DebugAgentLib: Rename IsBsp to DebugAgentIsBsp

2018-02-07 Thread Ni, Ruiyu
Remember to update the copyright year when committing the patch.

Thanks/Ray

> -Original Message-
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Ni,
> Ruiyu
> Sent: Wednesday, February 7, 2018 11:30 AM
> To: Zeng, Star ; edk2-devel@lists.01.org
> Cc: Wu, Hao A 
> Subject: Re: [edk2] [PATCH] SourceLevelDebugPkg DebugAgentLib: Rename
> IsBsp to DebugAgentIsBsp
> 
> On 2/6/2018 8:20 PM, Star Zeng wrote:
> > For avoiding function name confliction, rename IsBsp to
> > DebugAgentIsBsp.
> >
> > Cc: Ruiyu Ni 
> > Cc: Hao Wu 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Star Zeng 
> > ---
> >
> SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAg
> ent.c | 4 ++--
> >
> SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugM
> p.c| 4 ++--
> >
> SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugM
> p.h| 2 +-
> >   3 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git
> >
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Agent.c
> >
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Agent.c
> > index 36b1ef924cd2..7c05ce2f2806 100644
> > ---
> >
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Agent.c
> > +++
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Age
> > +++ nt.c
> > @@ -2485,7 +2485,7 @@ InterruptProcess (
> >   AcquireMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
> >
> >   if (MultiProcessorDebugSupport()) {
> > -  if (IsBsp (ProcessorIndex)) {
> > +  if (DebugAgentIsBsp (ProcessorIndex)) {
> >   //
> >   // If current processor is BSP, check Apic timer's init count if 
> > changed,
> >   // it may be re-written when switching BSP.
> > @@ -2498,7 +2498,7 @@ InterruptProcess (
> >   }
> > }
> >
> > -  if (!IsBsp (ProcessorIndex) || mDebugMpContext.IpiSentByAp) {
> > +  if (!DebugAgentIsBsp (ProcessorIndex) ||
> > + mDebugMpContext.IpiSentByAp) {
> >   ReleaseMpSpinLock (&mDebugMpContext.DebugPortSpinLock);
> >   //
> >   // If current processor is not BSP or this is one IPI sent
> > by AP diff --git
> >
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.c
> >
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.c
> > index d49d4ee32347..51f40cb56b77 100644
> > ---
> >
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.c
> > +++
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.
> > +++ c
> > @@ -75,7 +75,7 @@ HaltOtherProcessors (
> > )
> >   {
> > DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to halt
> > other processors.\n", CurrentProcessorIndex);
> > -  if (!IsBsp (CurrentProcessorIndex)) {
> > +  if (!DebugAgentIsBsp (CurrentProcessorIndex)) {
> >   SetIpiSentByApFlag (TRUE);;
> > }
> >
> > @@ -137,7 +137,7 @@ GetProcessorIndex (
> >
> >   **/
> >   BOOLEAN
> > -IsBsp (
> > +DebugAgentIsBsp (
> > IN UINT32  ProcessorIndex
> > )
> >   {
> > diff --git
> >
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.h
> >
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.h
> > index 5bb50960ca72..d9c21efdaad1 100644
> > ---
> >
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.h
> > +++
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Debug
> Mp.
> > +++ h
> > @@ -96,7 +96,7 @@ ReleaseMpSpinLock (
> >
> >   **/
> >   BOOLEAN
> > -IsBsp (
> > +DebugAgentIsBsp (
> > IN UINT32 ProcessorIndex
> > );
> >
> >
> Reviewed-by: Ruiyu Ni 
> 
> --
> Thanks,
> Ray
> ___
> 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/FeaturesLib: don't init MCi_CTL/STATUS when MCA's disabled

2018-02-07 Thread Dong, Eric
Reviewed-by: Eric Dong 

-Original Message-
From: Ni, Ruiyu 
Sent: Thursday, February 8, 2018 2:44 PM
To: edk2-devel@lists.01.org
Cc: Dong, Eric 
Subject: [PATCH] UefiCpuPkg/FeaturesLib: don't init MCi_CTL/STATUS when MCA's 
disabled

Today's McaInitialize() doesn't check State value before initialize MCi_CTL and 
MCi_STATUS.
The patch fixes this issue by only initializing the two kinds of MSRs when 
State is enabled.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Eric Dong 
---
 .../Library/CpuCommonFeaturesLib/MachineCheck.c| 32 --
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
index 58dc45aeda..cc64dbbf0a 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
@@ -1,7 +1,7 @@
 /** @file
   Machine Check features.
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2018, Intel Corporation. All rights 
+ reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at @@ -140,25 +140,27 @@ McaInitialize (
   MSR_IA32_MCG_CAP_REGISTER  McgCap;
   UINT32 BankIndex;
 
-  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
-  for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) {
-CPU_REGISTER_TABLE_WRITE64 (
-  ProcessorNumber,
-  Msr,
-  MSR_IA32_MC0_CTL + BankIndex * 4,
-  MAX_UINT64
-  );
-  }
-
-  if (PcdGetBool (PcdIsPowerOnReset)) {
-for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {
+  if (State == TRUE) {
+McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
+for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; 
+ BankIndex++) {
   CPU_REGISTER_TABLE_WRITE64 (
 ProcessorNumber,
 Msr,
-MSR_IA32_MC0_STATUS + BankIndex * 4,
-0
+MSR_IA32_MC0_CTL + BankIndex * 4,
+MAX_UINT64
 );
 }
+
+if (PcdGetBool (PcdIsPowerOnReset)) {
+  for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {
+CPU_REGISTER_TABLE_WRITE64 (
+  ProcessorNumber,
+  Msr,
+  MSR_IA32_MC0_STATUS + BankIndex * 4,
+  0
+  );
+  }
+}
   }
 
   return RETURN_SUCCESS;
--
2.16.1.windows.1

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


[edk2] [PATCH] UefiCpuPkg/FeaturesLib: don't init MCi_CTL/STATUS when MCA's disabled

2018-02-07 Thread Ruiyu Ni
Today's McaInitialize() doesn't check State value before initialize
MCi_CTL and MCi_STATUS.
The patch fixes this issue by only initializing the two kinds of
MSRs when State is enabled.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Eric Dong 
---
 .../Library/CpuCommonFeaturesLib/MachineCheck.c| 32 --
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
index 58dc45aeda..cc64dbbf0a 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
@@ -1,7 +1,7 @@
 /** @file
   Machine Check features.
 
-  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -140,25 +140,27 @@ McaInitialize (
   MSR_IA32_MCG_CAP_REGISTER  McgCap;
   UINT32 BankIndex;
 
-  McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
-  for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) {
-CPU_REGISTER_TABLE_WRITE64 (
-  ProcessorNumber,
-  Msr,
-  MSR_IA32_MC0_CTL + BankIndex * 4,
-  MAX_UINT64
-  );
-  }
-
-  if (PcdGetBool (PcdIsPowerOnReset)) {
-for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {
+  if (State == TRUE) {
+McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
+for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) {
   CPU_REGISTER_TABLE_WRITE64 (
 ProcessorNumber,
 Msr,
-MSR_IA32_MC0_STATUS + BankIndex * 4,
-0
+MSR_IA32_MC0_CTL + BankIndex * 4,
+MAX_UINT64
 );
 }
+
+if (PcdGetBool (PcdIsPowerOnReset)) {
+  for (BankIndex = 0; BankIndex < (UINTN) McgCap.Bits.Count; BankIndex++) {
+CPU_REGISTER_TABLE_WRITE64 (
+  ProcessorNumber,
+  Msr,
+  MSR_IA32_MC0_STATUS + BankIndex * 4,
+  0
+  );
+  }
+}
   }
 
   return RETURN_SUCCESS;
-- 
2.16.1.windows.1

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


Re: [edk2] [PATCH v2] UefiCpuPkg/S3Resume: Add more perf entry for S3 phase

2018-02-07 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Bi, Dandan
>Sent: Thursday, February 08, 2018 2:20 PM
>To: edk2-devel@lists.01.org
>Cc: Dong, Eric ; Laszlo Ersek ;
>Gao, Liming 
>Subject: [PATCH v2] UefiCpuPkg/S3Resume: Add more perf entry for S3
>phase
>
>V2: Just update the commit message.
>
>Add more perf entry to hook BootScriptDonePpi/EndOfPeiPpi/
>EndOfS3Resume.
>
>Add the new perf entry with Identifier
>PERF_INMODULE_START_ID/PERF_INMODULE_END_ID which are defined
>in new performance infrastructure (edk2 trunk commit hash value:
>SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~
>SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4).
>PERF_INMODULE_START_ID/PERF_INMODULE_END_ID are general Identifier
>which are used within a module.
>
>Cc: Eric Dong 
>Cc: Laszlo Ersek 
>Cc: Liming Gao 
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Dandan Bi 
>---
> UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 15
>++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
>diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
>b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
>index b597ac7..d7d2a4d 100644
>--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
>+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
>@@ -2,11 +2,11 @@
>   This module produces the EFI_PEI_S3_RESUME2_PPI.
>   This module works with StandAloneBootScriptExecutor to S3 resume to OS.
>   This module will execute the boot script saved during last boot and after 
> that,
>   control is passed to OS waking up handler.
>
>-  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
>+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
>   Copyright (c) 2017, AMD Incorporated. 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
>@@ -21,10 +21,11 @@
> #include 
>
> #include 
> #include 
> #include 
>+#include 
> #include 
> #include 
> #include 
> #include 
> #include 
>@@ -551,13 +552,17 @@ S3ResumeBootOs (
>   PERF_END (NULL, "ScriptExec", NULL, 0);
>
>   //
>   // Install BootScriptDonePpi
>   //
>+  PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0,
>PERF_INMODULE_START_ID);
>+
>   Status = PeiServicesInstallPpi (&mPpiListPostScriptTable);
>   ASSERT_EFI_ERROR (Status);
>
>+  PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0,
>PERF_INMODULE_END_ID);
>+
>   //
>   // Get ACPI Table Address
>   //
>   Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN)
>(AcpiS3Context->AcpiFacsTable));
>
>@@ -576,18 +581,26 @@ S3ResumeBootOs (
>   }
>
>   //
>   // Install EndOfPeiPpi
>   //
>+  PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0,
>PERF_INMODULE_START_ID);
>+
>   Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable);
>   ASSERT_EFI_ERROR (Status);
>
>+  PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
>+
>   //
>   // Signal EndOfS3Resume event.
>   //
>+  PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0,
>PERF_INMODULE_START_ID);
>+
>   SignalEndOfS3Resume ();
>
>+  PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0,
>PERF_INMODULE_END_ID);
>+
>   //
>   // report status code on S3 resume
>   //
>   REPORT_STATUS_CODE (EFI_PROGRESS_CODE,
>EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE);
>
>--
>1.9.5.msysgit.1

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


[edk2] [PATCH] SecurityPkg: Tcg2Smm: Fix type casting issue

2018-02-07 Thread Zhang, Chao B
Fix type casting issue when calculating pointers offset

Cc: Wu Hao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang 
---
 SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c 
b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
index 6eb62ae..c3cee83 100644
--- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
+++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
@@ -543,7 +543,7 @@ UpdatePossibleResource (
   //
   DataPtr += 2;
   if (DataPtr < DataEndPtr) {
-SetMem(DataPtr, (UINTN)(DataEndPtr - DataPtr), AML_NOOP_OP);
+SetMem(DataPtr, (UINTN)DataEndPtr - (UINTN)DataPtr, AML_NOOP_OP);
   }
 
   return EFI_SUCCESS;
-- 
1.9.5.msysgit.1

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


[edk2] [PATCH v2] UefiCpuPkg/S3Resume: Add more perf entry for S3 phase

2018-02-07 Thread Dandan Bi
V2: Just update the commit message.

Add more perf entry to hook BootScriptDonePpi/EndOfPeiPpi/
EndOfS3Resume.

Add the new perf entry with Identifier
PERF_INMODULE_START_ID/PERF_INMODULE_END_ID which are defined
in new performance infrastructure (edk2 trunk commit hash value:
SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~
SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4).
PERF_INMODULE_START_ID/PERF_INMODULE_END_ID are general Identifier
which are used within a module.

Cc: Eric Dong 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c 
b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index b597ac7..d7d2a4d 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -2,11 +2,11 @@
   This module produces the EFI_PEI_S3_RESUME2_PPI.
   This module works with StandAloneBootScriptExecutor to S3 resume to OS.
   This module will execute the boot script saved during last boot and after 
that,
   control is passed to OS waking up handler.
 
-  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
   Copyright (c) 2017, AMD Incorporated. 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
@@ -21,10 +21,11 @@
 #include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
@@ -551,13 +552,17 @@ S3ResumeBootOs (
   PERF_END (NULL, "ScriptExec", NULL, 0);
 
   //
   // Install BootScriptDonePpi
   //
+  PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_START_ID);
+
   Status = PeiServicesInstallPpi (&mPpiListPostScriptTable);
   ASSERT_EFI_ERROR (Status);
 
+  PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_END_ID);
+
   //
   // Get ACPI Table Address
   //
   Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) 
(AcpiS3Context->AcpiFacsTable));
 
@@ -576,18 +581,26 @@ S3ResumeBootOs (
   }
 
   //
   // Install EndOfPeiPpi
   //
+  PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_START_ID);
+
   Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable);
   ASSERT_EFI_ERROR (Status);
 
+  PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
+
   //
   // Signal EndOfS3Resume event.
   //
+  PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID);
+
   SignalEndOfS3Resume ();
 
+  PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID);
+
   //
   // report status code on S3 resume
   //
   REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | 
EFI_SW_PEI_PC_OS_WAKE);
 
-- 
1.9.5.msysgit.1

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


Re: [edk2] [Patch V2 1/3] MdeModulePkg/EsrtFmpDxe: Add EsrtFmpDxe module

2018-02-07 Thread Zeng, Star
Reviewed-by: Star Zeng 

Thanks,
Star
-Original Message-
From: Kinney, Michael D 
Sent: Thursday, February 8, 2018 6:38 AM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D ; Sean Brogan 
; Yao, Jiewen ; Zeng, Star 
; Dong, Eric ; Ni, Ruiyu 

Subject: [Patch V2 1/3] MdeModulePkg/EsrtFmpDxe: Add EsrtFmpDxe module

From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

The EsrtFmpDxe module is a lightweight version of the EsrtDxe module that 
produces ESRT entries based only on FMP Protocol instances.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c| 482 +
 .../Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c   | 161 +++
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf   |  74 
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.uni   |  19 +
 .../Universal/EsrtFmpDxe/EsrtFmpDxeExtra.uni   |  18 +
 6 files changed, 755 insertions(+)
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.uni
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxeExtra.uni

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc 
index 1c0085aee6..50002f8e3f 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -412,6 +412,7 @@
 
   MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf
   MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
   
   
MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAttributesDxe.inf
   MdeModulePkg/Universal/FileExplorerDxe/FileExplorerDxe.inf  { diff --git 
a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c 
b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
new file mode 100644
index 00..b98430edbf
--- /dev/null
+++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
@@ -0,0 +1,482 @@
+/** @file
+  Publishes ESRT table from Firmware Management Protocol instances
+
+  Copyright (c) 2016, Microsoft Corporation  Copyright (c) 2018, Intel 
+ Corporation. All rights reserved.
+
+  All rights reserved.
+  Redistribution and use in source and binary forms, with or without  
+ modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright 
+ notice,  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright 
+ notice,  this list of conditions and the following disclaimer in the 
+ documentation  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ "AS IS" AND  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ LIMITED TO, THE IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
PARTICULAR PURPOSE ARE DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
+ ANY DIRECT,  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ CONSEQUENTIAL DAMAGES (INCLUDING,  BUT NOT LIMITED TO, PROCUREMENT OF 
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS; OR 
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  LIABILITY, 
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF  
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+#include 
+#include  #include 
+
+#include 
+#include 
+#include 
+#include  #include  
+#include 
+
+//
+// Print ESRT to debug console
+//
+VOID
+EFIAPI
+PrintTable (
+  IN EFI_SYSTEM_RESOURCE_TABLE  *Table
+  );
+
+//
+// Number of ESRT entries to grow by each time we run out of room // 
+#define GROWTH_STEP  10
+
+//
+// Module globals.
+//
+EFI_EVENT  mEsrtReadyToBootEvent;
+EFI_SYSTEM_RESOURCE_TABLE  *mTable = NULL;
+BOOLEANmEsrtInstalled = FALSE;
+EFI_EVENT  mFmpInstallEvent;
+VOID   *mFmpInstallEventRegistration = NULL;
+
+/**
+  Install EFI System Resource Table into the UEFI Configuration Table
+
+  @return  Status code.
+
+**/
+EFI_STATUS
+InstallEfiSystemResourceTableInUefiConfigurationTable (
+   VOID
+  )
+{
+  EFI_STATUS Status;
+
+  Status = EFI_SUCCESS;
+  if (!mEsrtInstalled) {
+if (mTable == NULL) {
+  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Can't install ESRT table because it is 
NULL. \n"));
+  Status = EFI_OUT_OF_RESOURCES;
+} else if (mTable->FwResourceCount 

Re: [edk2] [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP

2018-02-07 Thread Zeng, Star
Reviewed-by: Star Zeng 

Thanks,
Star
-Original Message-
From: Yao, Jiewen 
Sent: Thursday, February 8, 2018 8:18 AM
To: Kinney, Michael D ; edk2-devel@lists.01.org
Cc: Zeng, Star ; Dong, Eric 
Subject: RE: [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with 
FMP

Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Kinney, Michael D
> Sent: Thursday, February 8, 2018 2:50 AM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Zeng, Star 
> ; Dong, Eric ; Kinney, 
> Michael D 
> Subject: [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule 
> with FMP
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=873
> 
> Update IsNestedFmpCapsule() to verify the CapsuleGuid in the 
> CapsuleHeader against the installed Firmware Management Protocol 
> instances.  The current logic that uses the ESRT Table does not work 
> because capsules are processed before the ESRT Table is published at 
> the Ready To Boot event.
> 
> Cc: Jiewen Yao 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney 
> ---
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c   | 27
> --
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf |  3 +--
>  2 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> index 2f397789b5..87e1deec03 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> @@ -10,7 +10,7 @@
>ValidateFmpCapsule(), DisplayCapsuleImage(), ConvertBmpToGopBlt() will
>receive untrusted input and do basic validation.
> 
> -  Copyright (c) 2016 - 2017, Intel Corporation. All rights 
> reserved.
> +  Copyright (c) 2016 - 2018, Intel Corporation. All rights 
> + reserved.
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of 
> the BSD License
>which accompanies this distribution.  The full text of the license 
> may be found at @@ -1446,7 +1446,6 @@ IsNestedFmpCapsule (
>)
>  {
>EFI_STATUS Status;
> -  EFI_SYSTEM_RESOURCE_TABLE  *Esrt;
>EFI_SYSTEM_RESOURCE_ENTRY  *EsrtEntry;
>UINTN  Index;
>BOOLEANEsrtGuidFound;
> @@ -1454,6 +1453,8 @@ IsNestedFmpCapsule (
>UINTN  NestedCapsuleSize;
>ESRT_MANAGEMENT_PROTOCOL   *EsrtProtocol;
>EFI_SYSTEM_RESOURCE_ENTRY  Entry;
> +  EFI_HANDLE *HandleBuffer;
> +  UINTN  NumberOfHandles;
> 
>EsrtGuidFound = FALSE;
>if (mIsVirtualAddrConverted) {
> @@ -1479,19 +1480,21 @@ IsNestedFmpCapsule (
>  }
> 
>  //
> -// Check ESRT configuration table
> +// Check Firmware Management Protocols
>  //
>  if (!EsrtGuidFound) {
> -  Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid,
> (VOID **)&Esrt);
> +  HandleBuffer = NULL;
> +  Status = GetFmpHandleBufferByType (
> + &CapsuleHeader->CapsuleGuid,
> + 0,
> + &NumberOfHandles,
> + &HandleBuffer
> + );
>if (!EFI_ERROR(Status)) {
> -ASSERT (Esrt != NULL);
> -EsrtEntry = (VOID *)(Esrt + 1);
> -for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++)
> {
> -  if (CompareGuid(&EsrtEntry->FwClass,
> &CapsuleHeader->CapsuleGuid)) {
> -EsrtGuidFound = TRUE;
> -break;
> -  }
> -}
> +EsrtGuidFound = TRUE;
> +  }
> +  if (HandleBuffer != NULL) {
> +FreePool (HandleBuffer);
>}
>  }
>}
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> index a7c36993c4..90edc52ee0 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> @@ -3,7 +3,7 @@
>  #
>  #  Capsule library instance for DXE_DRIVER module types.
>  #
> -#  Copyright (c) 2016 - 2017, Intel Corporation. All rights 
> reserved.
> +#  Copyright (c) 2016 - 2018, Intel Corporation. All rights 
> +reserved.
>  #  This program and the accompanying materials  #  are licensed and 
> made available under the terms and conditions of the BSD License  #  
> which accompanies this distribution.  The full text of the license may 
> be found at @@ -72,7 +72,6 @@  [Guids]
>gEfiFmpCapsuleGuid  ## SOMETIMES_CONSUMES
> ## GUID
>gWindowsUxCapsuleGuid   ## SOMETIMES_CONSUMES
> ## GUID
> -  gEfiSystemResourceTableGuid ## SOMETIMES_CONSUMES ##
> GUID
>## SOMETIMES_CONSUMES ## Variable:L"CapsuleMax"
>## SOMETIMES_PRODUCES ## Variable:L"CapsuleMax"
>gEfiCapsuleReportGuid
> --
> 2.14.2.windows.3

_

Re: [edk2] [Patch 01/10] MdeModulePkg: Add BmpSupportLib class and instance

2018-02-07 Thread Zeng, Star
Reviewed-by: Star Zeng  to MdeModulePkg change with a 
minor comment below.

Update the comments in MdeModulePkg/Include/Library/BmpSupportLib.h and 
MdeModulePkg.dec?

Provides services to convert a BMP graphics image to a GOP BLT buffer.
->
Provides services to convert a BMP graphics image to a GOP BLT buffer and to 
convert a GOP BLT buffer to a BMP graphics image.


Thanks,
Star
-Original Message-
From: Kinney, Michael D 
Sent: Thursday, February 8, 2018 6:58 AM
To: edk2-devel@lists.01.org
Cc: Sean Brogan ; Yao, Jiewen 
; Zeng, Star ; Dong, Eric 
; Ni, Ruiyu ; Kinney, Michael D 

Subject: [Patch 01/10] MdeModulePkg: Add BmpSupportLib class and instance

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Add BmpSupportLib class and instances that provides services to convert a BMP 
graphics image to a GOP BLT buffer and to convert a GOP BLT buffer to a BMP 
graphics image.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Include/Library/BmpSupportLib.h   | 105 
 .../BaseBmpSupportLib/BaseBmpSupportLib.inf|  49 ++
 .../BaseBmpSupportLib/BaseBmpSupportLib.uni|  20 +
 .../Library/BaseBmpSupportLib/BmpSupportLib.c  | 583 +
 MdeModulePkg/MdeModulePkg.dec  |   6 +-
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 6 files changed, 763 insertions(+), 1 deletion(-)  create mode 100644 
MdeModulePkg/Include/Library/BmpSupportLib.h
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.uni
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c

diff --git a/MdeModulePkg/Include/Library/BmpSupportLib.h 
b/MdeModulePkg/Include/Library/BmpSupportLib.h
new file mode 100644
index 00..3406aa3fca
--- /dev/null
+++ b/MdeModulePkg/Include/Library/BmpSupportLib.h
@@ -0,0 +1,105 @@
+/** @file
+
+Provides services to convert a BMP graphics image to a GOP BLT buffer.
+
+Copyright (c) 2016, Microsoft Corporation Copyright (c) 2018, Intel 
+Corporation. All rights reserved.
+
+All rights reserved.
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright 
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation  and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
OF SUCH DAMAGE.
+
+**/
+
+#ifndef __BMP_SUPPORT_LIB_H__
+#define __BMP_SUPPORT_LIB_H__
+
+#include 
+
+/**
+  Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt 
+buffer
+  is passed in a GopBlt buffer will be allocated by this routine using
+  EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it 
+will be
+  used if it is big enough.
+
+  @param [in]  BmpImage  Pointer to BMP file.
+  @param [in]  BmpImageSize  Number of bytes in BmpImage.
+  @param [in, out] GopBltBuffer containing GOP version of BmpImage.
+  @param [in, out] GopBltSizeSize of GopBlt in bytes.
+  @param [out] PixelHeight   Height of GopBlt/BmpImage in pixels.
+  @param [out] PixelWidthWidth of GopBlt/BmpImage in pixels.
+
+  @retval RETURN_SUCCESSGopBlt and GopBltSize are returned.
+  @retval RETURN_INVALID_PARAMETER  BmpImage is NULL.
+  @retval RETURN_INVALID_PARAMETER  GopBlt is NULL.
+  @retval RETURN_INVALID_PARAMETER  GopBltSize is NULL.
+  @retval RETURN_INVALID_PARAMETER  PixelHeight is NULL.
+  @retval RETURN_INVALID_PARAMETER  PixelWidt

[edk2] [PATCH] ShellPkg/hexedit: Fix a read-after-free bug

2018-02-07 Thread Ruiyu Ni
HDiskImageSetDiskNameOffsetSize() and HFileImageSetFileName()
may be called using the current disk name or file name.
When this happens, today's implementation firstly frees the memory
and then accesses the just-freed memory.
The patch fixes this issue by doing nothing when the disk or file
name is the current one.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 .../UefiShellDebug1CommandsLib/HexEdit/DiskImage.c | 22 +
 .../UefiShellDebug1CommandsLib/HexEdit/FileImage.c | 23 +-
 2 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
index 846b102975..8deb643f07 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/DiskImage.c
@@ -1,7 +1,7 @@
 /** @file
   Functions to deal with Disk buffer.
 
-  Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. 
+  Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -120,27 +120,23 @@ HDiskImageSetDiskNameOffsetSize (
   IN UINTNSize
   )
 {
-  UINTN Len;
-  UINTN Index;
+  if (Str == HDiskImage.Name) {
+//
+// This function might be called using HDiskImage.FileName as Str.
+// Directly return without updating HDiskImage.FileName.
+//
+return EFI_SUCCESS;
+  }
 
   //
   // free the old file name
   //
   SHELL_FREE_NON_NULL (HDiskImage.Name);
-
-  Len = StrLen (Str);
-
-  HDiskImage.Name = AllocateZeroPool (2 * (Len + 1));
+  HDiskImage.Name = AllocateCopyPool (StrSize (Str), Str);
   if (HDiskImage.Name == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
-  for (Index = 0; Index < Len; Index++) {
-HDiskImage.Name[Index] = Str[Index];
-  }
-
-  HDiskImage.Name[Len]  = L'\0';
-
   HDiskImage.Offset = Offset;
   HDiskImage.Size   = Size;
 
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
index 2517a57f59..d9fd72cdd2 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
@@ -1,7 +1,7 @@
 /** @file
   Functions to deal with file buffer.
 
-  Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved. 
+  Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -110,27 +110,22 @@ HFileImageSetFileName (
   IN CONST CHAR16 *Str
   )
 {
-  UINTN Size;
-  UINTN Index;
-
+  if (Str == HFileImage.FileName) {
+//
+// This function might be called using HFileImage.FileName as Str.
+// Directly return without updating HFileImage.FileName.
+//
+return EFI_SUCCESS;
+  }
   //
   // free the old file name
   //
   SHELL_FREE_NON_NULL (HFileImage.FileName);
-
-  Size= StrLen (Str);
-
-  HFileImage.FileName = AllocateZeroPool (2 * (Size + 1));
+  HFileImage.FileName = AllocateCopyPool (StrSize (Str), Str);
   if (HFileImage.FileName == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
-  for (Index = 0; Index < Size; Index++) {
-HFileImage.FileName[Index] = Str[Index];
-  }
-
-  HFileImage.FileName[Size] = L'\0';
-
   return EFI_SUCCESS;
 }
 
-- 
2.16.1.windows.1

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


[edk2] [PATCH] ShellPkg/rm: fix hang when deleting an absolutely-empty directory An ordinary empty directory should contain "." and ".." entries. When an empty directory even doesn't contain "." or ".

2018-02-07 Thread Ruiyu Ni
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
Cc: Jaben Carsey 
---
 ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c 
b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
index 618610d0f3..288e7666a8 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Rm.c
@@ -2,7 +2,7 @@
   Main file for attrib shell level 2 function.
 
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -33,6 +33,7 @@ IsDirectoryEmpty (
   IN EFI_HANDLE   FileHandle
   )
 {
+  EFI_STATUS  Status;
   EFI_FILE_INFO   *FileInfo;
   BOOLEAN NoFile;
   BOOLEAN RetVal;
@@ -41,8 +42,8 @@ IsDirectoryEmpty (
   NoFile = FALSE;
   FileInfo = NULL;
 
-  for (FileHandleFindFirstFile(FileHandle, &FileInfo)
-;  !NoFile
+  for (Status = FileHandleFindFirstFile(FileHandle, &FileInfo)
+;  !NoFile && !EFI_ERROR (Status)
 ;  FileHandleFindNextFile(FileHandle, FileInfo, &NoFile)
){
 if (StrStr(FileInfo->FileName, L".") != FileInfo->FileName
-- 
2.16.1.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] ShellPkg/UefiShellDebug1CommandsLib: sync Compress() definition with decl.

2018-02-07 Thread Gary Lin
On Wed, Feb 07, 2018 at 11:44:34PM +0100, Laszlo Ersek wrote:
> "Compress.h" declares the Compress() function as EFIAPI, but the
> definition in "Compress.c" lacks EFIAPI.
> 
> GCC toolchains without LTO do not catch this error because "Compress.c"
> does not include "Compress.h"; i.e. the declaration used by callers such
> as "EfiCompress.c" is not actually matched against the function definition
> at build time.
> 
> With LTO enabled, the mismatch is found -- however, as a warning only, due
> to commit f8d0b9662993 ("BaseTools GCC5: disable warnings-as-errors for
> now", 2016-08-03).
> 
> Include the header in the C file (which turns the issue into a hard build
> error on all GCC toolchains), plus sync the declaration from the header
> file to the C file. Finally, remove EFIAPI from both declaration and
> definition -- this was the original intent of commit c4e74e9b814c
> ("ShellPkg/UefiShellDebug1CommandsLib: Remove unnecessary EFIAPI",
> 2016-10-09), but it missed the header file.
> 
> (Gary meant to address that omission in Oct 2017:
> 
>   [edk2] [PATCH] ShellPkg/UefiShellDebug1CommandsLib: Remove EFIAPI from
>  Compress()
> 
>   http://mid.mail-archive.com/20171026065329.32311-1-glin@suse.com
> 
> and Ray reviewed the patch, but then the patch was never committed.)
> 
I forgot to track the commit. Thanks for picking it up!

Reviewed-by Gary Lin 

> So do the sync and drop EFIAPI now.
> 
> This happens to fix the EFICOMPRESS shell command, when built with GCC for
> X64.
> 
> Cc: Gary Lin 
> Cc: Jaben Carsey 
> Cc: Ruiyu Ni 
> Fixes: c4e74e9b814cfb4b51cf832f3bb218cd2aba348b
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek 
> ---
> 
> Notes:
> v2:
> - drop EFIAPI based on Gary's earlier patch which I just stumbled upon
> - do not pick up Jaben's R-b from v1, due to inverted EFIAPI handling
> - add "Fixes:" tag
> 
>  ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h |  1 -
>  ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c | 14 --
>  2 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h 
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
> index 39a997178fb7..7fe844e212a8 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
> @@ -28,7 +28,6 @@
>@retval EFI_BUFFER_TOO_SMALL  The buffer was too small.  DstSize is 
> required.
>  **/
>  EFI_STATUS
> -EFIAPI
>  Compress (
>IN  VOID*SrcBuffer,
>IN  UINT64  SrcSize,
> diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c 
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
> index 736d2a35b3ac..cde2c54f1b45 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
> @@ -23,6 +23,8 @@
>  #include 
>  #include 
>  
> +#include "Compress.h"
> +
>  //
>  // Macro Definitions
>  //
> @@ -1307,20 +1309,20 @@ Encode (
>The compression routine.
>  
>@param[in]   SrcBuffer The buffer containing the source data.
> -  @param[in]   SrcSize   The number of bytes in SrcBuffer.
> +  @param[in]   SrcSize   Number of bytes in SrcBuffer.
>@param[in]   DstBuffer The buffer to put the compressed image in.
>@param[in, out]  DstSize   On input the size (in bytes) of DstBuffer, 
> on
> -return the number of bytes placed in 
> DstBuffer.
> + return the number of bytes placed in 
> DstBuffer.
>  
>@retval EFI_SUCCESS   The compression was sucessful.
>@retval EFI_BUFFER_TOO_SMALL  The buffer was too small.  DstSize is 
> required.
>  **/
>  EFI_STATUS
>  Compress (
> -  IN   VOID   *SrcBuffer,
> -  IN   UINT64 SrcSize,
> -  IN   VOID   *DstBuffer,
> -  IN OUT   UINT64 *DstSize
> +  IN  VOID*SrcBuffer,
> +  IN  UINT64  SrcSize,
> +  IN  VOID*DstBuffer,
> +  IN OUT  UINT64  *DstSize
>)
>  {
>EFI_STATUS  Status;
> -- 
> 2.14.1.3.gb7cf6e02401b
> 
> 
> ___
> 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 Build failed issue.

2018-02-07 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>BobCF
>Sent: Tuesday, February 06, 2018 3:21 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming 
>Subject: [edk2] [Patch] BaseTools: Fixed Build failed issue.
>
>If the PCD is not used in DSC file and user set
>that PCD value from Command line, build will fail.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/Workspace/DscBuildData.py | 7 ++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 1da4f03ab8..6e3cd0f3f1 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -896,11 +896,12 @@ class DscBuildData(PlatformBuildClassObject):
> else:
> pcdobj = self._Pcds.get((pcd[1],pcd[0]))
> if pcdobj:
> pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue))
> else:
>-pcdset.append((pcd[0],pcd[1],pcd[3]))
>+pcdvalue = pcd[3] if len(pcd) == 4 else pcd[2]
>+pcdset.append((pcd[0],pcd[1],pcdvalue))
> GlobalData.BuildOptionPcd = pcdset
> def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName,
>TokenCName, FieldName):
> PredictedFieldType = "VOID*"
> if ValueStr.startswith('L'):
> if not ValueStr[1]:
>@@ -2163,14 +2164,18 @@ class DscBuildData(PlatformBuildClassObject):
>
>
> for pcd in Pcds.values():
> SkuInfoObj = pcd.SkuInfoList.values()[0]
> pcdDecObject = self._DecPcds[pcd.TokenCName,
>pcd.TokenSpaceGuidCName]
>+pcd.DatumType = pcdDecObject.DatumType
> # Only fix the value while no value provided in DSC file.
> for sku in pcd.SkuInfoList.values():
> if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue == None):
> sku.HiiDefaultValue = pcdDecObject.DefaultValue
>+for default_store in sku.DefaultStoreDict:
>+
>sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue
>+pcd.DefaultValue = pcdDecObject.DefaultValue
> if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in
>pcd.SkuInfoList.keys():
> valuefromDec = pcdDecObject.DefaultValue
> SkuInfo = SkuInfoClass('DEFAULT', '0', 
> SkuInfoObj.VariableName,
>SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset,
>valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore=
>{DefaultStore:valuefromDec})
> pcd.SkuInfoList['DEFAULT'] = SkuInfo
> elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in
>pcd.SkuInfoList.keys():
>--
>2.14.3.windows.1
>
>___
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [Patch] BaseTools: Fixed incorrect Structure Pcd Value.

2018-02-07 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Feng, Bob C
>Sent: Wednesday, February 07, 2018 12:10 PM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming 
>Subject: [Patch] BaseTools: Fixed incorrect Structure Pcd Value.
>
>When structurePCD only has overall value assigned
>in Dsc under different SKU, the value under default sku is used.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/Workspace/DscBuildData.py | 20
>+---
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 8833034a1e..0da3efbb43 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -1283,11 +1283,14 @@ class DscBuildData(PlatformBuildClassObject):
> if str_pcd_dec:
> str_pcd_obj_str = StructurePcd()
> str_pcd_obj_str.copy(str_pcd_dec)
> if str_pcd_obj:
> str_pcd_obj_str.copy(str_pcd_obj)
>-str_pcd_obj_str.DefaultFromDSC = str_pcd_obj_str.DefaultValue
>+if str_pcd_obj.Type in
>[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
>self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
>+str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>+else:
>+str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
> for str_pcd_data in StrPcdSet[str_pcd]:
> if str_pcd_data[3] in SkuIds:
> str_pcd_obj_str.AddOverrideValue(str_pcd_data[2],
>str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else
>str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else
>str_pcd_data[4], self.MetaFile.File,LineNo=str_pcd_data[5])
> S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str
> else:
>@@ -1301,12 +1304,14 @@ class DscBuildData(PlatformBuildClassObject):
> str_pcd_obj_str = StructurePcd()
> str_pcd_obj_str.copy(self._DecPcds[Pcd])
> str_pcd_obj = Pcds.get(Pcd, None)
> if str_pcd_obj:
> str_pcd_obj_str.copy(str_pcd_obj)
>-if str_pcd_obj.DefaultValue:
>-str_pcd_obj_str.DefaultFromDSC = 
>str_pcd_obj.DefaultValue
>+if str_pcd_obj.Type in
>[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
>self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
>+str_pcd_obj_str.DefaultFromDSC = 
>{skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
>+else:
>+str_pcd_obj_str.DefaultFromDSC = 
>{skuname:{defaultstore:
>str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
>str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in
>DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
> S_pcd_set[Pcd] = str_pcd_obj_str
> if S_pcd_set:
> GlobalData.gStructurePcd[self.Arch] = S_pcd_set
> for stru_pcd in S_pcd_set.values():
> for skuid in SkuIds:
>@@ -1695,29 +1700,30 @@ class DscBuildData(PlatformBuildClassObject):
> for skuname in self.SkuIdMgr.GetSkuChain(SkuName):
> inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]
> storeset = [DefaultStoreName] if DefaultStoreName == 
> 'STANDARD'
>else ['STANDARD', DefaultStoreName]
> for defaultstorenameitem in storeset:
> CApp = CApp + "// SkuName: %s,  DefaultStoreName: %s \n" %
>(skuname, defaultstorenameitem)
>-for FieldList in
>[Pcd.DefaultFromDSC,inherit_OverrideValues.get(defaultstorenameitem)]:
>+pcddefaultvalue =
>Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem,
>Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue
>+for FieldList in
>[pcddefaultvalue,inherit_OverrideValues.get(defaultstorenameitem)]:
> if not FieldList:
> continue
>-if Pcd.DefaultFromDSC and FieldList == 
>Pcd.DefaultFromDSC:
>+if pcddefaultvalue and FieldLi

Re: [edk2] [Patch] BaseTool: Fixed Pcd issues.

2018-02-07 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: Feng, Bob C
>Sent: Wednesday, February 07, 2018 10:02 AM
>To: edk2-devel@lists.01.org
>Cc: Feng, Bob C ; Gao, Liming 
>Subject: [Patch] BaseTool: Fixed Pcd issues.
>
>1. Check variable offset when merging Hii Pcds
>2. Fixed the issue of Hii value inherit with default store.
>3. Error handling for incorrect structure pcd declare.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Bob Feng 
>Cc: Liming Gao 
>---
> BaseTools/Source/Python/AutoGen/GenVar.py  |  19 ++-
> .../Source/Python/Workspace/BuildClassObject.py|   1 +
> BaseTools/Source/Python/Workspace/DecBuildData.py  |   7 +-
> BaseTools/Source/Python/Workspace/DscBuildData.py  | 152 +++-
>-
> 4 files changed, 100 insertions(+), 79 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py
>b/BaseTools/Source/Python/AutoGen/GenVar.py
>index 1389d7ff62..d222e6ed5e 100644
>--- a/BaseTools/Source/Python/AutoGen/GenVar.py
>+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
>@@ -102,14 +102,31 @@ class VariableMgr(object):
> data = value_list[0]
> value_list = []
> for data_byte in pack(data_flag,int(data,16) if
>data.upper().startswith('0X') else int(data)):
> value_list += [hex(unpack("B",data_byte)[0])]
> newvalue[int(item.var_offset,16) if
>item.var_offset.upper().startswith("0X") else int(item.var_offset)] =
>value_list
>-newvaluestr = "{" + ",".join(reduce(lambda x,y: x+y, [newvalue[k] 
>for k
>in sorted(newvalue.keys())] )) +"}"
>+try:
>+newvaluestr = "{" + 
>",".join(self.assemble_variable(newvalue)) +"}"
>+except:
>+EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset 
>conflict
>in PCDs: %s \n" % (" and ".join([item.pcdname for item in
>sku_var_info_offset_list])))
> n = sku_var_info_offset_list[0]
> indexedvarinfo[key] =
>[var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_na
>me, n.var_guid, "0x00",n.var_attribute,newvaluestr  , newvaluestr , "VOID*")]
> self.VarInfo = [item[0] for item in indexedvarinfo.values()]
>+
>+def assemble_variable(self, valuelist):
>+ordered_value = [valuelist[k] for k in sorted(valuelist.keys())]
>+ordered_offset = sorted(valuelist.keys())
>+var_value = []
>+num = 0
>+for offset in ordered_offset:
>+if offset < len(var_value):
>+raise
>+for _ in xrange(offset - len(var_value)):
>+var_value.append('0x00')
>+var_value += ordered_value[num]
>+num +=1
>+return var_value
> def process_variable_data(self):
>
> var_data = dict()
>
> indexedvarinfo = collections.OrderedDict()
>diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>index 0e1161c96f..f499cbd58b 100644
>--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
>+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
>@@ -112,10 +112,11 @@ class StructurePcd(PcdClassObject):
> def __init__(self, StructuredPcdIncludeFile=None, Packages=None,
>Name=None, Guid=None, Type=None, DatumType=None, Value=None,
>Token=None, MaxDatumSize=None, SkuInfoList=None, IsOverrided=False,
>GuidValue=None, validateranges=None, validlists=None,
>expressions=None,default_store = TAB_DEFAULT_STORES_DEFAULT):
> if SkuInfoList is None: SkuInfoList={}
> if validateranges is None: validateranges=[]
> if validlists is None: validlists=[]
> if expressions is None : expressions=[]
>+if Packages is None : Packages = []
> super(StructurePcd, self).__init__(Name, Guid, Type, DatumType, Value,
>Token, MaxDatumSize, SkuInfoList, IsOverrided, GuidValue, validateranges,
>validlists, expressions)
> self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is 
> None else
>StructuredPcdIncludeFile
> self.PackageDecs = Packages
> self.DefaultStoreName = [default_store]
> self.DefaultValues = collections.OrderedDict({})
>diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py
>b/BaseTools/Source/Python/Workspace/DecBuildData.py
>index 2266b0b7a6..99c3bf14f1 100644
>--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
>@@ -387,10 +387,12 @@ class DecBuildData(PackageBuildClassObject):
> struct_pcd.PkgPath = self.MetaFile.File
> else:
> struct_pcd.AddDefaultValue(item.TokenCName,
>item.DefaultValue,self.MetaFile.File,LineNo)
>
> struct_pcd.PackageDecs = dep_pkgs
>+if not struct_pcd.StructuredPcdIncludeFile:
>+EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The
>structure Pcd %s.%s header file is 

Re: [edk2] [Patch] BaseTools: not specified value of MAX_CONCURRENT_THREAD_NUMBER

2018-02-07 Thread Gao, Liming
Reviewed-by: Liming Gao 

>-Original Message-
>From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of
>Yonghong Zhu
>Sent: Thursday, February 08, 2018 9:50 AM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [Patch] BaseTools: not specified value of
>MAX_CONCURRENT_THREAD_NUMBER
>
>V3: Update the build option help info
>
>when MAX_CONCURRENT_THREAD_NUMBER is not specified, tool will
>automatically detect number of processor threads.
>
>Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu 
>---
> BaseTools/Conf/target.template | 14 +-
> BaseTools/Source/Python/build/build.py |  3 ++-
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
>diff --git a/BaseTools/Conf/target.template
>b/BaseTools/Conf/target.template
>index 787fc64..e5c31fe 100644
>--- a/BaseTools/Conf/target.template
>+++ b/BaseTools/Conf/target.template
>@@ -1,7 +1,7 @@
> #
>-#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
>+#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> #
> #  This program and the accompanying materials
> #  are licensed and made available under the terms and conditions of the BSD
>License
> #  which accompanies this distribution.  The full text of the license may be
>found at
> #  http://opensource.org/licenses/bsd-license.php
>@@ -57,14 +57,18 @@ TOOL_CHAIN_CONF   = Conf/tools_def.txt
> #  TAGNAME   List  Optional   Specify the name(s) of the 
> tools_def.txt
>TagName to use.
> # If not specified, all 
> applicable TagName tools will be
> # used for the build.  The list 
> uses space character
>separation.
> TOOL_CHAIN_TAG= MYTOOLS
>
>-# MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number
>of concurrent threads. Recommend to set this
>-# value to one more than the 
>number of your
>compurter
>-# cores or CPUs. Less than 2 
>means disable
>multithread build.
>-MAX_CONCURRENT_THREAD_NUMBER = 1
>+# MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number
>of concurrent threads. If not specified or set
>+# to zero, tool automatically 
>detect number of
>processor
>+# threads. Recommend to set 
>this value to one less
>than the
>+# number of your computer 
>cores or CPUs. When
>value set to 1,
>+# means disable multi-thread 
>build, value set to
>more than 1,
>+# means user specify the 
>thread number to build.
>Not specify
>+# the default value in this 
>file.
>+# MAX_CONCURRENT_THREAD_NUMBER = 1
>
>
> # BUILD_RULE_CONF  Filename Optional  Specify the file name to use for the
>build rules that are followed
> # when generating Makefiles. If not 
> specified, the file:
> # WORKSPACE/Conf/build_rule.txt will be 
> used
>diff --git a/BaseTools/Source/Python/build/build.py
>b/BaseTools/Source/Python/build/build.py
>index 24f9962..06a89ed 100644
>--- a/BaseTools/Source/Python/build/build.py
>+++ b/BaseTools/Source/Python/build/build.py
>@@ -2321,11 +2321,12 @@ def MyOptionParser():
> help="Using the Tool Chain Tagname to build the platform, overriding
>target.txt's TOOL_CHAIN_TAG definition.")
> Parser.add_option("-x", "--sku-id", action="callback", type="string",
>dest="SkuId", callback=SingleCheckCallback,
> help="Using this name of SKU ID to build the platform, overriding
>SKUID_IDENTIFIER in DSC file.")
>
> Parser.add_option("-n", action="callback", type="int",
>dest="ThreadNumber", callback=SingleCheckCallback,
>-help="Build the platform using multi-threaded compiler. The value
>overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. Less than 2 will
>disable multi-thread builds.")
>+help="Build the platform using multi-threaded compiler. The value
>overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. When value is
>set to 0, tool automatically detect number of "\
>+ "processor threads, set value to 1 means disable multi-thread 
>build,
>and set value more than 1  means user specify the threads number to build.")
>
> Parser.add_option("-f", "--fdf", action="callback", type="string",
>dest="FdfFile", callback=SingleCheckCallback,
> help="The name of the FDF file to use, which overrides the setting in 
> the
>DSC file.")
> Parser.add_option("-r", "--rom-image", action="append", type="string",
>dest="RomImage", default=[],
> help="The name of FD to be generated. The name must be from [FD]
>section in FDF file.")

Re: [edk2] [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI

2018-02-07 Thread Zeng, Star

On 2018/2/7 20:40, Zeng, Star wrote:

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Bret Barkelew 

The Reset Notification protocol is added in UEFI spec to support
reset notification mechanism in the DXE phase.
This patch adds similar EDKII specific Reset Notification PPI to PEI
phase to provide the same support.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bret Barkelew 
Signed-off-by: Ruiyu Ni 
---
  .../Ppi/PlatformSpecificResetNotification.h    | 31 
++

  MdeModulePkg/MdeModulePkg.dec  |  3 +++
  .../Universal/ResetSystemPei/ResetSystem.c | 16 +++
  .../Universal/ResetSystemPei/ResetSystem.h |  1 +
  .../Universal/ResetSystemPei/ResetSystemPei.inf    |  7 ++---
  5 files changed, 55 insertions(+), 3 deletions(-)
  create mode 100644 
MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h


diff --git 
a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h 
b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h

new file mode 100644
index 00..ea53e24133
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
@@ -0,0 +1,31 @@
+/** @file
+  This PPI provides services to register a platform specific 
notification callback for

+  ResetSystem().  The registered handlers are processed after
+  EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.


How about adding "and after EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI" 
at the end of the sentence?


And also need enhance the comments in 
MdeModulePkg\Include\Ppi\PlatformSpecificResetFilter.h to state it will 
be processed before EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI 
instead of EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI.


And also need enhance the comments in 
MdeModulePkg\Include\Ppi\PlatformSpecificResetHandler.h to state it will 
be processed after EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI 
instead of EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI.



Thanks,
Star


Please also update the comments for PcdMaximumPeiResetNotifies in 
MdeModulePkg.dec and MdeModulePkg.uni accordingly.



Thanks,
Star




+
+  Copyright (c) 2017 Intel Corporation. All rights reserved.
+  Copyright (c) 2017 Microsoft Corporation. All rights reserved.
+
+  This program and the accompanying materials are licensed and made 
available under
+  the terms and conditions of the BSD License that accompanies this 
distribution.

+  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
OR IMPLIED.

+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
+#define _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
+
+#include 
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_GUID \
+  { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0x0f, 0xdc, 
0xf7, 0xcb } }

+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL  
EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI;

+
+extern EFI_GUID gEdkiiPlatformSpecificResetNotificationPpiGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec 
b/MdeModulePkg/MdeModulePkg.dec

index 1b971d599f..297b02ffa9 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -444,6 +444,9 @@ [Ppis]
    ## Include/Ppi/PlatformSpecificResetFilter.h
    gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90, 
0x47ef, { 0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }

+  ## Include/Ppi/PlatformSpecificResetNotification.h
+  gEdkiiPlatformSpecificResetNotificationPpiGuid = { 0xe09f355d, 
0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0xf, 0xdc, 0xf7, 0xcb } }

+
    ## Include/Ppi/PlatformSpecificResetHandler.h
    gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441, 
0x49dc, { 0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c 
b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c

index 720593de6a..4dfe303f77 100644
--- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
@@ -25,6 +25,7 @@ EFI_PEI_RESET2_PPI mPpiReset2 = {
  EFI_GUID    *mProcessingOrder[] = {
    &gEdkiiPlatformSpecificResetFilterPpiGuid,
+  &gEdkiiPlatformSpecificResetNotificationPpiGuid,
    &gEdkiiPlatformSpecificResetHandlerPpiGuid
  };
@@ -36,6 +37,14 @@ RESET_FILTER_INSTANCE   mResetFilter = {
    &gEdkiiPlatformSpecificResetFilterPpiGuid
  };
+RESET_FILTER_INSTANCE   mResetNotification = {
+  {
+    RegisterResetNotify,
+    UnregisterResetNotify
+  },
+  &gEdkiiPlatformSpecificResetNotificationPpiGuid
+};
+
  RESET_FILTER_INSTANCE   mResetHandler = {
    {
  RegisterResetNotify,
@@ -55,6 +64,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
  &gEdkiiPlatformSpecificResetFilterPpiGuid,
  &mResetFilter.ResetFi

Re: [edk2] [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM

2018-02-07 Thread Zeng, Star

Sorry for the trivial comments.

1. A typo "recurstion" should be "recursion" is in ResetSystem.h for 
both ResetSystemPei and ResetSystemRuntimeDxe.


2. Should "RUNTIME/runtime/RS" be "PEI" in the comments and code like below?

//
// Indicate reset system runtime service is called.
//
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, 
(EFI_SOFTWARE_EFI_RUNTIME_SERVICE | EFI_SW_RS_PC_RESET_SYSTEM));


->

//
// Indicate reset system PEI service is called.
//
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE_PEI_SERVICE | 
EFI_SW_PS_PC_RESET_SYSTEM));


3. We need update MdeModulePkg.uni for the new PCD 
PcdMaximumPeiResetNotifies accordingly.



Thanks,
Star

On 2018/2/7 20:35, Zeng, Star wrote:

On 2018/2/2 14:45, Ruiyu Ni wrote:

This driver implements Reset2, ResetFilter and ResetHandler PPIs.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 


Should ResetSystemPei be added in MdeModulePkg.dsc for build coverage?

Same comment has been provided to ResetSystemRuntimeDxe.
Should be (*RecursionDepthPointer < MAX_RESET_NOTIFY_DEPTH) instead of 
(*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH)>



Thanks,
Star


---
  MdeModulePkg/MdeModulePkg.dec  |   4 +
  .../Universal/ResetSystemPei/ResetSystem.c | 355 
+

  .../Universal/ResetSystemPei/ResetSystem.h | 129 
  .../Universal/ResetSystemPei/ResetSystemPei.inf    |  62 
  .../Universal/ResetSystemPei/ResetSystemPei.uni    |  20 ++
  .../ResetSystemPei/ResetSystemPeiExtra.uni |  20 ++
  6 files changed, 590 insertions(+)
  create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
  create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
  create mode 100644 
MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
  create mode 100644 
MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
  create mode 100644 
MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni


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

index 1cc9bc8ea1..1b971d599f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
    # @Prompt CapsuleMax value in capsule report variable.
    gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0x|UINT16|0x0107
+  ## Indicates the allowable maximum number of Reset Filters or Reset 
Handlers in PEI phase.

+  # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x0109 


+
  [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
    ## This PCD defines the Console output row. The default value is 
25 according to UEFI spec.
    #  This PCD could be set to 0 then console output would be at max 
column and max row.
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c 
b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c

new file mode 100644
index 00..720593de6a
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
@@ -0,0 +1,355 @@
+/** @file
+  Implementation of Reset2, ResetFilter and ResetHandler PPIs.
+
+  Copyright (c) 2017, 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 "ResetSystem.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
+  L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
+};
+
+EFI_PEI_RESET2_PPI mPpiReset2 = {
+  ResetSystem2
+};
+
+EFI_GUID    *mProcessingOrder[] = {
+  &gEdkiiPlatformSpecificResetFilterPpiGuid,
+  &gEdkiiPlatformSpecificResetHandlerPpiGuid
+};
+
+RESET_FILTER_INSTANCE   mResetFilter = {
+  {
+    RegisterResetNotify,
+    UnregisterResetNotify
+  },
+  &gEdkiiPlatformSpecificResetFilterPpiGuid
+};
+
+RESET_FILTER_INSTANCE   mResetHandler = {
+  {
+    RegisterResetNotify,
+    UnregisterResetNotify
+  },
+  &gEdkiiPlatformSpecificResetHandlerPpiGuid
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
+  {
+    EFI_PEI_PPI_DESCRIPTOR_PPI,
+    &gEfiPeiReset2PpiGuid,
+    &mPpiReset2
+  },
+  {
+    EFI_PEI_PPI_DESCRIPTOR_PPI,
+    &gEdkiiPlatformSpecificResetFilterPpiGuid,
+    &mResetFilter.ResetFilter
+  },
+  {
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+    &gEdkiiPlatformSpecificResetHandlerPpiGuid,
+    &mResetHandler.ResetFilter
+  }
+};
+
+/**
+  Register a notification function to be called when ResetSystem() is 
called.

+
+  The RegisterResetNotif

[edk2] [Patch V3] Build spec: Add description about auto detect thread number

2018-02-07 Thread Yonghong Zhu
V3: Update the build option help info

Add description about enable auto detect thread number when
MAX_CONCURRENT_THREAD_NUMBER is not specified.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 5_meta-data_file_specifications/53_target_txt_file.md | 8 +---
 appendix_d_buildexe_command/d4_usage.md   | 7 +--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/5_meta-data_file_specifications/53_target_txt_file.md 
b/5_meta-data_file_specifications/53_target_txt_file.md
index ff8c2ec..755d3fb 100644
--- a/5_meta-data_file_specifications/53_target_txt_file.md
+++ b/5_meta-data_file_specifications/53_target_txt_file.md
@@ -116,13 +116,15 @@ Specify the name of the `tools_def.txt` tool chain tag 
name to use. If not
 specified in this file and it is not specified using the `-t` option on the
 command-line, then the build will break.
 
 **_Integer_**
 
-The number of concurrent threads. The default, if not specified or set to zero,
-is 2 Recommend setting this value to one more than the number of computer cores
-or CPUs of the development workstation.
+The number of concurrent threads. If not specified or set to zero, tool
+automatically detect number of processor threads. Recommend setting this
+value to one less than the number of computer cores or CPUs of the development
+workstation. When value set to 1, means disable multi-thread build, and value 
set
+to more than 1, means user specify the thread number to build.
 
 **_BuildRulesFile_**
 
 Specify the file name to use for the build rules that are followed when
 generating Makefiles. If not specified, the file:
diff --git a/appendix_d_buildexe_command/d4_usage.md 
b/appendix_d_buildexe_command/d4_usage.md
index 57d2656..c5c2584 100644
--- a/appendix_d_buildexe_command/d4_usage.md
+++ b/appendix_d_buildexe_command/d4_usage.md
@@ -60,12 +60,15 @@ Options:
   -x SKUID, --sku-id=SKUID
 Using this name of SKU ID to build the platform,
 overriding SKUID_IDENTIFIER in DSC file.
   -n THREADNUMBER   Build the platform using multi-threaded compiler. The
 value overrides target.txt's
-MAX_CONCURRENT_THREAD_NUMBER. Less than 2 will disable
-multi-thread builds.
+MAX_CONCURRENT_THREAD_NUMBER. When value is set to 0,
+tool automatically detect number of processor threads,
+set value to 1 means disable multi-thread build, and
+set value to more than 1 means user specify the threads
+number to build.
   -f FDFFILE, --fdf=FDFFILE
 The name of the FDF file to use, which overrides the
 setting in the DSC file.
   -r ROMIMAGE, --rom-image=ROMIMAGE
 The name of FD to be generated. The name must be from
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance

2018-02-07 Thread Zeng, Star

Sorry for the trivial comments.

"@param[in]  ResetType Base reset type as defined in UEFI spec." 
needs to be removed for ResetPlatformSpecificGuid.


There is "in in" in the comments for the implementation of 
GetResetPlatformSpecificGuid(). May should be one "in" only?



Thanks,
Star

On 2018/2/8 9:36, Zeng, Star wrote:

Another minor comments is to remove below sentences in ResetUtilityLib.inf.

 > +#  The application pops up a menu showing all the boot options 
referenced by

 > +#  BootOrder NV variable and user can choose to boot from one of them.


Thanks,
Star

On 2018/2/7 20:28, Zeng, Star wrote:

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

The library class that provides services to generate a GUID specific
reset, parse the GUID from a GUID specific reset, and build the
ResetData buffer for any type of reset that requires extra data.

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Signed-off-by: Ruiyu Ni 


Should we also add below lines in MdeModulePkg.dec?

   ##  @libraryclass  Defines a set of helper functions for resetting 
the system

   ResetUtilityLib|Include/Library/ResetUtilityLib.h


Thanks,
Star


---
  MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++
  .../Library/ResetUtilityLib/ResetUtility.c | 221 
+

  .../Library/ResetUtilityLib/ResetUtilityLib.inf    |  43 
  MdeModulePkg/MdeModulePkg.dsc  |   7 +
  4 files changed, 382 insertions(+)
  create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
  create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
  create mode 100644 
MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf


diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h 
b/MdeModulePkg/Include/Library/ResetUtilityLib.h

new file mode 100644
index 00..94828785e2
--- /dev/null
+++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
@@ -0,0 +1,111 @@
+/** @file
+  This header describes various helper functions for resetting the 
system.

+
+  Copyright (c) 2017 Intel Corporation. All rights reserved.
+  Copyright (c) 2016 Microsoft Corporation. All rights reserved.
+
+  This program and the accompanying materials are licensed and made 
available under
+  the terms and conditions of the BSD License that accompanies this 
distribution.

+  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
OR IMPLIED.

+
+**/
+#ifndef _RESET_UTILITY_LIB_H_
+#define _RESET_UTILITY_LIB_H_
+
+/**
+  This is a shorthand helper function to reset with a subtype so that
+  the caller doesn't have to bother with a function that has half a 
dozen

+  parameters.
+
+  This will generate a reset with status EFI_SUCCESS, a NULL string, 
and
+  no custom data. The subtype will be formatted in such a way that 
it can be

+  picked up by notification registrations and custom handlers.
+
+  NOTE: This call will fail if the architectural ResetSystem 
underpinnings
+    are not initialized. For DXE, you can add 
gEfiResetArchProtocolGuid

+    to your DEPEX.
+
+  @param[in]  ResetType Base reset type as defined in UEFI spec.
+  @param[in]  ResetSubtype  GUID pointer for the reset subtype to be 
used.

+
+**/
+VOID
+EFIAPI
+ResetPlatformSpecificGuid (
+  IN CONST  GUID    *ResetSubtype
+  );
+
+/**
+  This function examines the DataSize and ResetData parameters 
passed to
+  to ResetSystem() and detemrines if the ResetData contains a 
Null-terminated
+  Unicode string followed by a GUID specific subtype.  If the GUID 
specific
+  subtype is present, then a pointer to the GUID value in ResetData 
is returned.

+
+  @param[in]  DataSize    The size, in bytes, of ResetData.
+  @param[in]  ResetData   Pointer to the data buffer passed into 
ResetSystem().

+
+  @retval Pointer Pointer to the GUID value in ResetData.
+  @retval NULL    ResetData is NULL.
+  @retval NULL    ResetData does not start with a 
Null-terminated

+  Unicode string.
+  @retval NULL    A Null-terminated Unicode string is 
present, but there
+  are less than sizeof (GUID) bytes after 
the string.

+  @retval NULL    No subtype is found.
+
+**/
+GUID *
+EFIAPI
+GetResetPlatformSpecificGuid (
+  IN UINTN   DataSize,
+  IN CONST VOID  *ResetData
+  );
+
+/**
+  This is a helper function that creates the reset data buffer that 
can be

+  passed into ResetSystem().
+
+  The reset data buffer is returned in ResetData and contains 
ResetString

+  followed by the ResetSubtype GUID followed by the ExtraData.
+
+  NOTE: Strings are internally limited by MAX_UINT16.
+
+  @param[in, out] ResetDataSize  On input, the size of the ResetD

[edk2] [Patch] BaseTools: not specified value of MAX_CONCURRENT_THREAD_NUMBER

2018-02-07 Thread Yonghong Zhu
V3: Update the build option help info

when MAX_CONCURRENT_THREAD_NUMBER is not specified, tool will
automatically detect number of processor threads.

Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 BaseTools/Conf/target.template | 14 +-
 BaseTools/Source/Python/build/build.py |  3 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Conf/target.template b/BaseTools/Conf/target.template
index 787fc64..e5c31fe 100644
--- a/BaseTools/Conf/target.template
+++ b/BaseTools/Conf/target.template
@@ -1,7 +1,7 @@
 #
-#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -57,14 +57,18 @@ TOOL_CHAIN_CONF   = Conf/tools_def.txt
 #  TAGNAME   List  Optional   Specify the name(s) of the 
tools_def.txt TagName to use.
 # If not specified, all applicable 
TagName tools will be
 # used for the build.  The list 
uses space character separation.
 TOOL_CHAIN_TAG= MYTOOLS
 
-# MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number of concurrent 
threads. Recommend to set this
-# value to one more than the 
number of your compurter
-# cores or CPUs. Less than 2 
means disable multithread build.
-MAX_CONCURRENT_THREAD_NUMBER = 1
+# MAX_CONCURRENT_THREAD_NUMBER  NUMBER  Optional  The number of concurrent 
threads. If not specified or set
+# to zero, tool automatically 
detect number of processor
+# threads. Recommend to set 
this value to one less than the
+# number of your computer 
cores or CPUs. When value set to 1,
+# means disable multi-thread 
build, value set to more than 1,
+# means user specify the 
thread number to build. Not specify
+# the default value in this 
file.
+# MAX_CONCURRENT_THREAD_NUMBER = 1
 
 
 # BUILD_RULE_CONF  Filename Optional  Specify the file name to use for the 
build rules that are followed
 # when generating Makefiles. If not 
specified, the file: 
 # WORKSPACE/Conf/build_rule.txt will be 
used
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 24f9962..06a89ed 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -2321,11 +2321,12 @@ def MyOptionParser():
 help="Using the Tool Chain Tagname to build the platform, overriding 
target.txt's TOOL_CHAIN_TAG definition.")
 Parser.add_option("-x", "--sku-id", action="callback", type="string", 
dest="SkuId", callback=SingleCheckCallback,
 help="Using this name of SKU ID to build the platform, overriding 
SKUID_IDENTIFIER in DSC file.")
 
 Parser.add_option("-n", action="callback", type="int", 
dest="ThreadNumber", callback=SingleCheckCallback,
-help="Build the platform using multi-threaded compiler. The value 
overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. Less than 2 will disable 
multi-thread builds.")
+help="Build the platform using multi-threaded compiler. The value 
overrides target.txt's MAX_CONCURRENT_THREAD_NUMBER. When value is set to 0, 
tool automatically detect number of "\
+ "processor threads, set value to 1 means disable multi-thread 
build, and set value more than 1  means user specify the threads number to 
build.")
 
 Parser.add_option("-f", "--fdf", action="callback", type="string", 
dest="FdfFile", callback=SingleCheckCallback,
 help="The name of the FDF file to use, which overrides the setting in 
the DSC file.")
 Parser.add_option("-r", "--rom-image", action="append", type="string", 
dest="RomImage", default=[],
 help="The name of FD to be generated. The name must be from [FD] 
section in FDF file.")
-- 
2.6.1.windows.1

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


Re: [edk2] [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance

2018-02-07 Thread Zeng, Star

Another minor comments is to remove below sentences in ResetUtilityLib.inf.

> +#  The application pops up a menu showing all the boot options 
referenced by

> +#  BootOrder NV variable and user can choose to boot from one of them.


Thanks,
Star

On 2018/2/7 20:28, Zeng, Star wrote:

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

The library class that provides services to generate a GUID specific
reset, parse the GUID from a GUID specific reset, and build the
ResetData buffer for any type of reset that requires extra data.

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Signed-off-by: Ruiyu Ni 


Should we also add below lines in MdeModulePkg.dec?

   ##  @libraryclass  Defines a set of helper functions for resetting 
the system

   ResetUtilityLib|Include/Library/ResetUtilityLib.h


Thanks,
Star


---
  MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++
  .../Library/ResetUtilityLib/ResetUtility.c | 221 
+

  .../Library/ResetUtilityLib/ResetUtilityLib.inf    |  43 
  MdeModulePkg/MdeModulePkg.dsc  |   7 +
  4 files changed, 382 insertions(+)
  create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
  create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
  create mode 100644 
MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf


diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h 
b/MdeModulePkg/Include/Library/ResetUtilityLib.h

new file mode 100644
index 00..94828785e2
--- /dev/null
+++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
@@ -0,0 +1,111 @@
+/** @file
+  This header describes various helper functions for resetting the 
system.

+
+  Copyright (c) 2017 Intel Corporation. All rights reserved.
+  Copyright (c) 2016 Microsoft Corporation. All rights reserved.
+
+  This program and the accompanying materials are licensed and made 
available under
+  the terms and conditions of the BSD License that accompanies this 
distribution.

+  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS 
OR IMPLIED.

+
+**/
+#ifndef _RESET_UTILITY_LIB_H_
+#define _RESET_UTILITY_LIB_H_
+
+/**
+  This is a shorthand helper function to reset with a subtype so that
+  the caller doesn't have to bother with a function that has half a 
dozen

+  parameters.
+
+  This will generate a reset with status EFI_SUCCESS, a NULL string, and
+  no custom data. The subtype will be formatted in such a way that it 
can be

+  picked up by notification registrations and custom handlers.
+
+  NOTE: This call will fail if the architectural ResetSystem 
underpinnings
+    are not initialized. For DXE, you can add 
gEfiResetArchProtocolGuid

+    to your DEPEX.
+
+  @param[in]  ResetType Base reset type as defined in UEFI spec.
+  @param[in]  ResetSubtype  GUID pointer for the reset subtype to be 
used.

+
+**/
+VOID
+EFIAPI
+ResetPlatformSpecificGuid (
+  IN CONST  GUID    *ResetSubtype
+  );
+
+/**
+  This function examines the DataSize and ResetData parameters passed to
+  to ResetSystem() and detemrines if the ResetData contains a 
Null-terminated
+  Unicode string followed by a GUID specific subtype.  If the GUID 
specific
+  subtype is present, then a pointer to the GUID value in ResetData 
is returned.

+
+  @param[in]  DataSize    The size, in bytes, of ResetData.
+  @param[in]  ResetData   Pointer to the data buffer passed into 
ResetSystem().

+
+  @retval Pointer Pointer to the GUID value in ResetData.
+  @retval NULL    ResetData is NULL.
+  @retval NULL    ResetData does not start with a 
Null-terminated

+  Unicode string.
+  @retval NULL    A Null-terminated Unicode string is 
present, but there
+  are less than sizeof (GUID) bytes after the 
string.

+  @retval NULL    No subtype is found.
+
+**/
+GUID *
+EFIAPI
+GetResetPlatformSpecificGuid (
+  IN UINTN   DataSize,
+  IN CONST VOID  *ResetData
+  );
+
+/**
+  This is a helper function that creates the reset data buffer that 
can be

+  passed into ResetSystem().
+
+  The reset data buffer is returned in ResetData and contains 
ResetString

+  followed by the ResetSubtype GUID followed by the ExtraData.
+
+  NOTE: Strings are internally limited by MAX_UINT16.
+
+  @param[in, out] ResetDataSize  On input, the size of the ResetData 
buffer. On
+ output, either the total number of 
bytes

+ copied, or the required buffer size.
+  @param[in, out] ResetData  A pointer to the buffer in which to 
place the

+ final structure.
+  @param[in]  ResetSubtype   Poin

Re: [edk2] [Patch] MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance

2018-02-07 Thread Laszlo Ersek
On 02/08/18 01:32, Laszlo Ersek wrote:
> On 12/19/17 20:36, Kinney, Michael D wrote:
>> From: Sean Brogan 
>>
>> SafeIntLib provides helper functions to prevent integer overflow
>> during type conversion, addition, subtraction, and multiplication.
> 
> I clearly cannot review such a huge patch, but I've noticed something
> and would like to ask for clarification:
> 
>> +/**
>> +  INT64 Subtraction
>> +
>> +  Performs the requested operation using the input parameters into a value
>> +  specified by Result type and stores the converted value into the caller
>> +  allocated output buffer specified by Result.  The caller must pass in a
>> +  Result buffer that is at least as large as the Result type.
>> +
>> +  If Result is NULL, RETURN_INVALID_PARAMETER is returned.
>> +
>> +  If the requested operation results in an overflow or an underflow 
>> condition,
>> +  then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
>> +
>> +  @param[in]   Minuend A number from which another is to be subtracted.
>> +  @param[in]   Subtrahend  A number to be subtracted from another
>> +  @param[out]  Result  Pointer to the result of subtraction
>> +
>> +  @retval  RETURN_SUCCESSSuccessful subtraction
>> +  @retval  RETURN_BUFFER_TOO_SMALL   Underflow
>> +  @retval  RETURN_INVALID_PARAMETER  Result is NULL
>> +**/
>> +RETURN_STATUS
>> +EFIAPI
>> +SafeInt64Sub (
>> +  IN  INT64  Minuend,
>> +  IN  INT64  Subtrahend,
>> +  OUT INT64  *Result
>> +  )
>> +{
>> +  RETURN_STATUS  Status;
>> +  INT64  SignedResult;
>> +
>> +  if (Result == NULL) {
>> +return RETURN_INVALID_PARAMETER;
>> +  }
>> +
>> +  SignedResult = Minuend - Subtrahend;
>> +
>> +  //
>> +  // Subtracting a positive number from a positive number never overflows.
>> +  // Subtracting a negative number from a negative number never overflows.
>> +  // If you subtract a negative number from a positive number, you expect a 
>> positive result.
>> +  // If you subtract a positive number from a negative number, you expect a 
>> negative result.
>> +  // Overflow if inputs vary in sign and the output does not have the same 
>> sign as the first input.
>> +  //
>> +  if (((Minuend < 0) != (Subtrahend < 0)) &&
>> +  ((Minuend < 0) != (SignedResult < 0))) {
>> +*Result = INT64_ERROR;
>> +Status = RETURN_BUFFER_TOO_SMALL;
>> +  } else {
>> +*Result = SignedResult;
>> +Status = RETURN_SUCCESS;
>> +  }
>> +
>> +  return Status;
>> +}
> 
> Is our goal to
> 
> (a) catch overflows before the caller goes wrong due to them, or
> (b) completely prevent undefined behavior from happening, even inside
> SafeInt64Sub()?
> 
> The above implementation may be good for (a), but it's not correct for
> (b). The
> 
>   SignedResult = Minuend - Subtrahend;
> 
> subtraction invokes undefined behavior if the result cannot be
> represented [*]; the rest of the code cannot help.
> 
> Now if we say that such subtractions always occur according to the
> "usual two's complement definition", on all architectures that edk2
> targets, and we're sure that no compiler or analysis tool will flag --
> or exploit -- the UB either, then the code is fine; meaning our choice
> is (a).
> 
> But, if (b) is our goal, I would replace the current error condition with:
> 
>   (((Subtrahend > 0) && (Minuend < MIN_INT64 + Subtrahend)) ||
>((Subtrahend < 0) && (Minuend > MAX_INT64 + Subtrahend)))

To clarify, I wouldn't just replace the error condition. In addition to
that, I would remove the SignedResult helper variable (together with the
current subtraction), and calculate & assign

  *Result = Minuend - Subtrahend;

only after the error condition fails (i.e. the subtraction is safe).

Thanks,
Laszlo


> Justification:
> 
> * Subtrahend==0 can never cause overflow
> 
> * Subtrahend>0 can only cause overflow at the negative end, so check
>   that: (Minuend - Subtrahend < MIN_INT64), mathematically speaking.
>   In order to write that down in C, add Subtrahend (a positive value)
>   to both sides, yielding (Minuend < MIN_INT64 + Subtrahend). Here,
>   (MIN_INT64 + Subtrahend) will never go out of range, because
>   Subtrahend is positive, and (MIN_INT64 + MAX_INT64) is representable.
> 
> * Subtrahend<0 can only cause overflow at the positive end, so check
>   that: (Minuend - Subtrahend > MAX_INT64), mathematically speaking.
>   In order to write that down in C, add Subtrahend (a negative value)
>   to both sides, yielding (Minuend > MAX_INT64 + Subtrahend). Here,
>   (MAX_INT64 + Subtrahend) will never go out of range, because
>   Subtrahend is negative, and (MAX_INT64 + MIN_INT64) is representable.
> 
> (
> 
> [*] ISO C99 section 6.5 Expressions, p5: "If an exceptional condition
> occurs during the evaluation of an expression (that is, if the result is
> not mathematically defined or not in the range of representable values
> for its type), the behavior is undefined."
> 
> Section 6.2.5 Types, p9 only exempts unsigned integers, "A computation
> i

Re: [edk2] [Patch 05/10] OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Laszlo Ersek
On 02/08/18 00:48, Kinney, Michael D wrote:
> Laszlo,
> 
> The BmpSupportLib content was from contributions from 
> a capsule related branch.  However, the BmpSupportLib 
> can be used for UX capsules as well as other places that
> conversions between BMP and GOP BLT buffers are needed,
> so it is a more generic feature.  The SafeIntLib was also
> based on content from the same capsule related branch but
> also has uses other than capsules.
> 
> Yes.  I need to add Signed-off-by for Sean.

OK, with the S-o-b updated, for patches #5 and #10:

Reviewed-by: Laszlo Ersek 

Thank you,
Laszlo

> Thanks for the "xfuncname" tip.  I will add that to my
> notes for sending patch emails so it is always enabled.
> 
> Mike
> 
>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Wednesday, February 7, 2018 3:17 PM
>> To: Kinney, Michael D ; edk2-
>> de...@lists.01.org
>> Cc: Sean Brogan ; Yao, Jiewen
>> ; Justen, Jordan L
>> ; Ard Biesheuvel
>> 
>> Subject: Re: [Patch 05/10] OvmfPkg: Add SafeIntLib and
>> BmpSupportLib to DSC files
>>
>> Hi Mike,
>>
>> On 02/07/18 23:58, Kinney, Michael D wrote:
>>> From: Michael D Kinney 
>>>
>>> https://bugzilla.tianocore.org/show_bug.cgi?id=800
>>>
>>> Based on content from the following branch/commits:
>>>
>> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsule
>> Support
>>>
>> https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417
>> d7d5a7d356c15a14c2e60302b2d
>>>
>> https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315
>> c2d823f453e12d2135098f53d61
>>>
>> https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a
>> 4c2ef4c4e32379e111f016dbd9b
>>
>> These commits look capsule-related, but the paragraph
>> below speaks about
>> BootGraphicsResourceTableDxe and image format conversion.
>> Should the
>> references be updated?
>>
>> Also, if part of the code is from Sean, do we need an S-
>> o-b from him,
>> above yours?
>>
>> The DSC file changes look fine; I'm ready to R-b once the
>> above is
>> clarified.
>>
>> (For the future, please consider the "xfuncname" setting
>> from
>> > szlo's-unkempt-git-guide-for-edk2-contributors-and-
>> maintainers#contrib-05>,
>> together with
>> > szlo's-unkempt-git-guide-for-edk2-contributors-and-
>> maintainers#contrib-09>.
>>
>> Those settings help with the review of DSC and similar
>> files -- the @@
>> hunk headers in the patch will state the [LibraryClasses]
>> file section,
>> for example.)
>>
>> Thanks,
>> Laszlo
>>
>>> The BootGraphicsResourceTableDxe module uses the
>> BmpSupportLib
>>> and SafeIntLib to convert a GOP BLT buffer to a BMP
>> graphics image.
>>> Add library mappings for these new library classes.
>>>
>>> Cc: Sean Brogan 
>>> Cc: Jiewen Yao 
>>> Cc: Jordan Justen 
>>> Cc: Laszlo Ersek 
>>> Cc: Ard Biesheuvel 
>>> Contributed-under: TianoCore Contribution Agreement 1.1
>>> Signed-off-by: Michael D Kinney
>> 
>>> ---
>>>  OvmfPkg/OvmfPkgIa32.dsc| 2 ++
>>>  OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++
>>>  OvmfPkg/OvmfPkgX64.dsc | 2 ++
>>>  3 files changed, 6 insertions(+)
>>>
>>> diff --git a/OvmfPkg/OvmfPkgIa32.dsc
>> b/OvmfPkg/OvmfPkgIa32.dsc
>>> index d762955c5d..e10f898607 100644
>>> --- a/OvmfPkg/OvmfPkgIa32.dsc
>>> +++ b/OvmfPkg/OvmfPkgIa32.dsc
>>> @@ -104,6 +104,8 @@
>>>
>> PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
>>>
>> BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemo
>> ryLibRepStr.inf
>>>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
>>> +
>> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.i
>> nf
>>> +
>> BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/Base
>> BmpSupportLib.inf
>>>
>> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/
>> BaseSynchronizationLib.inf
>>>CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
>>>
>> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/Base
>> PerformanceLibNull.inf
>>> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc
>> b/OvmfPkg/OvmfPkgIa32X64.dsc
>>> index 6bcbe70d64..a31c7919ad 100644
>>> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
>>> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
>>> @@ -109,6 +109,8 @@
>>>
>> PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
>>>
>> BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemo
>> ryLibRepStr.inf
>>>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
>>> +
>> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.i
>> nf
>>> +
>> BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/Base
>> BmpSupportLib.inf
>>>
>> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/
>> BaseSynchronizationLib.inf
>>>CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
>>>
>> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/Base
>> PerformanceLibNull.inf
>>> diff --git a/OvmfPkg/OvmfPkgX64.dsc
>> b/OvmfPkg/OvmfPkgX64.dsc
>>> index 70fcdcba11..bc433a9724 100644
>>> --- a/OvmfPkg/OvmfPkgX64.dsc
>>> +++ b/OvmfPkg/OvmfPkgX64.dsc
>>> @@ -109,6 +109,8 @@
>>>
>> PrintLib|M

Re: [edk2] [Patch] MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance

2018-02-07 Thread Laszlo Ersek
On 12/19/17 20:36, Kinney, Michael D wrote:
> From: Sean Brogan 
> 
> SafeIntLib provides helper functions to prevent integer overflow
> during type conversion, addition, subtraction, and multiplication.

I clearly cannot review such a huge patch, but I've noticed something
and would like to ask for clarification:

> +/**
> +  INT64 Subtraction
> +
> +  Performs the requested operation using the input parameters into a value
> +  specified by Result type and stores the converted value into the caller
> +  allocated output buffer specified by Result.  The caller must pass in a
> +  Result buffer that is at least as large as the Result type.
> +
> +  If Result is NULL, RETURN_INVALID_PARAMETER is returned.
> +
> +  If the requested operation results in an overflow or an underflow 
> condition,
> +  then Result is set to INT64_ERROR and RETURN_BUFFER_TOO_SMALL is returned.
> +
> +  @param[in]   Minuend A number from which another is to be subtracted.
> +  @param[in]   Subtrahend  A number to be subtracted from another
> +  @param[out]  Result  Pointer to the result of subtraction
> +
> +  @retval  RETURN_SUCCESSSuccessful subtraction
> +  @retval  RETURN_BUFFER_TOO_SMALL   Underflow
> +  @retval  RETURN_INVALID_PARAMETER  Result is NULL
> +**/
> +RETURN_STATUS
> +EFIAPI
> +SafeInt64Sub (
> +  IN  INT64  Minuend,
> +  IN  INT64  Subtrahend,
> +  OUT INT64  *Result
> +  )
> +{
> +  RETURN_STATUS  Status;
> +  INT64  SignedResult;
> +
> +  if (Result == NULL) {
> +return RETURN_INVALID_PARAMETER;
> +  }
> +
> +  SignedResult = Minuend - Subtrahend;
> +
> +  //
> +  // Subtracting a positive number from a positive number never overflows.
> +  // Subtracting a negative number from a negative number never overflows.
> +  // If you subtract a negative number from a positive number, you expect a 
> positive result.
> +  // If you subtract a positive number from a negative number, you expect a 
> negative result.
> +  // Overflow if inputs vary in sign and the output does not have the same 
> sign as the first input.
> +  //
> +  if (((Minuend < 0) != (Subtrahend < 0)) &&
> +  ((Minuend < 0) != (SignedResult < 0))) {
> +*Result = INT64_ERROR;
> +Status = RETURN_BUFFER_TOO_SMALL;
> +  } else {
> +*Result = SignedResult;
> +Status = RETURN_SUCCESS;
> +  }
> +
> +  return Status;
> +}

Is our goal to

(a) catch overflows before the caller goes wrong due to them, or
(b) completely prevent undefined behavior from happening, even inside
SafeInt64Sub()?

The above implementation may be good for (a), but it's not correct for
(b). The

  SignedResult = Minuend - Subtrahend;

subtraction invokes undefined behavior if the result cannot be
represented [*]; the rest of the code cannot help.

Now if we say that such subtractions always occur according to the
"usual two's complement definition", on all architectures that edk2
targets, and we're sure that no compiler or analysis tool will flag --
or exploit -- the UB either, then the code is fine; meaning our choice
is (a).

But, if (b) is our goal, I would replace the current error condition with:

  (((Subtrahend > 0) && (Minuend < MIN_INT64 + Subtrahend)) ||
   ((Subtrahend < 0) && (Minuend > MAX_INT64 + Subtrahend)))

Justification:

* Subtrahend==0 can never cause overflow

* Subtrahend>0 can only cause overflow at the negative end, so check
  that: (Minuend - Subtrahend < MIN_INT64), mathematically speaking.
  In order to write that down in C, add Subtrahend (a positive value)
  to both sides, yielding (Minuend < MIN_INT64 + Subtrahend). Here,
  (MIN_INT64 + Subtrahend) will never go out of range, because
  Subtrahend is positive, and (MIN_INT64 + MAX_INT64) is representable.

* Subtrahend<0 can only cause overflow at the positive end, so check
  that: (Minuend - Subtrahend > MAX_INT64), mathematically speaking.
  In order to write that down in C, add Subtrahend (a negative value)
  to both sides, yielding (Minuend > MAX_INT64 + Subtrahend). Here,
  (MAX_INT64 + Subtrahend) will never go out of range, because
  Subtrahend is negative, and (MAX_INT64 + MIN_INT64) is representable.

(

[*] ISO C99 section 6.5 Expressions, p5: "If an exceptional condition
occurs during the evaluation of an expression (that is, if the result is
not mathematically defined or not in the range of representable values
for its type), the behavior is undefined."

Section 6.2.5 Types, p9 only exempts unsigned integers, "A computation
involving unsigned operands can never overflow, because a result that
cannot be represented by the resulting unsigned integer type is reduced
modulo the number that is one greater than the largest value that can be
represented by the resulting type."

Note that this is different from conversion, where the computation first
succeeds (= we have a value), and then the value is converted to a type
that causes truncation: section 6.3.1.3 Signed and unsigned integers,
p3: "Otherwise, the new type is signed and the value cannot be

Re: [edk2] [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP

2018-02-07 Thread Yao, Jiewen
Reviewed-by: jiewen@intel.com

> -Original Message-
> From: Kinney, Michael D
> Sent: Thursday, February 8, 2018 2:50 AM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen ; Zeng, Star ;
> Dong, Eric ; Kinney, Michael D
> 
> Subject: [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with
> FMP
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=873
> 
> Update IsNestedFmpCapsule() to verify the CapsuleGuid in
> the CapsuleHeader against the installed Firmware Management
> Protocol instances.  The current logic that uses the ESRT
> Table does not work because capsules are processed before
> the ESRT Table is published at the Ready To Boot event.
> 
> Cc: Jiewen Yao 
> Cc: Star Zeng 
> Cc: Eric Dong 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney 
> ---
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c   | 27
> --
>  .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf |  3 +--
>  2 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> index 2f397789b5..87e1deec03 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
> @@ -10,7 +10,7 @@
>ValidateFmpCapsule(), DisplayCapsuleImage(), ConvertBmpToGopBlt() will
>receive untrusted input and do basic validation.
> 
> -  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
> +  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
>This program and the accompanying materials
>are licensed and made available under the terms and conditions of the BSD
> License
>which accompanies this distribution.  The full text of the license may be
> found at
> @@ -1446,7 +1446,6 @@ IsNestedFmpCapsule (
>)
>  {
>EFI_STATUS Status;
> -  EFI_SYSTEM_RESOURCE_TABLE  *Esrt;
>EFI_SYSTEM_RESOURCE_ENTRY  *EsrtEntry;
>UINTN  Index;
>BOOLEANEsrtGuidFound;
> @@ -1454,6 +1453,8 @@ IsNestedFmpCapsule (
>UINTN  NestedCapsuleSize;
>ESRT_MANAGEMENT_PROTOCOL   *EsrtProtocol;
>EFI_SYSTEM_RESOURCE_ENTRY  Entry;
> +  EFI_HANDLE *HandleBuffer;
> +  UINTN  NumberOfHandles;
> 
>EsrtGuidFound = FALSE;
>if (mIsVirtualAddrConverted) {
> @@ -1479,19 +1480,21 @@ IsNestedFmpCapsule (
>  }
> 
>  //
> -// Check ESRT configuration table
> +// Check Firmware Management Protocols
>  //
>  if (!EsrtGuidFound) {
> -  Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid,
> (VOID **)&Esrt);
> +  HandleBuffer = NULL;
> +  Status = GetFmpHandleBufferByType (
> + &CapsuleHeader->CapsuleGuid,
> + 0,
> + &NumberOfHandles,
> + &HandleBuffer
> + );
>if (!EFI_ERROR(Status)) {
> -ASSERT (Esrt != NULL);
> -EsrtEntry = (VOID *)(Esrt + 1);
> -for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++)
> {
> -  if (CompareGuid(&EsrtEntry->FwClass,
> &CapsuleHeader->CapsuleGuid)) {
> -EsrtGuidFound = TRUE;
> -break;
> -  }
> -}
> +EsrtGuidFound = TRUE;
> +  }
> +  if (HandleBuffer != NULL) {
> +FreePool (HandleBuffer);
>}
>  }
>}
> diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> index a7c36993c4..90edc52ee0 100644
> --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
> @@ -3,7 +3,7 @@
>  #
>  #  Capsule library instance for DXE_DRIVER module types.
>  #
> -#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD
> License
>  #  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -72,7 +72,6 @@
>  [Guids]
>gEfiFmpCapsuleGuid  ## SOMETIMES_CONSUMES
> ## GUID
>gWindowsUxCapsuleGuid   ## SOMETIMES_CONSUMES
> ## GUID
> -  gEfiSystemResourceTableGuid ## SOMETIMES_CONSUMES ##
> GUID
>## SOMETIMES_CONSUMES ## Variable:L"CapsuleMax"
>## SOMETIMES_PRODUCES ## Variable:L"CapsuleMax"
>gEfiCapsuleReportGuid
> --
> 2.14.2.windows.3

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


Re: [edk2] [Patch 05/10] OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Kinney, Michael D
Laszlo,

The BmpSupportLib content was from contributions from 
a capsule related branch.  However, the BmpSupportLib 
can be used for UX capsules as well as other places that
conversions between BMP and GOP BLT buffers are needed,
so it is a more generic feature.  The SafeIntLib was also
based on content from the same capsule related branch but
also has uses other than capsules.

Yes.  I need to add Signed-off-by for Sean.

Thanks for the "xfuncname" tip.  I will add that to my
notes for sending patch emails so it is always enabled.

Mike

> -Original Message-
> From: Laszlo Ersek [mailto:ler...@redhat.com]
> Sent: Wednesday, February 7, 2018 3:17 PM
> To: Kinney, Michael D ; edk2-
> de...@lists.01.org
> Cc: Sean Brogan ; Yao, Jiewen
> ; Justen, Jordan L
> ; Ard Biesheuvel
> 
> Subject: Re: [Patch 05/10] OvmfPkg: Add SafeIntLib and
> BmpSupportLib to DSC files
> 
> Hi Mike,
> 
> On 02/07/18 23:58, Kinney, Michael D wrote:
> > From: Michael D Kinney 
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=800
> >
> > Based on content from the following branch/commits:
> >
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsule
> Support
> >
> https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417
> d7d5a7d356c15a14c2e60302b2d
> >
> https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315
> c2d823f453e12d2135098f53d61
> >
> https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a
> 4c2ef4c4e32379e111f016dbd9b
> 
> These commits look capsule-related, but the paragraph
> below speaks about
> BootGraphicsResourceTableDxe and image format conversion.
> Should the
> references be updated?
> 
> Also, if part of the code is from Sean, do we need an S-
> o-b from him,
> above yours?
> 
> The DSC file changes look fine; I'm ready to R-b once the
> above is
> clarified.
> 
> (For the future, please consider the "xfuncname" setting
> from
>  szlo's-unkempt-git-guide-for-edk2-contributors-and-
> maintainers#contrib-05>,
> together with
>  szlo's-unkempt-git-guide-for-edk2-contributors-and-
> maintainers#contrib-09>.
> 
> Those settings help with the review of DSC and similar
> files -- the @@
> hunk headers in the patch will state the [LibraryClasses]
> file section,
> for example.)
> 
> Thanks,
> Laszlo
> 
> > The BootGraphicsResourceTableDxe module uses the
> BmpSupportLib
> > and SafeIntLib to convert a GOP BLT buffer to a BMP
> graphics image.
> > Add library mappings for these new library classes.
> >
> > Cc: Sean Brogan 
> > Cc: Jiewen Yao 
> > Cc: Jordan Justen 
> > Cc: Laszlo Ersek 
> > Cc: Ard Biesheuvel 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Michael D Kinney
> 
> > ---
> >  OvmfPkg/OvmfPkgIa32.dsc| 2 ++
> >  OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++
> >  OvmfPkg/OvmfPkgX64.dsc | 2 ++
> >  3 files changed, 6 insertions(+)
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc
> b/OvmfPkg/OvmfPkgIa32.dsc
> > index d762955c5d..e10f898607 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -104,6 +104,8 @@
> >
> PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> >
> BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemo
> ryLibRepStr.inf
> >BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> > +
> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.i
> nf
> > +
> BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/Base
> BmpSupportLib.inf
> >
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/
> BaseSynchronizationLib.inf
> >CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> >
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/Base
> PerformanceLibNull.inf
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc
> b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index 6bcbe70d64..a31c7919ad 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -109,6 +109,8 @@
> >
> PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> >
> BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemo
> ryLibRepStr.inf
> >BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> > +
> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.i
> nf
> > +
> BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/Base
> BmpSupportLib.inf
> >
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/
> BaseSynchronizationLib.inf
> >CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> >
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/Base
> PerformanceLibNull.inf
> > diff --git a/OvmfPkg/OvmfPkgX64.dsc
> b/OvmfPkg/OvmfPkgX64.dsc
> > index 70fcdcba11..bc433a9724 100644
> > --- a/OvmfPkg/OvmfPkgX64.dsc
> > +++ b/OvmfPkg/OvmfPkgX64.dsc
> > @@ -109,6 +109,8 @@
> >
> PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> >
> BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemo
> ryLibRepStr.inf
> >BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> > +
> SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.i
> nf
> > +

Re: [edk2] [Patch 10/10] ArmVirtPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Laszlo Ersek
On 02/07/18 23:58, Kinney, Michael D wrote:
> From: Michael D Kinney 
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=800
> 
> Based on content from the following branch/commits:
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
> https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
> https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
> https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b
> 
> The BootGraphicsResourceTableDxe module uses the BmpSupportLib
> and SafeIntLib to convert a GOP BLT buffer to a BMP graphics image.
> Add library mappings for these new library classes.
> 
> Cc: Sean Brogan 
> Cc: Jiewen Yao 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney 
> ---
>  ArmVirtPkg/ArmVirt.dsc.inc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
> index 5144bb10df..0cb48f08e9 100644
> --- a/ArmVirtPkg/ArmVirt.dsc.inc
> +++ b/ArmVirtPkg/ArmVirt.dsc.inc
> @@ -1,7 +1,7 @@
>  #
>  #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
>  #  Copyright (c) 2014, Linaro Limited. All rights reserved.
> -#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
>  #
>  #  This program and the accompanying materials
>  #  are licensed and made available under the terms and conditions of the BSD 
> License
> @@ -34,6 +34,8 @@
>
> DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
>  
>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> +  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> +  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
>
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
>
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
>PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
> 

I have similar comments to those I made on patch #5.

(BootGraphicsResourceTableDxe is not included in the Xen builds, only in
the QEMU builds, but adding the library resolutions to the central DSC
include file under ArmVirtPkg is good, IMO.)

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


Re: [edk2] [Patch 05/10] OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Laszlo Ersek
Hi Mike,

On 02/07/18 23:58, Kinney, Michael D wrote:
> From: Michael D Kinney 
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=800
> 
> Based on content from the following branch/commits:
> https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
> https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
> https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
> https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

These commits look capsule-related, but the paragraph below speaks about
BootGraphicsResourceTableDxe and image format conversion. Should the
references be updated?

Also, if part of the code is from Sean, do we need an S-o-b from him,
above yours?

The DSC file changes look fine; I'm ready to R-b once the above is
clarified.

(For the future, please consider the "xfuncname" setting from
,
together with
.

Those settings help with the review of DSC and similar files -- the @@
hunk headers in the patch will state the [LibraryClasses] file section,
for example.)

Thanks,
Laszlo

> The BootGraphicsResourceTableDxe module uses the BmpSupportLib
> and SafeIntLib to convert a GOP BLT buffer to a BMP graphics image.
> Add library mappings for these new library classes.
> 
> Cc: Sean Brogan 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Michael D Kinney 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 2 ++
>  OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++
>  OvmfPkg/OvmfPkgX64.dsc | 2 ++
>  3 files changed, 6 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index d762955c5d..e10f898607 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -104,6 +104,8 @@
>PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
>BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> +  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> +  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
>
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
>CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
>
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 6bcbe70d64..a31c7919ad 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -109,6 +109,8 @@
>PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
>BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> +  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> +  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
>
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
>CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
>
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 70fcdcba11..bc433a9724 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -109,6 +109,8 @@
>PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
>BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
>BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> +  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> +  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
>
> SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
>CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
>
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
> 

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


[edk2] [Patch 08/10] DuetPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Add BmpSupportLib and SafeIntLib mappings that are required
by GenericBdsLib.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Ruiyu Ni 
Cc: Hao Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 DuetPkg/DuetPkgIa32.dsc | 4 +++-
 DuetPkg/DuetPkgX64.dsc  | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/DuetPkg/DuetPkgIa32.dsc b/DuetPkg/DuetPkgIa32.dsc
index ca3fbc2662..06cc61deb6 100644
--- a/DuetPkg/DuetPkgIa32.dsc
+++ b/DuetPkg/DuetPkgIa32.dsc
@@ -4,7 +4,7 @@
 #  Developer's UEFI Emulation. DUET provides an EFI/UEFI IA32/X64 environment 
on legacy BIOS,
 #  to help developing and debugging native EFI/UEFI drivers.
 #
-#  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -87,6 +87,8 @@
   UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
diff --git a/DuetPkg/DuetPkgX64.dsc b/DuetPkg/DuetPkgX64.dsc
index c41b9fbe8d..ee97dc2da2 100644
--- a/DuetPkg/DuetPkgX64.dsc
+++ b/DuetPkg/DuetPkgX64.dsc
@@ -4,7 +4,7 @@
 #  Developer's UEFI Emulation. DUET provides an EFI/UEFI IA32/X64 environment 
on legacy BIOS,
 #  to help developing and debugging native EFI/UEFI drivers.
 #
-#  Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -87,6 +87,8 @@
   UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
-- 
2.14.2.windows.3

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


[edk2] [Patch 06/10] Vlv2TbltDevicePkg/Override/GenericBdsLib: Use BmpSupportLib

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Update GenericBdsLib to use BmpSupportLib to convert a BMP
graphics image to a GOP BLT buffer to display the boot logo.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: David Wei 
Cc: Mang Guo 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../Library/GenericBdsLib/BdsConsole.c | 251 +
 .../Library/GenericBdsLib/GenericBdsLib.inf|   3 +-
 .../Library/GenericBdsLib/InternalBdsLib.h |   3 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|   4 +-
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |   4 +-
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |   4 +-
 6 files changed, 16 insertions(+), 253 deletions(-)

diff --git 
a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
 
b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
index eefec0642a..9c21cfcd59 100644
--- 
a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
+++ 
b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
@@ -1,7 +1,7 @@
 /** @file
   BDS Lib functions which contain all the code to connect console device
 
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 #include "InternalBdsLib.h"
-#include 
 
 
 /**
@@ -642,250 +641,6 @@ BdsLibConnectAllDefaultConsolesWithOutConIn (
 
 }
 
-/**
-  Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
-  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
-  buffer is passed in it will be used if it is big enough.
-
-  @param  BmpImage  Pointer to BMP file
-  @param  BmpImageSize  Number of bytes in BmpImage
-  @param  GopBltBuffer containing GOP version of BmpImage.
-  @param  GopBltSizeSize of GopBlt in bytes.
-  @param  PixelHeight   Height of GopBlt/BmpImage in pixels
-  @param  PixelWidthWidth of GopBlt/BmpImage in pixels
-
-  @retval EFI_SUCCESS   GopBlt and GopBltSize are returned.
-  @retval EFI_UNSUPPORTED   BmpImage is not a valid *.BMP image
-  @retval EFI_BUFFER_TOO_SMALL  The passed in GopBlt buffer is not big enough.
-GopBltSize will contain the required size.
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.
-
-**/
-EFI_STATUS
-ConvertBmpToGopBlt (
-  IN VOID  *BmpImage,
-  IN UINTN BmpImageSize,
-  IN OUT VOID  **GopBlt,
-  IN OUT UINTN *GopBltSize,
- OUT UINTN *PixelHeight,
- OUT UINTN *PixelWidth
-  )
-{
-  UINT8 *Image;
-  UINT8 *ImageHeader;
-  BMP_IMAGE_HEADER  *BmpHeader;
-  BMP_COLOR_MAP *BmpColorMap;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
-  UINT64BltBufferSize;
-  UINTN Index;
-  UINTN Height;
-  UINTN Width;
-  UINTN ImageIndex;
-  UINT32DataSizePerLine;
-  BOOLEAN   IsAllocated;
-  UINT32ColorMapNum;
-
-  if (sizeof (BMP_IMAGE_HEADER) > BmpImageSize) {
-return EFI_INVALID_PARAMETER;
-  }
-
-  BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
-
-  if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Doesn't support compress.
-  //
-  if (BmpHeader->CompressionType != 0) {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Only support BITMAPINFOHEADER format.
-  // BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER
-  //
-  if (BmpHeader->HeaderSize != sizeof (BMP_IMAGE_HEADER) - 
OFFSET_OF(BMP_IMAGE_HEADER, HeaderSize)) {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // The data size in each line must be 4 byte alignment.
-  //
-  DataSizePerLine = ((BmpHeader->PixelWidth * BmpHeader->BitPerPixel + 31) >> 
3) & (~0x3);
-  BltBufferSize = MultU64x32 (DataSizePerLine, BmpHeader->PixelHeight);
-  if (BltBufferSize > (UINT32) ~0) {
-return EFI_INVALID_PARAMETER;
-  }
-
-  if ((BmpHeader->Size 

[edk2] [Patch 09/10] EmulatorPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Add BmpSupportLib and SafeIntLib mappings that are required
by GenericBdsLib.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Andrew Fish 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 EmulatorPkg/EmulatorPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 818691ce3a..1c274cb723 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -83,6 +83,8 @@
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
-- 
2.14.2.windows.3

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


[edk2] [Patch 10/10] ArmVirtPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

The BootGraphicsResourceTableDxe module uses the BmpSupportLib
and SafeIntLib to convert a GOP BLT buffer to a BMP graphics image.
Add library mappings for these new library classes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 5144bb10df..0cb48f08e9 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -1,7 +1,7 @@
 #
 #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
@@ -34,6 +34,8 @@
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
 
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
-- 
2.14.2.windows.3

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


[edk2] [Patch 07/10] QuarkPlatformPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Add BmpSupportLib and SafeIntLib mappings that are required
by the DxeCapsuleLib when CAPSULE_ENABLE is set.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Kelly Steele 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 QuarkPlatformPkg/Quark.dsc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
index 5624451e12..7365a3a1bf 100644
--- a/QuarkPlatformPkg/Quark.dsc
+++ b/QuarkPlatformPkg/Quark.dsc
@@ -2,7 +2,7 @@
 # Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
 #
 # This package provides Clanton Peak CRB platform specific modules.
-# Copyright (c) 2013 - 2017 Intel Corporation.
+# Copyright (c) 2013 - 2018 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -231,6 +231,8 @@
 
 !if $(CAPSULE_ENABLE)
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
 !else
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
 !endif
-- 
2.14.2.windows.3

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


[edk2] [Patch 03/10] MdeModulePkg/BootGraphicsResourceTableDxe: Use BmpSupportLib

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Use BmpSupportLib to convert a GOP BLT Buffer to the BMP graphics
image that is published in an ACPI BGRT table.

* Remove use of IndustryStandard/Bmp.h include file
* Remove mBmpImageHeaderTemplate.  This is handled by BmpSupportLib
* Clean up code style with function prototypes at top
  and all module global variables together
* Update SetBootLogo() to use SafeIntLib to check input parameters
  for overflows.
* Remove internal function BgrtAcpiTableChecksum().  Use
  CalculateCheckSum8() directly from BgrtReadyToBootEventNotify()
* Remove InstallBootGraphicsResourceTable().  Move all the code into
  BgrtReadyToBootEventNotify() that is signaled at ready to boot.
* Remove all logic that converts a GOP BLT buffer to a BMP graphics image
  and use BmpSupportLib function TranslateGopBltToBmp() instead.
* Use AllocatePool() instead of AllocatePages() to allocate copy of
  BMP image that is provided by BGRT.  This is required to be compatible
  with BmpSupportLib function TranslateGopBltToBmp() that uses
  AllocatePool().
* Zero OemId in BGRT header before filling in value from PCD.
* Get size of PcdAcpiDefaultOemId and only copy the the size of the PCD
  if it is smaller than the size of the OemId field in the BGRT header.
* Use WriteUnaligned24() instead of CopyMem() for the OemTableId field
  of the BGRT header.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../BootGraphicsResourceTableDxe.c | 425 ++---
 .../BootGraphicsResourceTableDxe.inf   |   4 +-
 2 files changed, 197 insertions(+), 232 deletions(-)

diff --git 
a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
 
b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
index 6a7165a954..118fb4a922 100644
--- 
a/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
+++ 
b/MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.c
@@ -1,7 +1,7 @@
 /** @file
   This module install ACPI Boot Graphics Resource Table (BGRT).
 
-  Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.
+  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -14,7 +14,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 #include 
@@ -28,44 +27,65 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
+/**
+  Update information of logo image drawn on screen.
+
+  @param  This   The pointer to the Boot Logo protocol instance.
+  @param  BltBuffer  The BLT buffer for logo drawn on screen. If BltBuffer
+ is set to NULL, it indicates that logo image is no
+ longer on the screen.
+  @param  DestinationX   X coordinate of destination for the BltBuffer.
+  @param  DestinationY   Y coordinate of destination for the BltBuffer.
+  @param  Width  Width of rectangle in BltBuffer in pixels.
+  @param  Height Hight of rectangle in BltBuffer in pixels.
+
+  @retval EFI_SUCCESS The boot logo information was updated.
+  @retval EFI_INVALID_PARAMETER   One of the parameters has an invalid value.
+  @retval EFI_OUT_OF_RESOURCESThe logo information was not updated due to
+  insufficient memory resources.
+
+**/
+EFI_STATUS
+EFIAPI
+SetBootLogo (
+  IN EFI_BOOT_LOGO_PROTOCOL *This,
+  IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *BltBuffer   OPTIONAL,
+  IN UINTN  DestinationX,
+  IN UINTN  DestinationY,
+  IN UINTN  Width,
+  IN UINTN  Height
+  );
+
+//
+// Boot Logo Protocol Handle
 //
-// Module globals.
+EFI_HANDLE  mBootLogoHandle = NULL;
+
+//
+// Boot Logo Protocol Instance
 //
-EFI_EVENT  mBootGraphicsReadyToBootEvent;
-UINTN  mBootGraphicsResourceTableKey = 0;
+EFI_BOOT_LOGO_PROTOCOL  mBootLogoProtocolTemplate = {
+  SetBootLogo
+};
 
-EFI_HANDLE mBootLogoHandle = NULL;
+EFI_EVENT  mBootGraphicsReadyToBootEvent;
+UINTN  mBootGraphicsResourceTableKey = 0;
 BOOLEANmIsLogoValid = FALSE;
 EFI_GR

[edk2] [Patch 05/10] OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

The BootGraphicsResourceTableDxe module uses the BmpSupportLib
and SafeIntLib to convert a GOP BLT buffer to a BMP graphics image.
Add library mappings for these new library classes.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 OvmfPkg/OvmfPkgIa32.dsc| 2 ++
 OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++
 OvmfPkg/OvmfPkgX64.dsc | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index d762955c5d..e10f898607 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -104,6 +104,8 @@
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 6bcbe70d64..a31c7919ad 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -109,6 +109,8 @@
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 70fcdcba11..bc433a9724 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -109,6 +109,8 @@
   PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
   BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
   BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
-- 
2.14.2.windows.3

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


[edk2] [Patch 04/10] IntelFrameworkModulePkg/GenericBdsLib: Use BmpSupportLib

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Update GenericBdsLib to use BmpSupportLib to convert a BMP
graphics image to a GOP BLT Buffer to display the boot logo.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../IntelFrameworkModulePkg.dsc|   4 +-
 .../Library/GenericBdsLib/BdsConsole.c | 250 +
 .../Library/GenericBdsLib/GenericBdsLib.inf|   3 +-
 .../Library/GenericBdsLib/InternalBdsLib.h |   3 +-
 4 files changed, 10 insertions(+), 250 deletions(-)

diff --git a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc 
b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
index a9a01aa647..6c6c3d802a 100644
--- a/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
+++ b/IntelFrameworkModulePkg/IntelFrameworkModulePkg.dsc
@@ -3,7 +3,7 @@
 #
 # This file is used to build all modules in IntelFrameworkModulePkg.
 #
-#Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+#Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
 #This program and the accompanying materials are licensed and made available 
under 
 #the terms and conditions of the BSD License that accompanies this 
distribution.  
 #The full text of the license may be found at
@@ -54,6 +54,8 @@
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
   DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+  BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
   
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
   
PlatformBdsLib|IntelFrameworkModulePkg/Library/PlatformBdsLibNull/PlatformBdsLibNull.inf
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c 
b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
index 8f273ff1b1..9c21cfcd59 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c
@@ -1,7 +1,7 @@
 /** @file
   BDS Lib functions which contain all the code to connect console device
 
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD 
License
 which accompanies this distribution.  The full text of the license may be 
found at
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 **/
 
 #include "InternalBdsLib.h"
-#include 
 
 
 /**
@@ -642,249 +641,6 @@ BdsLibConnectAllDefaultConsolesWithOutConIn (
 
 }
 
-/**
-  Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
-  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
-  buffer is passed in it will be used if it is big enough.
-
-  @param  BmpImage  Pointer to BMP file
-  @param  BmpImageSize  Number of bytes in BmpImage
-  @param  GopBltBuffer containing GOP version of BmpImage.
-  @param  GopBltSizeSize of GopBlt in bytes.
-  @param  PixelHeight   Height of GopBlt/BmpImage in pixels
-  @param  PixelWidthWidth of GopBlt/BmpImage in pixels
-
-  @retval EFI_SUCCESS   GopBlt and GopBltSize are returned.
-  @retval EFI_UNSUPPORTED   BmpImage is not a valid *.BMP image
-  @retval EFI_BUFFER_TOO_SMALL  The passed in GopBlt buffer is not big enough.
-GopBltSize will contain the required size.
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.
-
-**/
-EFI_STATUS
-ConvertBmpToGopBlt (
-  IN VOID  *BmpImage,
-  IN UINTN BmpImageSize,
-  IN OUT VOID  **GopBlt,
-  IN OUT UINTN *GopBltSize,
- OUT UINTN *PixelHeight,
- OUT UINTN *PixelWidth
-  )
-{
-  UINT8 *Image;
-  UINT8 *ImageHeader;
-  BMP_IMAGE_HEADER  *BmpHeader;
-  BMP_COLOR_MAP *BmpColorMap;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
-  UINT64BltBufferSize;
-  UINTN Index;
-  UINTN Height;
-  UINTN Width;
-  UINTN ImageIndex;
-

[edk2] [Patch 02/10] MdeModulePkg/DxeCapsuleLibFmp: Use BmpSupportLib

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Use BmpSupportLib to convert a BMP graphics image to a
GOP BLT buffer.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c   | 268 +
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf |   3 +-
 .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf  |   3 +-
 MdeModulePkg/MdeModulePkg.dsc  |   2 +
 4 files changed, 12 insertions(+), 264 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c 
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 2f397789b5..56c8e98b84 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -7,10 +7,10 @@
   buffer overflow, integer overflow.
 
   SupportCapsuleImage(), ProcessCapsuleImage(), IsValidCapsuleHeader(),
-  ValidateFmpCapsule(), DisplayCapsuleImage(), ConvertBmpToGopBlt() will
-  receive untrusted input and do basic validation.
+  ValidateFmpCapsule(), and DisplayCapsuleImage() receives untrusted input and
+  performs basic validation.
 
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -23,7 +23,6 @@
 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -41,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -306,262 +306,6 @@ ValidateFmpCapsule (
   return EFI_SUCCESS;
 }
 
-/**
-  Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
-  is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
-  buffer is passed in it will be used if it is big enough.
-
-  Caution: This function may receive untrusted input.
-
-  @param[in]   BmpImage  Pointer to BMP file
-  @param[in]   BmpImageSize  Number of bytes in BmpImage
-  @param[in, out]  GopBltBuffer containing GOP version of BmpImage.
-  @param[in, out]  GopBltSizeSize of GopBlt in bytes.
-  @param[out]  PixelHeight   Height of GopBlt/BmpImage in pixels
-  @param[out]  PixelWidthWidth of GopBlt/BmpImage in pixels
-
-  @retval EFI_SUCCESS   GopBlt and GopBltSize are returned.
-  @retval EFI_UNSUPPORTED   BmpImage is not a valid *.BMP image
-  @retval EFI_BUFFER_TOO_SMALL  The passed in GopBlt buffer is not big enough.
-GopBltSize will contain the required size.
-  @retval EFI_OUT_OF_RESOURCES  No enough buffer to allocate.
-
-**/
-STATIC
-EFI_STATUS
-ConvertBmpToGopBlt (
-  IN VOID  *BmpImage,
-  IN UINTN BmpImageSize,
-  IN OUT VOID  **GopBlt,
-  IN OUT UINTN *GopBltSize,
- OUT UINTN *PixelHeight,
- OUT UINTN *PixelWidth
-  )
-{
-  UINT8 *Image;
-  UINT8 *ImageHeader;
-  BMP_IMAGE_HEADER  *BmpHeader;
-  BMP_COLOR_MAP *BmpColorMap;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
-  EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
-  UINT64BltBufferSize;
-  UINTN Index;
-  UINTN Height;
-  UINTN Width;
-  UINTN ImageIndex;
-  UINT32DataSizePerLine;
-  BOOLEAN   IsAllocated;
-  UINT32ColorMapNum;
-
-  if (sizeof (BMP_IMAGE_HEADER) > BmpImageSize) {
-return EFI_INVALID_PARAMETER;
-  }
-
-  BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
-
-  if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Doesn't support compress.
-  //
-  if (BmpHeader->CompressionType != 0) {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // Only support BITMAPINFOHEADER format.
-  // BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER
-  //
-  if (BmpHeader->HeaderSize != sizeof (BMP_IMAGE_HEADER) - 
OFFSET_OF(BMP_IMAGE_HEADER, HeaderSize)) {
-return EFI_UNSUPPORTED;
-  }
-
-  //
-  // The data size in each line must be 4 byte alignment.
-  //
-  DataSizePerLine = ((BmpHeader->PixelWidth * BmpHeader->BitPerPixel + 31) >> 
3) & (~0x3);
-  BltBufferSize = MultU64x32 (DataSizePerLine, BmpHeader->PixelHeight);
-

[edk2] [Patch 00/10] Add BmpSupportLib class and instance

2018-02-07 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=800

Branch for review:
https://github.com/mdkinney/edk2/commits/Bug_800_BmpSupportLib_V2

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Add BmpSupportLib class and instances that provides services to
convert a BMP graphics image to a GOP BLT buffer and to convert
a GOP BLT buffer to a BMP graphics image.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Cc: David Wei 
Cc: Mang Guo 
Cc: Kelly Steele 
Cc: Hao Wu 
Cc: Andrew Fish 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 

Kinney, Michael D (1):
  MdeModulePkg: Add BmpSupportLib class and instance

Michael D Kinney (9):
  MdeModulePkg/DxeCapsuleLibFmp: Use BmpSupportLib
  MdeModulePkg/BootGraphicsResourceTableDxe: Use BmpSupportLib
  IntelFrameworkModulePkg/GenericBdsLib: Use BmpSupportLib
  OvmfPkg: Add SafeIntLib and BmpSupportLib to DSC files
  Vlv2TbltDevicePkg/Override/GenericBdsLib: Use BmpSupportLib
  QuarkPlatformPkg: Add SafeIntLib and BmpSupportLib to DSC files
  DuetPkg: Add SafeIntLib and BmpSupportLib to DSC files
  EmulatorPkg: Add SafeIntLib and BmpSupportLib to DSC files
  ArmVirtPkg: Add SafeIntLib and BmpSupportLib to DSC files

 ArmVirtPkg/ArmVirt.dsc.inc |   4 +-
 DuetPkg/DuetPkgIa32.dsc|   4 +-
 DuetPkg/DuetPkgX64.dsc |   4 +-
 EmulatorPkg/EmulatorPkg.dsc|   2 +
 .../IntelFrameworkModulePkg.dsc|   4 +-
 .../Library/GenericBdsLib/BdsConsole.c | 250 +
 .../Library/GenericBdsLib/GenericBdsLib.inf|   3 +-
 .../Library/GenericBdsLib/InternalBdsLib.h |   3 +-
 MdeModulePkg/Include/Library/BmpSupportLib.h   | 105 
 .../BaseBmpSupportLib/BaseBmpSupportLib.inf|  49 ++
 .../BaseBmpSupportLib/BaseBmpSupportLib.uni|  20 +
 .../Library/BaseBmpSupportLib/BmpSupportLib.c  | 583 +
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c   | 268 +-
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf |   3 +-
 .../DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf  |   3 +-
 MdeModulePkg/MdeModulePkg.dec  |   6 +-
 MdeModulePkg/MdeModulePkg.dsc  |   3 +
 .../BootGraphicsResourceTableDxe.c | 425 +++
 .../BootGraphicsResourceTableDxe.inf   |   4 +-
 OvmfPkg/OvmfPkgIa32.dsc|   2 +
 OvmfPkg/OvmfPkgIa32X64.dsc |   2 +
 OvmfPkg/OvmfPkgX64.dsc |   2 +
 QuarkPlatformPkg/Quark.dsc |   4 +-
 .../Library/GenericBdsLib/BdsConsole.c | 251 +
 .../Library/GenericBdsLib/GenericBdsLib.inf|   3 +-
 .../Library/GenericBdsLib/InternalBdsLib.h |   3 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|   4 +-
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |   4 +-
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |   4 +-
 29 files changed, 1018 insertions(+), 1004 deletions(-)
 create mode 100644 MdeModulePkg/Include/Library/BmpSupportLib.h
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.uni
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c

-- 
2.14.2.windows.3

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


[edk2] [Patch 01/10] MdeModulePkg: Add BmpSupportLib class and instance

2018-02-07 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=800

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport
https://github.com/Microsoft/MS_UEFI/commit/33bab4031a417d7d5a7d356c15a14c2e60302b2d
https://github.com/Microsoft/MS_UEFI/commit/ca516b1a61315c2d823f453e12d2135098f53d61
https://github.com/Microsoft/MS_UEFI/commit/2b9f111f2e74a4c2ef4c4e32379e111f016dbd9b

Add BmpSupportLib class and instances that provides services to
convert a BMP graphics image to a GOP BLT buffer and to convert
a GOP BLT buffer to a BMP graphics image.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Include/Library/BmpSupportLib.h   | 105 
 .../BaseBmpSupportLib/BaseBmpSupportLib.inf|  49 ++
 .../BaseBmpSupportLib/BaseBmpSupportLib.uni|  20 +
 .../Library/BaseBmpSupportLib/BmpSupportLib.c  | 583 +
 MdeModulePkg/MdeModulePkg.dec  |   6 +-
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 6 files changed, 763 insertions(+), 1 deletion(-)
 create mode 100644 MdeModulePkg/Include/Library/BmpSupportLib.h
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.uni
 create mode 100644 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c

diff --git a/MdeModulePkg/Include/Library/BmpSupportLib.h 
b/MdeModulePkg/Include/Library/BmpSupportLib.h
new file mode 100644
index 00..3406aa3fca
--- /dev/null
+++ b/MdeModulePkg/Include/Library/BmpSupportLib.h
@@ -0,0 +1,105 @@
+/** @file
+
+Provides services to convert a BMP graphics image to a GOP BLT buffer.
+
+Copyright (c) 2016, Microsoft Corporation
+Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#ifndef __BMP_SUPPORT_LIB_H__
+#define __BMP_SUPPORT_LIB_H__
+
+#include 
+
+/**
+  Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
+  is passed in a GopBlt buffer will be allocated by this routine using
+  EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it will be
+  used if it is big enough.
+
+  @param [in]  BmpImage  Pointer to BMP file.
+  @param [in]  BmpImageSize  Number of bytes in BmpImage.
+  @param [in, out] GopBltBuffer containing GOP version of BmpImage.
+  @param [in, out] GopBltSizeSize of GopBlt in bytes.
+  @param [out] PixelHeight   Height of GopBlt/BmpImage in pixels.
+  @param [out] PixelWidthWidth of GopBlt/BmpImage in pixels.
+
+  @retval RETURN_SUCCESSGopBlt and GopBltSize are returned.
+  @retval RETURN_INVALID_PARAMETER  BmpImage is NULL.
+  @retval RETURN_INVALID_PARAMETER  GopBlt is NULL.
+  @retval RETURN_INVALID_PARAMETER  GopBltSize is NULL.
+  @retval RETURN_INVALID_PARAMETER  PixelHeight is NULL.
+  @retval RETURN_INVALID_PARAMETER  PixelWidth is NULL.
+  @retval RETURN_UNSUPPORTEDBmpImage is not a valid *.BMP image.
+  @retval RETURN_BUFFER_TOO_SMALL   The passed in GopBlt buffer is not big
+enough.  The required size is returned in
+GopBltSize.
+  @retval RETURN_OUT_OF_RESOURCES   The GopBlt buffer could not be allocated.
+
+**/
+RETURN_STATUS
+EFIAPI
+TranslateBmpToGopBlt (
+  IN VOID   *BmpImage,
+  IN UINTN  BmpImageSize,
+  IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL  **GopBlt,
+  IN OUT UINTN  *GopBltSize,
+  OUTUINTN  *PixelHeight,
+  OU

Re: [edk2] [PATCH edk2-platforms v1 13/14] Hisilicon/Library: Add OsBootLib

2018-02-07 Thread Peter Jones
Coming late to the party because Leif called my attention to this
thread...

On Mon, Jan 29, 2018 at 11:16:21AM +, Leif Lindholm wrote:
> This type of system behaviour has been seen multiple times to break
> installations in the real world.

I can't agree more; that's why there's a pile of language in 2.6 and
later that says how to do a better job of this.

> Note: my main objections here are really with regards to:
> 1) the expectation that variable store is erased on fw update
> 2) automatically rewriting boot variables
> 
> If (1) was resolved, then I could potentially see a use for a
> last-ditch fallback option (but even then, I don't think it should be
> enabled by default).

I certainly agree resolving #1 is the thing to do here, but there is is
actually useful functionality to have in general on the fallback path -
though I don't think this patch implements it in a correct or preferred
way.  In particular, it would be better to follow the advice in 3.1.1 of
the UEFI 2.7 spec, where we say that while yes, the firmware is allowed
to do boot order maintenance, it shouldn't remove anything or change the
order itself except in the most dire of circumstances.  In particular:

| The firmware should not, under normal operation, automatically remove
| any correctly formed Boot variable currently referenced by the
| BootOrder or BootNext variables. Such removal should be limited to
| scenarios where the firmware is guided by direct user interaction.

The right thing to do here is to publish some PlatformRecovery
variables as specified in 3.4.2, which can be a static list that's the
same every time you boot up, and when there's a failure here BootNext
and BootOrder have been exhausted, proceed according to 3.4.1 and 3.4.2,
which I'll attempt to summarize below.

The PlatformRecovery variables here should have device paths that
are something like:

PlatformRecovery: File(\EFI\BOOT\BOOTAA64.EFI)
PlatformRecovery0001:
File(\EFI\centos\grubaa64.efi)/EndInstance/File(\EFI\debian\grubaa64.efi)/EndInstance/File(\EFI\GRUB2\GRUBAA64.EFI)/EndInstance/File(\EFI\Microsoft\Boot\bootmgfw.efi)/EndInstance/File(\EFI\redhat\grub.efi)/EndInstance/...
 etc .../EndEntire

The EFI_OS_INDICATIONS_START_OS_RECOVERY and
EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY bits should be set in
OsIndicationsSupported.

(As an aside, I don't think we've explicitly said that multi-instance
device paths do or don't work in boot variables, so that may require
some work, or if you have a stronger preference about order you could
just make each one its own PlatformRecovery variable.  For what it's
worth, I don't think that the list in this patch is great - at the least
the arch suffixes should be generated according to what the build target
is, and what you've got currently doesn't correctly match several
shipping OSes - many of which *do* provide a file at
\EFI\BOOT\BOOT${ARCH}.EFI which will fix the BootOrder for you.)

If you supply those static variables, then in the normal boot path, if
you've exhausted BootNext and all of BootOrder, continue according to
chapter 3.4.2 and then 3.4.3 of the spec.  That basically says there's a
list of things to try as if they're Boot options:

- If OsRecoveryOrder exists, it's a list of GUIDs under which there may
  be OsRecovery variables.  The GUIDs are processed in the order
  they're listed, and the OsRecovery variables under each GUID are
  processed in hexadecimal numerical order.
- PlatformRecovery variables are processed in hexadecimal numerical
  order if OsRecovery variables are exhausted without successfully
  booting anything.

For everything in that list, the variables basically get treated exactly
like Boot variables.  For each  variable:
- parse the variable like you'd parse Boot, and use the normal
  discovery method to iterate across any files that match it.
  - if so, see if there's a Boot that matches that (it isn't
necessarily in BootOrder); if not create one.
  - Try to boot it like any other boot entry: set BootCurrent to the
Boot number, do LoadImage() and StartImage(), etc.  There's no
modification of BootOrder here.
  - If the binary there can't be found, loaded, or returns an
error, continue iterating the normal way to see if there are more
matching files, and if there aren't, then proceed to the next
variable.

If you exhaust this list, it's time for an error message and a
menu or something ;)

There are some important characteristics here that we need to maintain:
1) We haven't really talked enough about when it's really okay to
   Boot entries, because in general removing them is undoing
   something that was done on purpose (even if that purpose has been
   obviated now.) A pretty good rule is: don't remove Boot variables
   unless there are dire circumstances, like you've nearly completely
   run out of flash.  The user or the OS set these for a reason.  If you
   absolutely must prune them

[edk2] [PATCH v2 1/2] ShellPkg/UefiShellDebug1CommandsLib: sync Compress() definition with decl.

2018-02-07 Thread Laszlo Ersek
"Compress.h" declares the Compress() function as EFIAPI, but the
definition in "Compress.c" lacks EFIAPI.

GCC toolchains without LTO do not catch this error because "Compress.c"
does not include "Compress.h"; i.e. the declaration used by callers such
as "EfiCompress.c" is not actually matched against the function definition
at build time.

With LTO enabled, the mismatch is found -- however, as a warning only, due
to commit f8d0b9662993 ("BaseTools GCC5: disable warnings-as-errors for
now", 2016-08-03).

Include the header in the C file (which turns the issue into a hard build
error on all GCC toolchains), plus sync the declaration from the header
file to the C file. Finally, remove EFIAPI from both declaration and
definition -- this was the original intent of commit c4e74e9b814c
("ShellPkg/UefiShellDebug1CommandsLib: Remove unnecessary EFIAPI",
2016-10-09), but it missed the header file.

(Gary meant to address that omission in Oct 2017:

  [edk2] [PATCH] ShellPkg/UefiShellDebug1CommandsLib: Remove EFIAPI from
 Compress()

  http://mid.mail-archive.com/20171026065329.32311-1-glin@suse.com

and Ray reviewed the patch, but then the patch was never committed.)

So do the sync and drop EFIAPI now.

This happens to fix the EFICOMPRESS shell command, when built with GCC for
X64.

Cc: Gary Lin 
Cc: Jaben Carsey 
Cc: Ruiyu Ni 
Fixes: c4e74e9b814cfb4b51cf832f3bb218cd2aba348b
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:
- drop EFIAPI based on Gary's earlier patch which I just stumbled upon
- do not pick up Jaben's R-b from v1, due to inverted EFIAPI handling
- add "Fixes:" tag

 ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h |  1 -
 ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c | 14 --
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
index 39a997178fb7..7fe844e212a8 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h
@@ -28,7 +28,6 @@
   @retval EFI_BUFFER_TOO_SMALL  The buffer was too small.  DstSize is required.
 **/
 EFI_STATUS
-EFIAPI
 Compress (
   IN  VOID*SrcBuffer,
   IN  UINT64  SrcSize,
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
index 736d2a35b3ac..cde2c54f1b45 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include "Compress.h"
+
 //
 // Macro Definitions
 //
@@ -1307,20 +1309,20 @@ Encode (
   The compression routine.
 
   @param[in]   SrcBuffer The buffer containing the source data.
-  @param[in]   SrcSize   The number of bytes in SrcBuffer.
+  @param[in]   SrcSize   Number of bytes in SrcBuffer.
   @param[in]   DstBuffer The buffer to put the compressed image in.
   @param[in, out]  DstSize   On input the size (in bytes) of DstBuffer, on
-return the number of bytes placed in DstBuffer.
+ return the number of bytes placed in 
DstBuffer.
 
   @retval EFI_SUCCESS   The compression was sucessful.
   @retval EFI_BUFFER_TOO_SMALL  The buffer was too small.  DstSize is required.
 **/
 EFI_STATUS
 Compress (
-  IN   VOID   *SrcBuffer,
-  IN   UINT64 SrcSize,
-  IN   VOID   *DstBuffer,
-  IN OUT   UINT64 *DstSize
+  IN  VOID*SrcBuffer,
+  IN  UINT64  SrcSize,
+  IN  VOID*DstBuffer,
+  IN OUT  UINT64  *DstSize
   )
 {
   EFI_STATUS  Status;
-- 
2.14.1.3.gb7cf6e02401b


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


[edk2] [PATCH v2 0/2] sync some function definitions with their declarations

2018-02-07 Thread Laszlo Ersek
Repo:   https://github.com/lersek/edk2.git
Branch: sync_defs_to_decls_v2

This is version 2 of the series that I posted earlier. Because that
series didn't reach the list at all, due to SMTP issues on my end, I'm
including the v1 blurb here:

> The patches say it all, just a side remark up here:
>
> These errors would have been caught long ago if we had enabled the
> "-Wmissing-prototypes" gcc option.
>
> (Unfortunately, we can't enable that option even now, because it --
> laudably -- forces the programmer to give internal linkage ("STATIC")
> to their helper / local functions, and -- as we've learned -- some
> versions of the the Visual Studio debugger choke on STATIC functions.
> Thus, core modules basically never make their internal functions
> STATIC.)

The v2 changes are noted per patch.

(This posting should hopefully reach the list; while the original SMTP
issue remains undiagnosed, I attempted to put a work-around in place.
Let's see if it works.)

Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Gary Lin 
Cc: Jaben Carsey 
Cc: Jordan Justen 
Cc: Ruiyu Ni 

Thanks,
Laszlo

Laszlo Ersek (2):
  ShellPkg/UefiShellDebug1CommandsLib: sync Compress() definition with
decl.
  OvmfPkg/PlatformPei: sync AmdSevInitialize() definition with
declaration

 OvmfPkg/PlatformPei/AmdSev.c   |  3 ++-
 ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c | 14 --
 ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.h |  1 -
 3 files changed, 10 insertions(+), 8 deletions(-)

-- 
2.14.1.3.gb7cf6e02401b

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


[edk2] [PATCH v2 2/2] OvmfPkg/PlatformPei: sync AmdSevInitialize() definition with declaration

2018-02-07 Thread Laszlo Ersek
"Platform.h" declares the AmdSevInitialize() function without EFIAPI, but
the definition in "AmdSev.c" includes EFIAPI.

GCC toolchains without LTO do not catch this error because "AmdSev.c" does
not include "Platform.h"; i.e. the declaration used by callers such as
"Platform.c" is not actually matched against the function definition at
build time.

With LTO enabled, the mismatch is found -- however, as a warning only, due
to commit f8d0b9662993 ("BaseTools GCC5: disable warnings-as-errors for
now", 2016-08-03).

Include the header in the C file (which turns the issue into a hard build
error on all GCC toolchains), plus sync the declaration from the header
file to the C file.

There's been no functional breakage because AmdSevInitialize() takes no
parameters.

Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Jordan Justen 
Fixes: 13b5d743c87a22dfcd94e8475d943dee5712b62d
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek 
Reviewed-by: Brijesh Singh 
Reviewed-by: Jaben Carsey 
Acked-by: Ard Biesheuvel 
---

Notes:
v2:
- no code changes, just pick up feedback tags
- add "Fixes:" tag to the commit message

 OvmfPkg/PlatformPei/AmdSev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c
index 1539e5b5cdce..ad31b69fb032 100644
--- a/OvmfPkg/PlatformPei/AmdSev.c
+++ b/OvmfPkg/PlatformPei/AmdSev.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include "Platform.h"
+
 /**
 
   Function checks if SEV support is available, if present then it sets
@@ -30,7 +32,6 @@
 
   **/
 VOID
-EFIAPI
 AmdSevInitialize (
   VOID
   )
-- 
2.14.1.3.gb7cf6e02401b

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


[edk2] [Patch V2 3/3] Vlv2TbltDevicePkg: Switch from EsrtDxe to EsrtFmpDxe

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

The EsrtFmpDxe module is a lightweight version of the EsrtDxe
module that produces ESRT entries based only on FMP Protocol
instances.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 Vlv2TbltDevicePkg/PlatformPkg.fdf   | 4 ++--
 Vlv2TbltDevicePkg/PlatformPkgGcc.fdf| 4 ++--
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 4 ++--
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 4 ++--
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc| 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Vlv2TbltDevicePkg/PlatformPkg.fdf 
b/Vlv2TbltDevicePkg/PlatformPkg.fdf
index 5ed85f4dee..148553828c 100644
--- a/Vlv2TbltDevicePkg/PlatformPkg.fdf
+++ b/Vlv2TbltDevicePkg/PlatformPkg.fdf
@@ -1,7 +1,7 @@
 #/** @file
 # FDF file of Platform.
 #
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
 #
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
@@ -773,7 +773,7 @@ FILE FREEFORM = 878AC2CC-5343-46F2-B563-51F89DAF56BA {
 !endif
 
 !if $(CAPSULE_ENABLE) || $(MICOCODE_CAPSULE_ENABLE)
-INF  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+INF  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 !endif
 !if $(CAPSULE_ENABLE)
 INF  
SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf 
b/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
index a02a4f6286..d208871ae6 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
+++ b/Vlv2TbltDevicePkg/PlatformPkgGcc.fdf
@@ -1,7 +1,7 @@
 #/** @file
 # FDF file of Platform.
 #
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
 #
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
@@ -730,7 +730,7 @@ FILE FREEFORM = 878AC2CC-5343-46F2-B563-51F89DAF56BA {
 !endif
 
 !if $(CAPSULE_ENABLE) || $(MICOCODE_CAPSULE_ENABLE)
-INF  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+INF  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 !endif
 !if $(CAPSULE_ENABLE)
 INF  
SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index f98263d8a5..7a431130a3 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -1,7 +1,7 @@
 #/** @file
 # Platform description.
 #
-# Copyright (c) 2012  - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2012  - 2018, Intel Corporation. All rights reserved.
 #
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
@@ -1567,7 +1567,7 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
   Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.inf
 
 !if $(CAPSULE_ENABLE) || $(MICOCODE_CAPSULE_ENABLE)
-  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
   MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf
 !endif
 
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index c755df2fe2..d27fc49df7 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -1,7 +1,7 @@
 #/** @file
 # Platform description.
 #
-# Copyright (c) 2012  - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2012  - 2018, Intel Corporation. All rights reserved.
 #
 # This program and the accompanying materials are licensed and made available 
under
 # the terms and conditions of the BSD License that accompanies this 
distribution.
@@ -1555,7 +1555,7 @@ 
$(PLATFORM_BINARY_PACKAGE)/$(DXE_ARCHITECTURE)$(TARGET)/IA32/fTPMInitPeim.inf
   Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareUpdate.inf
 
 !if $(CAPSULE_ENABLE) || $(MICOCODE_CAPSULE_ENABLE)
-  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
   MdeModulePkg/Application/CapsuleApp/CapsuleApp.inf
 !endif
 
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc 
b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index dda8216e6a..ca68928b23 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -1,7 +1,7 @@
 #/** @file
 # Platform description.
 #
-# Copyright (c) 2012  - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2012  - 2018, Intel Corpor

[edk2] [Patch V2 2/3] QuarkPlatformPkg: Switch from EsrtDxe to EsrtFmpDxe

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

The EsrtFmpDxe module is a lightweight version of the EsrtDxe
module that produces ESRT entries based only on FMP Protocol
instances.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 QuarkPlatformPkg/Quark.dsc | 4 ++--
 QuarkPlatformPkg/Quark.fdf | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
index 5624451e12..2176c8c9db 100644
--- a/QuarkPlatformPkg/Quark.dsc
+++ b/QuarkPlatformPkg/Quark.dsc
@@ -2,7 +2,7 @@
 # Clanton Peak CRB platform with 32-bit DXE for 4MB/8MB flash devices.
 #
 # This package provides Clanton Peak CRB platform specific modules.
-# Copyright (c) 2013 - 2017 Intel Corporation.
+# Copyright (c) 2013 - 2018 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -921,7 +921,7 @@
   }
 
 !if $(CAPSULE_ENABLE)
-  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 
   SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf {
 
diff --git a/QuarkPlatformPkg/Quark.fdf b/QuarkPlatformPkg/Quark.fdf
index ab0f84b860..609f6e9b35 100644
--- a/QuarkPlatformPkg/Quark.fdf
+++ b/QuarkPlatformPkg/Quark.fdf
@@ -2,7 +2,7 @@
 # FDF file of Clanton Peak CRB platform with 32-bit DXE
 #
 # This package provides QuarkNcSocId platform specific modules.
-# Copyright (c) 2013 - 2017 Intel Corporation.
+# Copyright (c) 2013 - 2018 Intel Corporation.
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -598,7 +598,7 @@ INF  RuleOverride = DRIVER_ACPITABLE 
SecurityPkg/Tcg/TcgSmm/TcgSmm.inf
 !endif
 
 !if $(CAPSULE_ENABLE)
-INF  MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+INF  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 INF  
SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
 !endif
 
-- 
2.14.2.windows.3

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


[edk2] [Patch V2 0/3] MdeModulePkg/EsrtFmpDxe: Add EsrtFmpDxe module

2018-02-07 Thread Kinney, Michael D
V2:
* Add .uni files with module name, abstract, description
* Use EfiCreateEventReadyToBootEx() instead of gBS->CreateEventEx()
* Change module type from UEFI_DRIVER to DXE_DRIVER with depex TRUE

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

Branch for review:
https://github.com/mdkinney/edk2/tree/Bug_802_EsrtFmpDxe_V2

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

The EsrtFmpDxe module is a lightweight version of the EsrtDxe
module that produces ESRT entries based only on FMP Protocol
instances.

Update Quark and Vlv2 platforms to use EsrtFmpDxe.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 

Michael D Kinney (3):
  MdeModulePkg/EsrtFmpDxe: Add EsrtFmpDxe module
  QuarkPlatformPkg: Switch from EsrtDxe to EsrtFmpDxe
  Vlv2TbltDevicePkg: Switch from EsrtDxe to EsrtFmpDxe

 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c| 482 +
 .../Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c   | 161 +++
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf   |  74 
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.uni   |  19 +
 .../Universal/EsrtFmpDxe/EsrtFmpDxeExtra.uni   |  18 +
 QuarkPlatformPkg/Quark.dsc |   4 +-
 QuarkPlatformPkg/Quark.fdf |   4 +-
 Vlv2TbltDevicePkg/PlatformPkg.fdf  |   4 +-
 Vlv2TbltDevicePkg/PlatformPkgGcc.fdf   |   4 +-
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc|   4 +-
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc  |   4 +-
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc   |   4 +-
 13 files changed, 769 insertions(+), 14 deletions(-)
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.uni
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxeExtra.uni

-- 
2.14.2.windows.3

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


[edk2] [Patch V2 1/3] MdeModulePkg/EsrtFmpDxe: Add EsrtFmpDxe module

2018-02-07 Thread Kinney, Michael D
From: Michael D Kinney 

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

Based on content from the following branch/commits:
https://github.com/Microsoft/MS_UEFI/tree/share/MsCapsuleSupport

The EsrtFmpDxe module is a lightweight version of the EsrtDxe
module that produces ESRT entries based only on FMP Protocol
instances.

Cc: Sean Brogan 
Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/MdeModulePkg.dsc  |   1 +
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c| 482 +
 .../Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c   | 161 +++
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf   |  74 
 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.uni   |  19 +
 .../Universal/EsrtFmpDxe/EsrtFmpDxeExtra.uni   |  18 +
 6 files changed, 755 insertions(+)
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.uni
 create mode 100644 MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxeExtra.uni

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 1c0085aee6..50002f8e3f 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -412,6 +412,7 @@
 
   MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf
   MdeModulePkg/Universal/EsrtDxe/EsrtDxe.inf
+  MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDxe.inf
   
   
MdeModulePkg/Universal/PropertiesTableAttributesDxe/PropertiesTableAttributesDxe.inf
   MdeModulePkg/Universal/FileExplorerDxe/FileExplorerDxe.inf  {
diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c 
b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
new file mode 100644
index 00..b98430edbf
--- /dev/null
+++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c
@@ -0,0 +1,482 @@
+/** @file
+  Publishes ESRT table from Firmware Management Protocol instances
+
+  Copyright (c) 2016, Microsoft Corporation
+  Copyright (c) 2018, Intel Corporation. All rights reserved.
+
+  All rights reserved.
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions are met:
+  1. Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED.
+  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 
DIRECT,
+  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
OF
+  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE
+  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+//
+// Print ESRT to debug console
+//
+VOID
+EFIAPI
+PrintTable (
+  IN EFI_SYSTEM_RESOURCE_TABLE  *Table
+  );
+
+//
+// Number of ESRT entries to grow by each time we run out of room
+//
+#define GROWTH_STEP  10
+
+//
+// Module globals.
+//
+EFI_EVENT  mEsrtReadyToBootEvent;
+EFI_SYSTEM_RESOURCE_TABLE  *mTable = NULL;
+BOOLEANmEsrtInstalled = FALSE;
+EFI_EVENT  mFmpInstallEvent;
+VOID   *mFmpInstallEventRegistration = NULL;
+
+/**
+  Install EFI System Resource Table into the UEFI Configuration Table
+
+  @return  Status code.
+
+**/
+EFI_STATUS
+InstallEfiSystemResourceTableInUefiConfigurationTable (
+   VOID
+  )
+{
+  EFI_STATUS Status;
+
+  Status = EFI_SUCCESS;
+  if (!mEsrtInstalled) {
+if (mTable == NULL) {
+  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Can't install ESRT table because it is 
NULL. \n"));
+  Status = EFI_OUT_OF_RESOURCES;
+} else if (mTable->FwResourceCount == 0) {
+  DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Can't install ESRT table because it 
has zero Entries. \n"));
+  Status = EFI_UNSUPPORTED;
+} else {
+  //
+  // Install the pointer into config table
+  //
+  Status = gBS->InstallConfigurationTable (&gEfiSystemResourceTableGuid, 
mTable);
+  if (EFI_ERROR (

[edk2] [Patch] MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP

2018-02-07 Thread Kinney, Michael D
https://bugzilla.tianocore.org/show_bug.cgi?id=873

Update IsNestedFmpCapsule() to verify the CapsuleGuid in
the CapsuleHeader against the installed Firmware Management
Protocol instances.  The current logic that uses the ESRT
Table does not work because capsules are processed before
the ESRT Table is published at the Ready To Boot event.

Cc: Jiewen Yao 
Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.c   | 27 --
 .../Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf |  3 +--
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c 
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
index 2f397789b5..87e1deec03 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c
@@ -10,7 +10,7 @@
   ValidateFmpCapsule(), DisplayCapsuleImage(), ConvertBmpToGopBlt() will
   receive untrusted input and do basic validation.
 
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -1446,7 +1446,6 @@ IsNestedFmpCapsule (
   )
 {
   EFI_STATUS Status;
-  EFI_SYSTEM_RESOURCE_TABLE  *Esrt;
   EFI_SYSTEM_RESOURCE_ENTRY  *EsrtEntry;
   UINTN  Index;
   BOOLEANEsrtGuidFound;
@@ -1454,6 +1453,8 @@ IsNestedFmpCapsule (
   UINTN  NestedCapsuleSize;
   ESRT_MANAGEMENT_PROTOCOL   *EsrtProtocol;
   EFI_SYSTEM_RESOURCE_ENTRY  Entry;
+  EFI_HANDLE *HandleBuffer;
+  UINTN  NumberOfHandles;
 
   EsrtGuidFound = FALSE;
   if (mIsVirtualAddrConverted) {
@@ -1479,19 +1480,21 @@ IsNestedFmpCapsule (
 }
 
 //
-// Check ESRT configuration table
+// Check Firmware Management Protocols
 //
 if (!EsrtGuidFound) {
-  Status = EfiGetSystemConfigurationTable(&gEfiSystemResourceTableGuid, 
(VOID **)&Esrt);
+  HandleBuffer = NULL;
+  Status = GetFmpHandleBufferByType (
+ &CapsuleHeader->CapsuleGuid,
+ 0,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
   if (!EFI_ERROR(Status)) {
-ASSERT (Esrt != NULL);
-EsrtEntry = (VOID *)(Esrt + 1);
-for (Index = 0; Index < Esrt->FwResourceCount; Index++, EsrtEntry++) {
-  if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
-EsrtGuidFound = TRUE;
-break;
-  }
-}
+EsrtGuidFound = TRUE;
+  }
+  if (HandleBuffer != NULL) {
+FreePool (HandleBuffer);
   }
 }
   }
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf 
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index a7c36993c4..90edc52ee0 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -3,7 +3,7 @@
 #
 #  Capsule library instance for DXE_DRIVER module types.
 #
-#  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+#  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD 
License
 #  which accompanies this distribution.  The full text of the license may be 
found at
@@ -72,7 +72,6 @@
 [Guids]
   gEfiFmpCapsuleGuid  ## SOMETIMES_CONSUMES ## GUID
   gWindowsUxCapsuleGuid   ## SOMETIMES_CONSUMES ## GUID
-  gEfiSystemResourceTableGuid ## SOMETIMES_CONSUMES ## GUID
   ## SOMETIMES_CONSUMES ## Variable:L"CapsuleMax"
   ## SOMETIMES_PRODUCES ## Variable:L"CapsuleMax"
   gEfiCapsuleReportGuid
-- 
2.14.2.windows.3

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


Re: [edk2] [PATCH v2 1/1] MdePkg/Include: Add management mode FV file type and depex.

2018-02-07 Thread Supreeth Venkatesh
Liming,

Thanks for your feedback.
I have sent v3 of this patch with your feedback, incorporated.

Supreeth

-Original Message-
From: Gao, Liming [mailto:liming@intel.com]
Sent: Tuesday, February 6, 2018 9:43 PM
To: Supreeth Venkatesh ; edk2-devel@lists.01.org
Cc: Kinney, Michael D ; marvin.haeu...@outlook.com; 
tim.le...@insyde.com; Yao, Jiewen ; Achin Gupta 

Subject: RE: [PATCH v2 1/1] MdePkg/Include: Add management mode FV file type 
and depex.

Supreeth:
  Thanks for your update. PI spec doesn't define EFI_FV_FILETYPE_SMM_STANDALONE 
and EFI_FV_FILETYPE_SMM_CORE_STANDALONE. So, please remove them in this patch.

Thanks
Liming
>-Original Message-
>From: Supreeth Venkatesh [mailto:supreeth.venkat...@arm.com]
>Sent: Thursday, February 01, 2018 4:06 AM
>To: edk2-devel@lists.01.org
>Cc: Kinney, Michael D ; Gao, Liming
>; marvin.haeu...@outlook.com;
>tim.le...@insyde.com; Yao, Jiewen ; Supreeth
>Venkatesh ; Achin Gupta
>
>Subject: [PATCH v2 1/1] MdePkg/Include: Add management mode FV file
>type and depex.
>
>As per PI specification v1.6,
>As per section 2.1.4.1,
>The following file types exist:
>Table 3. Defined File Types
>Name   Value
>EFI_FV_FILETYPE_RAW0x01
>EFI_FV_FILETYPE_FREEFORM   0x02
>EFI_FV_FILETYPE_SECURITY_CORE  0x03
>EFI_FV_FILETYPE_PEI_CORE   0x04
>EFI_FV_FILETYPE_DXE_CORE   0x05
>EFI_FV_FILETYPE_PEIM   0x06
>EFI_FV_FILETYPE_DRIVER 0x07
>EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER   0x08
>EFI_FV_FILETYPE_APPLICATION0x09
>EFI_FV_FILETYPE_MM 0x0A
>EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE  0x0B
>EFI_FV_FILETYPE_COMBINED_MM_DXE0x0C
>EFI_FV_FILETYPE_MM_CORE0x0D
>EFI_FV_FILETYPE_MM_STANDALONE  0x0E
>EFI_FV_FILETYPE_MM_CORE_STANDALONE 0x0F
>
>The following new section type is added:
>EFI_SECTION_MM_DEPEX
>
>This patch adds the management mode FV file type and depex.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Achin Gupta 
>Signed-off-by: Supreeth Venkatesh 
>Reviewed-by: Jiewen Yao 
>---
> MdePkg/Include/Pi/PiFirmwareFile.h | 16 
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
>diff --git a/MdePkg/Include/Pi/PiFirmwareFile.h
>b/MdePkg/Include/Pi/PiFirmwareFile.h
>index b982c9eda3..808202cd22 100644
>--- a/MdePkg/Include/Pi/PiFirmwareFile.h
>+++ b/MdePkg/Include/Pi/PiFirmwareFile.h
>@@ -71,10 +71,17 @@ typedef UINT8 EFI_FFS_FILE_STATE;
> #define EFI_FV_FILETYPE_DRIVER0x07
> #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER  0x08
> #define EFI_FV_FILETYPE_APPLICATION   0x09
>-#define EFI_FV_FILETYPE_SMM   0x0A
>+#define EFI_FV_FILETYPE_MM0x0A
>+#define EFI_FV_FILETYPE_SMM   EFI_FV_FILETYPE_MM
> #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
>-#define EFI_FV_FILETYPE_COMBINED_SMM_DXE  0x0C
>-#define EFI_FV_FILETYPE_SMM_CORE  0x0D
>+#define EFI_FV_FILETYPE_COMBINED_MM_DXE   0x0C
>+#define EFI_FV_FILETYPE_COMBINED_SMM_DXE
>EFI_FV_FILETYPE_COMBINED_MM_DXE
>+#define EFI_FV_FILETYPE_MM_CORE   0x0D
>+#define EFI_FV_FILETYPE_SMM_CORE  EFI_FV_FILETYPE_MM_CORE
>+#define EFI_FV_FILETYPE_MM_STANDALONE 0x0E
>+#define EFI_FV_FILETYPE_SMM_STANDALONE
>EFI_FV_FILETYPE_MM_STANDALONE
>+#define EFI_FV_FILETYPE_MM_CORE_STANDALONE0x0F
>+#define EFI_FV_FILETYPE_SMM_CORE_STANDALONE
>EFI_FV_FILETYPE_MM_CORE_STANDALONE
> #define EFI_FV_FILETYPE_OEM_MIN   0xc0
> #define EFI_FV_FILETYPE_OEM_MAX   0xdf
> #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
>@@ -217,7 +224,8 @@ typedef UINT8 EFI_SECTION_TYPE;  #define
>EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
> #define EFI_SECTION_RAW   0x19
> #define EFI_SECTION_PEI_DEPEX 0x1B
>-#define EFI_SECTION_SMM_DEPEX 0x1C
>+#define EFI_SECTION_MM_DEPEX  0x1C
>+#define EFI_SECTION_SMM_DEPEX EFI_SECTION_MM_DEPEX
>
> ///
> /// Common section header.
>--
>2.14.1

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v3 1/1] MdePkg/Include: Add management mode FV file type and depex.

2018-02-07 Thread Supreeth Venkatesh
As per PI specification v1.6,
As per section 2.1.4.1,
The following file types exist:
Table 3. Defined File Types
Name   Value
EFI_FV_FILETYPE_RAW0x01
EFI_FV_FILETYPE_FREEFORM   0x02
EFI_FV_FILETYPE_SECURITY_CORE  0x03
EFI_FV_FILETYPE_PEI_CORE   0x04
EFI_FV_FILETYPE_DXE_CORE   0x05
EFI_FV_FILETYPE_PEIM   0x06
EFI_FV_FILETYPE_DRIVER 0x07
EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER   0x08
EFI_FV_FILETYPE_APPLICATION0x09
EFI_FV_FILETYPE_MM 0x0A
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE  0x0B
EFI_FV_FILETYPE_COMBINED_MM_DXE0x0C
EFI_FV_FILETYPE_MM_CORE0x0D
EFI_FV_FILETYPE_MM_STANDALONE  0x0E
EFI_FV_FILETYPE_MM_CORE_STANDALONE 0x0F

The following new section type is added:
EFI_SECTION_MM_DEPEX

This patch adds the management mode FV file type and depex.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Achin Gupta 
Signed-off-by: Supreeth Venkatesh 
Reviewed-by: Jiewen Yao 
---
 MdePkg/Include/Pi/PiFirmwareFile.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Include/Pi/PiFirmwareFile.h 
b/MdePkg/Include/Pi/PiFirmwareFile.h
index 9c7a400329..16c007fc75 100644
--- a/MdePkg/Include/Pi/PiFirmwareFile.h
+++ b/MdePkg/Include/Pi/PiFirmwareFile.h
@@ -71,12 +71,13 @@ typedef UINT8 EFI_FFS_FILE_STATE;
 #define EFI_FV_FILETYPE_DRIVER0x07
 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER  0x08
 #define EFI_FV_FILETYPE_APPLICATION   0x09
-#define EFI_FV_FILETYPE_SMM   0x0A
 #define EFI_FV_FILETYPE_MM0x0A
+#define EFI_FV_FILETYPE_SMM   EFI_FV_FILETYPE_MM
 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
-#define EFI_FV_FILETYPE_COMBINED_SMM_DXE  0x0C
 #define EFI_FV_FILETYPE_COMBINED_MM_DXE   0x0C
-#define EFI_FV_FILETYPE_SMM_CORE  0x0D
+#define EFI_FV_FILETYPE_COMBINED_SMM_DXE  EFI_FV_FILETYPE_COMBINED_MM_DXE
+#define EFI_FV_FILETYPE_MM_CORE   0x0D
+#define EFI_FV_FILETYPE_SMM_CORE  EFI_FV_FILETYPE_MM_CORE
 #define EFI_FV_FILETYPE_MM_STANDALONE 0x0E
 #define EFI_FV_FILETYPE_MM_CORE_STANDALONE0x0F
 #define EFI_FV_FILETYPE_OEM_MIN   0xc0
@@ -221,8 +222,8 @@ typedef UINT8 EFI_SECTION_TYPE;
 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
 #define EFI_SECTION_RAW   0x19
 #define EFI_SECTION_PEI_DEPEX 0x1B
-#define EFI_SECTION_SMM_DEPEX 0x1C
 #define EFI_SECTION_MM_DEPEX  0x1C
+#define EFI_SECTION_SMM_DEPEX EFI_SECTION_MM_DEPEX
 
 ///
 /// Common section header.
-- 
2.14.1

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


Re: [edk2] [issue] Arrow key can't be read on tty terminal in release build

2018-02-07 Thread Ard Biesheuvel
On 7 February 2018 at 16:43, Haojian Zhuang  wrote:
> On 8 February 2018 at 00:13, Ard Biesheuvel  wrote:
>> On 7 February 2018 at 16:12, Haojian Zhuang  
>> wrote:
>>> On 7 February 2018 at 23:52, Ard Biesheuvel  
>>> wrote:

> On 7 Feb 2018, at 15:50, Haojian Zhuang  wrote:
>
> Hi all,
>
> I have an issue on tty terminal. I setup PL011 serial console as the
> tty terminal on HiKey platform. When it's built in debug mode, arrow
> key works well. When it's built in release mode, arrow key can't work.
>
> For example, DOWN key is gotten in terminal with "~[B" value in debug
> build. DOWN key is gotten in terminal with "~" value in release build.
> These values are fetched by GetOneKeyFromSerial().
>
> But I can't find any difference on PL011 serial driver between debug
> and release mode.
>
> Do you have any idea on this?
>
>

 You need to set the FIFO depth to 16 iirc
>>>
>>> I think you mean the initialization code in PL011UartInitializePort ().
>>>
>>>   HardwareFifoDepth = (PL011_UARTPID2_VER (MmioRead32 (UartBase + 
>>> UARTPID2)) \
>>>> PL011_VER_R1P4) \
>>>   ? 32 : 16 ;
>>>
>>> I tried to hardcode the value with both 32 and 16. The issue still exists.
>>>
>>
>> Actually, it is the other way around. You need to set
>>
>> gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
>>
>> as the default is 1, which makes no sense at all.
>
> After updating the PCD value to 0, this issue is gone. Great thanks
> for your help.
>
> Now I have a new question. Why do I miss the issue in debug build? Do
> you have any idea?
>

Because the DEBUG build uses the serial port for DEBUG output, and
performs its own initialization.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [issue] Arrow key can't be read on tty terminal in release build

2018-02-07 Thread Haojian Zhuang
On 8 February 2018 at 00:13, Ard Biesheuvel  wrote:
> On 7 February 2018 at 16:12, Haojian Zhuang  wrote:
>> On 7 February 2018 at 23:52, Ard Biesheuvel  
>> wrote:
>>>
 On 7 Feb 2018, at 15:50, Haojian Zhuang  wrote:

 Hi all,

 I have an issue on tty terminal. I setup PL011 serial console as the
 tty terminal on HiKey platform. When it's built in debug mode, arrow
 key works well. When it's built in release mode, arrow key can't work.

 For example, DOWN key is gotten in terminal with "~[B" value in debug
 build. DOWN key is gotten in terminal with "~" value in release build.
 These values are fetched by GetOneKeyFromSerial().

 But I can't find any difference on PL011 serial driver between debug
 and release mode.

 Do you have any idea on this?


>>>
>>> You need to set the FIFO depth to 16 iirc
>>
>> I think you mean the initialization code in PL011UartInitializePort ().
>>
>>   HardwareFifoDepth = (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) 
>> \
>>> PL011_VER_R1P4) \
>>   ? 32 : 16 ;
>>
>> I tried to hardcode the value with both 32 and 16. The issue still exists.
>>
>
> Actually, it is the other way around. You need to set
>
> gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
>
> as the default is 1, which makes no sense at all.

After updating the PCD value to 0, this issue is gone. Great thanks
for your help.

Now I have a new question. Why do I miss the issue in debug build? Do
you have any idea?

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


Re: [edk2] [edk2-platforms][PATCH] Platform/Hisilicon/HiKey960: add skeleton of HiKey960

2018-02-07 Thread Leif Lindholm
On Wed, Feb 07, 2018 at 11:45:54PM +0800, Haojian Zhuang wrote:
> On 7 February 2018 at 01:29, Leif Lindholm  wrote:
> > On Mon, Feb 05, 2018 at 04:25:52PM +0800, Haojian Zhuang wrote:
> >> Add skeleton of HiKey960 platform.
> >>
> >> Contributed-under: TianoCore Contribution Agreement 1.1
> >> Signed-off-by: Haojian Zhuang 
> >> ---
> >> +  gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd|FALSE
> >> +
> >> +  gEmbeddedTokenSpaceGuid.PcdCacheEnable|TRUE
> >
> > The above Pcds are all obsolete.
> > Seeing this patch made me go through and clean up EmbeddedPkg and
> > platform templates.
> >
> > Could you generate a new version of this patch that applies and builds
> > cleanly against the cleanup series I just posted to edk2-devel?:
> > https://git.linaro.org/people/leif.lindholm/edk2.git/log/?h=embeddedpkg-cleanup
> > and
> > https://git.linaro.org/people/leif.lindholm/edk2-platforms.git/log/?h=embeddedpkg-cleanup
> >
> 
> OK. I'll rebase on it.

Thanks.

(These have now been pushed to Tianocore master, so no need to work
against my tree.)

/
Leif

> > (I would be even happier if you could break the common parts of
> > Hikey/Hikey960 descriptions into a common .dsc, like the d02,3,5
> > platforms do with Silicon/Hisilicon/Hisilicon.dsc.inc.)
> >
> 
> OK.


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


Re: [edk2] [issue] Arrow key can't be read on tty terminal in release build

2018-02-07 Thread Ard Biesheuvel
On 7 February 2018 at 16:12, Haojian Zhuang  wrote:
> On 7 February 2018 at 23:52, Ard Biesheuvel  wrote:
>>
>>> On 7 Feb 2018, at 15:50, Haojian Zhuang  wrote:
>>>
>>> Hi all,
>>>
>>> I have an issue on tty terminal. I setup PL011 serial console as the
>>> tty terminal on HiKey platform. When it's built in debug mode, arrow
>>> key works well. When it's built in release mode, arrow key can't work.
>>>
>>> For example, DOWN key is gotten in terminal with "~[B" value in debug
>>> build. DOWN key is gotten in terminal with "~" value in release build.
>>> These values are fetched by GetOneKeyFromSerial().
>>>
>>> But I can't find any difference on PL011 serial driver between debug
>>> and release mode.
>>>
>>> Do you have any idea on this?
>>>
>>>
>>
>> You need to set the FIFO depth to 16 iirc
>
> I think you mean the initialization code in PL011UartInitializePort ().
>
>   HardwareFifoDepth = (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) \
>> PL011_VER_R1P4) \
>   ? 32 : 16 ;
>
> I tried to hardcode the value with both 32 and 16. The issue still exists.
>

Actually, it is the other way around. You need to set

gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0

as the default is 1, which makes no sense at all.
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [issue] Arrow key can't be read on tty terminal in release build

2018-02-07 Thread Haojian Zhuang
On 7 February 2018 at 23:52, Ard Biesheuvel  wrote:
>
>> On 7 Feb 2018, at 15:50, Haojian Zhuang  wrote:
>>
>> Hi all,
>>
>> I have an issue on tty terminal. I setup PL011 serial console as the
>> tty terminal on HiKey platform. When it's built in debug mode, arrow
>> key works well. When it's built in release mode, arrow key can't work.
>>
>> For example, DOWN key is gotten in terminal with "~[B" value in debug
>> build. DOWN key is gotten in terminal with "~" value in release build.
>> These values are fetched by GetOneKeyFromSerial().
>>
>> But I can't find any difference on PL011 serial driver between debug
>> and release mode.
>>
>> Do you have any idea on this?
>>
>>
>
> You need to set the FIFO depth to 16 iirc

I think you mean the initialization code in PL011UartInitializePort ().

  HardwareFifoDepth = (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPID2)) \
   > PL011_VER_R1P4) \
  ? 32 : 16 ;

I tried to hardcode the value with both 32 and 16. The issue still exists.

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


Re: [edk2] [issue] Arrow key can't be read on tty terminal in release build

2018-02-07 Thread Ard Biesheuvel

> On 7 Feb 2018, at 15:50, Haojian Zhuang  wrote:
> 
> Hi all,
> 
> I have an issue on tty terminal. I setup PL011 serial console as the
> tty terminal on HiKey platform. When it's built in debug mode, arrow
> key works well. When it's built in release mode, arrow key can't work.
> 
> For example, DOWN key is gotten in terminal with "~[B" value in debug
> build. DOWN key is gotten in terminal with "~" value in release build.
> These values are fetched by GetOneKeyFromSerial().
> 
> But I can't find any difference on PL011 serial driver between debug
> and release mode.
> 
> Do you have any idea on this?
> 
> 

You need to set the FIFO depth to 16 iirc
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [issue] Arrow key can't be read on tty terminal in release build

2018-02-07 Thread Haojian Zhuang
Hi all,

I have an issue on tty terminal. I setup PL011 serial console as the
tty terminal on HiKey platform. When it's built in debug mode, arrow
key works well. When it's built in release mode, arrow key can't work.

For example, DOWN key is gotten in terminal with "~[B" value in debug
build. DOWN key is gotten in terminal with "~" value in release build.
These values are fetched by GetOneKeyFromSerial().

But I can't find any difference on PL011 serial driver between debug
and release mode.

Do you have any idea on this?

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


Re: [edk2] [edk2-platforms][PATCH] Platform/Hisilicon/HiKey960: add skeleton of HiKey960

2018-02-07 Thread Haojian Zhuang
On 7 February 2018 at 01:29, Leif Lindholm  wrote:
> On Mon, Feb 05, 2018 at 04:25:52PM +0800, Haojian Zhuang wrote:
>> Add skeleton of HiKey960 platform.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Haojian Zhuang 
>> ---
>> +  gEmbeddedTokenSpaceGuid.PcdEmbeddedScriptCmd|FALSE
>> +
>> +  gEmbeddedTokenSpaceGuid.PcdCacheEnable|TRUE
>
> The above Pcds are all obsolete.
> Seeing this patch made me go through and clean up EmbeddedPkg and
> platform templates.
>
> Could you generate a new version of this patch that applies and builds
> cleanly against the cleanup series I just posted to edk2-devel?:
> https://git.linaro.org/people/leif.lindholm/edk2.git/log/?h=embeddedpkg-cleanup
> and
> https://git.linaro.org/people/leif.lindholm/edk2-platforms.git/log/?h=embeddedpkg-cleanup
>

OK. I'll rebase on it.

> (I would be even happier if you could break the common parts of
> Hikey/Hikey960 descriptions into a common .dsc, like the d02,3,5
> platforms do with Silicon/Hisilicon/Hisilicon.dsc.inc.)
>

OK.

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


Re: [edk2] [PATCH edk2-platforms v4 00/15] Improve D0x platforms and bug fix

2018-02-07 Thread Leif Lindholm
On Wed, Feb 07, 2018 at 04:22:34PM +0800, Heyi Guo wrote:
> The major features of this patchset include
> adding PPTT support, 
> switching to Generic BDS driver,
> adding capsule upgrade support,
> open-source version for SnpPlatform and SasPlatform
> changing DmaLib to CoherentDmaLib.
> 
> Comparison of V3:
> 1 Modify PPTT as the edk2 patch "MdePkg ACPI: Add some macros for 
> PPTT".(hash:c4e7557)
> 2 Correct the email of Graeme Gregory.
> 
> Code can also be found in github: 
> https://github.com/hisilicon/OpenPlatformPkg.git
> branch: rp-1802-platforms-v4

Thanks!

Series pushed as b75684ef78..d82055b43d.

> Heyi Guo (15):
>   Hisilicon/D05: Move Madt definition to head file
>   Hisilicon/D05: Add PPTT support
>   Hisilicon/D0x/BDS: Switch to Generic BDS driver
>   Hisilicon/D0x: Break BMC SetBoot option out into separate library
>   Hisilicon D03/D05: Add capsule upgrade support
>   Hisilicon D03/D05: Open SasPlatform source code
>   Hisilicon D03/D05: Open SnpPlatform source code
>   Hilisicon: Change DmaLib to CoherentDmaLib
>   Hisilicon/Smbios: Indicate use of ProcessorFamily2 in type 4 table
>   Hisilicon/PCIe: Disable PCIe ASPM
>   Hisilicon/D05: Replace SP805Watchdog by WatchdogTimer driver.
>   Hisilicon/D03: Replace SP805Watchdog by WatchdogTimer driver.
>   Hisilicon/D05/ACPI: Add ITS PXM
>   Hisilicon/D05/ACPI: Add Pcie, HNS and SAS PXM
>   Hisilicon D03/D05: Update firmware version to 18.02
> 
>  
> Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
>  |  45 ++
>  Platform/Hisilicon/D03/D03.dsc   
> |  42 +-
>  Platform/Hisilicon/D03/D03.fdf   
> |  79 ++-
>  
> Platform/Hisilicon/D03/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
> |  81 +++
>  
> Platform/Hisilicon/D03/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>  |  50 ++
>  
> Platform/Hisilicon/D03/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
> |  70 +++
>  
> Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
>  |  45 ++
>  Platform/Hisilicon/D05/D05.dsc   
> |  47 +-
>  Platform/Hisilicon/D05/D05.fdf   
> |  80 ++-
>  
> Platform/Hisilicon/D05/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
> |  81 +++
>  
> Platform/Hisilicon/D05/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
>  |  50 ++
>  
> Platform/Hisilicon/D05/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
> |  70 +++
>  Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.c  
> | 106 
>  Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.inf
> |  45 ++
>  Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c
> |   4 +-
>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c  
> | 115 
>  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
> |  46 ++
>  Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.c
> |   2 +-
>  Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.c   
> |   3 +-
>  Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c  
> | 103 
>  Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h  
> |   2 +
>  Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc  
> |  10 +
>  Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Hns.asl   
> |   9 +
>  Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl   
> |  34 +-
>  Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl   
> |  19 +-
>  Silicon/Hisilicon/Hi1616/D05AcpiTables/Hi1616Platform.h  
> |  30 +-
>  Silicon/Hisilicon/Hi1616/D05AcpiTables/MadtHi1616.aslc   
> |  23 +-
>  Silicon/Hisilicon/Hi1616/Pptt/Pptt.c 
> | 529 
>  Silicon/Hisilicon/Hi1616/Pptt/Pptt.h 
> |  67 ++
>  Silicon/Hisilicon/Hi1616/Pptt/Pptt.inf   
> |  48 ++
>  Silicon/Hisilicon/HisiPkg.dec
> |   6 +
>  Silicon/Hisilicon/Hisilicon.dsc.inc  
> |  12 +-
>  Silicon/Hisilicon/Hisilicon.fdf.inc  
> |   9 +
>  Silicon/Hisilicon/Include/Library/AcpiNextLib.h  
>  

Re: [edk2] [PATCH edk2-non-osi v3 0/7] Improve D0x platforms and bug fix

2018-02-07 Thread Leif Lindholm
Thanks!

For the series:
Reviewed-by: Leif Lindholm 

Pushed as 168344f..1aaec67

On Fri, Feb 02, 2018 at 07:57:21PM +0800, Heyi Guo wrote:
> The major features of this patchset:
> 1 Upgrade trusted firmware to 1.4
> 2 Workarounds for CVE-2017-5715 on Cortex A57/A72/A73 and A75 #1214
> 3 Delete some binary for open-source version
> 4 Update binary follow changing DmaLib to CoherentDmaLib
> 
> Code can also be found in github: 
> https://github.com/hisilicon/OpenPlatformPkg.git
> branch: rp-1802-osi-v3
> 
> 
> Heyi Guo (6):
>   Hisilicon D0x: Fix network interface order issue
>   Hisilicon D0x: Delete SnpPlatform
>   Hisilicon D03/D05: Update SasDriverDxe binary
>   Hisilicon D03/D05: Update NativeOhci binary
>   Hisilicon/D03: Update binary of trusted-firmware
>   Hisilicon/D05: Update binary of trusted-firmware
> 
> Jason Zhang (1):
>   Hisilicon D03/D05: Delete SasPlatform
> 
>  Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi | Bin 26688 
> -> 27392 bytes
>  Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi | Bin 3040 -> 
> 0 bytes
>  Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf |  24 
> 
>  Platform/Hisilicon/D03/Drivers/OhciDxe/NativeOhci.efi  | Bin 21664 
> -> 22336 bytes
>  Platform/Hisilicon/D03/Drivers/Sas/SasDriverDxe.efi| Bin 98112 
> -> 100224 bytes
>  Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi | Bin 3040 -> 
> 0 bytes
>  Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf |  24 
> 
>  Platform/Hisilicon/D03/bl1.bin | Bin 14336 
> -> 12416 bytes
>  Platform/Hisilicon/D03/fip.bin | Bin 62513 
> -> 66758 bytes
>  Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.efi | Bin 28544 
> -> 27680 bytes
>  Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.efi | Bin 3392 -> 
> 0 bytes
>  Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf |  24 
> 
>  Platform/Hisilicon/D05/Drivers/OhciDxe/NativeOhci.efi  | Bin 23328 
> -> 22624 bytes
>  Platform/Hisilicon/D05/Drivers/Sas/SasDriverDxe.efi| Bin 112832 
> -> 115008 bytes
>  Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.efi | Bin 3424 -> 
> 0 bytes
>  Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf |  24 
> 
>  Platform/Hisilicon/D05/bl1.bin | Bin 14344 
> -> 12424 bytes
>  Platform/Hisilicon/D05/fip.bin | Bin 41493 
> -> 37546 bytes
>  18 files changed, 96 deletions(-)
>  delete mode 100644 
> Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.efi
>  delete mode 100644 
> Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf
>  delete mode 100644 Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.efi
>  delete mode 100644 Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf
>  delete mode 100644 
> Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.efi
>  delete mode 100644 
> Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf
>  delete mode 100644 Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.efi
>  delete mode 100644 Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf
> 
> -- 
> 1.9.1
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] test message

2018-02-07 Thread Laszlo Ersek
Hi All,

my deepest apology for spamming the list with a test message. I have been 
having problems sending emails to the list, both with git-send-email (i.e. 
patches) and with Thunderbird (i.e. manually written emails). Both kinds have 
been rejected with SPF (Sender Policy Framework) error messages, blaming the 
Red Hat side mail server configuration.

I have a ticket open with the Red Hat Service Desk, and they're now asking me 
to test-email the list using a third channel (the internal RH webmail 
interface; so neither git-send-email nor Thunderbird from my laptop). If this 
email gets through then it should help the analysis I suppose (hope!); on the 
other hand it will also be spam for subscribers, and annoy them. Sorry about 
that!

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


Re: [edk2] [PATCH 10/10] MdeModulePkg/ResetSystemPei: Add reset notifications in PEI

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Bret Barkelew 

The Reset Notification protocol is added in UEFI spec to support
reset notification mechanism in the DXE phase.
This patch adds similar EDKII specific Reset Notification PPI to PEI
phase to provide the same support.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bret Barkelew 
Signed-off-by: Ruiyu Ni 
---
  .../Ppi/PlatformSpecificResetNotification.h| 31 ++
  MdeModulePkg/MdeModulePkg.dec  |  3 +++
  .../Universal/ResetSystemPei/ResetSystem.c | 16 +++
  .../Universal/ResetSystemPei/ResetSystem.h |  1 +
  .../Universal/ResetSystemPei/ResetSystemPei.inf|  7 ++---
  5 files changed, 55 insertions(+), 3 deletions(-)
  create mode 100644 
MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h

diff --git a/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h 
b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
new file mode 100644
index 00..ea53e24133
--- /dev/null
+++ b/MdeModulePkg/Include/Ppi/PlatformSpecificResetNotification.h
@@ -0,0 +1,31 @@
+/** @file
+  This PPI provides services to register a platform specific notification 
callback for
+  ResetSystem().  The registered handlers are processed after
+  EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI notifications.


How about adding "and after EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI" 
at the end of the sentence?


And also need enhance the comments in 
MdeModulePkg\Include\Ppi\PlatformSpecificResetFilter.h to state it will 
be processed before EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI 
instead of EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PPI.


And also need enhance the comments in 
MdeModulePkg\Include\Ppi\PlatformSpecificResetHandler.h to state it will 
be processed after EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI 
instead of EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PPI.



Thanks,
Star


+
+  Copyright (c) 2017 Intel Corporation. All rights reserved.
+  Copyright (c) 2017 Microsoft Corporation. All rights reserved.
+
+  This program and the accompanying materials are licensed and made available 
under
+  the terms and conditions of the BSD License that accompanies this 
distribution.
+  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
+#define _PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_H_
+
+#include 
+
+#define EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI_GUID \
+  { 0xe09f355d, 0xdae8, 0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0x0f, 0xdc, 0xf7, 
0xcb } }
+
+typedef EFI_RESET_NOTIFICATION_PROTOCOL  
EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PPI;
+
+extern EFI_GUID gEdkiiPlatformSpecificResetNotificationPpiGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 1b971d599f..297b02ffa9 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -444,6 +444,9 @@ [Ppis]
## Include/Ppi/PlatformSpecificResetFilter.h
gEdkiiPlatformSpecificResetFilterPpiGuid = { 0x8c9f4de3, 0x7b90, 0x47ef, { 
0x93, 0x8, 0x28, 0x7c, 0xec, 0xd6, 0x6d, 0xe8 } }
  
+  ## Include/Ppi/PlatformSpecificResetNotification.h

+  gEdkiiPlatformSpecificResetNotificationPpiGuid = { 0xe09f355d, 0xdae8, 
0x4910, { 0xb1, 0x4a, 0x92, 0x78, 0xf, 0xdc, 0xf7, 0xcb } }
+
## Include/Ppi/PlatformSpecificResetHandler.h
gEdkiiPlatformSpecificResetHandlerPpiGuid = { 0x75cf14ae, 0x3441, 0x49dc, { 
0xaa, 0x10, 0xbb, 0x35, 0xa7, 0xba, 0x8b, 0xab } }
  
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c

index 720593de6a..4dfe303f77 100644
--- a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
@@ -25,6 +25,7 @@ EFI_PEI_RESET2_PPI mPpiReset2 = {
  
  EFI_GUID*mProcessingOrder[] = {

&gEdkiiPlatformSpecificResetFilterPpiGuid,
+  &gEdkiiPlatformSpecificResetNotificationPpiGuid,
&gEdkiiPlatformSpecificResetHandlerPpiGuid
  };
  
@@ -36,6 +37,14 @@ RESET_FILTER_INSTANCE   mResetFilter = {

&gEdkiiPlatformSpecificResetFilterPpiGuid
  };
  
+RESET_FILTER_INSTANCE   mResetNotification = {

+  {
+RegisterResetNotify,
+UnregisterResetNotify
+  },
+  &gEdkiiPlatformSpecificResetNotificationPpiGuid
+};
+
  RESET_FILTER_INSTANCE   mResetHandler = {
{
  RegisterResetNotify,
@@ -55,6 +64,11 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
  &gEdkiiPlatformSpecificResetFilterPpiGuid,
  &mResetFilter.ResetFilter
},
+  {
+EFI_PEI_PPI_DESCRIPTOR_PPI,
+&gEdkiiPlatformSpecificResetNotificationPpiGuid,
+&mResetNotification.ResetFilter
+  },
{
  EFI_PEI_PPI_DE

Re: [edk2] [PATCH 09/10] MdeModulePkg: Add ResetSystemPei PEIM

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

This driver implements Reset2, ResetFilter and ResetHandler PPIs.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 


Should ResetSystemPei be added in MdeModulePkg.dsc for build coverage?

Same comment has been provided to ResetSystemRuntimeDxe.
Should be (*RecursionDepthPointer < MAX_RESET_NOTIFY_DEPTH) instead of 
(*RecursionDepthPointer <= MAX_RESET_NOTIFY_DEPTH)>



Thanks,
Star


---
  MdeModulePkg/MdeModulePkg.dec  |   4 +
  .../Universal/ResetSystemPei/ResetSystem.c | 355 +
  .../Universal/ResetSystemPei/ResetSystem.h | 129 
  .../Universal/ResetSystemPei/ResetSystemPei.inf|  62 
  .../Universal/ResetSystemPei/ResetSystemPei.uni|  20 ++
  .../ResetSystemPei/ResetSystemPeiExtra.uni |  20 ++
  6 files changed, 590 insertions(+)
  create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
  create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystem.h
  create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.inf
  create mode 100644 MdeModulePkg/Universal/ResetSystemPei/ResetSystemPei.uni
  create mode 100644 
MdeModulePkg/Universal/ResetSystemPei/ResetSystemPeiExtra.uni

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 1cc9bc8ea1..1b971d599f 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1419,6 +1419,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
# @Prompt CapsuleMax value in capsule report variable.
gEfiMdeModulePkgTokenSpaceGuid.PcdCapsuleMax|0x|UINT16|0x0107
  
+  ## Indicates the allowable maximum number of Reset Filters or Reset Handlers in PEI phase.

+  # @Prompt Maximum Number of PEI Reset Filters or Reset Handlers.
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdMaximumPeiResetNotifies|0x10|UINT32|0x0109
+
  [PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This PCD defines the Console output row. The default value is 25 
according to UEFI spec.
#  This PCD could be set to 0 then console output would be at max column 
and max row.
diff --git a/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c 
b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
new file mode 100644
index 00..720593de6a
--- /dev/null
+++ b/MdeModulePkg/Universal/ResetSystemPei/ResetSystem.c
@@ -0,0 +1,355 @@
+/** @file
+  Implementation of Reset2, ResetFilter and ResetHandler PPIs.
+
+  Copyright (c) 2017, 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 "ResetSystem.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {
+  L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
+};
+
+EFI_PEI_RESET2_PPI mPpiReset2 = {
+  ResetSystem2
+};
+
+EFI_GUID*mProcessingOrder[] = {
+  &gEdkiiPlatformSpecificResetFilterPpiGuid,
+  &gEdkiiPlatformSpecificResetHandlerPpiGuid
+};
+
+RESET_FILTER_INSTANCE   mResetFilter = {
+  {
+RegisterResetNotify,
+UnregisterResetNotify
+  },
+  &gEdkiiPlatformSpecificResetFilterPpiGuid
+};
+
+RESET_FILTER_INSTANCE   mResetHandler = {
+  {
+RegisterResetNotify,
+UnregisterResetNotify
+  },
+  &gEdkiiPlatformSpecificResetHandlerPpiGuid
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPpiListReset[] = {
+  {
+EFI_PEI_PPI_DESCRIPTOR_PPI,
+&gEfiPeiReset2PpiGuid,
+&mPpiReset2
+  },
+  {
+EFI_PEI_PPI_DESCRIPTOR_PPI,
+&gEdkiiPlatformSpecificResetFilterPpiGuid,
+&mResetFilter.ResetFilter
+  },
+  {
+EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+&gEdkiiPlatformSpecificResetHandlerPpiGuid,
+&mResetHandler.ResetFilter
+  }
+};
+
+/**
+  Register a notification function to be called when ResetSystem() is called.
+
+  The RegisterResetNotify() function registers a notification function that is 
called when
+  ResetSystem()is called and prior to completing the reset of the platform.
+  The registered functions must not perform a platform reset themselves. These
+  notifications are intended only for the notification of components which may 
need some
+  special-purpose maintenance prior to the platform resetting.
+  The list of registered reset notification functions are processed if 
ResetSystem()is called
+  before ExitBootServices(). The list of registered reset notification 
functions is ignored if
+  ResetSystem()is called after ExitBootServices().
+
+  @param[in]  This  A pointer to the 
EFI_RESET_NOTIFICATION_PROTOCOL instance.
+  @param[in]  ResetFunct

[edk2] [Patch V2] INF spec: Add flexible PCD value format into spec

2018-02-07 Thread Yonghong Zhu
V2: update EBNF for Array format.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 .../32_component_inf_definition.md | 75 +-
 3_edk_ii_inf_file_format/38_pcd_sections.md| 39 ++-
 2 files changed, 83 insertions(+), 31 deletions(-)

diff --git a/3_edk_ii_inf_file_format/32_component_inf_definition.md 
b/3_edk_ii_inf_file_format/32_component_inf_definition.md
index 72bcf2c..ef70927 100644
--- a/3_edk_ii_inf_file_format/32_component_inf_definition.md
+++ b/3_edk_ii_inf_file_format/32_component_inf_definition.md
@@ -111,15 +111,16 @@ The following are common definitions used by multiple 
section types.
   ::= (0-9)
::= (a-zA-Z_)
  ::=  *
   ::=  # A valid C variable name.
  ::= (0x21 - 0x7E)
- ::= [{0x21} {(0x23 - 0x5B)} {(0x5D - 0x7E)}
- {}]*
+ ::= [{0x21} {(0x23 - 0x26)} {(0x28 - 0x5B)}
+ {(0x5D - 0x7E)} {}]*
::= 0x22
+   ::= 0x27
  ::= "\" {"n"} {"t"} {"f"} {"r"} {"b"} {"0"} {"\"}
- {}
+ {} {}
::= {} {}
  ::= *
 ::= +
 ::= 0x09
   ::= 0x20
@@ -137,15 +138,16 @@ The following are common definitions used by multiple 
section types.
 ::= [ * * ]*
 ::= 
  ::= 
  ::= {} {}
::=  * 
-::= ["L"] 
+::=  * 
+::= {} {}
::=  [{} {}]+ 
   ::=  "#" [] +
 ::= "#"  +
-  ::= "L" 
+  ::= "L" {} {}
::= (a-fA-F0-9)
 ::= {"0x"} {"0X"}  
   ::= {"0x"} {"0X"} *
  ::= "0x"  
   ::= ? ? ?
@@ -181,14 +183,14 @@ The following are common definitions used by multiple 
section types.
   ::= {} {}
::= (\x1 - \x)
::= (1-18446744073709551615)
   ::= {} {}
 ::= {"TRUE"} {"true"} {"True"} {"0x1"} {"0x01"} {"1"}
-  {}
::= {"FALSE"} {"false"} {"False"} {"0x0"}
   {"0x00"} {"0"}
-::= {} {}
+ ::= {} {}
+::= {} {"{""}"}
::= (A-Z)(A-Z0-9_)*
 ::= "$("  ")"
  ::=  "." 
 ::= 
  ::= 
@@ -209,14 +211,49 @@ The following are common definitions used by multiple 
section types.

 ::= (0-255)
   ::= (0-65535)
  ::= (0-4294967295)
  ::= (0-18446744073709551615)
- ::= {} {}
-::= {} {}
-::= {} {}
-::= {} {}
+::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  {} {}
+ ::= {} {"{""}"}
+::= {}
+  {"{" [ ]*"}"}
+::= {}
+  {"{" [ ]*"}"}
+::= {}
+  {"{" [ ]*"}"}
+   ::= {} {} {}
+   ::= "{" {} {[] 
+   [ [] ]* } "}"
+::= {} {} {}
+  ::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  ::= {} {} {}
+  ::= {} {} {}
+  ::= {} {} {}
+ ::= "GUID("  ")"
+ ::= {  }
+  {} {}
+  ::= "DEVICE_PATH("  ")"
+   ::= A double quoted string that follow the device path
+  as string format defined in UEFI Specification 2.6
+  Section 9.6
+ ::= {} {} {} 
{}
+::= "UINT8("  ")"
+   ::= "UINT16("  ")"
+   ::= "UINT32("  ")"
+   ::= "UINT64("  ")"
+   ::= "LABEL("  ")"
+  ::= "OFFSET_OF("  ")"
   ::= {"BASE"} {"SEC"} {"PEI_CORE"} {"PEIM"}
   {"DXE_CORE"} {"DXE_DRIVER"} {"SMM_CORE"}
   {"DXE_RUNTIME_DRIVER"} {"DXE_SAL_DRIVER"}
   {"DXE_SMM_DRIVER"} {"UEFI_DRIVER"}
   {"UEFI_APPLICATION"} {"USER_DEFINED"}
@@ -233,10 +270,18 @@ The following are common definitions used by multiple 
section types.
   {"SMM_CORE"} {"DXE_SMM_DRIVER"}
   {"UEFI_DRIVER"} {"UEFI_APPLICATION"}
 ```
 
 **
+**Note:** When using CString, UnicodeString or byte array format as
+UINT8/UINT16/UINT32/UINT64 values, please make sure they fit in the
+target type's size, otherwise tool would report failure.
+**
+**Note:** LABEL() macro in byte arrays to tag the byte offset of a
+location in a byte array. OFFSET_OF() macro in byte arrays that returns
+the byte offset of a LABEL() declared in a byte array.
+**

[edk2] [Patch V2] DEC spec: Add flexible PCD value format into spec

2018-02-07 Thread Yonghong Zhu
V2: update EBNF for Array format.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 3_edk_ii_dec_file_format/310_pcd_sections.md   | 14 ++--
 .../32_package_declaration_dec_definitions.md  | 74 ++
 2 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/3_edk_ii_dec_file_format/310_pcd_sections.md 
b/3_edk_ii_dec_file_format/310_pcd_sections.md
index 488f17f..36c32ff 100644
--- a/3_edk_ii_dec_file_format/310_pcd_sections.md
+++ b/3_edk_ii_dec_file_format/310_pcd_sections.md
@@ -113,24 +113,24 @@ PCDs listed in `PcdsFeatureFlag` sections must only be 
listed in
   [ ]
   [] 
 ::=  {} {} {}
  ::= {} {} {} {}
  ::=  
- ::=   "BOOLEAN"
+ ::=   "BOOLEAN"
  ::= {} {}
 ::=  
-::=   "UINT8"
+::= {} {}  "UINT8"
::=  
-   ::=   "UINT16"
+   ::= {} {}  "UINT16"
::=  
-   ::=   "UINT32"
+   ::= {} {}  "UINT32"
::=  
-   ::=   "UINT64"
+   ::= {} {}  "UINT64"
   ::=  
::=   "VOID*"
-  ::= {} {}
-   ::= 
+  ::= {} {}
+   ::= {} {}
   ::=  {+} {} {+}
   ::= "#"  "@Prompt   
::= "#"  "@ValidRange"   
 ::= [ ] 
 ::= "#"  "@ValidList"   
diff --git a/3_edk_ii_dec_file_format/32_package_declaration_dec_definitions.md 
b/3_edk_ii_dec_file_format/32_package_declaration_dec_definitions.md
index 8e473f2..c701603 100644
--- a/3_edk_ii_dec_file_format/32_package_declaration_dec_definitions.md
+++ b/3_edk_ii_dec_file_format/32_package_declaration_dec_definitions.md
@@ -86,15 +86,16 @@ DEC file (for example, `` statements are not 
permitted).
::= (0-9)
 ::= (a-zA-Z_)
   ::=  *
::=  # A valid C variable name.
   ::= (0x21 - 0x7E)
-  ::= [{0x21} {(0x23 - 0x5B)} {(0x5D - 0x7E)}
-  {}]*
+  ::= [{0x21} {(0x23 - 0x26)} {(0x28 - 0x5B)}
+  {(0x5D - 0x7E)} {}]*
 ::= 0x22
+::= 0x27
   ::= "\" {"n"} {"t"} {"f"} {"r"} {"b"} {"0"} {"\"}
-  {}
+  {} {}
 ::= {} {}
   ::= *
  ::= +
  ::= 0x09
::= 0x20
@@ -112,15 +113,16 @@ DEC file (for example, `` statements are not 
permitted).
  ::= [ * * ]*
  ::= 
   ::= 
   ::= {} {}
 ::=  * 
- ::= ["L"] 
+ ::=  * 
+ ::= {} {}
 ::=  [{} {}]+ 
::=  "#" [ ] +
  ::= "#"   +
-   ::= "L" 
+   ::= "L" {} {}
 ::= (a-fA-F0-9)
  ::= {"0x"} {"0X"} [] 
::= {"0x"} {"0X"} +
   ::= "0x" [0]*  
::= ? ? ?
@@ -157,11 +159,12 @@ DEC file (for example, `` statements are not 
permitted).
   ::= {} {}
 ::= {"TRUE"} {"true"} {"True"} {"0x1"}
   {"0x01"} {"1"}
::= {"FALSE"} {"false"} {"False"} {"0x0"}
   {"0x00"} {"0"}
-::= {} {}
+ ::= {} {}
+::= {} {"{""}"}
::= (A-Z)(A-Z0-9_)*
 ::= "$("  ")"
  ::=  "." 
 ::= 
  ::= 
@@ -182,14 +185,49 @@ DEC file (for example, `` statements are not 
permitted).

 ::= (0-255)
   ::= (0-65535)
  ::= (0-4294967295)
  ::= (0-18446744073709551615)
- ::= {} {}
-::= {} {}
-::= {} {}
-::= {} {}
+::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  {} {}
+   ::= {} {} {}
+  {} {}
+ ::= {} {"{""}"}
+::= {}
+  {"{" [ ]*"}"}
+::= {}
+  {"{" [ ]*"}"}
+::= {}
+  {"{" [ ]*"}"}
+   ::= {} {} {}
+   ::= "{" {} {[]  
+   [ [] ]* } "}"
+::= {} {} {} 
+  ::= {}{} {}
+  {} {}
+   ::= {} {} {}
+  ::= {} {} {}
+  ::= {} {} {}
+  ::= {} {} {}
+ ::= "GUID("  ")"
+ ::= {  }
+  {} {}
+  ::= "DEVICE_PATH("  ")"
+   ::= A double quoted string that follow the device path
+  as string format defined in UEFI Specification 2.6
+  Section 9.6
+ ::= {} {} {} 
{}
+::= "UINT8("  ")"
+   ::= "UINT16("  ")"
+   ::= "UINT32("  ")"
+   ::= "UINT64("  ")"
+   ::= "LABEL("  ")"
+   

[edk2] [Patch V2] Build spec: Add flexible PCD value format into spec

2018-02-07 Thread Yonghong Zhu
V2: update EBNF for Array format.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 7_build_environment/73_guided_tools.md |  8 +--
 .../82_auto-generation_process.md  | 18 +++---
 appendix_d_buildexe_command/d4_usage.md| 72 +++---
 3 files changed, 77 insertions(+), 21 deletions(-)

diff --git a/7_build_environment/73_guided_tools.md 
b/7_build_environment/73_guided_tools.md
index a8881d3..50119f1 100644
--- a/7_build_environment/73_guided_tools.md
+++ b/7_build_environment/73_guided_tools.md
@@ -119,21 +119,21 @@ file required by the build system is provided in the 
appendix, VPD Tool.
 ```
 
   If using automatic offset feature, the build tools byte-align numeric values,
   while `VOID*` PCD types will be aligned using the following rules:
 
-  * ASCII strings, "string", will be byte aligned.
-  * Unicode strings, L"string" will be two-byte aligned.
+  * ASCII strings, "string" or 'string', will be byte aligned.
+  * Unicode strings, L"string" or L'string' will be two-byte aligned.
   * Byte arrays, {0x00, 0x01} will be 8-byte aligned.
 
   If the developer manually assigns offset values in the DSC file, the 
developer
   must follow the same rules.
 
   **
   **Note:** If a developer manually sets the offset of a `VOID*` PCD with
-  Unicode string, L"string", style to a value that is not 2-byte aligned, then
-  an error is generated and the build halts.
+  Unicode string, L"string"/L'string' style to a value that is not 2-byte 
aligned,
+  then an error is generated and the build halts.
   **
   **Note:** If a developer manually sets the offset of a `VOID*` PCD with byte
   array {} style to a value that is not 8-byte aligned, then a warning is
   generated, but the build will continue.
   **
diff --git a/8_pre-build_autogen_stage/82_auto-generation_process.md 
b/8_pre-build_autogen_stage/82_auto-generation_process.md
index f610185..5a950d7 100644
--- a/8_pre-build_autogen_stage/82_auto-generation_process.md
+++ b/8_pre-build_autogen_stage/82_auto-generation_process.md
@@ -875,41 +875,41 @@ A PCD value set on the command-line has the highest 
precedence. It overrides
 all instances of the PCD value specified in the DSC or FDF file. The following
 is the syntax to override the value of a PCD on the command line:
 
 `--pcd [.]=`
 
-For `VOID*` type PCDs, `` supports the following syntax:
+`` supports the following syntax:
 
-* ASCII string value for a `VOID*` PCD
+* ASCII string value for a PCD
 
   `--pcd  [.]="String"`
+  `--pcd  [.]='String'`
 
-*  Unicode string value for a `VOID*` PCD
+* Unicode string value for a PCD
 
   `--pcd  [.]=L"String"`
+  `--pcd  [.]=L'String'`
 
-*  Byte array value for a `VOID*` PCD
+* Byte array value for a PCD
 
   `--pcd  [.]= H"{0x1, 0x2}"`
 
 **
 **Note:** The EDK II meta-data specs have changed to permit a PCD entry (or any
 other entry) to be listed only one time per section.
 **
-**Caution:** Dynamic and DynamicEx `VOID*` VPD PCD array values must be hex 
byte
-arrays. Using a Registry or C format GUID value in the value field of a `VOID*`
-VPD PCD is not permitted.
-**
 
 If the maximum size of a `VOID*` PCD is not specified in the DSC file, then the
 maximum size is calculated based on the largest size of 1) the string or array
 in the DSC file, 2) the string or array in the INF file and 3) the string or
 array in the DEC file. If the value is a quoted text string, the size of the
 string will be incremented by one to handle string termination. If the quoted
 string is preceded by L, as in `L"This is a string"`, then the size of the 
string
 will be incremented by two to handle unicode string termination. If the value
-is a byte array, then the size of the byte array is not modified.
+is a byte array, then the size of the byte array is not modified. If the value 
is
+a single quoted string, as in 'string' or L'string', the size of the string 
doesn't
+need to include string null termination character.
 
 For example, if the string in the DSC file is `L"DSC Length"`, the INF file has
 `L"Module Length"` and the DEC file declares the default as `L"Length"`, then
 the maximum size that will be allocated for this PCD will be 28 bytes (`
 L"Module Length"` 26 bytes, 2 bytes for null termination character).
diff --git a/appendix_d_buildexe_command/d4_usage.md 
b/appendix_d_buildexe_command/d4_usage.md
index c901266..57d2656 100644
--- a/appendix_d_buildexe_command/d4_usage.md
+++ b/appendix_d_buildexe_command/d4_usage.md
@@ -195,24 +195,80 @@ precedence over PCD provided in DSC, FDF, INF, and DEC 
files.
 
 ```c
::= "--pcd"  ["=" ] 
   ::= 0x20
  ::= +
+  ::= *
+  ::= "," *
+::= (a-fA-F0-9)
+   ::= A valid C variable name.
  ::= [ "."] 
  ::= C Variable Name of the Token Space GUID
 ::= C 

[edk2] [Patch V2] Expression spec: update format to support flexible Pcd format

2018-02-07 Thread Yonghong Zhu
V2: update EBNF for Array format.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 2_expression_overview.md |  3 +++
 3_expression_format.md   | 50 +++-
 2 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/2_expression_overview.md b/2_expression_overview.md
index 34ceb97..c29a632 100644
--- a/2_expression_overview.md
+++ b/2_expression_overview.md
@@ -100,5 +100,8 @@ directives section do not apply.
 12. Logical operators require operands that are type scalar.
 
 13. For the Conditional Operator, the first operand must be scalar, while the
 second and third operands must have the same type (i.e., both being scalar,
 both being integers, or both being string literals).
+
+14. Array format like "{0x10, 0x20}" can't be a operand of any operator except
+Relational and equality operators.
diff --git a/3_expression_format.md b/3_expression_format.md
index 50b94c4..1f90fc9 100644
--- a/3_expression_format.md
+++ b/3_expression_format.md
@@ -93,10 +93,21 @@ GRACEFULLY._
  ::= 
 ::=  []+
   ::= (a-fA-F0-9)
  ::= {"0x"} {"0X"}
  ::= {} {}
+ ::=  (\x0 - \xFF)
+::=  (\x0 - \x)
+::=  (\x0 - \x)
+::=  (\x0 - \x)
+  ::= (0-255)
+::= (0-65535)
+   ::= (0-4294967295)
+   ::= (0-18446744073709551615)
+   ::= "GUID("  ")"
+   ::= {  }
+{} {}
 Rhex2   ::= [] 
 Rhex4   ::= [] [] Rhex2
 Rhex8   ::= [] [] [] 
[] Rhex4
::= Rghex8 "-" Rghex4 "-" Rghex4 "-" Rghex4 "-" Rghex12
 Rghex2  ::=  
@@ -111,19 +122,42 @@ Rghex12 ::=   
  Rghex8
::= "{" []* 
  ::=   "{" []*   
  ::=   
  ::=   
  ::=  []* "}" []* "}"
- ::= {} {}
+ ::= {} {}
 ::= "{" * "}"
- ::= "{" *  [ ]* "}"
+ ::= "{" * []  
+ [ [] ]* "}"
+  ::= {} {} {}
+::= "DEVICE_PATH("  ")"
+ ::= A double quoted string that follow the device path
+as string format defined in UEFI Specification 2.6
+Section 9.6
+ ::= "LABEL("  ")"
+::= "OFFSET_OF("  ")"
  ::= {} {"L" }
+{} {"L" }
   ::= 0x22
+  ::= 0x27
   ::=  []* 
+   ::=  []* 
  ::= {} {}
-   ::= {0x20} {0x21} {(0x23 - 0x5B)} {(0x5D - 0x7E)}
- ::= "\" {"n"} {"r"} {"t"} {"f"} {"b"} {"0"} {"\"} 
{}
+   ::= {0x21} {(0x23 - 0x26)} {(0x28 - 0x5B)}
+{(0x5D - 0x7E)} {}
+ ::= "\" {"n"} {"r"} {"t"} {"f"} {"b"} {"0"} {"\"}
+{} {}
+::= {} {} {} 
{}
+ ::= {} {} {}
+::= {} {} {}
+::= {} {} {}
+::= {} {} {}
+   ::= {} {} {} 
{}
+  ::= "UINT8("  ")"
+ ::= "UINT16("  ")"
+ ::= "UINT32("  ")"
+ ::= "UINT64("  ")"
  ::= {} {}
::=  "." 
::= {} { }
::= {} {}
 ::= {"+"} {"-"} {"~"}
@@ -187,13 +221,19 @@ gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress | 
!gCrownBayTokenSpaceGuid.
 
 This is the value of the MACRO assigned in a DEFINE statement.
 
 **Expressions**
 
-If the "|" character is used in an expression, the expression must be
+If the "|" or "||"character is used in an expression, the expression must be
 encapsulated by parenthesis.
 
+**OFFSET_OF()**
+
+LABEL() macro in byte arrays to tag the byte offset of a location in a byte
+array. OFFSET_OF() macro in byte arrays that returns the byte offset of a
+LABEL() declared in a byte array.
+
 ## 3.2 Conditional Directive Expressions
 
 Conditional directive statements are defined in the EDK II Platform Description
 (DSC) File and Flash Definition (FDF) File. The following EBNF describes the
 format for expressions used in conditional directives. The format is based on
-- 
2.6.1.windows.1

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


[edk2] [Patch V2] DSC spec: Add flexible PCD value format into spec

2018-02-07 Thread Yonghong Zhu
V2: update EBNF for Array format.

Cc: Liming Gao 
Cc: Michael Kinney 
Cc: Kevin W Shaw 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu 
---
 3_edk_ii_dsc_file_format/310_pcd_sections.md   | 160 +
 .../33_platform_dsc_definition.md  |  78 +++---
 2 files changed, 161 insertions(+), 77 deletions(-)

diff --git a/3_edk_ii_dsc_file_format/310_pcd_sections.md 
b/3_edk_ii_dsc_file_format/310_pcd_sections.md
index 2af42cc..18a243d 100644
--- a/3_edk_ii_dsc_file_format/310_pcd_sections.md
+++ b/3_edk_ii_dsc_file_format/310_pcd_sections.md
@@ -98,13 +98,11 @@ is permissible to list multiple architectures in a single 
method section as in:
 It is permissible to list a PCD in a common architecture section and also list
 it in an architecturally modified section. In this case, the value in the
 architectural section overrides the value specified in the common section.
 
 The PCD values must match the datum type declared for a given PCD in the DEC
-file. While a PCD of datum type `BOOLEAN` is permitted to have a `1` or a `0`
-(instead of TRUE or FALSE) in the value field, a PCD of type UINT* cannot use
-`TRUE` or `FALSE` for values.
+file.
 
 PCDs with a data type of `VOID`* can optionally provide the maximum size of the
 value. If not provided, the maximum length will be calculated as the largest of
 the size of the data in the DSC file, the size of the data in the INF file or
 the size of the data in the DEC file that declares the PCD.
@@ -220,21 +218,24 @@ fields that are separated by the pipe character, "|".
 ::=  [ ]*
::= 
 ::= 
  ::= {} {} {}
   ::=   [ ] 
-  ::= if (pcddatumtype == "BOOLEAN"): {} {}
-elif (pcddatumtype == "UINT8"): {}
-{} elif (pcddatumtype == "UINT16"):
-{} {} elif (pcddatumtype ==
-"UINT32"): {} {} elif
-(pcddatumtype == "UINT64"): {} {}
+  ::= if (pcddatumtype == "BOOLEAN"):
+  {} {}
+elif (pcddatumtype == "UINT8"):
+  {} {}
+elif (pcddatumtype == "UINT16"):
+  {} {}
+elif (pcddatumtype == "UINT32"):
+  {} {}
+elif (pcddatumtype == "UINT64"):
+  {} {}
 else:
- []
+   []
::=  "VOID*"  {} {}
-   ::= {} {} {}
-{} {}
+   ::= {} {} {}
 ```
 
  Parameters
 
 **_Expression_**
@@ -325,21 +326,24 @@ of the DSC file.
 ::=  [ ]*
::= 
 ::= 
  ::= {} {} {}
   ::=   [ ] 
-  ::= if (pcddatumtype == "BOOLEAN"): {} {}
-elif (pcddatumtype == "UINT8"): {}
-{} elif (pcddatumtype == "UINT16"):
-{} {} elif (pcddatumtype ==
-"UINT32"): {} {} elif
-(pcddatumtype == "UINT64"): {} {}
+  ::= if (pcddatumtype == "BOOLEAN"):
+  {} {}
+elif (pcddatumtype == "UINT8"):
+  {} {}
+elif (pcddatumtype == "UINT16"):
+  {} {}
+elif (pcddatumtype == "UINT32"):
+  {} {}
+elif (pcddatumtype == "UINT64"):
+  {} {}
 else:
- []
+   []
::=  {} {}
-   ::= {} {} {}
-{} {}
+   ::= {} {} {}
 ```
 
  Parameters
 
 **_Expression_**
@@ -458,41 +462,58 @@ sections of the DSC file.
   ::= "."  ["." ]
  ::=  [ ]*
 ::= 
  ::= 
::=  [ ] 
-   ::= if (pcddatumtype == "BOOLEAN"): {} {}
- elif (pcddatumtype == "UINT8"): {}
- {} elif (pcddatumtype == "UINT16"):
- {} {} elif (pcddatumtype ==
- "UINT32"): {} {} elif
- (pcddatumtype == "UINT64"): {}
- {} else:
-  []
+   ::= if (pcddatumtype == "BOOLEAN"):
+   {} {}
+ elif (pcddatumtype == "UINT8"):
+   {} {}
+ elif (pcddatumtype == "UINT16"):
+   {} {}
+ elif (pcddatumtype == "UINT32"):
+   {} {}
+ elif (pcddatumtype == "UINT64"):
+   {} {}
+ else:
+[]
 ::=  "VOID*" [ ]
   ::= {} {}
-::= {} {} {} {}
- {}
+::= {} {} {}
::=[ ] 
   ::= {} {"*"}
-::= if (pcddatumtype == "BOOLEAN"): {} {}
- elif (pcddatumtype == "UINT8"): {}
- {} elif (pcddatumtype == "UINT16"):
- {} {} elif (pcddatumtype ==
-

Re: [edk2] [PATCH 07/10] MdeModulePkg: Add ResetUtility librray class and BASE instance

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

The library class that provides services to generate a GUID specific
reset, parse the GUID from a GUID specific reset, and build the
ResetData buffer for any type of reset that requires extra data.

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Signed-off-by: Ruiyu Ni 


Should we also add below lines in MdeModulePkg.dec?

  ##  @libraryclass  Defines a set of helper functions for resetting 
the system

  ResetUtilityLib|Include/Library/ResetUtilityLib.h


Thanks,
Star


---
  MdeModulePkg/Include/Library/ResetUtilityLib.h | 111 +++
  .../Library/ResetUtilityLib/ResetUtility.c | 221 +
  .../Library/ResetUtilityLib/ResetUtilityLib.inf|  43 
  MdeModulePkg/MdeModulePkg.dsc  |   7 +
  4 files changed, 382 insertions(+)
  create mode 100644 MdeModulePkg/Include/Library/ResetUtilityLib.h
  create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c
  create mode 100644 MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf

diff --git a/MdeModulePkg/Include/Library/ResetUtilityLib.h 
b/MdeModulePkg/Include/Library/ResetUtilityLib.h
new file mode 100644
index 00..94828785e2
--- /dev/null
+++ b/MdeModulePkg/Include/Library/ResetUtilityLib.h
@@ -0,0 +1,111 @@
+/** @file
+  This header describes various helper functions for resetting the system.
+
+  Copyright (c) 2017 Intel Corporation. All rights reserved.
+  Copyright (c) 2016 Microsoft Corporation. All rights reserved.
+
+  This program and the accompanying materials are licensed and made available 
under
+  the terms and conditions of the BSD License that accompanies this 
distribution.
+  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#ifndef _RESET_UTILITY_LIB_H_
+#define _RESET_UTILITY_LIB_H_
+
+/**
+  This is a shorthand helper function to reset with a subtype so that
+  the caller doesn't have to bother with a function that has half a dozen
+  parameters.
+
+  This will generate a reset with status EFI_SUCCESS, a NULL string, and
+  no custom data. The subtype will be formatted in such a way that it can be
+  picked up by notification registrations and custom handlers.
+
+  NOTE: This call will fail if the architectural ResetSystem underpinnings
+are not initialized. For DXE, you can add gEfiResetArchProtocolGuid
+to your DEPEX.
+
+  @param[in]  ResetType Base reset type as defined in UEFI spec.
+  @param[in]  ResetSubtype  GUID pointer for the reset subtype to be used.
+
+**/
+VOID
+EFIAPI
+ResetPlatformSpecificGuid (
+  IN CONST  GUID*ResetSubtype
+  );
+
+/**
+  This function examines the DataSize and ResetData parameters passed to
+  to ResetSystem() and detemrines if the ResetData contains a Null-terminated
+  Unicode string followed by a GUID specific subtype.  If the GUID specific
+  subtype is present, then a pointer to the GUID value in ResetData is 
returned.
+
+  @param[in]  DataSizeThe size, in bytes, of ResetData.
+  @param[in]  ResetData   Pointer to the data buffer passed into ResetSystem().
+
+  @retval Pointer Pointer to the GUID value in ResetData.
+  @retval NULLResetData is NULL.
+  @retval NULLResetData does not start with a Null-terminated
+  Unicode string.
+  @retval NULLA Null-terminated Unicode string is present, but 
there
+  are less than sizeof (GUID) bytes after the string.
+  @retval NULLNo subtype is found.
+
+**/
+GUID *
+EFIAPI
+GetResetPlatformSpecificGuid (
+  IN UINTN   DataSize,
+  IN CONST VOID  *ResetData
+  );
+
+/**
+  This is a helper function that creates the reset data buffer that can be
+  passed into ResetSystem().
+
+  The reset data buffer is returned in ResetData and contains ResetString
+  followed by the ResetSubtype GUID followed by the ExtraData.
+
+  NOTE: Strings are internally limited by MAX_UINT16.
+
+  @param[in, out] ResetDataSize  On input, the size of the ResetData buffer. On
+ output, either the total number of bytes
+ copied, or the required buffer size.
+  @param[in, out] ResetData  A pointer to the buffer in which to place the
+ final structure.
+  @param[in]  ResetSubtype   Pointer to the GUID specific subtype.  This
+ parameter is optional and may be NULL.
+  @param[in]  ResetStringPointer to a Null-terminated Unicode string
+ that describes the reset.  This parameter is
+ optional and may be NU

Re: [edk2] [PATCH 08/10] MdePkg/UefiRuntimeLib: Support more module types.

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

Because DxeResetSystemLib links to this library to provide
reset system services, change UefiRuntimeLib to support
the same set of module types as what DxeResetSystemLib does.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 


Do you think it is ok or not to let DxeResetSystemLib consume 
UefiRuntimeServicesTableLib and use gRT->ResetSystem? Then this patch 
will be not needed.


If we still prefer to let DxeResetSystemLib consume UefiRuntimeLib, I am 
also ok. Reviewed-by: Star Zeng 


Thanks,
Star


---
  MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf 
b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
index 8f46495fc5..d053da545a 100644
--- a/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+++ b/MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
@@ -5,7 +5,7 @@
  #  EVT_SIGNAL_EXIT_BOOT_SERVICES event, to provide runtime services.
  # This instance also supports SAL drivers for better performance.
  #
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2017, 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
@@ -24,7 +24,7 @@ [Defines]
FILE_GUID  = b1ee6c28-54aa-4d17-b705-3e28ccb27b2e
MODULE_TYPE= DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
-  LIBRARY_CLASS  = UefiRuntimeLib|DXE_RUNTIME_DRIVER 
DXE_SAL_DRIVER
+  LIBRARY_CLASS  = UefiRuntimeLib|DXE_RUNTIME_DRIVER 
DXE_SAL_DRIVER DXE_CORE DXE_DRIVER DXE_SMM_DRIVER
  
CONSTRUCTOR= RuntimeDriverLibConstruct

DESTRUCTOR = RuntimeDriverLibDeconstruct



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


Re: [edk2] [PATCH 06/10] MdeModulePkg: Add ResetSystemLib instances that call core services

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

Add a PEI instance of ResetSystemLib that calls the ResetSystem2()
service in the PEI Services Table.

Add a DXE instance of ResetSystemLib that calls the ResetSystem()
service in the UEFI Runtime Services Table.

These 2 library instances should be the default ResetSystemLib
mapping for most PEIMs and DXE drivers so all reset system requests
go through the core service.

Only the implementation of the core servies should use the
platform specific instance of the ResetSystemLib that actually
performs the hardware actions to reset the platform.

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 


Could we remove DebugLib in *.inf and #include  in 
*.c as the code seems not using any DebugLib interface at all?



Thanks,
Star


---
  .../Library/DxeResetSystemLib/DxeResetSystemLib.c  | 100 +
  .../DxeResetSystemLib/DxeResetSystemLib.inf|  40 +
  .../DxeResetSystemLib/DxeResetSystemLib.uni|  21 +
  .../Library/PeiResetSystemLib/PeiResetSystemLib.c  | 100 +
  .../PeiResetSystemLib/PeiResetSystemLib.inf|  40 +
  .../PeiResetSystemLib/PeiResetSystemLib.uni|  21 +
  6 files changed, 322 insertions(+)
  create mode 100644 MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
  create mode 100644 
MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
  create mode 100644 
MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.uni
  create mode 100644 MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c
  create mode 100644 
MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
  create mode 100644 
MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.uni

diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c 
b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
new file mode 100644
index 00..70ee1175d5
--- /dev/null
+++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c
@@ -0,0 +1,100 @@
+/** @file
+  DXE Reset System Library instance that calls gRT->ResetSystem().
+
+  Copyright (c) 2017, 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 
+
+/**
+  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
+  )
+{
+  EfiResetSystem (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
+  )
+{
+  EfiResetSystem (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
+  )
+{
+  EfiResetSystem (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
+  )
+{
+  EfiResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
+}
diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf 
b/MdeModulePkg/Library/DxeResetSys

Re: [edk2] [PATCH 05/10] MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

The patch adds more debug message in ResetSystem().
It also removes unnecessary check of mResetNotifyDepth.

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni 
---
  .../Universal/ResetSystemRuntimeDxe/ResetSystem.c  | 88 +++---
  1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c 
b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
index 43400e1338..4b5af76999 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c
@@ -15,6 +15,10 @@
  
  #include "ResetSystem.h"
  
+GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = {

+  L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific"
+};
+
  //
  // The current ResetSystem() notification recursion depth
  //
@@ -251,16 +255,6 @@ ResetSystem (
LIST_ENTRY  *Link;
RESET_NOTIFY_ENTRY  *Entry;
  
-  //

-  // Above the maximum recursion depth, so do the smallest amount of
-  // work to perform a cold reset.
-  //
-  if (mResetNotifyDepth >= MAX_RESET_NOTIFY_DEPTH) {
-ResetCold ();
-ASSERT (FALSE);
-return;
-  }
-
//
// Only do REPORT_STATUS_CODE() on first call to ResetSystem()
//
@@ -272,40 +266,47 @@ ResetSystem (
}
  
mResetNotifyDepth++;

-  if (!EfiAtRuntime () && mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH) {
-//
-// Call reset notification functions registered through the
-// EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
-//
-for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
-; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
-; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, 
Link)
-) {
-  Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
-  Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
-}
-//
-// Call reset notification functions registered through the
-// EFI_RESET_NOTIFICATION_PROTOCOL.
-//
-for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
-; !IsNull (&mResetNotification.ResetNotifies, Link)
-; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
-) {
-  Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
-  Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
-}
-//
-// call reset notification functions registered through the
-// EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
-//
-for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
-; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
-; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, 
Link)
-) {
-  Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
-  Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+  DEBUG ((DEBUG_INFO, "DXE ResetSystem2: Reset call depth = %d.\n", 
mResetNotifyDepth));
+
+  if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) {


Should be mResetNotifyDepth < MAX_RESET_NOTIFY_DEPTH?

Thanks,
Star


+if (!EfiAtRuntime ()) {
+  //
+  // Call reset notification functions registered through the
+  // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL.
+  //
+  for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies)
+  ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link)
+  ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, 
Link)
+  ) {
+Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+  }
+  //
+  // Call reset notification functions registered through the
+  // EFI_RESET_NOTIFICATION_PROTOCOL.
+  //
+  for ( Link = GetFirstNode (&mResetNotification.ResetNotifies)
+  ; !IsNull (&mResetNotification.ResetNotifies, Link)
+  ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link)
+  ) {
+Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+  }
+  //
+  // call reset notification functions registered through the
+  // EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.
+  //
+  for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
+  ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+  ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, 
Link)
+  ) {
+Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+  }
  }
+  } else {
+ASSERT (ResetType < ARRAY_SIZE (mResetTypeStr));
+DEBUG ((DEBUG_ERROR, "DXE ResetSystem2: Maximum reset call depth is met. Use 
the current rese

Re: [edk2] [PATCH 04/10] MdeModulePkg/ResetSystemRuntimeDxe: Add platform filter and handler

2018-02-07 Thread Zeng, Star

Some minor comments added below except Laszlo's.

With them handled, Reviewed-by: Star Zeng 

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

Add support for platform specific reset filters and platform
specific reset handlers to ResetSystem().  A filter may modify
the reset type and reset data and call ResetSystem() with the
modified parameters.  A handler performs the reset action.

The support for platform specific filters and platform specific
handlers is based on the Reset Notification feature added to the
UEFI 2.7 Specification.

Platform specific reset filters are processed first so the final
reset type and reset data can be determined.  In the DXE Phase
The UEFI Reset Notifications are processed second so all UEFI
Drivers that have registered for a Reset Notification can perform
any required clean up actions.  The platform specific reset
handlers are processed third.  If there are no registered
platform specific reset handlers or none of them reset the
platform, then the default reset action based on the
ResetSystemLib is performed.

In the PEI Phase, filters are handlers are registered through


Should be "filters and handlers"?


the folloiwng 2 PPIs that are based on
EFI_RESET_NOTIFICATION_PROTOCOL.
* gEdkiiPlatformSpecificResetFilterPpiGuid
* gEdkiiPlatformSpecificResetFilterPpiGuid

In the DXE Phase, filters are handlers are registered through


Should be "filters and handlers"?


the folloiwng 2 Protocols that are based on
EFI_RESET_NOTIFICATION_PROTOCOL.
* gEdkiiPlatformSpecificResetFilterProtocolGuid
* gEdkiiPlatformSpecificResetFilterProtocolGuid

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
---


[...]


+//
+// call reset notification functions registered through the
+// EDKII_PLATFORM_SPECIFIC_RESET_NOTIFICATION_PROTOCOL.


Should be EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL?

Thanks,
Star


+//
+for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies)
+; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link)
+; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, 
Link)
+) {
+  Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link);
+  Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData);
+}
}
  
switch (ResetType) {

diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h 
b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
index 75cdd88896..ea5660274b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.h
@@ -20,6 +20,8 @@
  
  #include 

  #include 
+#include 
+#include 
  #include 
  
  #include 

@@ -34,6 +36,11 @@
  #include 
  #include 
  
+//

+// The maximum recurstion depth to ResetSystem() by reset notification handlers
+//
+#define MAX_RESET_NOTIFY_DEPTH 10
+
  typedef struct {
UINT32   Signature;
LIST_ENTRY   Link;
diff --git 
a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf 
b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
index 11233757c2..da9e8e118b 100644
--- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
@@ -55,9 +55,10 @@ [Guids]
  
  
  [Protocols]

-  gEfiResetArchProtocolGuid ## PRODUCES
-  gEfiResetNotificationProtocolGuid ## PRODUCES
-
+  gEfiResetArchProtocolGuid   ## PRODUCES
+  gEfiResetNotificationProtocolGuid   ## PRODUCES
+  gEdkiiPlatformSpecificResetFilterProtocolGuid   ## PRODUCES
+  gEdkiiPlatformSpecificResetHandlerProtocolGuid  ## PRODUCES
  
  [Depex]

TRUE



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


Re: [edk2] [PATCH 03/10] MdeModulePkg/PeiMain: Cleanup whitespace in Reset.c

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 


Reviewed-by: Star Zeng 

Thanks,
Star

---
  MdeModulePkg/Core/Pei/Reset/Reset.c | 41 ++---
  1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c 
b/MdeModulePkg/Core/Pei/Reset/Reset.c
index cd36c526b5..e6d7899ef7 100644
--- a/MdeModulePkg/Core/Pei/Reset/Reset.c
+++ b/MdeModulePkg/Core/Pei/Reset/Reset.c
@@ -1,14 +1,14 @@
  /** @file
Pei Core Reset System Support
-
+
  Copyright (c) 2006 - 2017, 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.
+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.
  
  **/
  
@@ -29,11 +29,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

  EFI_STATUS
  EFIAPI
  PeiResetSystem (
-  IN CONST EFI_PEI_SERVICES **PeiServices
+  IN CONST EFI_PEI_SERVICES  **PeiServices
)
  {
-  EFI_STATUSStatus;
-  EFI_PEI_RESET_PPI *ResetPpi;
+  EFI_STATUS Status;
+  EFI_PEI_RESET_PPI  *ResetPpi;
  
//

// Attempt to use newer ResetSystem2().  If this returns, then 
ResetSystem2()
@@ -52,9 +52,10 @@ PeiResetSystem (
   );
if (!EFI_ERROR (Status)) {
  return ResetPpi->ResetSystem (PeiServices);
-  }
+  }
+
//
-  // Report Status Code that Reset PPI is not available
+  // Report Status Code that Reset PPI is not available.
//
REPORT_STATUS_CODE (
  EFI_ERROR_CODE | EFI_ERROR_MINOR,
@@ -85,14 +86,14 @@ PeiResetSystem (
  VOID
  EFIAPI
  PeiResetSystem2 (
-  IN EFI_RESET_TYPE ResetType,
-  IN EFI_STATUS ResetStatus,
-  IN UINTN  DataSize,
-  IN VOID   *ResetData OPTIONAL
+  IN EFI_RESET_TYPE  ResetType,
+  IN EFI_STATUS  ResetStatus,
+  IN UINTN   DataSize,
+  IN VOID*ResetData OPTIONAL
)
  {
-  EFI_STATUSStatus;
-  EFI_PEI_RESET2_PPI*Reset2Ppi;
+  EFI_STATUS  Status;
+  EFI_PEI_RESET2_PPI  *Reset2Ppi;
  
//

// Look for PEI Reset System 2 PPI
@@ -103,7 +104,6 @@ PeiResetSystem2 (
   NULL,
   (VOID **)&Reset2Ppi
   );
-
if (!EFI_ERROR (Status)) {
  Reset2Ppi->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
  return;
@@ -117,4 +117,3 @@ PeiResetSystem2 (
  (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
  );
  }
-



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


Re: [edk2] [PATCH 02/10] MdeModulePkg/PeiMain: Always attempt to use Reset2 PPI first

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

Update PEI Service ResetSystem() to always attempt to use
the Reset2 PPI before looking for the Reset PPI.

Cc: Liming Gao 
Reviewed-by: Ruiyu Ni 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 


Reviewed-by: Star Zeng 

Thanks,
Star

---
  MdeModulePkg/Core/Pei/Reset/Reset.c | 26 +++---
  1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c 
b/MdeModulePkg/Core/Pei/Reset/Reset.c
index 7440eefd78..cd36c526b5 100644
--- a/MdeModulePkg/Core/Pei/Reset/Reset.c
+++ b/MdeModulePkg/Core/Pei/Reset/Reset.c
@@ -35,16 +35,21 @@ PeiResetSystem (
EFI_STATUSStatus;
EFI_PEI_RESET_PPI *ResetPpi;
  
-  Status = PeiServicesLocatePpi (

- &gEfiPeiResetPpiGuid,
- 0,
- NULL,
- (VOID **)&ResetPpi
- );
+  //
+  // Attempt to use newer ResetSystem2().  If this returns, then ResetSystem2()
+  // is not available.
+  //
+  PeiResetSystem2 (EfiResetCold, EFI_SUCCESS, 0, NULL);
  
//

-  // LocatePpi returns EFI_NOT_FOUND on error
+  // Look for PEI Reset System PPI
//
+  Status = PeiServicesLocatePpi (
+ &gEfiPeiResetPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&ResetPpi
+ );
if (!EFI_ERROR (Status)) {
  return ResetPpi->ResetSystem (PeiServices);
}
@@ -55,6 +60,10 @@ PeiResetSystem (
  EFI_ERROR_CODE | EFI_ERROR_MINOR,
  (EFI_SOFTWARE_PEI_CORE | EFI_SW_PS_EC_RESET_NOT_AVAILABLE)
  );
+
+  //
+  // No reset PPIs are available yet.
+  //
return  EFI_NOT_AVAILABLE_YET;
  }
  
@@ -85,6 +94,9 @@ PeiResetSystem2 (

EFI_STATUSStatus;
EFI_PEI_RESET2_PPI*Reset2Ppi;
  
+  //

+  // Look for PEI Reset System 2 PPI
+  //
Status = PeiServicesLocatePpi (
   &gEfiPeiReset2PpiGuid,
   0,



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


Re: [edk2] [PATCH 01/10] MdePkg/PeiServicesLib: Add PeiServicesResetSystem2()

2018-02-07 Thread Zeng, Star

On 2018/2/2 14:45, Ruiyu Ni wrote:

From: Michael D Kinney 

Add the PeiServicesResetSytstem2() function to the PeiServiesLib
to call the ResetSystem2() services in the PEI Services Table.

Cc: Liming Gao 
Cc: Ruiyu Ni 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney 
Signed-off-by: Ruiyu Ni 


Reviewed-by: Star Zeng 

Thanks,
Star


---
  MdePkg/Include/Library/PeiServicesLib.h| 24 
  MdePkg/Library/PeiServicesLib/PeiServicesLib.c | 26 ++
  2 files changed, 50 insertions(+)

diff --git a/MdePkg/Include/Library/PeiServicesLib.h 
b/MdePkg/Include/Library/PeiServicesLib.h
index 9fc22a10c1..0be72237f2 100644
--- a/MdePkg/Include/Library/PeiServicesLib.h
+++ b/MdePkg/Include/Library/PeiServicesLib.h
@@ -540,4 +540,28 @@ PeiServicesInstallFvInfo2Ppi (
IN   UINT32  AuthenticationStatus
);
  
+/**

+  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
+PeiServicesResetSystem2 (
+  IN EFI_RESET_TYPE ResetType,
+  IN EFI_STATUS ResetStatus,
+  IN UINTN  DataSize,
+  IN VOID   *ResetData OPTIONAL
+  );
+
  #endif
diff --git a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c 
b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
index 89166ccd38..d0838ed709 100644
--- a/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
+++ b/MdePkg/Library/PeiServicesLib/PeiServicesLib.c
@@ -789,3 +789,29 @@ PeiServicesInstallFvInfo2Ppi (
InternalPeiServicesInstallFvInfoPpi (FALSE, FvFormat, FvInfo, FvInfoSize, 
ParentFvName, ParentFileName, AuthenticationStatus);
  }
  
+/**

+  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
+PeiServicesResetSystem2 (
+  IN EFI_RESET_TYPE ResetType,
+  IN EFI_STATUS ResetStatus,
+  IN UINTN  DataSize,
+  IN VOID   *ResetData OPTIONAL
+  )
+{
+  (*GetPeiServicesTablePointer())->ResetSystem2 (ResetType, ResetStatus, 
DataSize, ResetData);
+}



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


Re: [edk2] [Patch] MdePkg BaseCpuLib: Make it pass VS ARM build

2018-02-07 Thread Pete Batard

Thanks Liming. Looks good to me.

/Pete

On 2018.02.07 01:56, Liming Gao wrote:

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao 


Reviewed-by: Pete Batard 


---
  MdePkg/Library/BaseCpuLib/BaseCpuLib.inf | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf 
b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
index 637a3c5..996446e 100644
--- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
+++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
@@ -4,7 +4,7 @@
  #  CPU Library implemented using ASM functions for IA-32 and X64,
  #  PAL CALLs for IPF, and empty functions for EBC.
  #
-#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
  #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
  #
@@ -65,6 +65,8 @@
  [Sources.ARM]
Arm/CpuFlushTlb.asm | RVCT
Arm/CpuSleep.asm| RVCT
+  Arm/CpuFlushTlb.asm | MSFT
+  Arm/CpuSleep.asm| MSFT
Arm/CpuFlushTlb.S   | GCC
Arm/CpuSleep.S  | GCC
  



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


Re: [edk2] [PATCH edk2-platforms v3 13/15] Hisilicon/D05/ACPI: Add ITS PXM

2018-02-07 Thread graeme . gregory
On Tue, Feb 06, 2018 at 03:04:48PM +, Leif Lindholm wrote:
> On Fri, Feb 02, 2018 at 08:05:41PM +0800, Heyi Guo wrote:
> > Add ITS affinity structure in SRAT.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ming Huang 
> > Signed-off-by: Heyi Guo 
> > Reviewed-by: Ard Biesheuvel 
> > Reviewed-by: Graeme Gregory 
> 
> Err, a comment - and apologies if I missed this in other patches: this
> should probably be
> Graeme Gregory 
> 
> For my part:
> Reviewed-by: Leif Lindholm 
> 

Apologies yes, it should be the @linaro.org version, I must have
kicked off the wrong macro in vi.

Graeme

> > ---
> >  Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc | 10 ++
> >  Silicon/Hisilicon/Include/Library/AcpiNextLib.h | 10 +-
> >  2 files changed, 19 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc 
> > b/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc
> > index b448a29..8ea0c4b 100644
> > --- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc
> > +++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc
> > @@ -121,6 +121,16 @@ EFI_ACPI_STATIC_RESOURCE_AFFINITY_TABLE Srat = {
> >  
> > EFI_ACPI_6_1_GICC_AFFINITY_STRUCTURE_INIT(0x0003,0x003E,0x0001,0x),
> >//GICC Affinity Processor 62
> >  
> > EFI_ACPI_6_1_GICC_AFFINITY_STRUCTURE_INIT(0x0003,0x003F,0x0001,0x)
> > //GICC Affinity Processor 63
> >},
> > +  {
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x, 0x),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0001, 0x0001),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x, 0x0002),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0001, 0x0003),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0002, 0x0004),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0003, 0x0005),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0002, 0x0006),
> > +EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0003, 0x0007)
> > +  },
> >  };
> >  
> >  //
> > diff --git a/Silicon/Hisilicon/Include/Library/AcpiNextLib.h 
> > b/Silicon/Hisilicon/Include/Library/AcpiNextLib.h
> > index 60f9925..fd05a3b 100644
> > --- a/Silicon/Hisilicon/Include/Library/AcpiNextLib.h
> > +++ b/Silicon/Hisilicon/Include/Library/AcpiNextLib.h
> > @@ -39,6 +39,13 @@
> >   ACPIProcessorUID,  Flags,  ClockDomain
> >  \
> >}
> >  
> > +#define EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(  
> >  \
> > +ProximityDomain, ItsId)
> >  \
> > +  {
> >  \
> > +4, sizeof (EFI_ACPI_6_2_GIC_ITS_AFFINITY_STRUCTURE), ProximityDomain,  
> >  \
> > +{EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, ItsId
> >\
> > +  }
> > +
> >  #define EFI_ACPI_6_1_MEMORY_AFFINITY_STRUCTURE_INIT(   
> >\
> >  ProximityDomain, AddressBaseLow, AddressBaseHigh, LengthLow, 
> > LengthHigh, Flags)   \
> >{
> >\
> > @@ -70,12 +77,13 @@
> >  //
> >  #define EFI_ACPI_PROCESSOR_LOCAL_GICC_AFFINITY_STRUCTURE_COUNT  64
> >  #define EFI_ACPI_MEMORY_AFFINITY_STRUCTURE_COUNT10
> > -
> > +#define EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_COUNT   8
> >  
> >  typedef struct {
> >EFI_ACPI_6_0_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER  Header;
> >EFI_ACPI_6_0_MEMORY_AFFINITY_STRUCTURE  
> > Memory[EFI_ACPI_MEMORY_AFFINITY_STRUCTURE_COUNT];
> >EFI_ACPI_6_0_GICC_AFFINITY_STRUCTURE
> > Gicc[EFI_ACPI_PROCESSOR_LOCAL_GICC_AFFINITY_STRUCTURE_COUNT];
> > +  EFI_ACPI_6_2_GIC_ITS_AFFINITY_STRUCTURE 
> > Its[EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_COUNT];
> >  } EFI_ACPI_STATIC_RESOURCE_AFFINITY_TABLE;
> >  
> >  #pragma pack()
> > -- 
> > 1.9.1
> > 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH 2/2] OvmfPkg/PlatformPei: sync AmdSevInitialize() definition with declaration

2018-02-07 Thread Ard Biesheuvel
On 6 February 2018 at 23:01, Laszlo Ersek  wrote:
> "Platform.h" declares the AmdSevInitialize() function without EFIAPI, but
> the definition in "AmdSev.c" includes EFIAPI.
>
> GCC toolchains without LTO do not catch this error because "AmdSev.c" does
> not include "Platform.h"; i.e. the declaration used by callers such as
> "Platform.c" is not actually matched against the function definition at
> build time.
>
> With LTO enabled, the mismatch is found -- however, as a warning only, due
> to commit f8d0b9662993 ("BaseTools GCC5: disable warnings-as-errors for
> now", 2016-08-03).
>
> Include the header in the C file (which turns the issue into a hard build
> error on all GCC toolchains), plus sync the declaration from the header
> file to the C file.
>
> There's been no functional breakage because AmdSevInitialize() takes no
> parameters.
>
> Cc: Ard Biesheuvel 
> Cc: Brijesh Singh 
> Cc: Jordan Justen 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek 

Acked-by: Ard Biesheuvel 

> ---
>  OvmfPkg/PlatformPei/AmdSev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c
> index 1539e5b5cdce..ad31b69fb032 100644
> --- a/OvmfPkg/PlatformPei/AmdSev.c
> +++ b/OvmfPkg/PlatformPei/AmdSev.c
> @@ -23,6 +23,8 @@
>  #include 
>  #include 
>
> +#include "Platform.h"
> +
>  /**
>
>Function checks if SEV support is available, if present then it sets
> @@ -30,7 +32,6 @@
>
>**/
>  VOID
> -EFIAPI
>  AmdSevInitialize (
>VOID
>)
> --
> 2.14.1.3.gb7cf6e02401b
>
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v4 14/15] Hisilicon/D05/ACPI: Add Pcie, HNS and SAS PXM

2018-02-07 Thread Heyi Guo
Add PXM method for Pcie device, HNS device and SAS device.
Add STA method for HNS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: hensonwang 
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
Reviewed-by: Graeme Gregory 
---
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Hns.asl |  9 ++
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl | 34 
++--
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl | 19 +--
 3 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Hns.asl 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Hns.asl
index 11c28ba..7aa04af 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Hns.asl
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Hns.asl
@@ -233,6 +233,15 @@ Scope(_SB)
   }
 })
 
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x00)
+}
+Method (_STA, 0, NotSerialized)
+{
+  Return(0x0F)
+}
+
 //reset XGE port
 //Arg0 : XGE port index in dsaf
 //Arg1 : 0 reset, 1 cancle reset
diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl
index 55c7f50..122e4f0 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Pci.asl
@@ -141,7 +141,10 @@ Scope(_SB)
 {
   Return (0xf)
 }
-
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x00)
+}
   } // Device(PCI2)
 
   Device (RES2)
@@ -240,7 +243,10 @@ Scope(_SB)
 {
   Return (RBYV())
 }
-
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x01)
+}
   } // Device(PCI4)
   Device (RES4)
   {
@@ -338,6 +344,10 @@ Scope(_SB)
 {
   Return (RBYV())
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x01)
+}
   } // Device(PCI5)
   Device (RES5)
   {
@@ -435,6 +445,10 @@ Scope(_SB)
 {
   Return (RBYV())
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x01)
+}
   } // Device(PCI6)
   Device (RES6)
   {
@@ -531,6 +545,10 @@ Scope(_SB)
 {
   Return (RBYV())
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x01)
+}
   } // Device(PCI7)
   Device (RES7)
   {
@@ -690,6 +708,10 @@ Scope(_SB)
 {
   Return (0xf)
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x02)
+}
   } // Device(PCIa)
   Device (RESa)
   {
@@ -810,6 +832,10 @@ Scope(_SB)
 {
   Return (RBYV())
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x03)
+}
   } // Device(PCIc)
 
   Device (RESc)
@@ -907,6 +933,10 @@ Scope(_SB)
 {
   Return (RBYV())
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x03)
+}
   } // Device(PCId)
   Device (RESd)
   {
diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl
index 6455130..d5b7e2f 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Dsdt/D05Sas.asl
@@ -88,7 +88,10 @@ Scope(_SB)
   Store(0x7, CLK)
   Sleep(1)
 }
-
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x00)
+}
Method (_STA, 0, NotSerialized)
{
  Return (0x0)
@@ -169,8 +172,15 @@ Scope(_SB)
   Store(0x7, CLK)
   Sleep(1)
 }
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x00)
+}
+Method (_STA, 0, NotSerialized)
+{
+  Return(0x0F)
+}
   }
-
   Device(SAS2) {
 Name(_HID, "HISI0162")
 Name(_CCA, 1)
@@ -244,7 +254,10 @@ Scope(_SB)
   Store(0x7, CLK)
   Sleep(1)
 }
-
+Method (_PXM, 0, NotSerialized)
+{
+  Return(0x00)
+}
Method (_STA, 0, NotSerialized)
{
  Return (0x0)
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 12/15] Hisilicon/D03: Replace SP805Watchdog by WatchdogTimer driver.

2018-02-07 Thread Heyi Guo
In SCT test,we find SP805 watchdog driver can't reset when timeout
so we use another driver in MdeModulePkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Signed-off-by: GongChengYa 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D03/D03.dsc | 2 +-
 Platform/Hisilicon/D03/D03.fdf | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 947a8a5..37bec9e 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -374,7 +374,7 @@
 
   ArmPkg/Drivers/TimerDxe/TimerDxe.inf
 
-  ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
   #
   #ACPI
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index 1c55761..e6a4820 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -189,7 +189,7 @@ READ_LOCK_STATUS   = TRUE
   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
   INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
 
-  INF ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
+  INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 11/15] Hisilicon/D05: Replace SP805Watchdog by WatchdogTimer driver.

2018-02-07 Thread Heyi Guo
In SCT test,we find SP805 watchdog driver can't reset when timeout
so we use another driver in MdeModulePkg.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Signed-off-by: GongChengYa 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D05/D05.dsc | 2 +-
 Platform/Hisilicon/D05/D05.fdf | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index dfe19b0..b2ccd0e 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -511,7 +511,7 @@
 
   ArmPkg/Drivers/TimerDxe/TimerDxe.inf
 
-  ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
   
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
   #
   #ACPI
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index e829494..22609bb 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -193,7 +193,7 @@ READ_LOCK_STATUS   = TRUE
   INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
   INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
 
-  INF ArmPlatformPkg/Drivers/SP805WatchdogDxe/SP805WatchdogDxe.inf
+  INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 13/15] Hisilicon/D05/ACPI: Add ITS PXM

2018-02-07 Thread Heyi Guo
Add ITS affinity structure in SRAT.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
Reviewed-by: Graeme Gregory 
---
 Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc | 10 ++
 Silicon/Hisilicon/Include/Library/AcpiNextLib.h | 10 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc
index b448a29..8ea0c4b 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Srat.aslc
@@ -121,6 +121,16 @@ EFI_ACPI_STATIC_RESOURCE_AFFINITY_TABLE Srat = {
 
EFI_ACPI_6_1_GICC_AFFINITY_STRUCTURE_INIT(0x0003,0x003E,0x0001,0x),
   //GICC Affinity Processor 62
 
EFI_ACPI_6_1_GICC_AFFINITY_STRUCTURE_INIT(0x0003,0x003F,0x0001,0x)
//GICC Affinity Processor 63
   },
+  {
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x, 0x),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0001, 0x0001),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x, 0x0002),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0001, 0x0003),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0002, 0x0004),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0003, 0x0005),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0002, 0x0006),
+EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(0x0003, 0x0007)
+  },
 };
 
 //
diff --git a/Silicon/Hisilicon/Include/Library/AcpiNextLib.h 
b/Silicon/Hisilicon/Include/Library/AcpiNextLib.h
index 60f9925..fd05a3b 100644
--- a/Silicon/Hisilicon/Include/Library/AcpiNextLib.h
+++ b/Silicon/Hisilicon/Include/Library/AcpiNextLib.h
@@ -39,6 +39,13 @@
  ACPIProcessorUID,  Flags,  ClockDomain
 \
   }
 
+#define EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_INIT(  
 \
+ProximityDomain, ItsId)
 \
+  {
 \
+4, sizeof (EFI_ACPI_6_2_GIC_ITS_AFFINITY_STRUCTURE), ProximityDomain,  
 \
+{EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, ItsId
   \
+  }
+
 #define EFI_ACPI_6_1_MEMORY_AFFINITY_STRUCTURE_INIT(   
   \
 ProximityDomain, AddressBaseLow, AddressBaseHigh, LengthLow, LengthHigh, 
Flags)   \
   {
   \
@@ -70,12 +77,13 @@
 //
 #define EFI_ACPI_PROCESSOR_LOCAL_GICC_AFFINITY_STRUCTURE_COUNT  64
 #define EFI_ACPI_MEMORY_AFFINITY_STRUCTURE_COUNT10
-
+#define EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_COUNT   8
 
 typedef struct {
   EFI_ACPI_6_0_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER  Header;
   EFI_ACPI_6_0_MEMORY_AFFINITY_STRUCTURE  
Memory[EFI_ACPI_MEMORY_AFFINITY_STRUCTURE_COUNT];
   EFI_ACPI_6_0_GICC_AFFINITY_STRUCTURE
Gicc[EFI_ACPI_PROCESSOR_LOCAL_GICC_AFFINITY_STRUCTURE_COUNT];
+  EFI_ACPI_6_2_GIC_ITS_AFFINITY_STRUCTURE 
Its[EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_COUNT];
 } EFI_ACPI_STATIC_RESOURCE_AFFINITY_TABLE;
 
 #pragma pack()
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 15/15] Hisilicon D03/D05: Update firmware version to 18.02

2018-02-07 Thread Heyi Guo
Replace the old string with short one. The old one is
too long that can not be show integrallty in Setup nemu.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
Reviewed-by: Graeme Gregory 
---
 Platform/Hisilicon/D03/D03.dsc | 2 +-
 Platform/Hisilicon/D05/D05.dsc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 37bec9e..c496306 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -168,7 +168,7 @@
   !ifdef $(FIRMWARE_VER)
 gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
   !else
-gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build base on Hisilicon D03 UEFI 17.10 Release"
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 18.02 for Hisilicon D03"
   !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index b2ccd0e..0792b08 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -187,7 +187,7 @@
   !ifdef $(FIRMWARE_VER)
 gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"$(FIRMWARE_VER)"
   !else
-gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build base on Hisilicon D05 UEFI 17.10 Release"
+gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Development 
build 18.02 for Hisilicon D05"
   !endif
 
   gHisiTokenSpaceGuid.PcdBiosVersionString|L"10.01.01T18"
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 10/15] Hisilicon/PCIe: Disable PCIe ASPM

2018-02-07 Thread Heyi Guo
In order to replace command line parameter pcie_aspm=off, BIOS needs to
disable Pcie Aspm support during Pcie initilization.
D03 and D05 do not support PCIe ASPM, so we disable it in BIOS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Signed-off-by: Yan Zhang 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c | 103 

 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h |   2 +
 Silicon/Hisilicon/Include/Regs/HisiPcieV1RegOffset.h|   2 +
 3 files changed, 107 insertions(+)

diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c 
b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c
index f420c91..c1c3fbb 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.c
@@ -1033,6 +1033,106 @@ DisableRcOptionRom (
   return;
 }
 
+STATIC
+VOID
+PcieDbiCs2Enable (
+  IN UINT32 HostBridgeNum,
+  IN UINT32 Port,
+  IN BOOLEAN Val
+  )
+{
+  UINT32 RegVal;
+
+  RegRead (
+PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + 
PCIE_SUBCTRL_SC_PCIE_SYS_CTRL21,
+RegVal
+);
+  if (Val) {
+RegVal = RegVal | BIT2;
+/* BIT2: DBI Chip Select indicator. 0 indicates CS, 1 indicates CS2.*/
+  } else {
+RegVal = RegVal & (~BIT2);
+  }
+  RegWrite (
+PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + 
PCIE_SUBCTRL_SC_PCIE_SYS_CTRL21,
+RegVal
+);
+}
+
+STATIC
+BOOLEAN
+PcieDBIReadOnlyWriteEnable (
+  IN UINT32 HostBridgeNum,
+  IN UINT32 Port
+  )
+{
+  UINT32  Val;
+
+  RegRead (
+PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + 
PCIE_DBI_READ_ONLY_WRITE_ENABLE,
+Val
+);
+  if (Val == 0x1) {
+return TRUE;
+  } else {
+RegWrite (
+  PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + 
PCIE_DBI_READ_ONLY_WRITE_ENABLE,
+  0x1
+  );
+/* Delay 10us to make sure the PCIE device have enouph time to response. */
+MicroSecondDelay(10);
+RegRead (
+  PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + 
PCIE_DBI_READ_ONLY_WRITE_ENABLE,
+  Val
+  );
+if (Val == 0x1) {
+  return TRUE;
+}
+  }
+  DEBUG ((DEBUG_ERROR,"PcieDBIReadOnlyWriteEnable Fail!!!\n"));
+  return FALSE;
+}
+
+STATIC
+VOID
+SwitchPcieASPMSupport (
+  IN UINT32 HostBridgeNum,
+  IN UINT32 Port,
+  IN UINT8 Val
+  )
+{
+  PCIE_EP_PCIE_CAP3_U PcieCap3;
+
+  if (Port >= PCIE_MAX_ROOTBRIDGE) {
+DEBUG ((DEBUG_ERROR, "Port is not valid\n"));
+return;
+  }
+  if (!PcieDBIReadOnlyWriteEnable (HostBridgeNum, Port)) {
+DEBUG ((DEBUG_INFO, "PcieDBI ReadOnly Reg do not Enable!!!\n"));
+return;
+  }
+  PcieDbiCs2Enable (HostBridgeNum, Port, FALSE);
+
+  RegRead (
+PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + PCIE_EP_PCIE_CAP3_REG,
+PcieCap3.UInt32
+);
+  PcieCap3.Bits.active_state_power_management = Val;
+  RegWrite (
+PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + PCIE_EP_PCIE_CAP3_REG,
+PcieCap3.UInt32
+);
+  RegRead (
+PCIE_APB_SLAVE_BASE_1610[HostBridgeNum][Port] + PCIE_EP_PCIE_CAP3_REG,
+PcieCap3.UInt32
+);
+  DEBUG ((DEBUG_INFO,
+  "ASPI active state power management: %d\n",
+  PcieCap3.Bits.active_state_power_management));
+
+  PcieDbiCs2Enable (HostBridgeNum, Port, TRUE);
+}
+
 EFI_STATUS
 EFIAPI
 PciePortInit (
@@ -1090,6 +1190,9 @@ PciePortInit (
  /* disable link up interrupt */
  (VOID)PcieMaskLinkUpInit(soctype, HostBridgeNum, PortIndex);
 
+ /* disable ASPM */
+ SwitchPcieASPMSupport (HostBridgeNum, PortIndex, PCIE_ASPM_DISABLE);
+
  /* Pcie Equalization*/
  (VOID)PcieEqualization(soctype ,HostBridgeNum, PortIndex);
 
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h 
b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h
index 9a0f636..e96c53c 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h
@@ -77,6 +77,8 @@
 #define RegWrite(addr,data)MmioWrite32((addr), (data))
 #define RegRead(addr,data) ((data) = MmioRead32 (addr))
 
+#define PCIE_ASPM_DISABLE 0x0
+#define PCIE_ASPM_ENABLE 0x1
 
 typedef struct tagPcieDebugInfo
 {
diff --git a/Silicon/Hisilicon/Include/Regs/HisiPcieV1RegOffset.h 
b/Silicon/Hisilicon/Include/Regs/HisiPcieV1RegOffset.h
index bf57652..c8b9781 100644
--- a/Silicon/Hisilicon/Include/Regs/HisiPcieV1RegOffset.h
+++ b/Silicon/Hisilicon/Include/Regs/HisiPcieV1RegOffset.h
@@ -135,6 +135,7 @@
 #define PCIE_EEP_PORTLOGIC53_REG  (0x888)
 #define PCIE_EEP_GEN3_CONTRL_REG  (0x890)
 #define PCIE_EEP_PIPE_LOOPBACK_REG(0x8B8)
+#define PCIE_DBI_READ_ONLY_WRITE_ENABLE   (0x8BC)
 #define PCIE_EEP_PORTLOGIC54_REG  (0x900)
 #define PCIE_EEP_PORTLOGIC55_REG  (0x904)
 #define PCIE_EEP_PORTLOGIC56_REG

[edk2] [PATCH edk2-platforms v4 06/15] Hisilicon D03/D05: Open SasPlatform source code

2018-02-07 Thread Heyi Guo
This module install a protocol for SasDriverDxe. the protocol
include main information of sas controller, like controller ID,
enable or disable,base address of registers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jason Zhang 
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D03/D03.dsc   |   1 +
 Platform/Hisilicon/D03/D03.fdf   |   2 +-
 Platform/Hisilicon/D05/D05.dsc   |   1 +
 Platform/Hisilicon/D05/D05.fdf   |   2 +-
 Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.c  | 106 

 Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.inf|  45 +
 Silicon/Hisilicon/HisiPkg.dec|   2 +
 Silicon/Hisilicon/Include/Library/OemDevicePath.h|  52 ++
 Silicon/Hisilicon/Include/Protocol/HisiPlatformSasProtocol.h |  30 ++
 9 files changed, 239 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 82c8bb4..07da597 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -468,6 +468,7 @@
   Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.inf
   Platform/Hisilicon/D03/Drivers/Sm750Dxe/UefiSmi.inf
 
+  Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.inf
   Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClassDxe.inf
 
 
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index 6462a53..919f9d7 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -272,7 +272,7 @@ READ_LOCK_STATUS   = TRUE
   #
   INF Platform/Hisilicon/D03/Drivers/Sm750Dxe/UefiSmi.inf
 
-  INF Platform/Hisilicon/D03/Drivers/SasPlatform/SasPlatform.inf
+  INF Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.inf
   INF Platform/Hisilicon/D03/Drivers/Sas/SasDxeDriver.inf
 
   INF 
SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index e39acb1..b279c9e 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -621,6 +621,7 @@
   
Platform/Hisilicon/D05/Drivers/ReportPciePlugDidVidToBmc/ReportPciePlugDidVidToBmc.inf
   Silicon/Hisilicon/Drivers/Smbios/AddSmbiosType9/AddSmbiosType9.inf
   Platform/Hisilicon/D05/Drivers/Sm750Dxe/UefiSmi.inf
+  Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.inf
   MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
   Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClassDxe.inf
 
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index b0296e1..b105ee2 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -294,7 +294,7 @@ READ_LOCK_STATUS   = TRUE
   #
   INF Platform/Hisilicon/D05/Drivers/Sm750Dxe/UefiSmi.inf
   INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
-  INF Platform/Hisilicon/D05/Drivers/SasPlatform/SasPlatform.inf
+  INF Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.inf
   INF Platform/Hisilicon/D05/Drivers/Sas/SasDxeDriver.inf
 
   INF 
SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareReportDxe.inf
diff --git a/Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.c 
b/Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.c
new file mode 100644
index 000..7ae1f5d
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SasPlatform/SasPlatform.c
@@ -0,0 +1,106 @@
+/** @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.
+*
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define SAS0BusAddr 0xc300
+#define SAS1BusAddr 0xa200
+#define SAS2BusAddr 0xa300
+
+#define SAS0ResetAddr 0xc000
+#define SAS1ResetAddr 0xa000
+#define SAS2ResetAddr 0xa000
+
+typedef struct {
+  UINTN   Signature;
+  EFI_HANDLE  Handle;
+  HISI_PLATFORM_SAS_PROTOCOL  SasPlatformProtocol;
+} SAS_PLATFORM_INSTANCE;
+
+
+STATIC HISI_PLATFORM_SAS_PROTOCOL mSasPlatformProtocol[] = {
+  {
+0,
+FALSE,
+SAS0BusAddr,
+SAS0ResetAddr
+  },
+  {
+1,
+TRUE,
+SAS1BusAddr,
+SAS1ResetAddr
+  },
+  {
+2,
+FALSE,
+SAS2BusAddr,
+SAS2ResetAddr
+  }
+};
+
+EFI_STATUS
+EFIAPI
+SasPlatformIn

Re: [edk2] [patch] MdeModulePkg/PciBusDxe: Fix VS2012 build failure

2018-02-07 Thread Bi, Dandan
Hi Laszlo,

Thanks for your comments. I will update the commit message. 


Regards,
Dandan

-Original Message-
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Wednesday, February 7, 2018 4:17 PM
To: Zeng, Star ; Bi, Dandan ; 
edk2-devel@lists.01.org
Cc: Ni, Ruiyu 
Subject: Re: [patch] MdeModulePkg/PciBusDxe: Fix VS2012 build failure

On 02/07/18 02:44, Zeng, Star wrote:
> Reviewed-by: Star Zeng 
> 
> Cc Laszlo.

Thanks!

> You can add similar comment like 1ea53108f6c1010a00a828d1d59ea28934025415 as 
> recommended by https://bugzilla.tianocore.org/show_bug.cgi?id=607.

Yes, that would be nice.

The patch looks correct. Dandan, can you please add the following to the commit 
message too:


Both reads (dereferences) of "PciRootBridgeIo" in
PciBusDriverBindingStart() are only reached if "gFullEnumeration" is TRUE on 
entry *and* we successfully open the EfiPciRootBridgeIoProtocol interface.


With that:

Reviewed-by: Laszlo Ersek 

Thanks!
Laszlo


> Thanks,
> Star
> -Original Message-
> From: Bi, Dandan
> Sent: Wednesday, February 7, 2018 9:31 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star ; Ni, Ruiyu 
> Subject: [patch] MdeModulePkg/PciBusDxe: Fix VS2012 build failure
> 
> Initialize local variable to suppress warning C4703:
> potentially uninitialized local pointer variable.
> 
> Cc: Star Zeng 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Dandan Bi 
> ---
>  MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c 
> b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
> index c48e3bb..13221b9 100644
> --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
> +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c
> @@ -242,10 +242,12 @@ PciBusDriverBindingStart (  {
>EFI_STATUS  Status;
>EFI_DEVICE_PATH_PROTOCOL*ParentDevicePath;
>EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
>  
> +  PciRootBridgeIo = NULL;
> +
>//
>// Check RemainingDevicePath validation
>//
>if (RemainingDevicePath != NULL) {
>  //
> --
> 1.9.5.msysgit.1
> 

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


[edk2] [PATCH edk2-platforms v4 09/15] Hisilicon/Smbios: Indicate use of ProcessorFamily2 in type 4 table

2018-02-07 Thread Heyi Guo
modify processorFamily of type 4 to ProcessorFamilyIndicatorFamily2,
indicator to obtain the processor family from the Processor Family 2 field.
ProcessorFamily2 is already specified as ProcessorFamilyARM in the existing
table.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c | 4 
++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c 
b/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c
index 61473e8..c9903ba 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c
+++ b/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.c
@@ -125,7 +125,7 @@ SMBIOS_TABLE_TYPE4   mSmbiosProcessorTable[] = {
 },
 1,  //Socket
 CentralProcessor,   //ProcessorType
-ProcessorFamilyOther,   //ProcessorFamily
+ProcessorFamilyIndicatorFamily2,//ProcessorFamily
 2,  //ProcessorManufacture
 {   //ProcessorId
 {   //Signature
@@ -172,7 +172,7 @@ SMBIOS_TABLE_TYPE4   mSmbiosProcessorTable[] = {
 },
 1,  //Socket
 CentralProcessor,   //ProcessorType
-ProcessorFamilyOther,   //ProcessorFamily
+ProcessorFamilyIndicatorFamily2,//ProcessorFamily
 2,  //ProcessorManufacture
 {   //ProcessorId
 {   //Signature
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 07/15] Hisilicon D03/D05: Open SnpPlatform source code

2018-02-07 Thread Heyi Guo
1. This driver install a protocol for SnpPV600Dxe driver.
   The protocol indicate which ethernet port to use and port sequence.
2. Fixed bug:Confusing Ethernet port sequence.
   Move the most right Ethernet port (when looking from the front
   of the chassis) to the first one in BootManage for PXE boot.
   https://bugs.linaro.org/show_bug.cgi?id=2657

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jason Zhang 
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D03/D03.dsc   |   2 +
 Platform/Hisilicon/D03/D03.fdf   |   2 +-
 Platform/Hisilicon/D05/D05.dsc   |   2 +
 Platform/Hisilicon/D05/D05.fdf   |   2 +-
 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c  | 115 

 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf|  46 
 Silicon/Hisilicon/HisiPkg.dec|   1 +
 Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h |  32 ++
 8 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 07da597..947a8a5 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -399,6 +399,8 @@
 
   Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.inf
 
+  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
+
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index 919f9d7..1c55761 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -242,7 +242,7 @@ READ_LOCK_STATUS   = TRUE
   #Network
   #
 
-  INF Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf
+  INF Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
   INF Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
 
   INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index b279c9e..6e44041 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -537,6 +537,8 @@
 
   Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.inf
 
+  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
+
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index b105ee2..e829494 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -248,7 +248,7 @@ READ_LOCK_STATUS   = TRUE
   #Network
   #
 
-  INF Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf
+  INF Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
   INF Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
 
   INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c 
b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c
new file mode 100644
index 000..0d6e86e
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c
@@ -0,0 +1,115 @@
+/** @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.
+*
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+typedef struct {
+  UINTN  Signature;
+  EFI_HANDLE Handle;
+  HISI_PLATFORM_SNP_PROTOCOL SnpPlatformProtocol;
+} SNP_PLATFORM_INSTANCE;
+
+STATIC HISI_PLATFORM_SNP_PROTOCOL mSnpPlatformProtocol[] = {
+  {
+4,
+1
+  },
+  {
+5,
+1
+  },
+  {
+2,
+0
+  },
+  {
+3,
+0
+  },
+  {
+0,
+1
+  },
+ {
+1,
+1
+  },
+  {
+6,
+0
+  },
+  {
+7,
+0
+  }
+};
+
+
+EFI_STATUS
+EFIAPI
+SnpPlatformInitialize (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  UINTNLoop;
+  SNP_PLATFORM_INSTANCE*PrivateData;
+  EFI_STATUS   Status;
+
+  for (Loop = 0; Loop < ARRAY_SIZE (mSnpPlatformProtocol); Loop++) {
+if(mSnpPlatformProtocol[Loop].Enable != 1) {
+  continue;
+}
+

[edk2] [PATCH edk2-platforms v4 05/15] Hisilicon D03/D05: Add capsule upgrade support

2018-02-07 Thread Heyi Guo
This module support updating the boot CPU firmware only.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jason Zhang 
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 
---
 
Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
 |  45 +++
 Platform/Hisilicon/D03/D03.dsc 
  |  17 ++-
 Platform/Hisilicon/D03/D03.fdf 
  |  70 +++
 
Platform/Hisilicon/D03/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
|  81 +
 
Platform/Hisilicon/D03/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
 |  50 
 
Platform/Hisilicon/D03/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
|  70 +++
 
Platform/Hisilicon/D05/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
 |  45 +++
 Platform/Hisilicon/D05/D05.dsc 
  |  19 ++-
 Platform/Hisilicon/D05/D05.fdf 
  |  70 +++
 
Platform/Hisilicon/D05/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.aslc
|  81 +
 
Platform/Hisilicon/D05/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptor.inf
 |  50 
 
Platform/Hisilicon/D05/Drivers/SystemFirmwareDescriptor/SystemFirmwareDescriptorPei.c
|  70 +++
 Silicon/Hisilicon/Hisilicon.dsc.inc
  |  11 +-
 Silicon/Hisilicon/Hisilicon.fdf.inc
  |   9 ++
 Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.c   
  | 123 
 Silicon/Hisilicon/Library/PlatformFlashAccessLib/PlatformFlashAccessLibDxe.inf 
  |  51 
 16 files changed, 859 insertions(+), 3 deletions(-)

diff --git 
a/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
 
b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
new file mode 100644
index 000..fc834d9
--- /dev/null
+++ 
b/Platform/Hisilicon/D03/Capsule/SystemFirmwareUpdateConfig/SystemFirmwareUpdateConfig.ini
@@ -0,0 +1,45 @@
+#
+#  Copyright (c) 2018, Hisilicon Limited. All rights reserved.
+#  Copyright (c) 2018, Linaro Limited. All rights reserved.
+#  Copyright (c) 2016, 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.
+#
+##
+
+[Head]
+NumOfUpdate = 3
+NumOfRecovery = 0
+Update0 = SysFvMain
+Update1 = SysCustom
+Update2 = SysNvRam
+
+[SysFvMain]
+FirmwareType  = 0 # 0 - SystemFirmware, 1 - NvRam
+AddressType   = 0 # 0 - relative address, 1 - absolute address.
+BaseAddress   = 0x# Base address offset on flash
+Length= 0x002D# Length
+ImageOffset   = 0x# Image offset of this SystemFirmware image
+FileGuid  = 642e4fcf-2df7-4415-8b70-a03909c57b55  # 
PcdEdkiiSystemFirmwareFileGuid
+
+[SysCustom]
+FirmwareType  = 0 # 0 - SystemFirmware, 1 - NvRam
+AddressType   = 0 # 0 - relative address, 1 - absolute address.
+BaseAddress   = 0x002F# Base address offset on flash
+Length= 0x0001# Length
+ImageOffset   = 0x002F# Image offset of this SystemFirmware image
+FileGuid  = 642e4fcf-2df7-4415-8b70-a03909c57b55  # 
PcdEdkiiSystemFirmwareFileGuid
+
+[SysNvRam]
+FirmwareType  = 1 # 0 - SystemFirmware, 1 - NvRam
+AddressType   = 0 # 0 - relative address, 1 - absolute address.
+BaseAddress   = 0x002D# Base address offset on flash
+Length= 0x0002# Length
+ImageOffset   = 0x002D# Image offset of this SystemFirmware image
+FileGuid  = 642e4fcf-2df7-4415-8b70-a03909c57b55  # 
PcdEdkiiSystemFirmwareFileGuid
diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index e1e3b14..82c8bb4 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -65,7 +65,6 @@
   
OemAddressMapLib|Platform/Hisilicon/D03/Library/OemAddressMap2P/OemAddressMap2PHi1610.inf
   
PlatformSysCtrlLib|Silicon/Hisilicon/Hi1610/Library/PlatformSysCtrlLibHi1610/PlatformSysCtrlLibHi1610.inf
 
-  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
   
PlatformBdsLib|Silicon/Hisilicon/Libra

[edk2] [PATCH edk2-platforms v4 08/15] Hilisicon: Change DmaLib to CoherentDmaLib

2018-02-07 Thread Heyi Guo
Unify all D0x(include D06 in further) to cache coherent DmaLib.
This can improve boot speed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wang Yue 
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D05/D05.dsc| 2 +-
 Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.c | 2 +-
 Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.c| 3 +--
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 6e44041..dfe19b0 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -614,7 +614,7 @@
   Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
   Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridgeDxe.inf {
 
-  DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
+  DmaLib|EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf
   NULL|Platform/Hisilicon/D05/Library/PlatformPciLib/PlatformPciLib.inf
   }
 
diff --git a/Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.c 
b/Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.c
index 706eb12..63de50b 100644
--- a/Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.c
+++ b/Silicon/Hisilicon/Drivers/VirtualEhciPciIo/VirtualEhciPciIo.c
@@ -26,7 +26,7 @@ EhciVirtualPciIoInitialize (
 {
   return RegisterNonDiscoverableMmioDevice (
NonDiscoverableDeviceTypeEhci,
-   NonDiscoverableDeviceDmaTypeNonCoherent,
+   NonDiscoverableDeviceDmaTypeCoherent,
NULL,
NULL,
1,
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.c 
b/Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.c
index 2310ee4..3e272f8 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.c
+++ b/Silicon/Hisilicon/Hi1610/Drivers/IoInitDxe/IoInitDxe.c
@@ -27,7 +27,6 @@ ExitBootServicesEventSmmu (
   IN VOID   *Context
   )
 {
-  SmmuConfigForOS ();
   DEBUG((EFI_D_INFO,"SMMU ExitBootServicesEvent\n"));
 }
 
@@ -43,7 +42,7 @@ IoInitDxeEntry (
 
   (VOID) EfiSerdesInitWrap ();
 
-  SmmuConfigForBios ();
+  SmmuConfigForOS ();
 
   Status = gBS->CreateEvent (
   EVT_SIGNAL_EXIT_BOOT_SERVICES,
-- 
1.9.1

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


[edk2] [PATCH edk2-platforms v4 04/15] Hisilicon/D0x: Break BMC SetBoot option out into separate library

2018-02-07 Thread Heyi Guo
Modify the feature of BMC set boot option as switching generic
BDS. Break BMC SetBoot option out into BmcConfigBootLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D03/D03.dsc  |  
 1 +
 Platform/Hisilicon/D05/D05.dsc  |  
 1 +
 Silicon/Hisilicon/HisiPkg.dec   |  
 1 +
 Silicon/Hisilicon/Include/Library/BmcConfigBootLib.h|  
31 ++
 Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.c   | 
466 
 Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.inf |  
51 +++
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c   |  
 7 +
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  
 1 +
 8 files changed, 559 insertions(+)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 5fbe1f9..e1e3b14 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -68,6 +68,7 @@
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
   
PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+  
BmcConfigBootLib|Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.inf
   
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
   BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 4d630da..ac7da04 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -84,6 +84,7 @@
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
   
PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+  
BmcConfigBootLib|Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.inf
   
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec
index 398d0a7..889a181 100644
--- a/Silicon/Hisilicon/HisiPkg.dec
+++ b/Silicon/Hisilicon/HisiPkg.dec
@@ -43,6 +43,7 @@
 
   gHisiEfiMemoryMapGuid  = {0xf8870015, 0x6994, 0x4b98, {0x95, 0xa2, 0xbd, 
0x56, 0xda, 0x91, 0xc0, 0x7f}}
   gVersionInfoHobGuid = {0xe13a14c, 0x859c, 0x4f22, {0x82, 0xbd, 0x18, 0xe, 
0xe1, 0x42, 0x12, 0xbf}}
+  gOemBootVariableGuid = {0xb7784577, 0x5aaf, 0x4557, {0xa1, 0x99, 0xd4, 0xa4, 
0x2f, 0x45, 0x06, 0xf8}}
 
 [LibraryClasses]
   PlatformSysCtrlLib|Include/Library/PlatformSysCtrlLib.h
diff --git a/Silicon/Hisilicon/Include/Library/BmcConfigBootLib.h 
b/Silicon/Hisilicon/Include/Library/BmcConfigBootLib.h
new file mode 100644
index 000..d937234
--- /dev/null
+++ b/Silicon/Hisilicon/Include/Library/BmcConfigBootLib.h
@@ -0,0 +1,31 @@
+/** @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 _BMC_CONFIG_BOOT_LIB_H_
+#define _BMC_CONFIG_BOOT_LIB_H_
+
+VOID
+EFIAPI
+RestoreBootOrder (
+  VOID
+  );
+
+VOID
+EFIAPI
+HandleBmcBootType (
+  VOID
+  );
+
+#endif
diff --git a/Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.c 
b/Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.c
new file mode 100644
index 000..08a9c9c
--- /dev/null
+++ b/Silicon/Hisilicon/Library/BmcConfigBootLib/BmcConfigBootLib.c
@@ -0,0 +1,466 @@
+/** @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 EX

[edk2] [PATCH edk2-platforms v4 01/15] Hisilicon/D05: Move Madt definition to head file

2018-02-07 Thread Heyi Guo
Move definition of Madt struct to head file, so PPTT driver
can include it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Reviewed-by: Ard Biesheuvel 
Reviewed-by: Graeme Gregory 
Reveiwed-by: Jeremy Linton 
---
 Silicon/Hisilicon/Hi1616/D05AcpiTables/Hi1616Platform.h | 30 
+++-
 Silicon/Hisilicon/Hi1616/D05AcpiTables/MadtHi1616.aslc  | 23 +--
 2 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Hi1616Platform.h 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Hi1616Platform.h
index 808219a..ad73aa2 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/Hi1616Platform.h
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/Hi1616Platform.h
@@ -1,7 +1,7 @@
 /** @file
 *
 *  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
-*  Copyright (c) 2015-2016, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2015-2018, Hisilicon Limited. All rights reserved.
 *  Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
 *
 *  This program and the accompanying materials
@@ -20,6 +20,8 @@
 #ifndef _HI1610_PLATFORM_H_
 #define _HI1610_PLATFORM_H_
 
+#include 
+
 //
 // ACPI table information used to initialize tables.
 //
@@ -44,5 +46,31 @@
   }
 
 #define HI1616_WATCHDOG_COUNT  2
+#define HI1616_GIC_STRUCTURE_COUNT  64
+
+#define HI1616_MPID_TA_BASE  0x1
+#define HI1616_MPID_TB_BASE  0x3
+#define HI1616_MPID_TA_2_BASE  0x5
+#define HI1616_MPID_TB_2_BASE  0x7
+
+// Differs from Juno, we have another affinity level beyond cluster and core
+#define PLATFORM_GET_MPID_TA(ClusterId, CoreId)   (HI1616_MPID_TA_BASE | 
((ClusterId) << 8) | (CoreId))
+#define PLATFORM_GET_MPID_TB(ClusterId, CoreId)   (HI1616_MPID_TB_BASE | 
((ClusterId) << 8) | (CoreId))
+#define PLATFORM_GET_MPID_TA_2(ClusterId, CoreId)   (HI1616_MPID_TA_2_BASE | 
((ClusterId) << 8) | (CoreId))
+#define PLATFORM_GET_MPID_TB_2(ClusterId, CoreId)   (HI1616_MPID_TB_2_BASE | 
((ClusterId) << 8) | (CoreId))
+
+//
+// Multiple APIC Description Table
+//
+#pragma pack (1)
+
+typedef struct {
+  EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER   Header;
+  EFI_ACPI_6_1_GIC_STRUCTURE
GicInterfaces[HI1616_GIC_STRUCTURE_COUNT];
+  EFI_ACPI_6_1_GIC_DISTRIBUTOR_STRUCTUREGicDistributor;
+  EFI_ACPI_6_1_GIC_ITS_STRUCTUREGicITS[8];
+} EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE;
+
+#pragma pack ()
 
 #endif
diff --git a/Silicon/Hisilicon/Hi1616/D05AcpiTables/MadtHi1616.aslc 
b/Silicon/Hisilicon/Hi1616/D05AcpiTables/MadtHi1616.aslc
index 169ee72..54605a6 100644
--- a/Silicon/Hisilicon/Hi1616/D05AcpiTables/MadtHi1616.aslc
+++ b/Silicon/Hisilicon/Hi1616/D05AcpiTables/MadtHi1616.aslc
@@ -2,7 +2,7 @@
 *  Multiple APIC Description Table (MADT)
 *
 *  Copyright (c) 2012 - 2014, ARM Limited. All rights reserved.
-*  Copyright (c) 2015 - 2016, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2015 - 2018, Hisilicon Limited. All rights reserved.
 *  Copyright (c) 2015 - 2016, Linaro Limited. All rights reserved.
 *
 *  This program and the accompanying materials
@@ -27,27 +27,6 @@
 #include 
 #include "Hi1616Platform.h"
 
-// Differs from Juno, we have another affinity level beyond cluster and core
-// 0x2 is only for socket 0
-#define PLATFORM_GET_MPID_TA(ClusterId, CoreId)   (0x1 | ((ClusterId) << 
8) | (CoreId))
-#define PLATFORM_GET_MPID_TB(ClusterId, CoreId)   (0x3 | ((ClusterId) << 
8) | (CoreId))
-#define PLATFORM_GET_MPID_TA_2(ClusterId, CoreId)   (0x5 | ((ClusterId) << 
8) | (CoreId))
-#define PLATFORM_GET_MPID_TB_2(ClusterId, CoreId)   (0x7 | ((ClusterId) << 
8) | (CoreId))
-
-//
-// Multiple APIC Description Table
-//
-#pragma pack (1)
-
-typedef struct {
-  EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER   Header;
-  EFI_ACPI_6_1_GIC_STRUCTUREGicInterfaces[64];
-  EFI_ACPI_6_1_GIC_DISTRIBUTOR_STRUCTUREGicDistributor;
-  EFI_ACPI_6_1_GIC_ITS_STRUCTURE  GicITS[8];
-} EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE;
-
-#pragma pack ()
-
 EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE Madt = {
   {
 ARM_ACPI_HEADER (
-- 
1.9.1

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


[edk2] [Patch][edk2-platforms/devel-MinnowBoard3-UDK2017] Fix Windows 10 S3 failure.

2018-02-07 Thread zwei4
The FSP-S preferred memory region, which is defined in FSP Integration Guide, 
must be reserved for BIOS S3 resume.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: zwei4 
---
 .../PlatformPreMemPei/FvCallback.c | 29 +++---
 .../PlatformDsc/PcdsFixedAtBuild.dsc   |  2 ++
 2 files changed, 11 insertions(+), 20 deletions(-)

diff --git 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei/FvCallback.c
 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei/FvCallback.c
index 6a2c9fd91..4a3a67574 100644
--- 
a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei/FvCallback.c
+++ 
b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformPreMemPei/FvCallback.c
@@ -269,7 +269,6 @@ ParseObbPayload (
   UINTNVariableSize;
   EFI_STATUS   Status;
   EFI_FIRMWARE_VOLUME_HEADER   *FvHeader;
-  EFI_FIRMWARE_VOLUME_HEADER   *FvHeaderS3;
   EFI_PLATFORM_INFO_HOB*PlatformInfo;
   EFI_PEI_READ_ONLY_VARIABLE2_PPI  *VariableServices;
   SYSTEM_CONFIGURATION SystemConfiguration;
@@ -298,13 +297,17 @@ ParseObbPayload (
   DEBUG ((EFI_D_INFO, "FSP-S Fsp Size = 0x%X\n", FspHeader->ImageSize));
 
   //
-  // Copy to FSP-S to preferred base
+  // Copy to FSP-S to preferred base. The preferred base is defined in FSP 
Integration Guide.
+  // This region must be reserved for BIOS S3 resume.
   //
+  BuildMemoryAllocationHob (
+(EFI_PHYSICAL_ADDRESS)FspSImageBase,
+(UINT64)FspHeader->ImageSize,
+EfiReservedMemoryType
+  );
   CopyMemSse4 ((VOID*) FspSImageBase, FvHeader, (UINT32) FvHeader->FvLength);
 
-  if (BootMode != BOOT_ON_S3_RESUME) {
-PcdSet32S (PcdFspsBaseAddress, (UINT32) FspSImageBase);
-  }
+  PcdSet32S (PcdFspsBaseAddress, (UINT32) FspSImageBase);
 
   while ((UINT32) FvHeader < PayloadTail) {
 if (FvHeader->Signature != EFI_FVH_SIGNATURE) {
@@ -319,21 +322,7 @@ ParseObbPayload (
 }
 DEBUG ((EFI_D_INFO, "Found Fv with GUID: %g\n", FvName));
 
-if (BootMode == BOOT_ON_S3_RESUME) {
-  //
-  // FspW requires both IBBR and FSP-S on S3 resume
-  // but only copy FSP-S, do not install it.
-  //
-  DEBUG ((DEBUG_INFO, "S3 Resume: Only looking for IBBR and FSP-S.\n"));
-  if (CompareGuid (FvName, &gFspSFirmwareFileSystemFvGuid) || CompareGuid 
(FvName, &gIbbrFirmwareFileSystemFvGuid)) {
-FvHeaderS3 = FvHeader;
-if (CompareGuid (FvName, &gIbbrFirmwareFileSystemFvGuid)) {
-  PeiServicesInstallFvInfoPpi (NULL, FvHeaderS3, (UINT32) 
FvHeaderS3->FvLength, NULL, NULL);
-} else {
-  PcdSet32S (PcdFspsBaseAddress, (UINT32) FvHeaderS3);
-}
-  }
-} else if (CompareGuid (&FvHeader->FileSystemGuid, 
&gEfiSystemNvDataFvGuid)) {
+if (CompareGuid (&FvHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid)) {
   DEBUG ((EFI_D_INFO, "NVStorage FV at 0x%x.\n", (UINT32) FvHeader));
   Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, 
NULL, (VOID **) &VariableServices);
   if (EFI_ERROR (Status)) {
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
index b7cefdca0..6c26acaf5 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
@@ -83,4 +83,6 @@
 gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl|FALSE
   !endif
+  
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x3000
 
-- 
2.14.1.windows.1

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


[edk2] [PATCH edk2-platforms v4 03/15] Hisilicon/D0x/BDS: Switch to Generic BDS driver

2018-02-07 Thread Heyi Guo
Hisilicon-specific PlatformBootManagerLib added. It is convenient
to add specific feature, like BMC control boot option.
Remove Intel BDS from dsc file because it is out of use.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
Signed-off-by: Heyi Guo 
Signed-off-by: Jason Zhang 
Reviewed-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 
---
 Platform/Hisilicon/D03/D03.dsc  |  
17 +-
 Platform/Hisilicon/D03/D03.fdf  |  
 3 +-
 Platform/Hisilicon/D05/D05.dsc  |  
17 +-
 Platform/Hisilicon/D05/D05.fdf  |  
 3 +-
 Silicon/Hisilicon/HisiPkg.dec   |  
 2 +
 Silicon/Hisilicon/Hisilicon.dsc.inc |  
 1 +
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c   | 
636 
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.h   |  
31 +
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  
73 +++
 9 files changed, 777 insertions(+), 6 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index b434f68..5fbe1f9 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -68,6 +68,13 @@
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
   
PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+  
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
+  BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
+  SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+  
PlatformBootManagerLib|Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+  FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
 
   # USB Requirements
@@ -187,7 +194,7 @@
 
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
-  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 
0x7C, 0x3E, 0x9E, 0x1C, 0x4F, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 
}|VOID*|0x0001006b
 
   gHisiTokenSpaceGuid.PcdSysControlBaseAddress|0x4001
   gHisiTokenSpaceGuid.PcdMailBoxAddress|0xFFF8
@@ -405,6 +412,12 @@
   MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
   MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
 
+  MdeModulePkg/Application/UiApp/UiApp.inf {
+
+  NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
+  NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
+  
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
+  }
   MdeModulePkg/Application/HelloWorld/HelloWorld.inf
   #
   # Bds
@@ -457,7 +470,7 @@
 
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
-  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+  MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
   #
   # UEFI application (Shell Embedded Boot Loader)
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index 0b38eb4..474f37f 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -283,6 +283,7 @@ READ_LOCK_STATUS   = TRUE
   INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
 !endif #$(INCLUDE_TFTP_COMMAND)
 
+  INF MdeModulePkg/Application/UiApp/UiApp.inf
   #
   # Bds
   #
@@ -291,7 +292,7 @@ READ_LOCK_STATUS   = TRUE
   INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
   INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
-  INF IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+  INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
 [FV.FVMAIN_COMPACT]
 FvAlignment= 16
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 710339c..4d630da 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -84,6 +84,12 @@
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
   
PlatformBdsLib|Silicon/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf
+  
UefiBootManagerL

  1   2   >