[edk2] [PATCH] MdePkg: Add the missing spec version information for header files

2018-08-21 Thread shenglei
Cc: Michael D Kinney 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei 
---
 MdePkg/Include/Protocol/AbsolutePointer.h| 3 +++
 MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h | 3 +++
 MdePkg/Include/Protocol/AcpiTable.h  | 3 +++
 MdePkg/Include/Protocol/AtaPassThru.h| 3 +++
 MdePkg/Include/Protocol/BlockIoCrypto.h  | 5 -
 MdePkg/Include/Protocol/ExtendedSalBootService.h | 3 +++
 MdePkg/Include/Protocol/ExtendedSalServiceClasses.h  | 3 +++
 MdePkg/Include/Protocol/HiiConfigAccess.h| 3 +++
 MdePkg/Include/Protocol/HiiConfigKeyword.h   | 4 
 MdePkg/Include/Protocol/HiiConfigRouting.h   | 4 
 MdePkg/Include/Protocol/HiiDatabase.h| 3 +++
 MdePkg/Include/Protocol/HiiFont.h| 3 +++
 MdePkg/Include/Protocol/HiiImage.h   | 3 +++
 MdePkg/Include/Protocol/HiiImageDecoder.h| 5 -
 MdePkg/Include/Protocol/HiiImageEx.h | 5 -
 MdePkg/Include/Protocol/HiiPopup.h   | 5 -
 MdePkg/Include/Protocol/HiiString.h  | 3 +++
 MdePkg/Include/Protocol/MmReportStatusCodeHandler.h  | 3 +++
 MdePkg/Include/Protocol/NvmExpressPassthru.h | 3 +++
 MdePkg/Include/Protocol/Pcd.h| 3 +++
 MdePkg/Include/Protocol/PcdInfo.h| 3 +++
 MdePkg/Include/Protocol/RegularExpressionProtocol.h  | 5 -
 MdePkg/Include/Protocol/ReportStatusCodeHandler.h| 3 +++
 MdePkg/Include/Protocol/SmartCardEdge.h  | 5 -
 MdePkg/Include/Protocol/SmmReportStatusCodeHandler.h | 3 +++
 MdePkg/Include/Protocol/UsbFunctionIo.h  | 5 -
 26 files changed, 87 insertions(+), 7 deletions(-)

diff --git a/MdePkg/Include/Protocol/AbsolutePointer.h 
b/MdePkg/Include/Protocol/AbsolutePointer.h
index ecf476d7c0..ac1103aa35 100644
--- a/MdePkg/Include/Protocol/AbsolutePointer.h
+++ b/MdePkg/Include/Protocol/AbsolutePointer.h
@@ -11,6 +11,9 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+  @par Revision Reference:
+  This Protocol was introduced in UEFI Specification 2.3.
+
 **/
 
 #ifndef __ABSOLUTE_POINTER_H__
diff --git a/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h 
b/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
index c8bd429f1f..96913c68d1 100644
--- a/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
+++ b/MdePkg/Include/Protocol/AcpiSystemDescriptionTable.h
@@ -10,6 +10,9 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+  @par Revision Reference:
+  This Protocol was introduced in PI Specification 1.2.
+
 **/
 
 #ifndef __ACPI_SYSTEM_DESCRIPTION_TABLE_H___
diff --git a/MdePkg/Include/Protocol/AcpiTable.h 
b/MdePkg/Include/Protocol/AcpiTable.h
index 753d79e6bb..fbbd68d289 100644
--- a/MdePkg/Include/Protocol/AcpiTable.h
+++ b/MdePkg/Include/Protocol/AcpiTable.h
@@ -11,6 +11,9 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+  @par Revision Reference:
+  This Protocol was introduced in UEFI Specification 2.3.
+
 **/
 
 #ifndef __ACPI_TABLE_H___
diff --git a/MdePkg/Include/Protocol/AtaPassThru.h 
b/MdePkg/Include/Protocol/AtaPassThru.h
index 6d9b9f10b4..4979fadbfd 100644
--- a/MdePkg/Include/Protocol/AtaPassThru.h
+++ b/MdePkg/Include/Protocol/AtaPassThru.h
@@ -12,6 +12,9 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+  @par Revision Reference:
+  This Protocol was introduced in UEFI Specification 2.3.
+
 **/
 
 #ifndef __ATA_PASS_THROUGH_H__
diff --git a/MdePkg/Include/Protocol/BlockIoCrypto.h 
b/MdePkg/Include/Protocol/BlockIoCrypto.h
index 821b846d30..ac3740dcde 100644
--- a/MdePkg/Include/Protocol/BlockIoCrypto.h
+++ b/MdePkg/Include/Protocol/BlockIoCrypto.h
@@ -2,7 +2,7 @@
   The UEFI Inline Cryptographic Interface protocol provides services to 
abstract
   access to inline cryptographic capabilities.
 
-  Copyright (c) 2015, 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
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -11,6 +11,9 @@
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+  @par Revision Reference:
+  This Protocol was introduced in UEFI Specification 2.5.
+
 **/
 
 #ifndef __BLOCK_IO_CRYPTO_H__
diff --git 

[edk2] [Patch][edk2-platforms/devel-IntelAtomProcessorE3900] MinnowBoard3 Module UART

2018-08-21 Thread Guo, Mang
1. Change MinnowBoard3 Module UART number from 0 to 2.
2. Add zero checking before SetVariable to avoid seting variable each time boot.

Cc: David Wei 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Guo Mang 
---
 .../Board/UP2/BoardInitDxe/BoardInitDxe.c| 20 +++-
 .../PlatformDsc/PcdsFixedAtBuild.dsc |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitDxe/BoardInitDxe.c 
b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitDxe/BoardInitDxe.c
index 662d8f1..e0e2d93 100644
--- a/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitDxe/BoardInitDxe.c
+++ b/Platform/BroxtonPlatformPkg/Board/UP2/BoardInitDxe/BoardInitDxe.c
@@ -63,15 +63,17 @@ UpdateSetupVariable (
   ASSERT_EFI_ERROR (Status);
 
   if (Status == EFI_SUCCESS) {
-mSystemConfiguration.PcieRootPortEn[3]= (UINT8) 0;
-Status = gRT->SetVariable (
-L"Setup",
-,
-VariableAttributes,
-VarSize,
-
-);
-ASSERT_EFI_ERROR (Status);
+if (mSystemConfiguration.PcieRootPortEn[3] != 0) {
+  mSystemConfiguration.PcieRootPortEn[3]= (UINT8) 0;
+  Status = gRT->SetVariable (
+  L"Setup",
+  ,
+  VariableAttributes,
+  VarSize,
+  
+  );
+  ASSERT_EFI_ERROR (Status);
+}
   }
   
   return Status;
diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc 
b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
index db9b2e6..db7cba5 100644
--- a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
+++ b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFixedAtBuild.dsc
@@ -86,7 +86,7 @@
   
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x3000
   
-  !if $(UP2_BOARD) == TRUE || $(MINNOW3_MODULE_BOARD) == TRUE
+  !if $(UP2_BOARD) == TRUE
 gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|0
   !else 
 gPlatformModuleTokenSpaceGuid.PcdSerialIoUartNumber|2
-- 
2.10.1.windows.1

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


Re: [edk2] [PATCH] MdeModulePkg UhciPei: Remove a redundant function

2018-08-21 Thread Zeng, Star
It is changing EhciPei but not UhciPei, please update the title.

Reviewed-by: Star Zeng  with the title updated.


Thanks,
Star
-Original Message-
From: Zhang, Shenglei 
Sent: Wednesday, August 22, 2018 9:50 AM
To: edk2-devel@lists.01.org
Cc: Zeng, Star ; Dong, Eric 
Subject: [PATCH] MdeModulePkg UhciPei: Remove a redundant function

The function UsbHcUnlinkMemBlock that is never called and its related comments 
have been removed.
It is missed in the patch series according to the log in
https://bugzilla.tianocore.org/show_bug.cgi?id=1062

Cc: Star Zeng 
Cc: Eric Dong 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei 
---
 MdeModulePkg/Bus/Pci/EhciPei/UsbHcMem.c | 27 -
 1 file changed, 27 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/EhciPei/UsbHcMem.c 
b/MdeModulePkg/Bus/Pci/EhciPei/UsbHcMem.c
index 3cc31f5054..9f048e7b27 100644
--- a/MdeModulePkg/Bus/Pci/EhciPei/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/EhciPei/UsbHcMem.c
@@ -293,31 +293,6 @@ UsbHcIsMemBlockEmpty (
   return TRUE;
 }
 
-/**
-  Unlink the memory block from the pool's list.
-
-  @param  Head   The block list head of the memory's pool.
-  @param  BlockToUnlink  The memory block to unlink.
-
-**/
-VOID
-UsbHcUnlinkMemBlock (
-  IN USBHC_MEM_BLOCK  *Head,
-  IN USBHC_MEM_BLOCK  *BlockToUnlink
-  )
-{
-  USBHC_MEM_BLOCK *Block;
-
-  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
-
-  for (Block = Head; Block != NULL; Block = Block->Next) {
-if (Block->Next == BlockToUnlink) {
-  Block->Next = BlockToUnlink->Next;
-  BlockToUnlink->Next = NULL;
-  break;
-}
-  }
-}
 
 /**
   Initialize the memory management pool for the host controller.
@@ -390,8 +365,6 @@ UsbHcFreeMemPool (
 
   //
   // Unlink all the memory blocks from the pool, then free them.
-  // UsbHcUnlinkMemBlock can't be used to unlink and free the
-  // first block.
   //
   for (Block = Pool->Head->Next; Block != NULL; Block = Block->Next) {
 UsbHcFreeMemBlock (Ehc, Pool, Block);
--
2.18.0.windows.1

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


Re: [edk2] [PATCH 3/4] NetworkPkg/TlsAuthConfigDxe: fix TlsCaCertificate attributes retrieval

2018-08-21 Thread Wu, Jiaxin
Reviewed-by: Wu Jiaxin 

Thanks,
Jiaxin

> -Original Message-
> From: Li, Songpeng
> Sent: Monday, August 20, 2018 2:29 PM
> To: Laszlo Ersek ; edk2-devel-01  de...@lists.01.org>
> Cc: Wu, Jiaxin ; Fu, Siyuan 
> Subject: RE: [PATCH 3/4] NetworkPkg/TlsAuthConfigDxe: fix TlsCaCertificate
> attributes retrieval
> 
> It worked on my end.
> 
> Tested-by: Songpeng Li 
> 
> 
> Thanks & Best Regards,
> Songpeng
> 
> > -Original Message-
> > From: Laszlo Ersek [mailto:ler...@redhat.com]
> > Sent: Friday, August 17, 2018 10:36 PM
> > To: edk2-devel-01 
> > Cc: Wu, Jiaxin ; Fu, Siyuan ; Li,
> > Songpeng 
> > Subject: [PATCH 3/4] NetworkPkg/TlsAuthConfigDxe: fix TlsCaCertificate
> > attributes retrieval
> >
> > Per spec, the GetVariable() runtime service is not required to populate
> > (*Attributes) on output when it fails with EFI_BUFFER_TOO_SMALL.
> >
> > Therefore we have to fetch the full contents of the TlsCaCertificate
> > variable temporarily, just so we can (a) get the current attributes, and
> > (b) add EFI_VARIABLE_APPEND_WRITE to them for the subsequent
> > SetVariable()
> > call.
> >
> > Cc: Jiaxin Wu 
> > Cc: Siyuan Fu 
> > Cc: Songpeng Li 
> > Reported-by: Songpeng Li 
> > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1090
> > Fixes: b90c335fbbb674470fbf09601cc522bf61564c30
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Laszlo Ersek 
> > ---
> >
> > Notes:
> > Tested via loading the same CA cert .pem file twice in a row, using the
> > HII form, first without any pre-existent TlsCaCertificate variable.
> >
> > Songpeng, can you please test this patch as well, and confirm if it
> > works on your end? Thanks!
> >
> >  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c | 27
> > +++-
> >  1 file changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
> > b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
> > index 7259c5e82f61..0780b03bbab4 100644
> > --- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
> > +++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
> > @@ -663,6 +663,7 @@ EnrollX509toVariable (
> >EFI_SIGNATURE_LIST*CACert;
> >EFI_SIGNATURE_DATA*CACertData;
> >VOID  *Data;
> > +  VOID  *CurrentData;
> >UINTN DataSize;
> >UINTN SigDataSize;
> >UINT32Attr;
> > @@ -674,6 +675,7 @@ EnrollX509toVariable (
> >CACert= NULL;
> >CACertData= NULL;
> >Data  = NULL;
> > +  CurrentData   = NULL;
> >Attr  = 0;
> >
> >Status = ReadFileContent (
> > @@ -716,11 +718,30 @@ EnrollX509toVariable (
> >Status = gRT->GetVariable(
> >VariableName,
> >,
> > -  ,
> > +  NULL,
> >,
> >NULL
> >);
> >if (Status == EFI_BUFFER_TOO_SMALL) {
> > +//
> > +// Per spec, we have to fetch the variable's contents, even though
> we're
> > +// only interested in the variable's attributes.
> > +//
> > +CurrentData = AllocatePool (DataSize);
> > +if (CurrentData == NULL) {
> > +  Status = EFI_OUT_OF_RESOURCES;
> > +  goto ON_EXIT;
> > +}
> > +Status = gRT->GetVariable(
> > +VariableName,
> > +,
> > +,
> > +,
> > +CurrentData
> > +);
> > +if (EFI_ERROR (Status)) {
> > +  goto ON_EXIT;
> > +}
> >  Attr |= EFI_VARIABLE_APPEND_WRITE;
> >} else if (Status == EFI_NOT_FOUND) {
> >  Attr = TLS_AUTH_CONFIG_VAR_BASE_ATTR;
> > @@ -751,6 +772,10 @@ ON_EXIT:
> >  FreePool (Data);
> >}
> >
> > +  if (CurrentData != NULL) {
> > +FreePool (CurrentData);
> > +  }
> > +
> >if (X509Data != NULL) {
> >  FreePool (X509Data);
> >}
> > --
> > 2.14.1.3.gb7cf6e02401b
> >

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


Re: [edk2] [PATCH edk2-platforms v2 11/43] Platform/Hisilicon/D06: Add M41T83RealTimeClockLib

2018-08-21 Thread Leif Lindholm



On Tue, Aug 14, 2018 at 04:08:31PM +0800, Ming Huang wrote:
> Add M41T83RealTimeClockLib for RTC.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang 
> ---
>  Platform/Hisilicon/D06/D06.dsc  
> |   1 +
>  Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf 
> |  46 ++
>  Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h  
> | 158 ++
>  Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.c   
> | 564 
>  4 files changed, 769 insertions(+)
> 
> diff --git a/Platform/Hisilicon/D06/D06.dsc b/Platform/Hisilicon/D06/D06.dsc
> index d14fce1159..27358f8c78 100644
> --- a/Platform/Hisilicon/D06/D06.dsc
> +++ b/Platform/Hisilicon/D06/D06.dsc
> @@ -65,6 +65,7 @@
>CpldIoLib|Silicon/Hisilicon/Library/CpldIoLib/CpldIoLib.inf
>  
>TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
> +  
> RealTimeClockLib|Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf
>  
>CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
>
> GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
> diff --git 
> a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf 
> b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf
> new file mode 100644
> index 00..e0bf6b3f24
> --- /dev/null
> +++ 
> b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClockLib.inf
> @@ -0,0 +1,46 @@
> +#/** @file
> +#
> +#  Copyright (c) 2018, Hisilicon Limited. All rights reserved.
> +#  Copyright (c) 2018, 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.
> +#
> +#**/
> +
> +[Defines]
> +  INF_VERSION= 0x0001001A
> +  BASE_NAME  = M41T83RealTimeClockLib
> +  FILE_GUID  = 470DFB96-E205-4515-A75E-2E60F853E79D
> +  MODULE_TYPE= BASE
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = RealTimeClockLib
> +
> +[Sources.common]
> +  M41T83RealTimeClockLib.c
> +
> +[Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdePkg/MdePkg.dec
> +  Platform/Hisilicon/D06/D06.dec
> +  Silicon/Hisilicon/HisiPkg.dec
> +
> +[LibraryClasses]
> +  BaseMemoryLib
> +  CpldIoLib
> +  DebugLib
> +  I2CLib
> +  IoLib
> +  PcdLib
> +  TimeBaseLib
> +  TimerLib
> +  UefiLib
> +  UefiRuntimeLib# Use EFiAtRuntime to check stage
> +
> +[Depex]
> +  gEfiCpuArchProtocolGuid
> diff --git 
> a/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h 
> b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h
> new file mode 100644
> index 00..ed10099bf3
> --- /dev/null
> +++ b/Silicon/Hisilicon/Library/M41T83RealTimeClockLib/M41T83RealTimeClock.h
> @@ -0,0 +1,158 @@
> +/** @file
> +
> +  Copyright (c) 2018, Hisilicon Limited. All rights reserved.
> +  Copyright (c) 2018, 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 __M41T83_REAL_TIME_CLOCK_H__
> +#define __M41T83_REAL_TIME_CLOCK_H__
> +
> +// The delay is need for cpld and I2C. This is a empirical value. 
> MemoryFance is no need.
> +#define RTC_DELAY_30_MS3
> +// The delay is need for cpld and I2C. This is a empirical value. 
> MemoryFance is no need.
> +#define RTC_DELAY_1000_MACROSECOND 1000
> +// The delay is need for cpld and I2C. This is a empirical value. 
> MemoryFance is no need.
> +#define RTC_DELAY_2_MACROSECOND2
> +
> +#define M41T83_REGADDR_DOTSECONDS   0x00
> +#define M41T83_REGADDR_SECONDS  0x01
> +#define M41T83_REGADDR_MINUTES  0x02
> +#define M41T83_REGADDR_HOURS0x03
> +#define M41T83_REGADDR_WEEK_DAY 0x04
> +#define M41T83_REGADDR_DAY  0x05
> +#define M41T83_REGADDR_MONTH0x06
> +#define M41T83_REGADDR_YEAR 0x07
> +#define M41T83_REGADDR_ALARM1SEC0x0E
> +#define M41T83_REGADDR_ALARM1MIN0x0D
> +#define M41T83_REGADDR_ALARM1HOUR   0x0C
> +#define 

Re: [edk2] [PATCH edk2-platforms v2 10/43] Hisilicon/D06: Add several base file for D06

2018-08-21 Thread Leif Lindholm
On Tue, Aug 14, 2018 at 04:08:30PM +0800, Ming Huang wrote:
> Add several base head files and add several build
> files for D06.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang 

All my comments have been addressed, so:
Reviewed-by: Leif Lindholm 

> ---
>  Platform/Hisilicon/D06/D06.dec   |  29 ++
>  Platform/Hisilicon/D06/D06.dsc   | 455 
> 
>  Platform/Hisilicon/D06/D06.fdf   | 351 +++
>  Platform/Hisilicon/D06/Include/Library/CpldD06.h |  37 ++
>  Silicon/Hisilicon/Hi1620/Include/Library/SerdesLib.h |  85 
>  Silicon/Hisilicon/Hi1620/Include/PlatformArch.h  |  61 +++
>  Silicon/Hisilicon/Include/Library/OemAddressMapLib.h |   6 +
>  Silicon/Hisilicon/Include/Library/OemNicLib.h|  57 +++
>  8 files changed, 1081 insertions(+)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v3 17/36] Hisilicon/I2C: Fix a typo issue

2018-08-21 Thread Leif Lindholm
Err, that was 13, 14 and 17 in v3.

In v2, it's 20, 21, 24.

(I pushed the right patches, I just replied to the wrong email.)

On Tue, Aug 21, 2018 at 10:45:44PM +0100, Leif Lindholm wrote:
> Patches 13, 14 and 17/43 are just cleanup and refactoring of I2C
> library. It can (and should) go in before D06 support.
> 
> For the three patches:
> Reviewed-by: Leif Lindholm 
> 
> Pushed as 4e6af5fa1b..342330470f.
> 
> On Thu, Aug 16, 2018 at 08:12:20PM +0800, Ming Huang wrote:
> > Modify spedd to Speed.
> > 
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ming Huang 
> > ---
> >  Silicon/Hisilicon/Library/I2CLib/I2CHw.h  | 2 +-
> >  Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CHw.h 
> > b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h
> > index d77aea509e..6fd7b8183e 100644
> > --- a/Silicon/Hisilicon/Library/I2CLib/I2CHw.h
> > +++ b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h
> > @@ -81,7 +81,7 @@
> >   struct
> >   {
> >  UINT32  master: 1   ;
> > -UINT32  spedd : 2   ;
> > +UINT32  Speed : 2   ;
> >  UINT32  slave_10bit   : 1   ;
> >  UINT32  master_10bit  : 1   ;
> >  UINT32  restart_en: 1   ;
> > diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c 
> > b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c
> > index 59633106ce..ed44ac204f 100644
> > --- a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c
> > +++ b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c
> > @@ -158,7 +158,7 @@ I2CInit (
> >  
> >I2C_REG_READ (Base + I2C_CON_OFFSET, I2cControlReg.Val32);
> >I2cControlReg.bits.master = 1;
> > -  I2cControlReg.bits.spedd = 0x1;
> > +  I2cControlReg.bits.Speed = 0x1;
> >I2cControlReg.bits.restart_en = 1;
> >I2cControlReg.bits.slave_disable = 1;
> >I2C_REG_WRITE (Base + I2C_CON_OFFSET, I2cControlReg.Val32);
> > -- 
> > 2.17.0
> > 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v3 17/36] Hisilicon/I2C: Fix a typo issue

2018-08-21 Thread Leif Lindholm
Patches 13, 14 and 17/43 are just cleanup and refactoring of I2C
library. It can (and should) go in before D06 support.

For the three patches:
Reviewed-by: Leif Lindholm 

Pushed as 4e6af5fa1b..342330470f.

On Thu, Aug 16, 2018 at 08:12:20PM +0800, Ming Huang wrote:
> Modify spedd to Speed.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang 
> ---
>  Silicon/Hisilicon/Library/I2CLib/I2CHw.h  | 2 +-
>  Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CHw.h 
> b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h
> index d77aea509e..6fd7b8183e 100644
> --- a/Silicon/Hisilicon/Library/I2CLib/I2CHw.h
> +++ b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h
> @@ -81,7 +81,7 @@
>   struct
>   {
>  UINT32  master: 1   ;
> -UINT32  spedd : 2   ;
> +UINT32  Speed : 2   ;
>  UINT32  slave_10bit   : 1   ;
>  UINT32  master_10bit  : 1   ;
>  UINT32  restart_en: 1   ;
> diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c 
> b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c
> index 59633106ce..ed44ac204f 100644
> --- a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c
> +++ b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c
> @@ -158,7 +158,7 @@ I2CInit (
>  
>I2C_REG_READ (Base + I2C_CON_OFFSET, I2cControlReg.Val32);
>I2cControlReg.bits.master = 1;
> -  I2cControlReg.bits.spedd = 0x1;
> +  I2cControlReg.bits.Speed = 0x1;
>I2cControlReg.bits.restart_en = 1;
>I2cControlReg.bits.slave_disable = 1;
>I2C_REG_WRITE (Base + I2C_CON_OFFSET, I2cControlReg.Val32);
> -- 
> 2.17.0
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v3 32/36] Silicon/Hisilicon/Setup: Support SPCR table switch

2018-08-21 Thread Leif Lindholm
On Thu, Aug 16, 2018 at 08:12:35PM +0800, Ming Huang wrote:
> If install SPCR table, KVM will not output while install or boot
> some OS, like ubuntu, so add SPCR switch setup item and set it
> disable by default.

This one was supposed to be replaced with
EmbeddedPkg/Drivers/ConsolePrefDxe, right?

/
Leif

> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang 
> Signed-off-by: Heyi Guo 
> ---
>  Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
>  Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c   | 24 
> 
>  2 files changed, 25 insertions(+)
> 
> diff --git 
> a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf 
> b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf
> index 281a4f2ebd..3d133aff85 100644
> --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf
> +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf
> @@ -51,6 +51,7 @@
>  
>  [Guids]
>gHisiEfiMemoryMapGuid
> +  gOemConfigGuid
>  
>  [Pcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile## CONSUMES
> diff --git a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c 
> b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c
> index 54f49977c3..32878ca4f9 100644
> --- a/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c
> +++ b/Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c
> @@ -16,8 +16,10 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define CORECOUNT(X) ((X) * CORE_NUM_PER_SOCKET)
> @@ -114,6 +116,25 @@ UpdateSlit (
>return  EFI_SUCCESS;
>  }
>  
> +STATIC
> +EFI_STATUS
> +IsNeedSpcr (
> +  IN OUT EFI_ACPI_DESCRIPTION_HEADER  *Table
> +  )
> +{
> +  EFI_STATUS Status;
> +  OEM_CONFIG_DATASetupData;
> +  UINTN  DataSize = sizeof (OEM_CONFIG_DATA);
> +
> +  Status = gRT->GetVariable (OEM_CONFIG_NAME, , NULL, 
> , );
> +  if (!EFI_ERROR (Status) && (SetupData.EnableSpcr == FALSE)) {
> +return EFI_ABORTED;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +
>  EFI_STATUS
>  UpdateAcpiTable (
>IN OUT EFI_ACPI_DESCRIPTION_HEADER  *TableHeader
> @@ -130,6 +151,9 @@ UpdateAcpiTable (
>case EFI_ACPI_6_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE:
>  Status = UpdateSlit (TableHeader);
>  break;
> +  case EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE:
> +Status = IsNeedSpcr (TableHeader);
> +break;
>}
>return Status;
>  }
> -- 
> 2.17.0
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 01/43] Silicon/Hisilicon: Modify the MRC interface for other module

2018-08-21 Thread Leif Lindholm
On Tue, Aug 14, 2018 at 04:08:21PM +0800, Ming Huang wrote:
> This patch is to unify D0x. Add pGBL_INTERFACE struct define
> and remove useless interfece. Replace DMRC pGblData with pGblInterface;

interfece ->
interface

I will fix that up on commit.
Reviewed-by: Leif Lindholm 


> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang 
> ---
>  Silicon/Hisilicon/Include/Library/HwMemInitLib.h| 356 
> 
>  Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/UpdateAcpiTable.c |   4 +-
>  Silicon/Hisilicon/Drivers/Smbios/MemorySubClassDxe/MemorySubClass.c |  26 +-
>  3 files changed, 78 insertions(+), 308 deletions(-)
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH edk2-platforms v2 05/43] Silicon/Hisilicon/D0x: Move RAS macro to PlatformArch.h

2018-08-21 Thread Leif Lindholm
This one needs to be rebased onto the modified 3/43.
I have no other issues with it, so when you resubmit:
Reviewed-by: Leif Lindholm 

On Tue, Aug 14, 2018 at 04:08:25PM +0800, Ming Huang wrote:
> From: Sun Yuanchen 
> 
> Move some RAS macros definition to PlatformArch.h for
> unifying D0x
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Sun Yuanchen 
> ---
>  Silicon/Hisilicon/Hi1610/Include/PlatformArch.h |  9 +++--
>  Silicon/Hisilicon/Hi1616/Include/PlatformArch.h | 12 
>  2 files changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/Silicon/Hisilicon/Hi1610/Include/PlatformArch.h 
> b/Silicon/Hisilicon/Hi1610/Include/PlatformArch.h
> index 2ff076901e..f39ae0748c 100644
> --- a/Silicon/Hisilicon/Hi1610/Include/PlatformArch.h
> +++ b/Silicon/Hisilicon/Hi1610/Include/PlatformArch.h
> @@ -1,7 +1,7 @@
>  /** @file
>  *
> -*  Copyright (c) 2015, Hisilicon Limited. All rights reserved.
> -*  Copyright (c) 2015, Linaro Limited. All rights reserved.
> +*  Copyright (c) 2015 - 2018, Hisilicon Limited. All rights reserved.
> +*  Copyright (c) 2015 - 2018, 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
> @@ -32,6 +32,11 @@
>  
>  #define S1_BASE   0x400
>  
> +#define RASC_BASE(0x5000)
> +/* configuration register for Rank statistical information */
> +#define RASC_CFG_INFOIDX_REG (RASC_BASE + 0x5C)
> +/* configuration register for Sparing level */
> +#define RASC_CFG_SPLVL_REG   (RASC_BASE + 0xB8)
>  
>  //
>  // ACPI table information used to initialize tables.
> diff --git a/Silicon/Hisilicon/Hi1616/Include/PlatformArch.h 
> b/Silicon/Hisilicon/Hi1616/Include/PlatformArch.h
> index 60a60593be..e02e4bdabd 100644
> --- a/Silicon/Hisilicon/Hi1616/Include/PlatformArch.h
> +++ b/Silicon/Hisilicon/Hi1616/Include/PlatformArch.h
> @@ -30,6 +30,18 @@
>  // Max NUMA node number for each node type
>  #define MAX_NUM_PER_TYPE 8
>  
> +#define RASC_BASE(0x5000)
> +/* configuration register for Rank statistical information */
> +#define RASC_CFG_INFOIDX_REG (RASC_BASE + 0x5C)
> +/* configuration register for Sparing level */
> +#define RASC_CFG_SPLVL_REG   (RASC_BASE + 0xB8)
> +
> +// for acpi
> +#define NODE_IN_SOCKET  2
> +#define CORE_NUM_PER_SOCKET 32
> +#define EFI_ACPI_MEMORY_AFFINITY_STRUCTURE_COUNT10
> +#define EFI_ACPI_6_2_ITS_AFFINITY_STRUCTURE_COUNT   8
> +
>  #define S1_BASE   0x400
>  
>  //
> -- 
> 2.17.0
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH V2] BaseTools: Fix regression issue by b23414f6540d

2018-08-21 Thread Carsey, Jaben
Reviewed-by: Jaben Carsey 

> -Original Message-
> From: Zhu, Yonghong
> Sent: Monday, August 20, 2018 10:33 PM
> To: Feng, YunhuaX ; edk2-devel@lists.01.org
> Cc: Gao, Liming ; Carsey, Jaben
> ; Zhu, Yonghong 
> Subject: RE: [PATCH V2] BaseTools: Fix regression issue by b23414f6540d
> Importance: High
> 
> Reviewed-by: Yonghong Zhu 
> 
> Best Regards,
> Zhu Yonghong
> 
> 
> -Original Message-
> From: Feng, YunhuaX
> Sent: Tuesday, August 21, 2018 8:49 AM
> To: edk2-devel@lists.01.org
> Cc: Zhu, Yonghong ; Gao, Liming
> ; Carsey, Jaben 
> Subject: [PATCH V2] BaseTools: Fix regression issue by b23414f6540d
> 
> V2: Renaming function DepexExpressionTokenList to  DepexExpressionDict
> instead of changing the callers
> 
> Fix regression issue by b23414f6540d4f336b6f00b44681911d469f9a04
> AttributeError: 'ModuleAutoGen' object has no attribute
> 'DepexExpressionDict'
> 
> Cc: Liming Gao 
> Cc: Yonghong Zhu 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Yunhua Feng 
> ---
>  BaseTools/Source/Python/AutoGen/AutoGen.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
> b/BaseTools/Source/Python/AutoGen/AutoGen.py
> index 3b1ddc74e8..d30a9be6ee 100644
> --- a/BaseTools/Source/Python/AutoGen/AutoGen.py
> +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
> @@ -2899,11 +2899,11 @@ class ModuleAutoGen(AutoGen):
>  ## Merge dependency expression
>  #
>  #   @retval listThe token list of the dependency expression after
> parsed
>  #
>  @cached_property
> -def DepexExpressionTokenList(self):
> +def DepexExpressionDict(self):
>  if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE 
> in
> self.FileTypes:
>  return {}
> 
>  RetVal = {self.ModuleType:''}
> 
> --
> 2.12.2.windows.2

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


Re: [edk2] [PATCH v2 3/4] UefiCpuPkg/CpuDxe: implement non-stop mode for uefi

2018-08-21 Thread Laszlo Ersek
I only have some superficial comments here.

On 08/21/18 05:05, Jian J Wang wrote:
>> v2 changes:
>>n/a
> 
> Same as SMM profile feature, a special #PF is used to set page attribute
> to 'present' and a special #DB handler to reset it back to 'not-present',
> right after the instruction causing #PF got executed.
> 
> Since the new #PF handler won't enter into dead-loop, the instruction
> which caused the #PF will get chance to re-execute with accessible pages.
> 
> The exception message will still be printed out on debug console so that
> the developer/QA can find that there's potential heap overflow or null
> pointer access occurred.
> 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  UefiCpuPkg/CpuDxe/CpuDxe.h   |  39 ++
>  UefiCpuPkg/CpuDxe/CpuDxe.inf |   3 +
>  UefiCpuPkg/CpuDxe/CpuMp.c|  34 -
>  UefiCpuPkg/CpuDxe/CpuPageTable.c | 271 
> +++
>  4 files changed, 341 insertions(+), 6 deletions(-)
> 
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
> index 540f5f2dbf..7d65e39e90 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.h
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
> @@ -57,6 +57,12 @@
> EFI_MEMORY_RO\
> )
>  
> +#define HEAP_GUARD_NONSTOP_MODE   \
> +((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT1|BIT0)) > BIT6)
> +
> +#define NULL_DETECTION_NONSTOP_MODE   \
> +((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT0)) > 
> BIT6)
> +
>  /**
>Flush CPU data cache. If the instruction cache is fully coherent
>with all DMA operations then function can just return EFI_SUCCESS.
> @@ -273,7 +279,40 @@ RefreshGcdMemoryAttributesFromPaging (
>VOID
>);
>  
> +/**
> +  Special handler for #DB exception, which will restore the page attributes
> +  (not-present). It should work with #PF handler which will set pages to
> +  'present'.
> +
> +  @param ExceptionType  Exception type.
> +  @param SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
> +
> +**/
> +VOID
> +EFIAPI
> +DebugExceptionHandler (
> +  IN EFI_EXCEPTION_TYPE   InterruptType,
> +  IN EFI_SYSTEM_CONTEXT   SystemContext
> +  );
> +
> +/**
> +  Special handler for #PF exception, which will set the pages which caused
> +  #PF to be 'present'. The attribute of those pages should be restored in
> +  the subsequent #DB handler.
> +
> +  @param ExceptionType  Exception type.
> +  @param SystemContext  Pointer to EFI_SYSTEM_CONTEXT.
> +
> +**/
> +VOID
> +EFIAPI
> +PageFaultExceptionHandler (
> +  IN EFI_EXCEPTION_TYPE   InterruptType,
> +  IN EFI_SYSTEM_CONTEXT   SystemContext
> +  );
> +
>  extern BOOLEAN mIsAllocatingPageTable;
> +extern UINTN   mNumberOfProcessors;
>  
>  #endif
>  
> diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf
> index 6a199b72f7..97a381b046 100644
> --- a/UefiCpuPkg/CpuDxe/CpuDxe.inf
> +++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf
> @@ -46,6 +46,7 @@
>ReportStatusCodeLib
>MpInitLib
>TimerLib
> +  PeCoffGetEntryPointLib
>  
>  [Sources]
>CpuDxe.c
> @@ -79,6 +80,8 @@
>  [Pcd]
>gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask## 
> CONSUMES
>gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard   ## 
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask   ## 
> CONSUMES
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask## 
> CONSUMES
>gUefiCpuPkgTokenSpaceGuid.PcdCpuStackSwitchExceptionList  ## 
> CONSUMES
>gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownGoodStackSize## 
> CONSUMES
>  
> diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
> index 82145e7624..f8489eb1c3 100644
> --- a/UefiCpuPkg/CpuDxe/CpuMp.c
> +++ b/UefiCpuPkg/CpuDxe/CpuMp.c
> @@ -673,10 +673,6 @@ InitializeMpExceptionStackSwitchHandlers (
>UINT8   *GdtBuffer;
>UINT8   *StackTop;
>  
> -  if (!PcdGetBool (PcdCpuStackGuard)) {
> -return;
> -  }
> -
>ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);
>NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;
>  
> @@ -790,6 +786,32 @@ InitializeMpExceptionStackSwitchHandlers (
>}
>  }
>  
> +/**
> +  Initializes MP exceptions handlers for special features, such as Heap Guard
> +  and Stack Guard.
> +**/
> +VOID
> +InitializeMpExceptionHandlers (
> +  VOID
> +  )
> +{
> +  //
> +  // Enable non-stop mode for #PF triggered by Heap Guard or NULL Pointer
> +  // Detection.
> +  //
> +  if (HEAP_GUARD_NONSTOP_MODE || NULL_DETECTION_NONSTOP_MODE) {
> +RegisterCpuInterruptHandler(EXCEPT_IA32_DEBUG, DebugExceptionHandler);
> +RegisterCpuInterruptHandler(EXCEPT_IA32_PAGE_FAULT, 
> PageFaultExceptionHandler);
> +  }
> +
> +  //
> +  // Setup stack switch for 

Re: [edk2] [PATCH v2 2/4] UefiCpuPkg/CpuExceptionHandlerLib: Setup single step in #PF handler

2018-08-21 Thread Laszlo Ersek
On 08/21/18 05:05, Jian J Wang wrote:
>> v2 changes:
>>n/a
> 
> Once the #PF handler has set the page to be 'present', there should
> be a way to reset it to 'not-present'. 'TF' bit in EFLAGS can be used
> for this purpose. 'TF' bit will be set in interrupted function context
> so that it can be triggered once the cpu control returns back to the
> instruction causing #PF and re-execute it.
> 
> This is an necessary step to implement non-stop mode for Heap Guard
> and NULL Pointer Detection feature.
> 
> Cc: Eric Dong 
> Cc: Laszlo Ersek 
> Cc: Ruiyu Ni 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang 
> ---
>  .../Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm   | 7 
> +++
>  .../Library/CpuExceptionHandlerLib/Ia32/ExceptionTssEntryAsm.nasm  | 4 +---
>  .../Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm| 4 
>  3 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git 
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm 
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm
> index 45d6474091..6fcf5fb23f 100644
> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm
> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionHandlerAsm.nasm
> @@ -383,6 +383,13 @@ ErrorCodeAndVectorOnStack:
>  pop dword [ebp - 4]
>  mov esp, ebp
>  pop ebp
> +
> +; Enable TF bit after page fault handler runs
> +cmp dword [esp], 14   ; #PF?
> +jne .5
> +bts dword [esp + 16], 8   ; EFLAGS
> +
> +.5:
>  add esp, 8
>  cmp dword [esp - 16], 0   ; check 
> EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
>  jz  DoReturn
> diff --git 
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionTssEntryAsm.nasm 
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionTssEntryAsm.nasm
> index 62bcedea1a..7aac29c7e7 100644
> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionTssEntryAsm.nasm
> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Ia32/ExceptionTssEntryAsm.nasm
> @@ -355,10 +355,8 @@ o16 mov [ecx + IA32_TSS._SS], ax
>  movzx  ebx, word [ecx + IA32_TSS._CS]
>  mov[eax - 0x8], ebx  ; create CS in old stack
>  movebx, dword [ecx + IA32_TSS.EFLAGS]
> -btsebx, 8
> +btsebx, 8; Set TF
>  mov[eax - 0x4], ebx  ; create eflags in old stack
> -movdword [ecx + IA32_TSS.EFLAGS], ebx; update eflags in old TSS
> -moveax, dword [ecx + IA32_TSS._ESP]  ; Get old stack pointer
>  subeax, 0xc  ; minus 12 byte
>  movdword [ecx + IA32_TSS._ESP], eax  ; Set new stack pointer
>  
> diff --git 
> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> index 7b97810d10..f842af2336 100644
> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> @@ -336,6 +336,10 @@ HasErrorCode:
>  pop r15
>  
>  mov rsp, rbp
> +cmp qword [rbp + 8], 14 ; #PF?
> +jne .1
> +bts qword [rsp + 40], 8 ; RFLAGS.TF
> +.1:
>  pop rbp
>  add rsp, 16
>  cmp qword [rsp - 32], 0  ; check 
> EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
> 

I'll defer to Ray and Eric on this.

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


Re: [edk2] [PATCH v2 0/4] Support non-stop mode in heap guard and null detection

2018-08-21 Thread Laszlo Ersek
On 08/21/18 05:05, Jian J Wang wrote:
>> v2 changes:
>>fix GCC build error
> 
> Background:
> Heap Guard and NULL Pointer Detection are very useful features to detect
> code flaw in EDK II. If an issue is detected, #PF exception will be
> triggered and the BIOS will enter into dead loop, which is the default
> behavior of exception handling. From QA perspective, this default behavior
> will block them to collect all tests result in reasonable time.
> 
> Solution:
> This patch series update CpuDxe, PiSmmCpuDxeSmm and CpuExceptionHandlerLib
> to allow the code to continue execution after #PF. The mechanism behind it
> is the same as SMM Profile feature, in which a special #PF handler is
> registered to set the page causing #PF to be 'present' and setup single
> steop trap, then return the control back to the instruction accessing that
> page. Once the instruction is re-executed, a #DB is triggered and a special
> handler for it will be called to reset the page back to 'not-present'.
> 
> Usage:
> The non-stop mode is enabled/disabled by BIT6 of following PCDs
> 
>   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask
>   gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
> 
> The default setting is 'disable'.
> 
> BZ Tracker:
> https://bugzilla.tianocore.org/show_bug.cgi?id=1095
> 
> OS Boot Validation:
>   Platform: OVMF
>   OS (x64): Fedora 26, Ubuntu 18.04, Windows 10, Windows 7
> 
> Jian J Wang (4):
>   MdeModulePkg/MdeModulePkg.dec: add new settings for PCDs
>   UefiCpuPkg/CpuExceptionHandlerLib: Setup single step in #PF handler
>   UefiCpuPkg/CpuDxe: implement non-stop mode for uefi
>   UefiCpuPkg/PiSmmCpuDxeSmm: implement non-stop mode for SMM
> 
>  MdeModulePkg/MdeModulePkg.dec  |   4 +-
>  UefiCpuPkg/CpuDxe/CpuDxe.h |  39 +++
>  UefiCpuPkg/CpuDxe/CpuDxe.inf   |   3 +
>  UefiCpuPkg/CpuDxe/CpuMp.c  |  34 ++-
>  UefiCpuPkg/CpuDxe/CpuPageTable.c   | 271 
> +
>  .../Ia32/ExceptionHandlerAsm.nasm  |   7 +
>  .../Ia32/ExceptionTssEntryAsm.nasm |   4 +-
>  .../X64/ExceptionHandlerAsm.nasm   |   4 +
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/PageTbl.c   |  43 ++--
>  UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmiException.nasm   |   3 +-
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c |  58 -
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h |  15 ++
>  UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h |   6 +
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c|  43 ++--
>  14 files changed, 493 insertions(+), 41 deletions(-)
> 


(1) This looks like a feature addition, so please include the BZ
reference (1095) on the following wiki page:

https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning

(under "Proposed Features")

(2) The general description should be moved (or copied) from this email
(v2 0/4) to patch #1 (v2 1/4). The cover letter is not captured in the
commit log, and I think there isn't going to be any other documentation
for the feature than the DEC file.

(Note that I'm not suggesting that you add the documentation to the DEC
file in patch #1 -- instead, the commit message on patch #1 should
contain it. Then people can find the commit from the DEC file with "git
blame", and read the description.)

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


Re: [edk2] [PATCH v2 4/7] MdePkg: Remove an unused PCD

2018-08-21 Thread Laszlo Ersek
On 08/21/18 03:35, shenglei wrote:
> The PCD below is unused, so it has been removed from inf.
> gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Laszlo Ersek 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: shenglei 
> ---
>  MdePkg/Library/BaseLib/BaseLib.inf | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf 
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index a1b5ec4b75..4ae8a0b05a 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -643,7 +643,6 @@
>gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength  ## 
> SOMETIMES_CONSUMES
>gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## 
> SOMETIMES_CONSUMES
>gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength   ## 
> SOMETIMES_CONSUMES
> -  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask## 
> SOMETIMES_CONSUMES
>  
>  [FeaturePcd]
>gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList  ## CONSUMES
> 

Looks OK to me.

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


Re: [edk2] [PATCH 3/4] NetworkPkg/TlsAuthConfigDxe: fix TlsCaCertificate attributes retrieval

2018-08-21 Thread Laszlo Ersek
On 08/20/18 08:29, Li, Songpeng wrote:
> It worked on my end.
> 
> Tested-by: Songpeng Li 

Thank you!

Jiaxin, Siyuan, are you guys OK with this patch?

Thanks
Laszlo

>> -Original Message-
>> From: Laszlo Ersek [mailto:ler...@redhat.com]
>> Sent: Friday, August 17, 2018 10:36 PM
>> To: edk2-devel-01 
>> Cc: Wu, Jiaxin ; Fu, Siyuan ; Li,
>> Songpeng 
>> Subject: [PATCH 3/4] NetworkPkg/TlsAuthConfigDxe: fix TlsCaCertificate
>> attributes retrieval
>>
>> Per spec, the GetVariable() runtime service is not required to populate
>> (*Attributes) on output when it fails with EFI_BUFFER_TOO_SMALL.
>>
>> Therefore we have to fetch the full contents of the TlsCaCertificate
>> variable temporarily, just so we can (a) get the current attributes, and
>> (b) add EFI_VARIABLE_APPEND_WRITE to them for the subsequent
>> SetVariable()
>> call.
>>
>> Cc: Jiaxin Wu 
>> Cc: Siyuan Fu 
>> Cc: Songpeng Li 
>> Reported-by: Songpeng Li 
>> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1090
>> Fixes: b90c335fbbb674470fbf09601cc522bf61564c30
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Laszlo Ersek 
>> ---
>>
>> Notes:
>> Tested via loading the same CA cert .pem file twice in a row, using the
>> HII form, first without any pre-existent TlsCaCertificate variable.
>>
>> Songpeng, can you please test this patch as well, and confirm if it
>> works on your end? Thanks!
>>
>>  NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c | 27
>> +++-
>>  1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
>> b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
>> index 7259c5e82f61..0780b03bbab4 100644
>> --- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
>> +++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
>> @@ -663,6 +663,7 @@ EnrollX509toVariable (
>>EFI_SIGNATURE_LIST*CACert;
>>EFI_SIGNATURE_DATA*CACertData;
>>VOID  *Data;
>> +  VOID  *CurrentData;
>>UINTN DataSize;
>>UINTN SigDataSize;
>>UINT32Attr;
>> @@ -674,6 +675,7 @@ EnrollX509toVariable (
>>CACert= NULL;
>>CACertData= NULL;
>>Data  = NULL;
>> +  CurrentData   = NULL;
>>Attr  = 0;
>>
>>Status = ReadFileContent (
>> @@ -716,11 +718,30 @@ EnrollX509toVariable (
>>Status = gRT->GetVariable(
>>VariableName,
>>,
>> -  ,
>> +  NULL,
>>,
>>NULL
>>);
>>if (Status == EFI_BUFFER_TOO_SMALL) {
>> +//
>> +// Per spec, we have to fetch the variable's contents, even though we're
>> +// only interested in the variable's attributes.
>> +//
>> +CurrentData = AllocatePool (DataSize);
>> +if (CurrentData == NULL) {
>> +  Status = EFI_OUT_OF_RESOURCES;
>> +  goto ON_EXIT;
>> +}
>> +Status = gRT->GetVariable(
>> +VariableName,
>> +,
>> +,
>> +,
>> +CurrentData
>> +);
>> +if (EFI_ERROR (Status)) {
>> +  goto ON_EXIT;
>> +}
>>  Attr |= EFI_VARIABLE_APPEND_WRITE;
>>} else if (Status == EFI_NOT_FOUND) {
>>  Attr = TLS_AUTH_CONFIG_VAR_BASE_ATTR;
>> @@ -751,6 +772,10 @@ ON_EXIT:
>>  FreePool (Data);
>>}
>>
>> +  if (CurrentData != NULL) {
>> +FreePool (CurrentData);
>> +  }
>> +
>>if (X509Data != NULL) {
>>  FreePool (X509Data);
>>}
>> --
>> 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] [edk2-wiki PATCH 0/2] document the Soft and Hard Feature Freezes

2018-08-21 Thread Laszlo Ersek
On 08/16/18 16:51, Laszlo Ersek wrote:
> The recently added "EDK II Release Planning" wiki page refers to the
> Soft and Hard Feature Freezes, but the definitions are missing. This
> series provides them, and updates the planning page to link them.
> 
> The pages can be read "live" in my wiki clone, by starting from
> 
>   https://github.com/lersek/edk2/wiki/EDK-II-Release-Planning
> 
> and by following the links. (At commit 3a54508927ce, pointed-to by both
> the "soft_hard_freeze" and "master" branches.)
> 
> Cc: Andrew Fish 
> Cc: Leif Lindholm 
> Cc: Michael D Kinney 
> 
> Thanks,
> Laszlo
> 
> Laszlo Ersek (2):
>   release planning: describe the hard and soft feature freezes
>   release planning: link soft and hard feature freeze definitions
> 
>  EDK-II-Release-Planning.md | 12 +++---
>  HardFeatureFreeze.md   |  6 +++
>  SoftFeatureFreeze.md   | 42 
>  3 files changed, 54 insertions(+), 6 deletions(-)
>  create mode 100644 HardFeatureFreeze.md
>  create mode 100644 SoftFeatureFreeze.md
> 

Thank you Mike and Leif for the reviews; pushed as commit range
72401c4dfd53..fd72923586a5.

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


Re: [edk2] [Patch] MdeModulePkg/PiSmmCore: Check valid memory range.

2018-08-21 Thread Dong, Eric
Hi Star,

Good catch. I tried to boot an test platform and it passed. I assume it has 
cases to free the smm memory. Seems like actually it doesn't.

I will add test code to verify the patch and send v2 change.

Thanks,
Eric
> -Original Message-
> From: Zeng, Star
> Sent: Tuesday, August 21, 2018 5:35 PM
> To: Dong, Eric ; edk2-devel@lists.01.org
> Cc: Zeng, Star 
> Subject: RE: [Patch] MdeModulePkg/PiSmmCore: Check valid memory range.
> 
> Hi Eric,
> 
> About
> +  EFI_PHYSICAL_ADDRESS Last;
> +  Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);
> 
> Shouldn't "-1" be also added like the code below in
> ConvertSmmMemoryMapEntry()?
>   EFI_PHYSICAL_ADDRESS End;
>   End = Memory + EFI_PAGES_TO_SIZE(NumberOfPages) - 1;
> 
> Could you double check the normal functionality (SMM AllocatePages +
> FreePages) with the patch?
> 
> 
> Thanks,
> Star
> -Original Message-
> From: Dong, Eric
> Sent: Tuesday, August 21, 2018 2:46 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star 
> Subject: [Patch] MdeModulePkg/PiSmmCore: Check valid memory range.
> 
> Call BS.AllocatePages in DXE driver and call SMM FreePages with the address
> of the buffer allocated in the DXE driver. SMM FreePages success and add a
> non-SMRAM range into SMM heap list. This is not an expected behavior.
> SMM FreePages should return error for this case and not free the pages.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1098
> 
> Cc: Star Zeng 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Dong 
> ---
>  MdeModulePkg/Core/PiSmmCore/Page.c | 39
> ++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/Page.c
> b/MdeModulePkg/Core/PiSmmCore/Page.c
> index 3699af7424..630678ccc3 100644
> --- a/MdeModulePkg/Core/PiSmmCore/Page.c
> +++ b/MdeModulePkg/Core/PiSmmCore/Page.c
> @@ -983,6 +983,41 @@ SmmInternalFreePages (
>return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);  }
> 
> +/**
> +  Check whether the input range is in smram.
> +
> +  @param  Memory Base address of memory being inputed.
> +  @param  NumberOfPages  The number of pages.
> +
> +  @retval TRUE   In the smram.
> +  @retval FALSE  Not in the smram.
> +
> +**/
> +BOOLEAN
> +InSmmRange (
> +  IN EFI_PHYSICAL_ADDRESS  Memory,
> +  IN UINTN NumberOfPages
> +  )
> +{
> +  LIST_ENTRY   *Link;
> +  MEMORY_MAP   *Entry;
> +  EFI_PHYSICAL_ADDRESS Last;
> +
> +  Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);
> +
> +  Link = gMemoryMap.ForwardLink;
> +  while (Link != ) {
> +Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
> +Link  = Link->ForwardLink;
> +
> +if ((Entry->Start <= Memory) && (Entry->End >= Last)) {
> +  return TRUE;
> +}
> +  }
> +
> +  return FALSE;
> +}
> +
>  /**
>Frees previous allocated pages.
> 
> @@ -1004,6 +1039,10 @@ SmmFreePages (
>EFI_STATUS  Status;
>BOOLEAN IsGuarded;
> 
> +  if (!InSmmRange(Memory, NumberOfPages)) {
> +return EFI_NOT_FOUND;
> +  }
> +
>IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
>Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
>if (!EFI_ERROR (Status)) {
> --
> 2.15.0.windows.1

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


[edk2] [Patch v2] MdeModulePkg/PiSmmCore: Check valid memory range.

2018-08-21 Thread Eric Dong
Call BS.AllocatePages in DXE driver and call SMM FreePages with the address of 
the buffer allocated in the DXE driver. SMM FreePages success and add a 
non-SMRAM range into SMM heap list. This is not an expected behavior. SMM 
FreePages should return error for this case and not free the pages.

V2 changes:
  Adjust "Last" variable value from "Last = Memory + EFI_PAGES_TO_SIZE 
(NumberOfPages);" to "Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages) - 1;"

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

Pass test:
1. Call SmmAllocatePages, to allocate pages, then call SmmFreePages to free 
same pages return success.
2. Call AllocatePages in Dxe then call SmmFreePages to free same pages, return 
failure.

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 MdeModulePkg/Core/PiSmmCore/Page.c | 39 ++
 1 file changed, 39 insertions(+)

diff --git a/MdeModulePkg/Core/PiSmmCore/Page.c 
b/MdeModulePkg/Core/PiSmmCore/Page.c
index 3699af7424..e9fcf01ecc 100644
--- a/MdeModulePkg/Core/PiSmmCore/Page.c
+++ b/MdeModulePkg/Core/PiSmmCore/Page.c
@@ -983,6 +983,41 @@ SmmInternalFreePages (
   return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);
 }
 
+/**
+  Check whether the input range is in smram.
+
+  @param  Memory Base address of memory being inputed.
+  @param  NumberOfPages  The number of pages.
+
+  @retval TRUE   In the smram.
+  @retval FALSE  Not in the smram.
+
+**/
+BOOLEAN
+InSmmRange (
+  IN EFI_PHYSICAL_ADDRESS  Memory,
+  IN UINTN NumberOfPages
+  )
+{
+  LIST_ENTRY   *Link;
+  MEMORY_MAP   *Entry;
+  EFI_PHYSICAL_ADDRESS Last;
+
+  Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages) - 1;
+
+  Link = gMemoryMap.ForwardLink;
+  while (Link != ) {
+Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+Link  = Link->ForwardLink;
+
+if ((Entry->Start <= Memory) && (Entry->End >= Last)) {
+  return TRUE;
+}
+  }
+
+  return FALSE;
+}
+
 /**
   Frees previous allocated pages.
 
@@ -1004,6 +1039,10 @@ SmmFreePages (
   EFI_STATUS  Status;
   BOOLEAN IsGuarded;
 
+  if (!InSmmRange(Memory, NumberOfPages)) {
+return EFI_NOT_FOUND;
+  }
+
   IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
   Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
   if (!EFI_ERROR (Status)) {
-- 
2.15.0.windows.1

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


[edk2] [PATCH edk-platforms v1 4/4] Platform/HiKey: enable usb driver

2018-08-21 Thread Haojian Zhuang
Enable Designware USB 2.0 device driver on HiKey platform. It's
used in Android Fastboot App.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dec |  2 ++
 Platform/Hisilicon/HiKey/HiKey.dsc | 13 +
 Platform/Hisilicon/HiKey/HiKey.fdf |  3 +++
 3 files changed, 18 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dec 
b/Platform/Hisilicon/HiKey/HiKey.dec
index d5de1a165910..ed9eab7ff2a9 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dec
+++ b/Platform/Hisilicon/HiKey/HiKey.dec
@@ -36,3 +36,5 @@ [PcdsFixedAtBuild.common]
   gHiKeyTokenSpaceGuid.PcdAndroidBootFile|{ 0x36, 0x8b, 0x73, 0x3a, 0xc5, 
0xb9, 0x63, 0x47, 0xab, 0xbd, 0x6c, 0xbd, 0x4b, 0x25, 0xf9, 0xff 
}|VOID*|0x0002
   gHiKeyTokenSpaceGuid.PcdAndroidFastbootFile|{ 0x2a, 0x50, 0x88, 0x95, 0x70, 
0x53, 0xe3, 0x11, 0x86, 0x31, 0xd7, 0xc5, 0x95, 0x13, 0x64, 0xc8 
}|VOID*|0x0003
   gHiKeyTokenSpaceGuid.PcdSdBootDevicePath|L""|VOID*|0x0004
+  gHiKeyTokenSpaceGuid.PcdAndroidFastbootNvmDevicePath|L""|VOID*|0x0005
+  gHiKeyTokenSpaceGuid.PcdArmFastbootFlashLimit|L""|VOID*|0x0006
diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 4b5b73c15afe..93b981767681 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -53,12 +53,16 @@ [LibraryClasses.common]
   # USB Requirements
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
 
+  
UsbSerialNumberLib|Platform/Hisilicon/Library/UsbSerialNumberLib/UsbSerialNumberLib.inf
+
   # Network Libraries
   NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
   DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
   IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
   UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
 
+  DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
+
 [LibraryClasses.common.SEC]
   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
   
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
@@ -85,6 +89,7 @@ [PcdsFeatureFlag.common]
 [PcdsFixedAtBuild.common]
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
 
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|"hikey"
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"Alpha"
 
   # System Memory (1GB)
@@ -126,6 +131,11 @@ [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|1000
 
   #
+  # DW USB controller
+  #
+  gDwUsbDxeTokenSpaceGuid.PcdDwUsbDxeBaseAddress|0xF72C
+
+  #
   #
   # Fastboot
   #
@@ -222,6 +232,9 @@ [Components.common]
   #
   # USB Peripheral Support
   #
+  Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.inf
+  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf
+  Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf
   
EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 89d3e9280ff6..aedf71667903 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -152,6 +152,9 @@ [FV.FvMain]
   #
   # USB Peripheral Support
   #
+  INF Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.inf
+  INF EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf
+  INF Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf
   INF 
EmbeddedPkg/Drivers/AndroidFastbootTransportUsbDxe/FastbootTransportUsbDxe.inf
 
   #
-- 
2.7.4

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


[edk2] [PATCH edk-platforms v1 3/4] Platform/HiKey: add fastboot platform driver

2018-08-21 Thread Haojian Zhuang
Implement Android Fastboot protocol on HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf |  61 ++
 Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c   | 630 

 2 files changed, 691 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf
new file mode 100644
index ..2f2f1c4cb0a0
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.inf
@@ -0,0 +1,61 @@
+#/** @file
+#
+#  Copyright (c) 2014, ARM Ltd. All rights reserved.
+#  Copyright (c) 2018, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution. The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = HiKeyFastbootDxe
+  FILE_GUID  = 8e335c38-c4e1-494e-8011-37a858d9763d
+  MODULE_TYPE= UEFI_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyFastbootPlatformEntryPoint
+
+[Sources.common]
+  HiKeyFastbootDxe.c
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  CacheMaintenanceLib
+  DebugLib
+  DevicePathLib
+  IoLib
+  MemoryAllocationLib
+  PcdLib
+  UefiBootServicesTableLib
+  UefiRuntimeServicesTableLib
+  UefiDriverEntryPoint
+  UsbSerialNumberLib
+  TimerLib
+
+[Protocols]
+  gAndroidFastbootPlatformProtocolGuid
+  gEfiBlockIoProtocolGuid
+  gEfiDiskIoProtocolGuid
+  gEfiEraseBlockProtocolGuid
+  gEfiSimpleTextOutProtocolGuid
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  ArmPkg/ArmPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Platform/Hisilicon/HiKey/HiKey.dec
+  Platform/Hisilicon/Library/UsbSerialNumberLib/UsbSerialNumberLib.dec
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
+  gHiKeyTokenSpaceGuid.PcdAndroidFastbootNvmDevicePath
+  gHiKeyTokenSpaceGuid.PcdArmFastbootFlashLimit
diff --git a/Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
new file mode 100644
index ..f5a9c53b6a23
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
@@ -0,0 +1,630 @@
+/** @file
+
+  Copyright (c) 2014, ARM Ltd. All rights reserved.
+  Copyright (c) 2018, Linaro. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+/*
+  Implementation of the Android Fastboot Platform protocol, to be used by the
+  Fastboot UEFI application, for Hisilicon HiKey platform.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define PARTITION_NAME_MAX_LENGTH (72/2)
+
+#define SERIAL_NUMBER_LBA1024
+#define RANDOM_MAX   0x7FFF
+#define RANDOM_MAGIC 0x9A4DBEAF
+
+#define ADB_REBOOT_ADDRESS   0x05F01000
+#define ADB_REBOOT_BOOTLOADER0x77665500
+
+#define MMC_BLOCK_SIZE   512
+#define HIKEY_ERASE_SIZE 4096
+
+typedef struct _FASTBOOT_PARTITION_LIST {
+  LIST_ENTRY  Link;
+  CHAR16  PartitionName[PARTITION_NAME_MAX_LENGTH];
+  EFI_LBA StartingLBA;
+  EFI_LBA EndingLBA;
+} FASTBOOT_PARTITION_LIST;
+
+STATIC LIST_ENTRY   mPartitionListHead;
+STATIC EFI_HANDLE   mFlashHandle;
+STATIC EFI_BLOCK_IO_PROTOCOL   *mFlashBlockIo;
+STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
+
+/*
+  Helper to free the partition list
+*/
+STATIC
+VOID
+FreePartitionList (
+  VOID
+  )
+{
+  FASTBOOT_PARTITION_LIST *Entry;
+  FASTBOOT_PARTITION_LIST *NextEntry;
+
+  Entry = (FASTBOOT_PARTITION_LIST *) GetFirstNode ();
+  while (!IsNull (, >Link)) {
+NextEntry = (FASTBOOT_PARTITION_LIST *) GetNextNode (, 
>Link);
+
+RemoveEntryList (>Link);
+FreePool (Entry);
+
+Entry = NextEntry;
+  }
+}
+
+/*
+  Read the PartitionName fields from the GPT 

[edk2] [PATCH edk-platforms v1 2/4] Platform/HiKey: add usb platform driver

2018-08-21 Thread Haojian Zhuang
Implement DwUsb protocol in the usb platform driver on HiKey
platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.inf |  46 
 Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.c   | 280 
 2 files changed, 326 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.inf
new file mode 100644
index ..bcba3f758c1a
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.inf
@@ -0,0 +1,46 @@
+#/** @file
+#
+#  Copyright (c) 2018, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution. The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = HiKeyUsbDxe
+  FILE_GUID  = c5c7089e-9b00-448c-8b23-a552688e2833
+  MODULE_TYPE= UEFI_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyUsbEntryPoint
+
+[Sources.common]
+  HiKeyUsbDxe.c
+
+[LibraryClasses]
+  DebugLib
+  IoLib
+  TimerLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gDwUsbProtocolGuid
+  gEfiDriverBindingProtocolGuid
+  gEmbeddedGpioProtocolGuid
+
+[Packages]
+  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Platform/Hisilicon/HiKey/HiKey.dec
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.c 
b/Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.c
new file mode 100644
index ..4d651746d590
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyUsbDxe/HiKeyUsbDxe.c
@@ -0,0 +1,280 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD 
License
+*  which accompanies this distribution.  The full text of the license may be 
found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+*
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+
+#define USB_SEL_GPIO0_3  3 // GPIO 0_3
+#define USB_5V_HUB_EN7 // GPIO 0_7
+#define USB_ID_DET_GPIO2_5   21// GPIO 2_5
+#define USB_VBUS_DET_GPIO2_6 22// GPIO 2_6
+
+//
+// Jumper on pin5-6 of J15 determines whether boot to fastboot
+//
+#define DETECT_J15_FASTBOOT  24// GPIO 3_0
+
+#define IOCG_GPIO0_BASE  0xF8001800
+#define IOCG_GPIO0_3_OFFSET  0x1C
+#define IOCG_GPIO0_7_OFFSET  0x2C
+#define IOCG_GPIO2_5_OFFSET  0x64
+#define IOCG_GPIO2_6_OFFSET  0x68
+
+#define IOCG_PULLUP  1
+#define IOCG_PULLDOWN2
+
+#define USB_EYE_PATTERN  0x70533483
+
+#define LANG_EN  0x409
+
+STATIC EMBEDDED_GPIO *mGpio;
+
+STATIC
+EFI_STATUS
+HiKeyDetectUsbModeInit (
+  IN VOID
+  )
+{
+  EFI_STATUS Status;
+
+  /* set pullup on both GPIO2_5 & GPIO2_6. It's required for inupt. */
+  MmioWrite32 (IOCG_GPIO0_BASE + IOCG_GPIO2_5_OFFSET, IOCG_PULLUP);
+  MmioWrite32 (IOCG_GPIO0_BASE + IOCG_GPIO2_6_OFFSET, IOCG_PULLUP);
+
+  Status = gBS->LocateProtocol (
+  ,
+  NULL,
+  (VOID **)
+  );
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "Can't locate gEmbeddedGpioProtocolGuid\n"));
+return Status;
+  }
+  /* power on USB HUB */
+  Status = mGpio->Set (mGpio, USB_5V_HUB_EN, GPIO_MODE_OUTPUT_0);
+  ASSERT_EFI_ERROR (Status);
+  /* start to detect USB device or host */
+  Status = mGpio->Set (mGpio, USB_SEL_GPIO0_3, GPIO_MODE_OUTPUT_0);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = mGpio->Set (mGpio, USB_ID_DET_GPIO2_5, GPIO_MODE_INPUT);
+  ASSERT_EFI_ERROR (Status);
+  Status = mGpio->Set (mGpio, USB_VBUS_DET_GPIO2_6, GPIO_MODE_INPUT);
+  ASSERT_EFI_ERROR (Status);
+  return EFI_SUCCESS;
+}
+
+UINTN
+HiKeyGetUsbMode (
+  IN VOID
+  )
+{
+  EFI_STATUS Status;
+  UINTN  GpioId, GpioVbus;
+
+  Status = mGpio->Get (mGpio, USB_ID_DET_GPIO2_5, );
+  ASSERT_EFI_ERROR (Status);
+  Status = mGpio->Get (mGpio, USB_VBUS_DET_GPIO2_6, );
+  ASSERT_EFI_ERROR (Status);
+
+  if ((GpioId == 1) && (GpioVbus == 0)) {
+return USB_DEVICE_MODE;
+  } else if ((GpioId == 0) && 

[edk2] [PATCH edk-platforms v1 1/4] Platform/HiKey: add more register definitions

2018-08-21 Thread Haojian Zhuang
These register definitions are used in USB device driver.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h | 53 
 1 file changed, 53 insertions(+)

diff --git a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h 
b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
index 9b2508955772..ff0ba691bb61 100644
--- a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
+++ b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
@@ -29,6 +29,23 @@
 #define IOCG_BASE   0xF7010800
 #define IOCG_084_REG(IOCG_BASE + 0x150)
 
+#define GPIO4_CTRL_BASE 0xF702
+#define GPIO5_CTRL_BASE 0xF7021000
+#define GPIO6_CTRL_BASE 0xF7022000
+#define GPIO7_CTRL_BASE 0xF7023000
+#define GPIO8_CTRL_BASE 0xF7024000
+#define GPIO9_CTRL_BASE 0xF7025000
+#define GPIO10_CTRL_BASE0xF7026000
+#define GPIO11_CTRL_BASE0xF7027000
+#define GPIO12_CTRL_BASE0xF7028000
+#define GPIO13_CTRL_BASE0xF7029000
+#define GPIO14_CTRL_BASE0xF702A000
+#define GPIO15_CTRL_BASE0xF702B000
+#define GPIO16_CTRL_BASE0xF702C000
+#define GPIO17_CTRL_BASE0xF702D000
+#define GPIO18_CTRL_BASE0xF702E000
+#define GPIO19_CTRL_BASE0xF702F000
+
 #define PERI_CTRL_BASE  0xF703
 #define SC_PERIPH_CTRL4 0x00C
 #define CTRL4_FPGA_EXT_PHY_SEL  BIT3
@@ -51,18 +68,47 @@
 
 #define SC_PERIPH_CTRL8 0x018
 #define SC_PERIPH_CLKEN00x200
+
+#define PERIPH_CLKEN0_USBOTGBIT4
+
 #define SC_PERIPH_CLKDIS0   0x204
 #define SC_PERIPH_CLKSTAT0  0x208
 
+#define SC_PERIPH_CLKEN30x230
 #define SC_PERIPH_RSTEN00x300
 #define SC_PERIPH_RSTDIS0   0x304
 #define SC_PERIPH_RSTSTAT0  0x308
+#define SC_PERIPH_RSTEN30x330
+#define SC_PERIPH_RSTDIS3   0x334
+#define SC_PERIPH_RSTSTAT3  0x338
 
 #define RST0_USBOTG_BUS BIT4
 #define RST0_POR_PICOPHYBIT5
 #define RST0_USBOTG BIT6
 #define RST0_USBOTG_32K BIT7
 
+/* SC_PERIPH_RSTEN0/RSTDIS0/RSTSTAT0 */
+#define PERIPH_RST0_MMC2(1 << 2)
+
+/* SC_PERIPH_RSTEN3/RSTDIS3/RSTSTAT3 */
+#define PERIPH_RST3_CSSYS   (1 << 0)
+#define PERIPH_RST3_I2C0(1 << 1)
+#define PERIPH_RST3_I2C1(1 << 2)
+#define PERIPH_RST3_I2C2(1 << 3)
+#define PERIPH_RST3_I2C3(1 << 4)
+#define PERIPH_RST3_UART1   (1 << 5)
+#define PERIPH_RST3_UART2   (1 << 6)
+#define PERIPH_RST3_UART3   (1 << 7)
+#define PERIPH_RST3_UART4   (1 << 8)
+#define PERIPH_RST3_SSP (1 << 9)
+#define PERIPH_RST3_PWM (1 << 10)
+#define PERIPH_RST3_BLPWM   (1 << 11)
+#define PERIPH_RST3_TSENSOR (1 << 12)
+#define PERIPH_RST3_DAPB(1 << 18)
+#define PERIPH_RST3_HKADC   (1 << 19)
+#define PERIPH_RST3_CODEC_SSI   (1 << 20)
+#define PERIPH_RST3_PMUSSI1 (1 << 22)
+
 #define EYE_PATTERN_PARA0x7053348c
 
 #define MDDRC_AXI_BASE  0xF712
@@ -80,4 +126,11 @@
 
 #define PMUSSI_BASE 0xF800
 
+#define PMUSSI_REG(x)   (PMUSSI_BASE + ((x) << 2))
+
+#define GPIO0_CTRL_BASE 0xF8011000
+#define GPIO1_CTRL_BASE 0xF8012000
+#define GPIO2_CTRL_BASE 0xF8013000
+#define GPIO3_CTRL_BASE 0xF8014000
+
 #endif /* __HI6220_H__ */
-- 
2.7.4

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


[edk2] [PATCH v1 1/1] EmbeddedPkg/Drivers: add DwUsbDxe

2018-08-21 Thread Haojian Zhuang
Add Designware USB 2.0 device driver that is used on HiKey platform.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec |  45 +
 EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf |  52 ++
 EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.h   | 655 ++
 EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.c   | 912 
 4 files changed, 1664 insertions(+)

diff --git a/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec 
b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec
new file mode 100644
index ..7eb65e498c04
--- /dev/null
+++ b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec
@@ -0,0 +1,45 @@
+#/** @file
+# Framework Module Development Environment Industry Standards
+#
+# This Package provides headers and libraries that conform to EFI/PI Industry 
standards.
+# Copyright (c) 2007, Intel Corporation. All rights reserved.
+# Copyright (c) 2012-2014, ARM Ltd. All rights reserved.
+# Copyright (c) 2018, Linaro. All rights reserved.
+#
+#This program and the accompanying materials are licensed and made 
available under
+#the terms and conditions of the BSD License which accompanies this 
distribution.
+#The full text of the license may be found at
+#http://opensource.org/licenses/bsd-license.php
+#
+#THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#**/
+
+[Defines]
+  DEC_SPECIFICATION  = 0x00010019
+  PACKAGE_NAME   = DwUsbDxePkg
+  PACKAGE_GUID   = 114a3be9-10f7-4bf1-81ca-09ac52d4c3d5
+  PACKAGE_VERSION= 0.1
+
+
+
+#
+# Include Section - list of Include Paths that are provided by this package.
+#   Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+
+
+[Guids.common]
+  gDwUsbDxeTokenSpaceGuid   = { 0x131c4d02, 0x9449, 0x4ee9, { 0xba, 0x3d, 
0x69, 0x50, 0x21, 0x89, 0x26, 0x0b }}
+
+[Protocols.common]
+  gDwUsbProtocolGuid= { 0x109fa264, 0x7811, 0x4862, { 0xa9, 0x73, 
0x4a, 0xb2, 0xef, 0x2e, 0xe2, 0xff }}
+
+[PcdsFixedAtBuild.common]
+  # DwUsb Driver PCDs
+  gDwUsbDxeTokenSpaceGuid.PcdDwUsbDxeBaseAddress|0x0|UINT32|0x0001
+  gDwUsbDxeTokenSpaceGuid.PcdSysCtrlBaseAddress|0x0|UINT32|0x0002
diff --git a/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf 
b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf
new file mode 100644
index ..56d518c27c32
--- /dev/null
+++ b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.inf
@@ -0,0 +1,52 @@
+#/** @file
+#
+#  Copyright (c) 2018, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials are licensed and made available
+#  under the terms and conditions of the BSD License which accompanies this
+#  distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = DwUsbDxe
+  FILE_GUID  = 72d78ea6-4dee-11e3-8100-f3842a48d0a0
+  MODULE_TYPE= UEFI_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= DwUsbEntryPoint
+
+[Sources.common]
+  DwUsbDxe.c
+
+[LibraryClasses]
+  ArmLib
+  CacheMaintenanceLib
+  DebugLib
+  DmaLib
+  IoLib
+  MemoryAllocationLib
+  TimerLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiDriverBindingProtocolGuid
+  gUsbDeviceProtocolGuid
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[Pcd]
+  gDwUsbDxeTokenSpaceGuid.PcdDwUsbDxeBaseAddress
+
+[Depex]
+  TRUE
diff --git a/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.h 
b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.h
new file mode 100644
index ..1595e09a92a4
--- /dev/null
+++ b/EmbeddedPkg/Drivers/DwUsbDxe/DwUsbDxe.h
@@ -0,0 +1,655 @@
+/** @file
+
+  Copyright (c) 2018, Linaro. All rights reserved.
+
+  This program and the accompanying materials are licensed and made available
+  under the terms and conditions of the BSD License which accompanies this
+  distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef 

Re: [edk2] [patch] MdeModulePkg/SmmCorePerfLib: Add DxeServicesLib library class in INF

2018-08-21 Thread Zeng, Star
Reviewed-by: Star Zeng 

-Original Message-
From: Bi, Dandan 
Sent: Tuesday, August 21, 2018 4:57 PM
To: edk2-devel@lists.01.org
Cc: Gao, Liming ; Zeng, Star 
Subject: [patch] MdeModulePkg/SmmCorePerfLib: Add DxeServicesLib library class 
in INF

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

SmmCorePerformanceLib consume the DxeServicesLib, but miss to add the library 
class in INF file.
This patch is to fix this issue.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
index 88052f8037..78b783b012 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.i
+++ nf
@@ -58,10 +58,11 @@
   SmmServicesTableLib
   SmmMemLib
   UefiLib
   ReportStatusCodeLib
   PeCoffGetEntryPointLib
+  DxeServicesLib
 
 [Protocols]
   gEfiSmmBase2ProtocolGuid  ## CONSUMES
   gEdkiiSmmReadyToBootProtocolGuid  ## NOTIFY
 
--
2.14.3.windows.1

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


Re: [edk2] [Patch] MdeModulePkg/PiSmmCore: Check valid memory range.

2018-08-21 Thread Zeng, Star
Hi Eric,

About
+  EFI_PHYSICAL_ADDRESS Last;
+  Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);

Shouldn't "-1" be also added like the code below in ConvertSmmMemoryMapEntry()?
  EFI_PHYSICAL_ADDRESS End;
  End = Memory + EFI_PAGES_TO_SIZE(NumberOfPages) - 1;

Could you double check the normal functionality (SMM AllocatePages + FreePages) 
with the patch?


Thanks,
Star
-Original Message-
From: Dong, Eric 
Sent: Tuesday, August 21, 2018 2:46 PM
To: edk2-devel@lists.01.org
Cc: Zeng, Star 
Subject: [Patch] MdeModulePkg/PiSmmCore: Check valid memory range.

Call BS.AllocatePages in DXE driver and call SMM FreePages with the address of 
the buffer allocated in the DXE driver. SMM FreePages success and add a 
non-SMRAM range into SMM heap list. This is not an expected behavior. SMM 
FreePages should return error for this case and not free the pages.

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

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 MdeModulePkg/Core/PiSmmCore/Page.c | 39 ++
 1 file changed, 39 insertions(+)

diff --git a/MdeModulePkg/Core/PiSmmCore/Page.c 
b/MdeModulePkg/Core/PiSmmCore/Page.c
index 3699af7424..630678ccc3 100644
--- a/MdeModulePkg/Core/PiSmmCore/Page.c
+++ b/MdeModulePkg/Core/PiSmmCore/Page.c
@@ -983,6 +983,41 @@ SmmInternalFreePages (
   return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);  }
 
+/**
+  Check whether the input range is in smram.
+
+  @param  Memory Base address of memory being inputed.
+  @param  NumberOfPages  The number of pages.
+
+  @retval TRUE   In the smram.
+  @retval FALSE  Not in the smram.
+
+**/
+BOOLEAN
+InSmmRange (
+  IN EFI_PHYSICAL_ADDRESS  Memory,
+  IN UINTN NumberOfPages
+  )
+{
+  LIST_ENTRY   *Link;
+  MEMORY_MAP   *Entry;
+  EFI_PHYSICAL_ADDRESS Last;
+
+  Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);
+
+  Link = gMemoryMap.ForwardLink;
+  while (Link != ) {
+Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+Link  = Link->ForwardLink;
+
+if ((Entry->Start <= Memory) && (Entry->End >= Last)) {
+  return TRUE;
+}
+  }
+
+  return FALSE;
+}
+
 /**
   Frees previous allocated pages.
 
@@ -1004,6 +1039,10 @@ SmmFreePages (
   EFI_STATUS  Status;
   BOOLEAN IsGuarded;
 
+  if (!InSmmRange(Memory, NumberOfPages)) {
+return EFI_NOT_FOUND;
+  }
+
   IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
   Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
   if (!EFI_ERROR (Status)) {
--
2.15.0.windows.1

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


[edk2] [patch] MdeModulePkg/SmmCorePerfLib: Add DxeServicesLib library class in INF

2018-08-21 Thread Dandan Bi
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1100

SmmCorePerformanceLib consume the DxeServicesLib, but miss to
add the library class in INF file.
This patch is to fix this issue.

Cc: Liming Gao 
Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi 
---
 MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf 
b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
index 88052f8037..78b783b012 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
@@ -58,10 +58,11 @@
   SmmServicesTableLib
   SmmMemLib
   UefiLib
   ReportStatusCodeLib
   PeCoffGetEntryPointLib
+  DxeServicesLib
 
 [Protocols]
   gEfiSmmBase2ProtocolGuid  ## CONSUMES
   gEdkiiSmmReadyToBootProtocolGuid  ## NOTIFY
 
-- 
2.14.3.windows.1

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


[edk2] [Patch][edk2-platforms/devel-IntelAtomProcessorE3900] Add /C build option

2018-08-21 Thread Guo, Mang
Add /C build option for Module FAB C board

Contributed-under: TianoCore Contribution Agreement 1.1

Signed-off-by: Guo Mang 
---
 BuildBIOS.bat  |  1 +
 Platform/BroxtonPlatformPkg/BuildBxtBios.bat   | 26 +++---
 Platform/BroxtonPlatformPkg/BuildIFWI.bat  | 12 +-
 .../Common/Tools/Stitch/IFWIStitch_Simple.bat  |  7 ++
 4 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/BuildBIOS.bat b/BuildBIOS.bat
index 22c8792..d8275ac 100644
--- a/BuildBIOS.bat
+++ b/BuildBIOS.bat
@@ -57,6 +57,7 @@ echo/x64   Set Arch to X64  (default: X64)
 echo/IA32  Set Arch to IA32 (default: X64)
 echo/A Set FabId to A
 echo/B Set FabId to B (default:  FAB_B)
+echo/C Set FabId to C
 echo/D Set FabId to D
 echo/MNMinnowBoard 3(default: MN)
 echo/MXMinnowBoard 3 Module
diff --git a/Platform/BroxtonPlatformPkg/BuildBxtBios.bat 
b/Platform/BroxtonPlatformPkg/BuildBxtBios.bat
index c3dd9f8..9858cea 100644
--- a/Platform/BroxtonPlatformPkg/BuildBxtBios.bat
+++ b/Platform/BroxtonPlatformPkg/BuildBxtBios.bat
@@ -90,21 +90,6 @@ if /i "%~1"=="/l" (
 shift
 goto OptLoop
 )
-if /i "%~1" == "/c" (
-echo Removing previous Build files...
-if exist build (
-del /f/s/q build > nul
-rmdir /s/q build
-)
-if exist Conf\.cache (
-del /f/s/q Conf\.cache > nul
-rmdir /s/q Conf\.cache
-)
-echo.
-shift
-goto OptLoop
-)
-
 if /i "%~1"=="/ia32" (
 set Arch=IA32
 shift
@@ -164,6 +149,12 @@ if /i "%~1"=="/B" (
 shift
 goto OptLoop
 )
+if /i "%~1"=="/C" (
+set FabId=C
+echo.
+shift
+goto OptLoop
+)
 if /i "%~1"=="/D" (
 set FabId=D
 echo.
@@ -318,8 +309,8 @@ if %BoardId%==MN (
 )
 
 if %BoardId%==MX (
-  if %FabId%==B (
-echo BOARD_REV = B >> Conf\BiosId.env
+  if %FabId%==C (
+echo BOARD_REV = C >> Conf\BiosId.env
   ) else (
 echo BOARD_REV = A >> Conf\BiosId.env
   )
@@ -652,7 +643,6 @@ echo Usage: %0 [options] ^ ^
 echo.
 echo.   /?   Display this help text
 echo/l   Log a copy of the build output to EDK2.log
-echo/c   CleanAll before building
 echo/x64 Set Arch to X64  (default)
 echo/ia32Set Arch to IA32
 echo/vs08Set compiler to VisualStudio 2008
diff --git a/Platform/BroxtonPlatformPkg/BuildIFWI.bat 
b/Platform/BroxtonPlatformPkg/BuildIFWI.bat
index 396e8c4..3212693 100644
--- a/Platform/BroxtonPlatformPkg/BuildIFWI.bat
+++ b/Platform/BroxtonPlatformPkg/BuildIFWI.bat
@@ -31,12 +31,6 @@ if /i "%~1"=="" goto Usage
 if /i "%~1"=="/?" goto Usage
 
 ::Build Flags
-if /i "%~1" == "/c" (
-set Build_Flags=%Build_Flags% /c
-shift
-set SkipUsageFlag=TRUE
-goto OptLoop
-)
 if /i "%~1"=="/ia32" (
 set Arch=IA32
 set Build_Flags=%Build_Flags% /ia32
@@ -92,6 +86,12 @@ if /i "%~1"=="/B" (
 shift
 goto OptLoop
 )
+if /i "%~1"=="/C" (
+set FabId=C
+set Build_Flags=%Build_Flags% /C
+shift
+goto OptLoop
+)
 if /i "%~1"=="/D" (
 set FabId=D
 set Build_Flags=%Build_Flags% /D
diff --git 
a/Platform/BroxtonPlatformPkg/Common/Tools/Stitch/IFWIStitch_Simple.bat 
b/Platform/BroxtonPlatformPkg/Common/Tools/Stitch/IFWIStitch_Simple.bat
index c8d0973..b859cb1 100644
--- a/Platform/BroxtonPlatformPkg/Common/Tools/Stitch/IFWIStitch_Simple.bat
+++ b/Platform/BroxtonPlatformPkg/Common/Tools/Stitch/IFWIStitch_Simple.bat
@@ -175,10 +175,17 @@ if %BoardId%==BG (
copy /y /b 
SpiChunk1.bin+.\BIOS_COMPONENTS\IBBL.Fv+.\BIOS_COMPONENTS\IBB.Fv+SpiChunk2.bin+.\BIOS_COMPONENTS\OBB.Fv+.\BIOS_COMPONENTS\NvStorage.Fv+SpiChunk3.bin
 spi_out.bin
  )
 ) else if %BoardId%==MX (
+ if %FabId%==A (
copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_A\SpiChunk1.bin .
copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_A\SpiChunk2.bin .
copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_A\SpiChunk3.bin .
copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_A\SpiChunk1SpiAccessControl.bin .
+ ) else (
+   copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_C\SpiChunk1.bin .
+   copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_C\SpiChunk2.bin .
+   copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_C\SpiChunk3.bin .
+   copy /y /b 
..\..\..\Board\MinnowBoard3Module\IFWI\FAB_C\SpiChunk1SpiAccessControl.bin .
+ )
if %SpiAccessControl% EQU 0 (
  copy /y /b 
SpiChunk1.bin+.\BIOS_COMPONENTS\IBBL.Fv+.\BIOS_COMPONENTS\IBB.Fv+SpiChunk2.bin+.\BIOS_COMPONENTS\OBB.Fv+.\BIOS_COMPONENTS\NvStorage.Fv+SpiChunk3.bin
 spi_out.bin
) else (
-- 
2.10.1.windows.1

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


[edk2] [PATCH 2/2] MdeModulePkg: Update SMBIOS PCDs to 3.2.0

2018-08-21 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1099

Cc: Liming Gao 
Cc: Dandan Bi 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdeModulePkg/MdeModulePkg.dec | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 6a6d9660edc2..261da61c18a2 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1763,11 +1763,11 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, 
PcdsDynamicEx]
 
   ## SMBIOS version.
   # @Prompt SMBIOS version.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0301|UINT16|0x00010055
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion|0x0302|UINT16|0x00010055
 
   ## SMBIOS Docrev field in SMBIOS 3.0 (64-bit) Entry Point Structure.
   # @Prompt SMBIOS Docrev field in SMBIOS 3.0 (64-bit) Entry Point Structure.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x1|UINT8|0x0001006A
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0|UINT8|0x0001006A
 
   ## SMBIOS produce method.
   #  BIT0 set indicates 32-bit entry point and table are produced.
-- 
2.7.0.windows.1

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


[edk2] [PATCH 1/2] MdePkg SmBios.h: Add SMBIOS 3.2.0 definitions

2018-08-21 Thread Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1099

Add SMBIOS 3.2.0 definitions according to
www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf.

Processor Information (Type 4):
- SMBIOSCR00163: add socket LGA2066
- SMBIOSCR00173: add Intel Core i9
- SMBIOSCR00176: add new processor sockets
Port Connector Information (Type 8):
- SMBIOSCR00168: add USB Type-C
System Slots (Type 9):
- SMBIOSCR00164: add "unavailable" to current usage field
- SMBIOSCR00167: add support for PCIe bifurcation
Memory Device (Type 17):
- SMBIOSCR00162: add support for NVDIMMs
- SMBIOSCR00166: extend support for NVDIMMs and add support for logical memory 
type
- SMBIOSCR00172: rename "Configured Memory Clock Speed" to "Configured Memory 
Speed"
- SMBIOSCR00174: add new memory technology value (Intel Persistent Memory, 3D 
XPoint)
IPMI Device Information (Type 38):
- SMBIOSCR00171: add SSIF
Management Controller Host Interface (Type 42)
- SMBIOSCR00175: fix structure data parsing issue

Cc: Liming Gao 
Cc: Dandan Bi 
Cc: Michael D Kinney 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng 
---
 MdePkg/Include/IndustryStandard/SmBios.h | 131 ++-
 1 file changed, 96 insertions(+), 35 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h 
b/MdePkg/Include/IndustryStandard/SmBios.h
index 5d0442873dfc..1b916d0ab03c 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -1,5 +1,5 @@
 /** @file
-  Industry Standard Definitions of SMBIOS Table Specification v3.1.1.
+  Industry Standard Definitions of SMBIOS Table Specification v3.2.0.
 
 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
 (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
@@ -685,6 +685,7 @@ typedef enum {
   ProcessorFamilyzArchitecture  = 0xCC,
   ProcessorFamilyIntelCoreI5= 0xCD,
   ProcessorFamilyIntelCoreI3= 0xCE,
+  ProcessorFamilyIntelCoreI9= 0xCF,
   ProcessorFamilyViaC7M = 0xD2,
   ProcessorFamilyViaC7D = 0xD3,
   ProcessorFamilyViaC7  = 0xD4,
@@ -806,7 +807,11 @@ typedef enum {
   ProcessorUpgradeSocketBGA1515   = 0x35,
   ProcessorUpgradeSocketLGA3647_1 = 0x36,
   ProcessorUpgradeSocketSP3   = 0x37,
-  ProcessorUpgradeSocketSP3r2 = 0x38
+  ProcessorUpgradeSocketSP3r2 = 0x38,
+  ProcessorUpgradeSocketLGA2066   = 0x39,
+  ProcessorUpgradeSocketBGA1392   = 0x3A,
+  ProcessorUpgradeSocketBGA1510   = 0x3B,
+  ProcessorUpgradeSocketBGA1528   = 0x3C
 } PROCESSOR_UPGRADE;
 
 ///
@@ -1159,6 +1164,7 @@ typedef enum {
   PortConnectorTypeBNC= 0x20,
   PortConnectorType1394   = 0x21,
   PortConnectorTypeSasSata= 0x22,
+  PortConnectorTypeUsbTypeC   = 0x23,
   PortConnectorTypePC98   = 0xA0,
   PortConnectorTypePC98Hireso = 0xA1,
   PortConnectorTypePCH98  = 0xA2,
@@ -1314,10 +1320,11 @@ typedef enum {
 /// System Slots - Current Usage.
 ///
 typedef enum {
-  SlotUsageOther = 0x01,
-  SlotUsageUnknown   = 0x02,
-  SlotUsageAvailable = 0x03,
-  SlotUsageInUse = 0x04
+  SlotUsageOther= 0x01,
+  SlotUsageUnknown  = 0x02,
+  SlotUsageAvailable= 0x03,
+  SlotUsageInUse= 0x04,
+  SlotUsageUnavailable  = 0x05
 } MISC_SLOT_USAGE;
 
 ///
@@ -1350,7 +1357,8 @@ typedef struct {
   UINT8  PmeSignalSupported  :1;
   UINT8  HotPlugDevicesSupported :1;
   UINT8  SmbusSignalSupported:1;
-  UINT8  Reserved:5;  ///< Set to 0.
+  UINT8  BifurcationSupported:1;
+  UINT8  Reserved:4;  ///< Set to 0.
 } MISC_SLOT_CHARACTERISTICS2;
 
 ///
@@ -1668,7 +1676,8 @@ typedef enum {
   MemoryTypeLpddr  = 0x1B,
   MemoryTypeLpddr2 = 0x1C,
   MemoryTypeLpddr3 = 0x1D,
-  MemoryTypeLpddr4 = 0x1E
+  MemoryTypeLpddr4 = 0x1E,
+  MemoryTypeLogicalNonVolatileDevice   = 0x1F
 } MEMORY_DEVICE_TYPE;
 
 typedef struct {
@@ -1691,6 +1700,38 @@ typedef struct {
 } MEMORY_DEVICE_TYPE_DETAIL;
 
 ///
+/// Memory Device - Memory Technology
+///
+typedef enum {
+  MemoryTechnologyOther = 0x01,
+  MemoryTechnologyUnknown   = 0x02,
+  MemoryTechnologyDram  = 0x03,
+  MemoryTechnologyNvdimmN   = 0x04,
+  MemoryTechnologyNvdimmF   = 0x05,
+  MemoryTechnologyNvdimmP   = 0x06,
+  MemoryTechnologyIntelPersistentMemory = 0x07
+} MEMORY_DEVICE_TECHNOLOGY;
+
+typedef union {
+  ///
+  /// Individual bit fields
+  ///
+  struct {
+UINT16 Reserved :1; ///< Set to 0.
+UINT16 Other:1;
+UINT16 Unknown  :1;
+UINT16 VolatileMemory   :1;
+UINT16 

[edk2] [PATCH 0/2] Add SMBIOS 3.2.0 definitions

2018-08-21 Thread Star Zeng
https://bugzilla.tianocore.org/show_bug.cgi?id=1099
This patch series updates
1. MdePkg/Include/IndustryStandard/Smbios.h
2. gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosVersion and
   gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev

Star Zeng (2):
  MdePkg SmBios.h: Add SMBIOS 3.2.0 definitions
  MdeModulePkg: Update SMBIOS PCDs to 3.2.0

 MdeModulePkg/MdeModulePkg.dec|   4 +-
 MdePkg/Include/IndustryStandard/SmBios.h | 131 ++-
 2 files changed, 98 insertions(+), 37 deletions(-)

-- 
2.7.0.windows.1

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


Re: [edk2] [PATCH v2 7/7] ArmPkg: Extra action to update permissions for S-ELO MM Image

2018-08-21 Thread Sughosh Ganu
hi Ard,

On Tue July 23, 2018 at 11:03PM +0530, Supreeth Venkatesh wrote:
> 
> On Sat, 2018-07-21 at 20:06 +0900, Ard Biesheuvel wrote:
> > On 20 July 2018 at 21:38, Sughosh Ganu  wrote:
> > >
> > > From: Achin Gupta 
> > >
> > > The Standalone MM drivers runs in S-EL0 in AArch64 on ARM Standard
> > > Platforms and is deployed during SEC phase. The memory allocated to
> > > the Standalone MM drivers should be marked as RO+X.
> > >
> > > During PE/COFF Image section parsing, this patch implements extra
> > > action "UpdatePeCoffPermissions" to request the privileged firmware
> > > in
> > > EL3 to update the permissions.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Sughosh Ganu 
> > Apologies for bringing this up only now, but I don't think I was ever
> > cc'ed on these patches.
> >
> Apologies if you have missed it. But I am pretty sure it was part of
> earlier large patch-set on which you and leif were copied, as it was
> part of ArmPkg.
> >
> > We are relying on a debug hook in the PE/COFF loader to ensure that
> > we
> > don't end up with memory that is both writable and executable in the
> > secure world. Do we really think that is a good idea?
> >
> > (I know this code was derived from a proof of concept that I did
> > years
> > ago, but that was just a PoC)
> I think we need a little bit more details on what is your suggestion?
> 
> A little bit background here: This code runs in S-EL0 and Request gets
> sent to secure world SPM to ensure that the region permissions are
> updated correctly via the "ArmMmuStandaloneMmCoreLib" SVC -
> ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64.
> 
> DebugPeCoffExtraActionLib is just used to extract image region
> information, but the region permission
> update request is sent to secure world for validation.
> 
> With the above explanation, can you provide an insight into what was
> your thinking?
> Do you want us to create a separate library and call it
> as PeCoffExtraActionLib to avoid the "Debug" word though it is a hook
> to PeCoffExtraActionLib in MdePkg or do we want to create this library
> in a separate package (may be in MdePkg?) or something totally
> different.

Supreeth had replied to your comments on the patch. Can you please
check this. If you feel that this needs to be implemented differently,
can you please suggest it to us. Thanks.

-sughosh

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


[edk2] [Patch] MdeModulePkg/PiSmmCore: Check valid memory range.

2018-08-21 Thread Eric Dong
Call BS.AllocatePages in DXE driver and call SMM FreePages with the address of 
the buffer allocated in the DXE driver. SMM FreePages success and add a 
non-SMRAM range into SMM heap list. This is not an expected behavior. SMM 
FreePages should return error for this case and not free the pages.

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

Cc: Star Zeng 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong 
---
 MdeModulePkg/Core/PiSmmCore/Page.c | 39 ++
 1 file changed, 39 insertions(+)

diff --git a/MdeModulePkg/Core/PiSmmCore/Page.c 
b/MdeModulePkg/Core/PiSmmCore/Page.c
index 3699af7424..630678ccc3 100644
--- a/MdeModulePkg/Core/PiSmmCore/Page.c
+++ b/MdeModulePkg/Core/PiSmmCore/Page.c
@@ -983,6 +983,41 @@ SmmInternalFreePages (
   return SmmInternalFreePagesEx (Memory, NumberOfPages, FALSE);
 }
 
+/**
+  Check whether the input range is in smram.
+
+  @param  Memory Base address of memory being inputed.
+  @param  NumberOfPages  The number of pages.
+
+  @retval TRUE   In the smram.
+  @retval FALSE  Not in the smram.
+
+**/
+BOOLEAN
+InSmmRange (
+  IN EFI_PHYSICAL_ADDRESS  Memory,
+  IN UINTN NumberOfPages
+  )
+{
+  LIST_ENTRY   *Link;
+  MEMORY_MAP   *Entry;
+  EFI_PHYSICAL_ADDRESS Last;
+
+  Last = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);
+
+  Link = gMemoryMap.ForwardLink;
+  while (Link != ) {
+Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+Link  = Link->ForwardLink;
+
+if ((Entry->Start <= Memory) && (Entry->End >= Last)) {
+  return TRUE;
+}
+  }
+
+  return FALSE;
+}
+
 /**
   Frees previous allocated pages.
 
@@ -1004,6 +1039,10 @@ SmmFreePages (
   EFI_STATUS  Status;
   BOOLEAN IsGuarded;
 
+  if (!InSmmRange(Memory, NumberOfPages)) {
+return EFI_NOT_FOUND;
+  }
+
   IsGuarded = IsHeapGuardEnabled () && IsMemoryGuarded (Memory);
   Status = SmmInternalFreePages (Memory, NumberOfPages, IsGuarded);
   if (!EFI_ERROR (Status)) {
-- 
2.15.0.windows.1

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